From 4d47c2df466b24df8d5f44f9da2e5d40178c06fa Mon Sep 17 00:00:00 2001 From: Cataldo Date: Thu, 21 Sep 2023 12:21:52 +0200 Subject: [PATCH] fix: rename standalone to focus-mode --- package-lock.json | 2 +- src/boot/bootstrapper.tsx | 10 +++++----- src/boot/loader.tsx | 4 ++-- src/constants/index.ts | 6 +++--- src/network/fetch.ts | 4 ++-- src/shell/app-view-container.tsx | 4 ++-- src/shell/shell-view.tsx | 6 +++--- src/store/app/store.ts | 24 ++++++++++++------------ src/store/app/utils.tsx | 2 +- src/utility-bar/utils.ts | 2 +- types/apps/index.d.ts | 6 +++--- types/exports/index.d.ts | 2 +- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index d487d0fc..b4ffbd32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,7 @@ "@types/webpack": "^5.28.1", "@types/webpack-env": "^1.18.0", "@zextras/carbonio-ui-configs": "^0.1.12", - "@zextras/carbonio-ui-sdk": "^1.5.1", + "@zextras/carbonio-ui-sdk": "^1.5.4", "autoprefixer": "^10.4.14", "babel-loader": "^9.1.3", "babel-plugin-i18next-extract": "^0.9.0", diff --git a/src/boot/bootstrapper.tsx b/src/boot/bootstrapper.tsx index f6cd436c..455ee52e 100644 --- a/src/boot/bootstrapper.tsx +++ b/src/boot/bootstrapper.tsx @@ -16,15 +16,15 @@ import { ContextBridge } from './context-bridge'; import { Loader } from './loader'; import ShellI18nextProvider from './shell-i18n-provider'; import { ThemeProvider } from './theme-provider'; -import { BASENAME, IS_STANDALONE } from '../constants'; +import { BASENAME, IS_FOCUS_MODE } from '../constants'; import { NotificationPermissionChecker } from '../notification/NotificationPermissionChecker'; import ShellView from '../shell/shell-view'; import { useAppStore } from '../store/app'; -const StandaloneListener = (): null => { +const FocusModeListener = (): null => { const { route } = useParams<{ route?: string }>(); useEffect(() => { - if (route) useAppStore.setState({ standalone: route }); + if (route) useAppStore.setState({ focusMode: route }); }, [route]); return null; }; @@ -44,10 +44,10 @@ const Bootstrapper: FC = () => ( - {IS_STANDALONE && ( + {IS_FOCUS_MODE && ( - + )} diff --git a/src/boot/loader.tsx b/src/boot/loader.tsx index 37b92613..19ffb938 100644 --- a/src/boot/loader.tsx +++ b/src/boot/loader.tsx @@ -11,7 +11,7 @@ import { find } from 'lodash'; import { useTranslation } from 'react-i18next'; import { loadApps, unloadAllApps } from './app/load-apps'; -import { IS_STANDALONE } from '../constants'; +import { IS_FOCUS_MODE } from '../constants'; import { getComponents } from '../network/get-components'; import { getInfo } from '../network/get-info'; import { loginConfig } from '../network/login-config'; @@ -81,7 +81,7 @@ export const Loader = (): React.JSX.Element => { } else if ('message' in promiseRejectedResult.reason) { console.error(promiseRejectedResult.reason.message); } - if (!IS_STANDALONE) { + if (!IS_FOCUS_MODE) { setOpen(true); } } diff --git a/src/constants/index.ts b/src/constants/index.ts index fe346faf..3ec657c0 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -78,10 +78,10 @@ export const darkReaderDynamicThemeFixes: DynamicThemeFix = { const base = '/carbonio/'; -const standaloneBase = `${base}standalone`; +const focusModeBase = `${base}focus-mode`; -export const IS_STANDALONE = window.location.pathname.startsWith(standaloneBase); -export const BASENAME = IS_STANDALONE ? standaloneBase : base; +export const IS_FOCUS_MODE = window.location.pathname.startsWith(focusModeBase); +export const BASENAME = IS_FOCUS_MODE ? focusModeBase : base; export const EMAIL_VALIDATION_REGEX = // eslint-disable-next-line @typescript-eslint/no-unused-vars, max-len, no-control-regex /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/; diff --git a/src/network/fetch.ts b/src/network/fetch.ts index d526ef77..d6a21ff4 100644 --- a/src/network/fetch.ts +++ b/src/network/fetch.ts @@ -15,7 +15,7 @@ import { SoapContext, SoapResponse } from '../../types'; -import { IS_STANDALONE, SHELL_APP_ID } from '../constants'; +import { IS_FOCUS_MODE, SHELL_APP_ID } from '../constants'; import { report } from '../reporting/functions'; import { useAccountStore } from '../store/account'; import { useNetworkStore } from '../store/network'; @@ -103,7 +103,7 @@ const handleResponse = (api: string, res: SoapResponse): R | ErrorSoapBody (code) => code === (res).Body.Fault.Detail?.Error?.Code ) ) { - if (IS_STANDALONE) { + if (IS_FOCUS_MODE) { useAccountStore.setState({ authenticated: false }); } else { goToLogin(); diff --git a/src/shell/app-view-container.tsx b/src/shell/app-view-container.tsx index c31aea4e..9ad0008c 100644 --- a/src/shell/app-view-container.tsx +++ b/src/shell/app-view-container.tsx @@ -12,14 +12,14 @@ import { Redirect, Route, Switch, useLocation } from 'react-router-dom'; import styled from 'styled-components'; import AppContextProvider from '../boot/app/app-context-provider'; -import { IS_STANDALONE } from '../constants'; +import { IS_FOCUS_MODE } from '../constants'; import { useAppList, useAppStore, useRoutes } from '../store/app'; const _BoardsRouterContainer = styled(Container)` flex-grow: 1; flex-basis: 0; min-width: 0.0625rem; - max-height: ${IS_STANDALONE ? '100vh' : 'calc(100vh - 3.75rem)'}; + max-height: ${IS_FOCUS_MODE ? '100vh' : 'calc(100vh - 3.75rem)'}; overflow-y: auto; `; diff --git a/src/shell/shell-view.tsx b/src/shell/shell-view.tsx index 667aa14c..cd16b2c1 100644 --- a/src/shell/shell-view.tsx +++ b/src/shell/shell-view.tsx @@ -16,7 +16,7 @@ import ShellContextProvider from './shell-context-provider'; import ShellHeader from './shell-header'; import ShellNavigationBar from './shell-navigation-bar'; import { ThemeCallbacksContext } from '../boot/theme-provider'; -import { IS_STANDALONE } from '../constants'; +import { IS_FOCUS_MODE } from '../constants'; import { useDarkReaderResultValue } from '../dark-mode/use-dark-reader-result-value'; import { ShellUtilityBar } from '../utility-bar/bar'; import { ShellUtilityPanel } from '../utility-bar/panel'; @@ -49,7 +49,7 @@ const ShellComponent = (): React.JSX.Element => { return ( - {!IS_STANDALONE && ( + {!IS_FOCUS_MODE && ( setMobileNavOpen(!mobileNavOpen)} @@ -58,7 +58,7 @@ const ShellComponent = (): React.JSX.Element => { )} - {!IS_STANDALONE && } + {!IS_FOCUS_MODE && } diff --git a/src/store/app/store.ts b/src/store/app/store.ts index 538a4f53..c2f89eda 100644 --- a/src/store/app/store.ts +++ b/src/store/app/store.ts @@ -12,7 +12,7 @@ import { normalizeApp } from './utils'; import type { AppState, CarbonioModule } from '../../../types'; import { SHELL_APP_ID } from '../../constants'; -const STANDALONE_RESPONSE = 'standalone'; +const FOCUS_MODE_RESPONSE = 'focus-mode'; function addIfNotPresent( items: T[], @@ -42,7 +42,7 @@ function removeById(items: T[], id: unknown): void { // extra currying as suggested in https://github.com/pmndrs/zustand/blob/main/docs/guides/typescript.md#basic-usage export const useAppStore = create()((set, get) => ({ - standalone: false, + focusMode: false, apps: {}, appContexts: {}, shell: { @@ -114,14 +114,14 @@ export const useAppStore = create()((set, get) => ({ }, // add route (id route primaryBar secondaryBar app) addRoute: (routeData): string => { - const { standalone } = get(); - if (standalone && (routeData.route !== standalone || !routeData.standalone)) { - return STANDALONE_RESPONSE; + const { focusMode } = get(); + if (focusMode && (routeData.route !== focusMode || !routeData.focusMode)) { + return FOCUS_MODE_RESPONSE; } set( produce((state) => { state.routes[routeData.id] = routeData; - if (routeData.primaryBar && !routeData.standalone) { + if (routeData.primaryBar && !routeData.focusMode) { addAndSort(state.views.primaryBar, { app: routeData.app, id: routeData.id, @@ -199,9 +199,9 @@ export const useAppStore = create()((set, get) => ({ // add settings addSettingsView: (data): string => { - const { standalone } = get(); - if (standalone && data.route !== standalone) { - return STANDALONE_RESPONSE; + const { focusMode } = get(); + if (focusMode && data.route !== focusMode) { + return FOCUS_MODE_RESPONSE; } set( produce((state) => { @@ -222,9 +222,9 @@ export const useAppStore = create()((set, get) => ({ // // add search addSearchView: (data): string => { - const { standalone } = get(); - if (standalone && data.route !== standalone) { - return STANDALONE_RESPONSE; + const { focusMode } = get(); + if (focusMode && data.route !== focusMode) { + return FOCUS_MODE_RESPONSE; } set( produce((state) => { diff --git a/src/store/app/utils.tsx b/src/store/app/utils.tsx index 84f31396..488e9e08 100644 --- a/src/store/app/utils.tsx +++ b/src/store/app/utils.tsx @@ -60,7 +60,7 @@ export const normalizeRoute = ( primaryBar: data.primaryBar ?? app.icon ?? 'CubeOutline', secondaryBar: data.secondaryBar, appView: data.appView ?? FallbackView, - standalone: data.standalone + focusMode: data.focusMode }; }; diff --git a/src/utility-bar/utils.ts b/src/utility-bar/utils.ts index 19f821fe..00b29653 100644 --- a/src/utility-bar/utils.ts +++ b/src/utility-bar/utils.ts @@ -19,7 +19,7 @@ export const checkRoute = ( view: UtilityView | PrimaryAccessoryView | SecondaryAccessoryView, activeRoute?: AppRoute ): boolean => { - const activeRouteValues = Object.values(omit(activeRoute, 'standalone') ?? {}); + const activeRouteValues = Object.values(omit(activeRoute, 'focusMode') ?? {}); if (view.blacklistRoutes) return !checkList(activeRouteValues, view.blacklistRoutes); if (view.whitelistRoutes) return checkList(activeRouteValues, view.whitelistRoutes); return true; diff --git a/types/apps/index.d.ts b/types/apps/index.d.ts index 5886e747..155e8fb9 100644 --- a/types/apps/index.d.ts +++ b/types/apps/index.d.ts @@ -30,7 +30,7 @@ export type AppRoute = { id: string; route: string; app: string; - standalone?: boolean; + focusMode?: boolean; }; export type AppRouteData = AppRoute & { @@ -131,7 +131,7 @@ export type AppRouteDescriptor = { label: string; secondaryBar?: ComponentType; appView: ComponentType; - standalone?: boolean; + focusMode?: boolean; }; export type AppSetters = { setApps: (apps: Array>) => void; @@ -177,7 +177,7 @@ export type AppSetters = { setAppContext: (app: string) => (context: unknown) => void; }; export type AppState = { - standalone: false | string; + focusMode: false | string; apps: Record; appContexts: Record; entryPoints: Record; diff --git a/types/exports/index.d.ts b/types/exports/index.d.ts index 80a45227..ab4ee7fe 100644 --- a/types/exports/index.d.ts +++ b/types/exports/index.d.ts @@ -60,7 +60,7 @@ declare const ROOT_NAME: string; declare const SHELL_MODES: Record; declare const BASENAME: string; -declare const IS_STANDALONE: boolean; +declare const IS_FOCUS_MODE: boolean; // eslint-disable-next-line @typescript-eslint/ban-types declare const getIntegratedFunction: (id: string) => [Function, boolean];