From 101a18cd41f53b62c77d16442db955855f1f2703 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Thu, 18 Apr 2024 07:32:48 +0100 Subject: feat: hide all services workspace (#1713) * feat: hide all services workspace * fix: change from 'show' to 'hide' --- .../settings/settings/EditSettingsForm.tsx | 2 ++ src/config.ts | 1 + src/containers/layout/AppLayoutContainer.tsx | 2 ++ src/containers/settings/EditSettingsScreen.tsx | 16 ++++++++++ .../workspaces/components/WorkspaceDrawer.tsx | 36 ++++++++++++++-------- src/i18n/locales/en-US.json | 1 + src/lib/Menu.ts | 28 +++++++++-------- 7 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/components/settings/settings/EditSettingsForm.tsx b/src/components/settings/settings/EditSettingsForm.tsx index 7e6a89f99..84057091d 100644 --- a/src/components/settings/settings/EditSettingsForm.tsx +++ b/src/components/settings/settings/EditSettingsForm.tsx @@ -838,6 +838,8 @@ class EditSettingsForm extends Component { + + )} diff --git a/src/config.ts b/src/config.ts index 5b9a5eaba..f086c54ee 100644 --- a/src/config.ts +++ b/src/config.ts @@ -422,6 +422,7 @@ export const DEFAULT_APP_SETTINGS = { hideSettingsButton: false, hideDownloadButton: false, alwaysShowWorkspaces: false, + hideAllServicesWorkspace: false, liftSingleInstanceLock: false, enableLongPressServiceHint: false, isTodosFeatureEnabled: true, diff --git a/src/containers/layout/AppLayoutContainer.tsx b/src/containers/layout/AppLayoutContainer.tsx index 3f8aad0ac..b18aa4690 100644 --- a/src/containers/layout/AppLayoutContainer.tsx +++ b/src/containers/layout/AppLayoutContainer.tsx @@ -80,6 +80,8 @@ class AppLayoutContainer extends Component { ? workspaceStore.getWorkspaceServices(workspace).map(s => s.name) : services.all.map(s => s.name) } + stores={this.props.stores} + actions={this.props.actions} /> ); diff --git a/src/containers/settings/EditSettingsScreen.tsx b/src/containers/settings/EditSettingsScreen.tsx index b731ad50a..fdd9bd8bc 100644 --- a/src/containers/settings/EditSettingsScreen.tsx +++ b/src/containers/settings/EditSettingsScreen.tsx @@ -277,6 +277,10 @@ const messages = defineMessages({ id: 'settings.app.form.alwaysShowWorkspaces', defaultMessage: 'Always show workspace drawer', }, + hideAllServicesWorkspace: { + id: 'settings.app.form.hideAllServicesWorkspace', + defaultMessage: 'Hide "All services" workspace', + }, accentColor: { id: 'settings.app.form.accentColor', defaultMessage: 'Accent color', @@ -453,6 +457,9 @@ class EditSettingsScreen extends Component< hideSettingsButton: Boolean(settingsData.hideSettingsButton), hideDownloadButton: Boolean(settingsData.hideDownloadButton), alwaysShowWorkspaces: Boolean(settingsData.alwaysShowWorkspaces), + hideAllServicesWorkspace: Boolean( + settingsData.hideAllServicesWorkspace, + ), accentColor: settingsData.accentColor, progressbarAccentColor: settingsData.progressbarAccentColor, showMessageBadgeWhenMuted: Boolean( @@ -1155,6 +1162,15 @@ class EditSettingsScreen extends Component< default: DEFAULT_APP_SETTINGS.alwaysShowWorkspaces, type: 'checkbox', }, + hideAllServicesWorkspace: { + label: intl.formatMessage(messages.hideAllServicesWorkspace), + value: ifUndefined( + settings.all.app.hideAllServicesWorkspace, + DEFAULT_APP_SETTINGS.hideAllServicesWorkspace, + ), + default: DEFAULT_APP_SETTINGS.hideAllServicesWorkspace, + type: 'checkbox', + }, accentColor: { label: intl.formatMessage(messages.accentColor), value: ifUndefined( diff --git a/src/features/workspaces/components/WorkspaceDrawer.tsx b/src/features/workspaces/components/WorkspaceDrawer.tsx index 2826b741a..cce333b31 100644 --- a/src/features/workspaces/components/WorkspaceDrawer.tsx +++ b/src/features/workspaces/components/WorkspaceDrawer.tsx @@ -1,6 +1,6 @@ import { mdiCog, mdiPlusBox } from '@mdi/js'; import { noop } from 'lodash'; -import { observer } from 'mobx-react'; +import { inject, observer } from 'mobx-react'; import { Component, type ReactElement } from 'react'; import { type WrappedComponentProps, @@ -9,6 +9,7 @@ import { } from 'react-intl'; import withStyles, { type WithStylesProps } from 'react-jss'; import { Tooltip as ReactTooltip } from 'react-tooltip'; +import type { StoresProps } from 'src/@types/ferdium-components.types'; import { H1 } from '../../../components/ui/headline'; import Icon from '../../../components/ui/icon'; import workspaceActions from '../actions'; @@ -92,10 +93,14 @@ const styles = theme => ({ }, }); -interface IProps extends WithStylesProps, WrappedComponentProps { +interface IProps + extends WithStylesProps, + WrappedComponentProps, + StoresProps { getServicesForWorkspace: (workspace: Workspace | null) => string[]; } +@inject('stores') @observer class WorkspaceDrawer extends Component { componentDidMount(): void { @@ -115,6 +120,11 @@ class WorkspaceDrawer extends Component { const actualWorkspace = isSwitchingWorkspace ? nextWorkspace : activeWorkspace; + + const { settings } = this.props.stores; + + const { hideAllServicesWorkspace } = settings.all.app; + return (

@@ -138,16 +148,18 @@ class WorkspaceDrawer extends Component {

- { - workspaceActions.deactivate(); - workspaceActions.toggleWorkspaceDrawer(); - }} - services={getServicesForWorkspace(null)} - isActive={actualWorkspace == null} - shortcutIndex={0} - /> + {!hideAllServicesWorkspace && ( + { + workspaceActions.deactivate(); + workspaceActions.toggleWorkspaceDrawer(); + }} + services={getServicesForWorkspace(null)} + isActive={actualWorkspace == null} + shortcutIndex={0} + /> + )} {workspaces.map((workspace, index) => ( { - workspaceActions.deactivate(); + if (!this.stores.settings.app.hideAllServicesWorkspace) { + menu.push( + { + type: 'separator', }, - }, - ); + { + label: intl.formatMessage(menuItems.defaultWorkspace), + accelerator: `${cmdOrCtrlShortcutKey()}+${altKey()}+0`, + type: 'radio', + checked: !activeWorkspace, + click: () => { + workspaceActions.deactivate(); + }, + }, + ); + } // Workspace items for (const [i, workspace] of workspaces.entries()) { -- cgit v1.2.3-70-g09d2