diff --git a/api-extractor/carbonio-shell-ui.api.md b/api-extractor/carbonio-shell-ui.api.md index c714657e..8024c68a 100644 --- a/api-extractor/carbonio-shell-ui.api.md +++ b/api-extractor/carbonio-shell-ui.api.md @@ -229,6 +229,7 @@ type AnyFunction = (...args: any[]) => any; // @public (undocumented) type AppActions = { setApps: (apps: Array>) => void; + upsertApp: (app: Pick) => void; addRoute: (routeData: AppRouteDescriptor) => string; setRouteVisibility: (id: string, visible: boolean) => void; removeRoute: (id: string) => void; @@ -1477,6 +1478,9 @@ export const updatePrimaryBadge: (badge: Partial, id: string) => vo // @public (undocumented) export const updateUtilityBadge: (badge: Partial, id: string) => void; +// @public +export const upsertApp: (app: Pick) => void; + // @public (undocumented) export const useAction: (type: string, id: string, target?: T | undefined) => [Action | undefined, boolean]; @@ -1665,13 +1669,13 @@ interface ZimletProp { // lib/network/edit-settings.d.ts:9:5 - (ae-forgotten-export) The symbol "GrantRightsResponse" needs to be exported by the entry point lib.d.ts // lib/settings/components/settings-header.d.ts:5:5 - (ae-forgotten-export) The symbol "RouteLeavingGuardProps" needs to be exported by the entry point lib.d.ts // lib/store/app/store.d.ts:23:5 - (ae-forgotten-export) The symbol "CarbonioModule" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:24:5 - (ae-forgotten-export) The symbol "AppRouteDescriptor" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:29:5 - (ae-forgotten-export) The symbol "BoardView" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:31:5 - (ae-forgotten-export) The symbol "SettingsView" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:33:5 - (ae-forgotten-export) The symbol "SearchView" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:35:5 - (ae-forgotten-export) The symbol "UtilityView" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:37:5 - (ae-forgotten-export) The symbol "PrimaryAccessoryView" needs to be exported by the entry point lib.d.ts -// lib/store/app/store.d.ts:39:5 - (ae-forgotten-export) The symbol "SecondaryAccessoryView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:25:5 - (ae-forgotten-export) The symbol "AppRouteDescriptor" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:30:5 - (ae-forgotten-export) The symbol "BoardView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:32:5 - (ae-forgotten-export) The symbol "SettingsView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:34:5 - (ae-forgotten-export) The symbol "SearchView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:36:5 - (ae-forgotten-export) The symbol "UtilityView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:38:5 - (ae-forgotten-export) The symbol "PrimaryAccessoryView" needs to be exported by the entry point lib.d.ts +// lib/store/app/store.d.ts:40:5 - (ae-forgotten-export) The symbol "SecondaryAccessoryView" needs to be exported by the entry point lib.d.ts // lib/store/context-bridge.d.ts:4:5 - (ae-forgotten-export) The symbol "PackageDependentFunction" needs to be exported by the entry point lib.d.ts // lib/store/context-bridge.d.ts:5:5 - (ae-forgotten-export) The symbol "AnyFunction" needs to be exported by the entry point lib.d.ts // lib/store/integrations/store.d.ts:26:9 - (ae-forgotten-export) The symbol "Action_2" needs to be exported by the entry point lib.d.ts diff --git a/src/boot/app/app-loader-setters.ts b/src/boot/app/app-loader-setters.ts index 4883917a..873808ce 100644 --- a/src/boot/app/app-loader-setters.ts +++ b/src/boot/app/app-loader-setters.ts @@ -80,7 +80,19 @@ export const { removeSearchView, removeUtilityView, removePrimaryAccessoryView, - removeSecondaryAccessoryView + removeSecondaryAccessoryView, + /** + * Add or update the translatable display and description labels for an app. + * These fields are the ones used in the UI. + * @param app - The app to update based on the name field + * @example + * upsertApp(\{ + * name: 'carbonio-example-ui', + * display: t('label.app_name', 'Example') + * description: t('label.app_description', 'Example module') + * \}); + */ + upsertApp } = useAppStore.getState(); export const { diff --git a/src/lib.ts b/src/lib.ts index a673a434..29129317 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -57,7 +57,8 @@ export { removePrimaryAccessoryView, setRouteVisibility, updateUtilityBadge, - updatePrimaryBadge + updatePrimaryBadge, + upsertApp } from './boot/app/app-loader-setters'; export declare const getI18n: AppFunctions['getI18n']; diff --git a/src/store/app/store.ts b/src/store/app/store.ts index 4e30c211..9e1efe40 100644 --- a/src/store/app/store.ts +++ b/src/store/app/store.ts @@ -52,6 +52,7 @@ export type AppState = { export type AppActions = { setApps: (apps: Array>) => void; + upsertApp: (app: Pick) => void; addRoute: (routeData: AppRouteDescriptor) => string; setRouteVisibility: (id: string, visible: boolean) => void; removeRoute: (id: string) => void; @@ -166,6 +167,13 @@ export const useAppStore = create()((set, get) => ({ }; }); }, + upsertApp: (app): void => { + set( + produce((state) => { + state.apps[app.name] = { ...state.apps[app.name], ...app }; + }) + ); + }, setAppContext: (app) => (context): void => { @@ -211,6 +219,7 @@ export const useAppStore = create()((set, get) => ({ component: routeData.appView }); } + // TODO remove with SHELL-212 if (routeData.app && state.apps[routeData.app] && routeData.focusMode !== true) { state.apps[routeData.app].display = routeData.label; }