From 763f51a15068d583cc12467a5da714584e91469d Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Thu, 24 Oct 2024 11:45:38 +0530 Subject: [PATCH 01/22] Move the workspace family handling to the workspace container --- .../esm-extensions/src/workspaces.ts | 8 ---- .../esm-routes/src/loaders/components.ts | 2 - .../workspace-container.component.tsx | 24 ++++++++--- .../workspace-renderer.component.tsx | 2 +- .../useWorkspaceFamilyStore.ts | 2 +- .../src/workspaces/workspaces.test.ts | 42 +++++++++---------- .../src/workspaces/workspaces.ts | 41 +++++++++++------- .../shell/esm-app-shell/webpack.config.js | 4 +- 8 files changed, 69 insertions(+), 56 deletions(-) diff --git a/packages/framework/esm-extensions/src/workspaces.ts b/packages/framework/esm-extensions/src/workspaces.ts index bebd9a5e1..707e5cf71 100644 --- a/packages/framework/esm-extensions/src/workspaces.ts +++ b/packages/framework/esm-extensions/src/workspaces.ts @@ -14,8 +14,6 @@ export interface WorkspaceRegistration { canHide: boolean; canMaximize: boolean; width: 'narrow' | 'wider' | 'extra-wide'; - hasOwnSidebar: boolean; - sidebarFamily: string; preferredWindowSize: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; @@ -37,8 +35,6 @@ export interface RegisterWorkspaceOptions { canHide?: boolean; canMaximize?: boolean; width?: 'narrow' | 'wider' | 'extra-wide'; - hasOwnSidebar?: boolean; - sidebarFamily?: string; preferredWindowSize?: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; @@ -60,8 +56,6 @@ export function registerWorkspace(workspace: RegisterWorkspaceOptions) { canHide: workspace.canHide ?? false, canMaximize: workspace.canMaximize ?? false, width: workspace.width ?? 'narrow', - hasOwnSidebar: workspace.hasOwnSidebar ?? false, - sidebarFamily: workspace.sidebarFamily ?? 'default', }, }, })); @@ -97,8 +91,6 @@ export function getWorkspaceRegistration(name: string): WorkspaceRegistration { canHide: workspaceExtension.meta?.canHide ?? false, canMaximize: workspaceExtension.meta?.canMaximize ?? false, width: workspaceExtension.meta?.width ?? 'narrow', - sidebarFamily: 'default', - hasOwnSidebar: false, }; } else { throw new Error(`No workspace named '${name}' has been registered.`); diff --git a/packages/framework/esm-routes/src/loaders/components.ts b/packages/framework/esm-routes/src/loaders/components.ts index 791fb7541..baae05a98 100644 --- a/packages/framework/esm-routes/src/loaders/components.ts +++ b/packages/framework/esm-routes/src/loaders/components.ts @@ -193,8 +193,6 @@ supported, so the workspace will not be loaded.`, canHide: workspace.canHide, canMaximize: workspace.canMaximize, width: workspace.width, - hasOwnSidebar: workspace.hasOwnSidebar, - sidebarFamily: workspace.sidebarFamily, preferredWindowSize: workspace.preferredWindowSize, }); } diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index c4039a77a..2c354dea3 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -14,6 +14,7 @@ import styles from './workspace.module.scss'; export interface WorkspaceContainerProps { contextKey: string; + containerName?: string; overlay?: boolean; showSiderailAndBottomNav?: boolean; additionalWorkspaceProps?: object; @@ -67,17 +68,22 @@ export interface WorkspaceContainerProps { */ export function WorkspaceContainer({ contextKey, + containerName, overlay, showSiderailAndBottomNav, additionalWorkspaceProps, actionMenuProps, }: WorkspaceContainerProps) { const layout = useLayoutType(); - const { workspaces, workspaceWindowState } = useWorkspaces(); + const { workspaces, workspaceWindowState } = useWorkspaces(containerName); const activeWorkspace = workspaces[0]; const isHidden = workspaceWindowState === 'hidden' || activeWorkspace == null; const isMaximized = workspaceWindowState === 'maximized'; const width = activeWorkspace?.width ?? (overlay ? 'wider' : 'narrow'); + const showActionMenu = useMemo( + () => showSiderailAndBottomNav || (containerName && !isHidden), + [containerName, isHidden, showSiderailAndBottomNav], + ); useBodyScrollLock(!isHidden && !isDesktop(layout)); @@ -120,7 +126,13 @@ export function WorkspaceContainer({ - {showSiderailAndBottomNav && } + {showActionMenu && ( + + )} ); } @@ -148,7 +160,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro const { canHide = false, canMaximize = false, - hasOwnSidebar = false, + workspaceContainerName = '', closeWorkspace, } = useMemo(() => workspaceInstance ?? ({} as OpenWorkspace), [workspaceInstance]); @@ -171,7 +183,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
@@ -234,7 +246,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
- {hasOwnSidebar && } + {/* {hasOwnSidebar && } */} ) ); diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx index 6e3b404c8..b4f92b265 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx @@ -14,7 +14,7 @@ interface WorkspaceRendererProps { export function WorkspaceRenderer({ workspace, additionalPropsFromPage }: WorkspaceRendererProps) { const [lifecycle, setLifecycle] = useState(); - const workspaceFamilyState = useWorkspaceFamilyStore(workspace.sidebarFamily); + const workspaceFamilyState = useWorkspaceFamilyStore(workspace.workspaceContainerName); useEffect(() => { let active = true; diff --git a/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts b/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts index c3e5d8b02..e2460c261 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts @@ -12,7 +12,7 @@ import type { StoreApi } from 'zustand/vanilla'; * * @param {string} sidebarFamilyName The sidebarFamilyName of the workspace used when registering the workspace in the module's routes.json file. */ -export function useWorkspaceFamilyStore(sidebarFamilyName: string) { +export function useWorkspaceFamilyStore(sidebarFamilyName?: string) { const [storeState, setStoreState] = useState({}); const [currentSidebarFamilyName, setCurrentSidebarFamilyName] = useState(sidebarFamilyName); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index 7c567884d..c57386459 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -485,8 +485,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', }); launchWorkspace('ward-patient-workspace'); const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); @@ -508,8 +506,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', }); launchWorkspace('ward-patient-workspace', { foo: true, @@ -530,8 +528,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily, + // hasOwnSidebar: true, + // sidebarFamily, }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -539,8 +537,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily, + // hasOwnSidebar: true, + // sidebarFamily, }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -564,8 +562,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -573,8 +571,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'another-sidebar-family', + // hasOwnSidebar: true, + // sidebarFamily: 'another-sidebar-family', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -599,8 +597,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', canHide: true, }); registerWorkspace({ @@ -609,8 +607,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'another-sidebar-family', + // hasOwnSidebar: true, + // sidebarFamily: 'another-sidebar-family', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -634,8 +632,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', canHide: true, }); registerWorkspace({ @@ -644,8 +642,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -668,8 +666,8 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - hasOwnSidebar: true, - sidebarFamily: 'ward-patient-sidebar', + // hasOwnSidebar: true, + // sidebarFamily: 'ward-patient-sidebar', }); launchWorkspace('ward-patient-workspace', { foo: true, diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 4b56873ef..085653188 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -104,6 +104,7 @@ export interface WorkspaceStoreState { export interface OpenWorkspace extends WorkspaceRegistration, DefaultWorkspaceProps { additionalProps: object; + workspaceContainerName?: string; } /** @@ -122,7 +123,7 @@ export function canCloseWorkspaceWithoutPrompting(name: string, ignoreChanges: b function promptBeforeLaunchingWorkspace( workspace: OpenWorkspace, - newWorkspaceDetails: { name: string; additionalProps?: object }, + newWorkspaceDetails: { name: string; additionalProps?: object; workspaceContainerName?: string }, ) { const { name, additionalProps } = newWorkspaceDetails; const newWorkspaceRegistration = getWorkspaceRegistration(name); @@ -134,7 +135,7 @@ function promptBeforeLaunchingWorkspace( // might resolve, but we need to check all the cases before launching the form. onWorkspaceClose: () => launchWorkspace(name, additionalProps), // If the new workspace is of the same sidebar family, then we don't need to clear the workspace family store. - clearWorkspaceFamilyStore: newWorkspaceRegistration.sidebarFamily !== workspace.sidebarFamily, + clearWorkspaceFamilyStore: newWorkspaceDetails?.workspaceContainerName !== workspace.workspaceContainerName, }); }; @@ -176,7 +177,11 @@ function promptBeforeLaunchingWorkspace( */ export function launchWorkspace< T extends DefaultWorkspaceProps | object = DefaultWorkspaceProps & { [key: string]: any }, ->(name: string, additionalProps?: Omit & { workspaceTitle?: string }) { +>( + name: string, + additionalProps?: Omit & { workspaceTitle?: string }, + workspaceContainerName?: string, +) { const store = getWorkspaceStore(); const workspace = getWorkspaceRegistration(name); const newWorkspace: OpenWorkspace = { @@ -197,12 +202,13 @@ export function launchWorkspace< }; }); }, + workspaceContainerName, additionalProps: additionalProps ?? {}, }; - if (newWorkspace.sidebarFamily) { + if (workspaceContainerName) { // initialize workspace family store - getWorkspaceFamilyStore(newWorkspace.sidebarFamily, additionalProps); + getWorkspaceFamilyStore(workspaceContainerName, additionalProps); } function updateStoreWithNewWorkspace(workspaceToBeAdded: OpenWorkspace, restOfTheWorkspaces?: Array) { @@ -229,6 +235,7 @@ export function launchWorkspace< promptBeforeLaunchingWorkspace(openWorkspaces[0], { name, additionalProps, + workspaceContainerName, }); } else if (isWorkspaceAlreadyOpen) { const openWorkspace = openWorkspaces[workspaceIndexInOpenWorkspaces]; @@ -312,13 +319,13 @@ function closeWorkspaceInternal(name: string, options: CloseWorkspaceInternalOpt const updateStoreWithClosedWorkspace = () => { const state = store.getState(); const workspaceToBeClosed = state.openWorkspaces.find((w) => w.name === name); - const workspaceSidebarFamilyName = workspaceToBeClosed?.sidebarFamily; + const workspaceSidebarFamilyName = workspaceToBeClosed?.workspaceContainerName; const newOpenWorkspaces = state.openWorkspaces.filter((w) => w.name != name); const workspaceFamilyStore = getWorkspaceFamilyStore(workspaceSidebarFamilyName); if ( options.clearWorkspaceFamilyStore && workspaceFamilyStore && - !newOpenWorkspaces.some((w) => w.sidebarFamily === workspaceSidebarFamilyName) + !newOpenWorkspaces.some((w) => w.workspaceContainerName === workspaceSidebarFamilyName) ) { // Clearing the workspace family store if there are no more workspaces with the same sidebar family name and the new workspace is not of the same sidebar family, which is handled in the `launchWorkspace` function. workspaceFamilyStore.setState({}, true); @@ -415,18 +422,24 @@ export interface WorkspacesInfo { workspaces: Array; } -export function useWorkspaces(): WorkspacesInfo { - const { workspaceWindowState, openWorkspaces, prompt } = useStore(workspaceStore); +export function useWorkspaces(containerName?: string): WorkspacesInfo { + const { workspaceWindowState, openWorkspaces: allOpenWorkspaces, prompt } = useStore(workspaceStore); + const openWorkspaces = useMemo( + () => + allOpenWorkspaces.filter((w) => + containerName ? w.workspaceContainerName === containerName : !w.workspaceContainerName, + ), + [allOpenWorkspaces], + ); - const memoisedResults = useMemo( - () => ({ + const memoisedResults = useMemo(() => { + return { active: openWorkspaces.length > 0, prompt, workspaceWindowState, workspaces: openWorkspaces, - }), - [openWorkspaces, workspaceWindowState, prompt], - ); + }; + }, [openWorkspaces, workspaceWindowState, prompt]); return memoisedResults; } diff --git a/packages/shell/esm-app-shell/webpack.config.js b/packages/shell/esm-app-shell/webpack.config.js index a3be9324a..11fabee0a 100644 --- a/packages/shell/esm-app-shell/webpack.config.js +++ b/packages/shell/esm-app-shell/webpack.config.js @@ -23,7 +23,7 @@ const { ModuleFederationPlugin } = container; const openmrsAddCookie = process.env.OMRS_ADD_COOKIE; const openmrsApiUrl = removeTrailingSlash(process.env.OMRS_API_URL || '/openmrs'); const openmrsPublicPath = removeTrailingSlash(process.env.OMRS_PUBLIC_PATH || '/openmrs/spa'); -const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://dev3.openmrs.org/'; +const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://kgh-test.pih-emr.org/'; const openmrsPageTitle = process.env.OMRS_PAGE_TITLE || 'OpenMRS'; const openmrsFavicon = process.env.OMRS_FAVICON || `${openmrsPublicPath}/favicon.ico`; const openmrsEnvironment = process.env.OMRS_ENV || process.env.NODE_ENV || ''; @@ -34,7 +34,7 @@ const openmrsImportmapUrl = process.env.OMRS_ESM_IMPORTMAP_URL || `${openmrsPubl const openmrsRoutesDef = process.env.OMRS_ROUTES; const openmrsRoutesUrl = process.env.OMRS_ROUTES_URL || `${openmrsPublicPath}/routes.registry.json`; const openmrsCoreApps = process.env.OMRS_ESM_CORE_APPS_DIR || resolve(__dirname, '../../apps'); -const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '') +const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '/openmrs/spa/site/config.json') .split(';') .filter((url) => url.length > 0) .map((url) => JSON.stringify(url)) From 9183aa888095d45f5b77f5ff01a4aa8a9011847d Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Thu, 24 Oct 2024 11:50:39 +0530 Subject: [PATCH 02/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 19 +++++--- .../docs/interfaces/OpenWorkspace.md | 47 ++++++------------- .../interfaces/WorkspaceContainerProps.md | 17 +++++-- .../docs/interfaces/WorkspaceRegistration.md | 28 ++--------- .../docs/interfaces/WorkspacesInfo.md | 8 ++-- 5 files changed, 48 insertions(+), 71 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 809015f34..c66a937cf 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -8048,13 +8048,13 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:304](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L304) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:311](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L311) ___ ### launchWorkspace -▸ **launchWorkspace**<`T`\>(`name`, `additionalProps?`): `void` +▸ **launchWorkspace**<`T`\>(`name`, `additionalProps?`, `workspaceContainerName?`): `void` This launches a workspace by its name. The workspace must have been registered. Workspaces should be registered in the `routes.json` file. @@ -8092,6 +8092,7 @@ prop named `workspaceTitle` will override the title of the workspace. | :------ | :------ | :------ | | `name` | `string` | The name of the workspace to launch | | `additionalProps?` | `Omit`<`T`, keyof [`DefaultWorkspaceProps`](interfaces/DefaultWorkspaceProps.md)\> & { `workspaceTitle?`: `string` } | Props to pass to the workspace component being launched. Passing a prop named `workspaceTitle` will override the title of the workspace. | +| `workspaceContainerName?` | `string` | - | #### Returns @@ -8099,7 +8100,7 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:177](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L177) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:178](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L178) ___ @@ -8125,13 +8126,19 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:262](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L262) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:269](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L269) ___ ### useWorkspaces -▸ **useWorkspaces**(): [`WorkspacesInfo`](interfaces/WorkspacesInfo.md) +▸ **useWorkspaces**(`containerName?`): [`WorkspacesInfo`](interfaces/WorkspacesInfo.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `containerName?` | `string` | #### Returns @@ -8139,4 +8146,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:418](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L418) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:425](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L425) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md index 78c5f359b..09d345a6e 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md @@ -16,11 +16,9 @@ - [canHide](OpenWorkspace.md#canhide) - [canMaximize](OpenWorkspace.md#canmaximize) -- [hasOwnSidebar](OpenWorkspace.md#hasownsidebar) - [moduleName](OpenWorkspace.md#modulename) - [name](OpenWorkspace.md#name) - [preferredWindowSize](OpenWorkspace.md#preferredwindowsize) -- [sidebarFamily](OpenWorkspace.md#sidebarfamily) - [title](OpenWorkspace.md#title) - [titleNode](OpenWorkspace.md#titlenode) - [type](OpenWorkspace.md#type) @@ -29,6 +27,7 @@ ### Workspace Properties - [additionalProps](OpenWorkspace.md#additionalprops) +- [workspaceContainerName](OpenWorkspace.md#workspacecontainername) ### Methods @@ -68,20 +67,6 @@ ___ ___ -### hasOwnSidebar - -• **hasOwnSidebar**: `boolean` - -#### Inherited from - -[WorkspaceRegistration](WorkspaceRegistration.md).[hasOwnSidebar](WorkspaceRegistration.md#hasownsidebar) - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L17) - -___ - ### moduleName • **moduleName**: `string` @@ -92,7 +77,7 @@ ___ #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:21](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L21) +[packages/framework/esm-extensions/src/workspaces.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L19) ___ @@ -120,21 +105,7 @@ ___ #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L19) - -___ - -### sidebarFamily - -• **sidebarFamily**: `string` - -#### Inherited from - -[WorkspaceRegistration](WorkspaceRegistration.md).[sidebarFamily](WorkspaceRegistration.md#sidebarfamily) - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L18) +[packages/framework/esm-extensions/src/workspaces.ts:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L17) ___ @@ -204,6 +175,16 @@ ___ [packages/framework/esm-styleguide/src/workspaces/workspaces.ts:106](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L106) +___ + +### workspaceContainerName + +• `Optional` **workspaceContainerName**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:107](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L107) + ## Methods ### closeWorkspace @@ -277,7 +258,7 @@ ___ #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) +[packages/framework/esm-extensions/src/workspaces.ts:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L18) ___ diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md index 1c1d62001..660f1b2ac 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md @@ -8,6 +8,7 @@ - [actionMenuProps](WorkspaceContainerProps.md#actionmenuprops) - [additionalWorkspaceProps](WorkspaceContainerProps.md#additionalworkspaceprops) +- [containerName](WorkspaceContainerProps.md#containername) - [contextKey](WorkspaceContainerProps.md#contextkey) - [overlay](WorkspaceContainerProps.md#overlay) - [showSiderailAndBottomNav](WorkspaceContainerProps.md#showsiderailandbottomnav) @@ -30,7 +31,17 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L19) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L20) + +___ + +### containerName + +• `Optional` **containerName**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L17) ___ @@ -50,7 +61,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L17) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L18) ___ @@ -60,4 +71,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L18) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L19) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md index 551b9c588..b95f5e7c1 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md @@ -16,11 +16,9 @@ See [WorkspaceDefinition](../API.md#workspacedefinition) for more information ab - [canHide](WorkspaceRegistration.md#canhide) - [canMaximize](WorkspaceRegistration.md#canmaximize) -- [hasOwnSidebar](WorkspaceRegistration.md#hasownsidebar) - [moduleName](WorkspaceRegistration.md#modulename) - [name](WorkspaceRegistration.md#name) - [preferredWindowSize](WorkspaceRegistration.md#preferredwindowsize) -- [sidebarFamily](WorkspaceRegistration.md#sidebarfamily) - [title](WorkspaceRegistration.md#title) - [titleNode](WorkspaceRegistration.md#titlenode) - [type](WorkspaceRegistration.md#type) @@ -52,23 +50,13 @@ ___ ___ -### hasOwnSidebar - -• **hasOwnSidebar**: `boolean` - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L17) - -___ - ### moduleName • **moduleName**: `string` #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:21](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L21) +[packages/framework/esm-extensions/src/workspaces.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L19) ___ @@ -88,17 +76,7 @@ ___ #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L19) - -___ - -### sidebarFamily - -• **sidebarFamily**: `string` - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L18) +[packages/framework/esm-extensions/src/workspaces.ts:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L17) ___ @@ -152,4 +130,4 @@ ___ #### Defined in -[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) +[packages/framework/esm-extensions/src/workspaces.ts:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L18) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 2d5a1a4b1..9c9b5e4db 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -19,7 +19,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:412](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L412) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:419](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L419) ___ @@ -29,7 +29,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:413](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L413) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:420](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L420) ___ @@ -39,7 +39,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:414](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L414) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:421](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L421) ___ @@ -49,4 +49,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:415](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L415) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:422](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L422) From e527778eae7506aeb95e294edc4ecf215e3bd33e Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 28 Oct 2024 15:57:28 +0530 Subject: [PATCH 03/22] launchWorkspace should allow navigating workspaces inside a container --- .../esm-styleguide/src/workspaces/workspaces.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 085653188..c1a0dddcb 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -100,6 +100,7 @@ export interface WorkspaceStoreState { openWorkspaces: Array; prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; + currentContainerName?: string; } export interface OpenWorkspace extends WorkspaceRegistration, DefaultWorkspaceProps { @@ -183,6 +184,14 @@ export function launchWorkspace< workspaceContainerName?: string, ) { const store = getWorkspaceStore(); + + if (workspaceContainerName) { + store.setState((prev) => ({ + ...prev, + currentContainerName: workspaceContainerName, + })); + } + const workspace = getWorkspaceRegistration(name); const newWorkspace: OpenWorkspace = { ...workspace, @@ -202,7 +211,7 @@ export function launchWorkspace< }; }); }, - workspaceContainerName, + workspaceContainerName: workspaceContainerName || store.getState().currentContainerName, additionalProps: additionalProps ?? {}, }; @@ -378,6 +387,7 @@ const initialState: WorkspaceStoreState = { openWorkspaces: [], prompt: null, workspaceWindowState: 'normal', + currentContainerName: '', }; export const workspaceStore = createGlobalStore('workspace', initialState); From 2ffe42f4048c20267dc5b2e8c2a77cc8ac642d3f Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 28 Oct 2024 16:01:21 +0530 Subject: [PATCH 04/22] Remove comments --- .../src/workspaces/workspaces.test.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index c57386459..c765df380 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -506,8 +506,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', }); launchWorkspace('ward-patient-workspace', { foo: true, @@ -528,8 +526,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily, }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -537,8 +533,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily, }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -562,8 +556,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -571,8 +563,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'another-sidebar-family', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -597,8 +587,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', canHide: true, }); registerWorkspace({ @@ -607,8 +595,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'another-sidebar-family', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -632,8 +618,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', canHide: true, }); registerWorkspace({ @@ -642,8 +626,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', }); const workspaceStore = getWorkspaceStore(); launchWorkspace('ward-patient-workspace', { @@ -666,8 +648,6 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - // hasOwnSidebar: true, - // sidebarFamily: 'ward-patient-sidebar', }); launchWorkspace('ward-patient-workspace', { foo: true, From 9ae698b9d85bac59abf622ca8403c45835c8abb1 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 28 Oct 2024 16:01:49 +0530 Subject: [PATCH 05/22] Update documentation and revert webpack config --- packages/framework/esm-framework/docs/API.md | 8 ++++---- .../esm-framework/docs/interfaces/OpenWorkspace.md | 4 ++-- .../esm-framework/docs/interfaces/WorkspacesInfo.md | 8 ++++---- packages/shell/esm-app-shell/webpack.config.js | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index c66a937cf..9551c07e5 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -8048,7 +8048,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:311](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L311) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:320](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L320) ___ @@ -8100,7 +8100,7 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:178](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L178) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:179](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L179) ___ @@ -8126,7 +8126,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:269](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L269) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:278](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L278) ___ @@ -8146,4 +8146,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:425](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L425) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:435](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L435) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md index 09d345a6e..147f03491 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md @@ -173,7 +173,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:106](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L106) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:107](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L107) ___ @@ -183,7 +183,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:107](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L107) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:108](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L108) ## Methods diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 9c9b5e4db..4df75b7fc 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -19,7 +19,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:419](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L419) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:429](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L429) ___ @@ -29,7 +29,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:420](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L420) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:430](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L430) ___ @@ -39,7 +39,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:421](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L421) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:431](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L431) ___ @@ -49,4 +49,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:422](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L422) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:432](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L432) diff --git a/packages/shell/esm-app-shell/webpack.config.js b/packages/shell/esm-app-shell/webpack.config.js index 11fabee0a..a3be9324a 100644 --- a/packages/shell/esm-app-shell/webpack.config.js +++ b/packages/shell/esm-app-shell/webpack.config.js @@ -23,7 +23,7 @@ const { ModuleFederationPlugin } = container; const openmrsAddCookie = process.env.OMRS_ADD_COOKIE; const openmrsApiUrl = removeTrailingSlash(process.env.OMRS_API_URL || '/openmrs'); const openmrsPublicPath = removeTrailingSlash(process.env.OMRS_PUBLIC_PATH || '/openmrs/spa'); -const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://kgh-test.pih-emr.org/'; +const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://dev3.openmrs.org/'; const openmrsPageTitle = process.env.OMRS_PAGE_TITLE || 'OpenMRS'; const openmrsFavicon = process.env.OMRS_FAVICON || `${openmrsPublicPath}/favicon.ico`; const openmrsEnvironment = process.env.OMRS_ENV || process.env.NODE_ENV || ''; @@ -34,7 +34,7 @@ const openmrsImportmapUrl = process.env.OMRS_ESM_IMPORTMAP_URL || `${openmrsPubl const openmrsRoutesDef = process.env.OMRS_ROUTES; const openmrsRoutesUrl = process.env.OMRS_ROUTES_URL || `${openmrsPublicPath}/routes.registry.json`; const openmrsCoreApps = process.env.OMRS_ESM_CORE_APPS_DIR || resolve(__dirname, '../../apps'); -const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '/openmrs/spa/site/config.json') +const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '') .split(';') .filter((url) => url.length > 0) .map((url) => JSON.stringify(url)) From c1f31e8f5ca6e53ca7a2c8a5897a969879d60c98 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Tue, 29 Oct 2024 15:59:44 +0530 Subject: [PATCH 06/22] MID --- packages/shell/esm-app-shell/webpack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shell/esm-app-shell/webpack.config.js b/packages/shell/esm-app-shell/webpack.config.js index a3be9324a..11fabee0a 100644 --- a/packages/shell/esm-app-shell/webpack.config.js +++ b/packages/shell/esm-app-shell/webpack.config.js @@ -23,7 +23,7 @@ const { ModuleFederationPlugin } = container; const openmrsAddCookie = process.env.OMRS_ADD_COOKIE; const openmrsApiUrl = removeTrailingSlash(process.env.OMRS_API_URL || '/openmrs'); const openmrsPublicPath = removeTrailingSlash(process.env.OMRS_PUBLIC_PATH || '/openmrs/spa'); -const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://dev3.openmrs.org/'; +const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://kgh-test.pih-emr.org/'; const openmrsPageTitle = process.env.OMRS_PAGE_TITLE || 'OpenMRS'; const openmrsFavicon = process.env.OMRS_FAVICON || `${openmrsPublicPath}/favicon.ico`; const openmrsEnvironment = process.env.OMRS_ENV || process.env.NODE_ENV || ''; @@ -34,7 +34,7 @@ const openmrsImportmapUrl = process.env.OMRS_ESM_IMPORTMAP_URL || `${openmrsPubl const openmrsRoutesDef = process.env.OMRS_ROUTES; const openmrsRoutesUrl = process.env.OMRS_ROUTES_URL || `${openmrsPublicPath}/routes.registry.json`; const openmrsCoreApps = process.env.OMRS_ESM_CORE_APPS_DIR || resolve(__dirname, '../../apps'); -const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '') +const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '/openmrs/spa/site/config.json') .split(';') .filter((url) => url.length > 0) .map((url) => JSON.stringify(url)) From be0ae0e1b5bbb6526900a65f9f3984646b0897dd Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Sun, 3 Nov 2024 16:51:49 +0530 Subject: [PATCH 07/22] Add new API for launching workspace container --- .../workspace-container.component.tsx | 9 ++-- .../src/workspaces/workspaces.ts | 51 ++++++++++--------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index 2c354dea3..3ca200cd2 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -68,21 +68,20 @@ export interface WorkspaceContainerProps { */ export function WorkspaceContainer({ contextKey, - containerName, overlay, showSiderailAndBottomNav, additionalWorkspaceProps, actionMenuProps, }: WorkspaceContainerProps) { const layout = useLayoutType(); - const { workspaces, workspaceWindowState } = useWorkspaces(containerName); + const { workspaces, workspaceWindowState, currentContainerName } = useWorkspaces(); const activeWorkspace = workspaces[0]; const isHidden = workspaceWindowState === 'hidden' || activeWorkspace == null; const isMaximized = workspaceWindowState === 'maximized'; const width = activeWorkspace?.width ?? (overlay ? 'wider' : 'narrow'); const showActionMenu = useMemo( - () => showSiderailAndBottomNav || (containerName && !isHidden), - [containerName, isHidden, showSiderailAndBottomNav], + () => showSiderailAndBottomNav || (currentContainerName && !isHidden), + [currentContainerName, isHidden, showSiderailAndBottomNav], ); useBodyScrollLock(!isHidden && !isDesktop(layout)); @@ -128,7 +127,7 @@ export function WorkspaceContainer({ {showActionMenu && ( diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index c1a0dddcb..c98693173 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -147,6 +147,19 @@ function promptBeforeLaunchingWorkspace( } } +export function launchWorkspaceGroup(groupName: string, state: object) { + const store = getWorkspaceStore(); + if (!store.getState().currentContainerName) { + store.setState((prev) => ({ + ...prev, + currentContainerName: groupName, + })); + getWorkspaceFamilyStore(groupName, state); + } else { + // TODO: Write code to close any independent workspace opened, or any other workspace group + } +} + /** * This launches a workspace by its name. The workspace must have been registered. * Workspaces should be registered in the `routes.json` file. @@ -178,20 +191,9 @@ function promptBeforeLaunchingWorkspace( */ export function launchWorkspace< T extends DefaultWorkspaceProps | object = DefaultWorkspaceProps & { [key: string]: any }, ->( - name: string, - additionalProps?: Omit & { workspaceTitle?: string }, - workspaceContainerName?: string, -) { +>(name: string, additionalProps?: Omit & { workspaceTitle?: string }) { const store = getWorkspaceStore(); - if (workspaceContainerName) { - store.setState((prev) => ({ - ...prev, - currentContainerName: workspaceContainerName, - })); - } - const workspace = getWorkspaceRegistration(name); const newWorkspace: OpenWorkspace = { ...workspace, @@ -211,15 +213,10 @@ export function launchWorkspace< }; }); }, - workspaceContainerName: workspaceContainerName || store.getState().currentContainerName, + workspaceContainerName: store.getState().currentContainerName, additionalProps: additionalProps ?? {}, }; - if (workspaceContainerName) { - // initialize workspace family store - getWorkspaceFamilyStore(workspaceContainerName, additionalProps); - } - function updateStoreWithNewWorkspace(workspaceToBeAdded: OpenWorkspace, restOfTheWorkspaces?: Array) { store.setState((state) => { const openWorkspaces = [workspaceToBeAdded, ...(restOfTheWorkspaces ?? state.openWorkspaces)]; @@ -244,7 +241,6 @@ export function launchWorkspace< promptBeforeLaunchingWorkspace(openWorkspaces[0], { name, additionalProps, - workspaceContainerName, }); } else if (isWorkspaceAlreadyOpen) { const openWorkspace = openWorkspaces[workspaceIndexInOpenWorkspaces]; @@ -430,26 +426,33 @@ export interface WorkspacesInfo { prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; workspaces: Array; + currentContainerName: string | undefined; } -export function useWorkspaces(containerName?: string): WorkspacesInfo { - const { workspaceWindowState, openWorkspaces: allOpenWorkspaces, prompt } = useStore(workspaceStore); +export function useWorkspaces(): WorkspacesInfo { + const { + workspaceWindowState, + openWorkspaces: allOpenWorkspaces, + prompt, + currentContainerName, + } = useStore(workspaceStore); const openWorkspaces = useMemo( () => allOpenWorkspaces.filter((w) => - containerName ? w.workspaceContainerName === containerName : !w.workspaceContainerName, + currentContainerName ? w.workspaceContainerName === currentContainerName : !w.workspaceContainerName, ), [allOpenWorkspaces], ); - const memoisedResults = useMemo(() => { + const memoisedResults: WorkspacesInfo = useMemo(() => { return { active: openWorkspaces.length > 0, prompt, workspaceWindowState, workspaces: openWorkspaces, + currentContainerName, }; - }, [openWorkspaces, workspaceWindowState, prompt]); + }, [openWorkspaces, workspaceWindowState, prompt, currentContainerName]); return memoisedResults; } From ceee50248331505d2f9c0d3356412837a774d0e0 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 6 Nov 2024 12:30:28 +0530 Subject: [PATCH 08/22] Clear workspace group when a workspace is closed --- packages/framework/esm-framework/docs/API.md | 41 +++++++--- .../docs/interfaces/WorkspacesInfo.md | 11 +++ .../workspace-container.component.tsx | 12 +-- .../esm-styleguide/src/workspaces/public.ts | 8 +- .../src/workspaces/workspaces.ts | 79 ++++++++----------- 5 files changed, 87 insertions(+), 64 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 9551c07e5..4f7464e74 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -262,6 +262,7 @@ - [closeWorkspace](API.md#closeworkspace) - [launchWorkspace](API.md#launchworkspace) +- [launchWorkspaceGroup](API.md#launchworkspacegroup) - [navigateAndLaunchWorkspace](API.md#navigateandlaunchworkspace) - [useWorkspaces](API.md#useworkspaces) @@ -8048,13 +8049,13 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:320](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L320) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:315](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L315) ___ ### launchWorkspace -▸ **launchWorkspace**<`T`\>(`name`, `additionalProps?`, `workspaceContainerName?`): `void` +▸ **launchWorkspace**<`T`\>(`name`, `additionalProps?`): `void` This launches a workspace by its name. The workspace must have been registered. Workspaces should be registered in the `routes.json` file. @@ -8092,7 +8093,6 @@ prop named `workspaceTitle` will override the title of the workspace. | :------ | :------ | :------ | | `name` | `string` | The name of the workspace to launch | | `additionalProps?` | `Omit`<`T`, keyof [`DefaultWorkspaceProps`](interfaces/DefaultWorkspaceProps.md)\> & { `workspaceTitle?`: `string` } | Props to pass to the workspace component being launched. Passing a prop named `workspaceTitle` will override the title of the workspace. | -| `workspaceContainerName?` | `string` | - | #### Returns @@ -8100,7 +8100,28 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:179](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L179) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:192](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L192) + +___ + +### launchWorkspaceGroup + +▸ **launchWorkspaceGroup**(`groupName`, `state`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `groupName` | `string` | +| `state` | `object` | + +#### Returns + +`void` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:125](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L125) ___ @@ -8126,19 +8147,13 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:278](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L278) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:273](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L273) ___ ### useWorkspaces -▸ **useWorkspaces**(`containerName?`): [`WorkspacesInfo`](interfaces/WorkspacesInfo.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `containerName?` | `string` | +▸ **useWorkspaces**(): [`WorkspacesInfo`](interfaces/WorkspacesInfo.md) #### Returns @@ -8146,4 +8161,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:435](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L435) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:436](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L436) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 4df75b7fc..3af1bab2d 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -7,6 +7,7 @@ ### Workspace Properties - [active](WorkspacesInfo.md#active) +- [currentGroupName](WorkspacesInfo.md#currentgroupname) - [prompt](WorkspacesInfo.md#prompt) - [workspaceWindowState](WorkspacesInfo.md#workspacewindowstate) - [workspaces](WorkspacesInfo.md#workspaces) @@ -23,6 +24,16 @@ ___ +### currentGroupName + +• `Optional` **currentGroupName**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:433](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L433) + +___ + ### prompt • **prompt**: ``null`` \| [`Prompt`](Prompt.md) diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index 3ca200cd2..22c7ed4ff 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -74,14 +74,14 @@ export function WorkspaceContainer({ actionMenuProps, }: WorkspaceContainerProps) { const layout = useLayoutType(); - const { workspaces, workspaceWindowState, currentContainerName } = useWorkspaces(); + const { workspaces, workspaceWindowState, currentGroupName } = useWorkspaces(); const activeWorkspace = workspaces[0]; const isHidden = workspaceWindowState === 'hidden' || activeWorkspace == null; const isMaximized = workspaceWindowState === 'maximized'; const width = activeWorkspace?.width ?? (overlay ? 'wider' : 'narrow'); const showActionMenu = useMemo( - () => showSiderailAndBottomNav || (currentContainerName && !isHidden), - [currentContainerName, isHidden, showSiderailAndBottomNav], + () => showSiderailAndBottomNav || (currentGroupName && !isHidden), + [currentGroupName, isHidden, showSiderailAndBottomNav], ); useBodyScrollLock(!isHidden && !isDesktop(layout)); @@ -127,7 +127,7 @@ export function WorkspaceContainer({ {showActionMenu && ( @@ -144,7 +144,7 @@ interface WorkspaceProps { function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspaceProps) { const { t } = useTranslation(); const layout = useLayoutType(); - const { workspaceWindowState } = useWorkspaces(); + const { workspaceWindowState, currentGroupName } = useWorkspaces(); const isMaximized = workspaceWindowState === 'maximized'; // We use the feature name of the app containing the workspace in order to set the extension @@ -208,7 +208,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro {isMaximized ? : } )} - {canHide ? ( + {canHide && !currentGroupName ? ( ; prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; - currentContainerName?: string; + currentGroupName?: string; } export interface OpenWorkspace extends WorkspaceRegistration, DefaultWorkspaceProps { @@ -122,6 +122,19 @@ export function canCloseWorkspaceWithoutPrompting(name: string, ignoreChanges: b return !promptBeforeFn || !promptBeforeFn(); } +export function launchWorkspaceGroup(groupName: string, state: object) { + const store = getWorkspaceStore(); + if (!store.getState().currentGroupName) { + store.setState((prev) => ({ + ...prev, + currentGroupName: groupName, + })); + getWorkspaceFamilyStore(groupName, state); + } else { + // TODO: Write code to close any independent workspace opened, or any other workspace group + } +} + function promptBeforeLaunchingWorkspace( workspace: OpenWorkspace, newWorkspaceDetails: { name: string; additionalProps?: object; workspaceContainerName?: string }, @@ -136,7 +149,7 @@ function promptBeforeLaunchingWorkspace( // might resolve, but we need to check all the cases before launching the form. onWorkspaceClose: () => launchWorkspace(name, additionalProps), // If the new workspace is of the same sidebar family, then we don't need to clear the workspace family store. - clearWorkspaceFamilyStore: newWorkspaceDetails?.workspaceContainerName !== workspace.workspaceContainerName, + closeWorkspaceGroup: false, }); }; @@ -147,19 +160,6 @@ function promptBeforeLaunchingWorkspace( } } -export function launchWorkspaceGroup(groupName: string, state: object) { - const store = getWorkspaceStore(); - if (!store.getState().currentContainerName) { - store.setState((prev) => ({ - ...prev, - currentContainerName: groupName, - })); - getWorkspaceFamilyStore(groupName, state); - } else { - // TODO: Write code to close any independent workspace opened, or any other workspace group - } -} - /** * This launches a workspace by its name. The workspace must have been registered. * Workspaces should be registered in the `routes.json` file. @@ -213,7 +213,6 @@ export function launchWorkspace< }; }); }, - workspaceContainerName: store.getState().currentContainerName, additionalProps: additionalProps ?? {}, }; @@ -314,7 +313,7 @@ const defaultOptions: CloseWorkspaceOptions = { * @param options Options to close workspace */ export function closeWorkspace(name: string, options: CloseWorkspaceOptions = {}) { - return closeWorkspaceInternal(name, { ...options, clearWorkspaceFamilyStore: true }); + return closeWorkspaceInternal(name, { ...options, closeWorkspaceGroup: true }); } function closeWorkspaceInternal(name: string, options: CloseWorkspaceInternalOptions = {}): boolean { @@ -324,24 +323,29 @@ function closeWorkspaceInternal(name: string, options: CloseWorkspaceInternalOpt const updateStoreWithClosedWorkspace = () => { const state = store.getState(); const workspaceToBeClosed = state.openWorkspaces.find((w) => w.name === name); - const workspaceSidebarFamilyName = workspaceToBeClosed?.workspaceContainerName; const newOpenWorkspaces = state.openWorkspaces.filter((w) => w.name != name); - const workspaceFamilyStore = getWorkspaceFamilyStore(workspaceSidebarFamilyName); + const workspaceGroupName = store.getState().currentGroupName; + let currentGroupName = state.currentGroupName; if ( - options.clearWorkspaceFamilyStore && - workspaceFamilyStore && - !newOpenWorkspaces.some((w) => w.workspaceContainerName === workspaceSidebarFamilyName) + workspaceGroupName && + options.closeWorkspaceGroup + // !newOpenWorkspaces.some((w) => w.workspaceContainerName === workspaceSidebarFamilyName) ) { + currentGroupName = undefined; // Clearing the workspace family store if there are no more workspaces with the same sidebar family name and the new workspace is not of the same sidebar family, which is handled in the `launchWorkspace` function. - workspaceFamilyStore.setState({}, true); - const unsubscribe = workspaceFamilyStore.subscribe(() => {}); - unsubscribe?.(); + const workspaceFamilyStore = getWorkspaceFamilyStore(workspaceGroupName); + if (workspaceFamilyStore) { + workspaceFamilyStore.setState({}, true); + const unsubscribe = workspaceFamilyStore.subscribe(() => {}); + unsubscribe?.(); + } } // ensure closed workspace will not prompt promptBeforeClosing(name, () => false); store.setState({ ...state, + currentGroupName, prompt: null, openWorkspaces: newOpenWorkspaces, workspaceWindowState: getUpdatedWorkspaceWindowState(newOpenWorkspaces?.[0]), @@ -383,7 +387,7 @@ const initialState: WorkspaceStoreState = { openWorkspaces: [], prompt: null, workspaceWindowState: 'normal', - currentContainerName: '', + currentGroupName: undefined, }; export const workspaceStore = createGlobalStore('workspace', initialState); @@ -426,33 +430,20 @@ export interface WorkspacesInfo { prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; workspaces: Array; - currentContainerName: string | undefined; + currentGroupName?: string; } export function useWorkspaces(): WorkspacesInfo { - const { - workspaceWindowState, - openWorkspaces: allOpenWorkspaces, - prompt, - currentContainerName, - } = useStore(workspaceStore); - const openWorkspaces = useMemo( - () => - allOpenWorkspaces.filter((w) => - currentContainerName ? w.workspaceContainerName === currentContainerName : !w.workspaceContainerName, - ), - [allOpenWorkspaces], - ); - + const { workspaceWindowState, openWorkspaces, prompt, currentGroupName } = useStore(workspaceStore); const memoisedResults: WorkspacesInfo = useMemo(() => { return { active: openWorkspaces.length > 0, prompt, workspaceWindowState, workspaces: openWorkspaces, - currentContainerName, + currentGroupName, }; - }, [openWorkspaces, workspaceWindowState, prompt, currentContainerName]); + }, [openWorkspaces, workspaceWindowState, prompt, currentGroupName]); return memoisedResults; } From 1fe51e8cb83805c8cb4b22bedd7148f1edb2cdce Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 11:09:22 +0530 Subject: [PATCH 09/22] Handle cases revolving multiple groups and no groups --- .../esm-extensions/src/workspaces.ts | 3 + packages/framework/esm-globals/src/types.ts | 1 + .../esm-routes/src/loaders/components.ts | 1 + .../workspace-container.component.tsx | 12 +- .../workspace-renderer.component.tsx | 2 +- .../src/workspaces/workspaces.ts | 143 +++++++++++++----- 6 files changed, 114 insertions(+), 48 deletions(-) diff --git a/packages/framework/esm-extensions/src/workspaces.ts b/packages/framework/esm-extensions/src/workspaces.ts index 707e5cf71..002c4ab82 100644 --- a/packages/framework/esm-extensions/src/workspaces.ts +++ b/packages/framework/esm-extensions/src/workspaces.ts @@ -17,6 +17,7 @@ export interface WorkspaceRegistration { preferredWindowSize: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; + workspaceGroups?: Array; } interface WorkspaceRegistrationStore { @@ -38,6 +39,7 @@ export interface RegisterWorkspaceOptions { preferredWindowSize?: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; + workspaceGroups: Array; } /** @@ -91,6 +93,7 @@ export function getWorkspaceRegistration(name: string): WorkspaceRegistration { canHide: workspaceExtension.meta?.canHide ?? false, canMaximize: workspaceExtension.meta?.canMaximize ?? false, width: workspaceExtension.meta?.width ?? 'narrow', + workspaceGroups: workspaceExtension?.meta?.workspaceGroups ?? [], }; } else { throw new Error(`No workspace named '${name}' has been registered.`); diff --git a/packages/framework/esm-globals/src/types.ts b/packages/framework/esm-globals/src/types.ts index bfd9b9c47..53921ec1a 100644 --- a/packages/framework/esm-globals/src/types.ts +++ b/packages/framework/esm-globals/src/types.ts @@ -315,6 +315,7 @@ export type WorkspaceDefinition = { */ sidebarFamily?: string; preferredWindowSize?: WorkspaceWindowState; + workspaceGroups: Array; } & ( | { /** diff --git a/packages/framework/esm-routes/src/loaders/components.ts b/packages/framework/esm-routes/src/loaders/components.ts index baae05a98..bea38498e 100644 --- a/packages/framework/esm-routes/src/loaders/components.ts +++ b/packages/framework/esm-routes/src/loaders/components.ts @@ -194,6 +194,7 @@ supported, so the workspace will not be loaded.`, canMaximize: workspace.canMaximize, width: workspace.width, preferredWindowSize: workspace.preferredWindowSize, + workspaceGroups: workspace.workspaceGroups ?? [], }); } } diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index 22c7ed4ff..de895157d 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -74,7 +74,8 @@ export function WorkspaceContainer({ actionMenuProps, }: WorkspaceContainerProps) { const layout = useLayoutType(); - const { workspaces, workspaceWindowState, currentGroupName } = useWorkspaces(); + const { workspaces, workspaceWindowState, workspaceGroup } = useWorkspaces(); + const currentGroupName = workspaceGroup?.name; const activeWorkspace = workspaces[0]; const isHidden = workspaceWindowState === 'hidden' || activeWorkspace == null; const isMaximized = workspaceWindowState === 'maximized'; @@ -144,7 +145,8 @@ interface WorkspaceProps { function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspaceProps) { const { t } = useTranslation(); const layout = useLayoutType(); - const { workspaceWindowState, currentGroupName } = useWorkspaces(); + const { workspaceWindowState, workspaceGroup } = useWorkspaces(); + const currentGroupName = workspaceGroup?.name; const isMaximized = workspaceWindowState === 'maximized'; // We use the feature name of the app containing the workspace in order to set the extension @@ -159,7 +161,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro const { canHide = false, canMaximize = false, - workspaceContainerName = '', + currentWorkspaceGroup = '', closeWorkspace, } = useMemo(() => workspaceInstance ?? ({} as OpenWorkspace), [workspaceInstance]); @@ -182,7 +184,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
@@ -245,7 +247,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
(); - const workspaceFamilyState = useWorkspaceFamilyStore(workspace.workspaceContainerName); + const workspaceFamilyState = useWorkspaceFamilyStore(workspace.currentWorkspaceGroup); useEffect(() => { let active = true; diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index eabb5ae8a..c3bcfef82 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -23,9 +23,6 @@ export interface CloseWorkspaceOptions { * @returns void */ onWorkspaceClose?: () => void; -} - -interface CloseWorkspaceInternalOptions extends CloseWorkspaceOptions { /** * Controls whether the workspace family store will be cleared when this workspace is closed. Defaults to true except when opening a new workspace of the same family. * @@ -34,6 +31,8 @@ interface CloseWorkspaceInternalOptions extends CloseWorkspaceOptions { closeWorkspaceGroup?: boolean; } +interface CloseWorkspaceInternalOptions extends CloseWorkspaceOptions {} + /** The default parameters received by all workspaces */ export interface DefaultWorkspaceProps { /** @@ -100,12 +99,15 @@ export interface WorkspaceStoreState { openWorkspaces: Array; prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; - currentGroupName?: string; + workspaceGroup?: { + name: string; + cleanup?: Function; + }; } export interface OpenWorkspace extends WorkspaceRegistration, DefaultWorkspaceProps { additionalProps: object; - workspaceContainerName?: string; + currentWorkspaceGroup?: string; } /** @@ -122,16 +124,70 @@ export function canCloseWorkspaceWithoutPrompting(name: string, ignoreChanges: b return !promptBeforeFn || !promptBeforeFn(); } -export function launchWorkspaceGroup(groupName: string, state: object) { +function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { const store = getWorkspaceStore(); - if (!store.getState().currentGroupName) { + const currentWorkspaceGroup = store.getState()?.workspaceGroup; + const currentGroupName = store.getState()?.workspaceGroup?.name; + if (!currentGroupName || groupName !== currentGroupName) { + return; + } + const filter: (workspace: OpenWorkspace) => boolean = currentGroupName + ? (workspace) => workspace.currentWorkspaceGroup === currentGroupName + : () => true; + + closeAllWorkspaces(() => { + // Clearing the workspace family store if there are no more workspaces with the same sidebar family name and the new workspace is not of the same sidebar family, which is handled in the `launchWorkspace` function. + const workspaceFamilyStore = getWorkspaceFamilyStore(groupName); + if (workspaceFamilyStore) { + workspaceFamilyStore.setState({}, true); + const unsubscribe = workspaceFamilyStore.subscribe(() => {}); + unsubscribe?.(); + } + if (currentWorkspaceGroup && typeof currentWorkspaceGroup?.cleanup === 'function') { + currentWorkspaceGroup?.cleanup?.(); + } + store.setState((prev) => ({ ...prev, - currentGroupName: groupName, + workspaceGroup: undefined, })); - getWorkspaceFamilyStore(groupName, state); + if (onWorkspaceCloseup && typeof onWorkspaceCloseup === 'function') { + onWorkspaceCloseup?.(); + } + }, filter); +} + +interface LaunchWorkspaceGroupArg { + groupName: string; + state: object; + onWorkspaceGroupLaunch?: Function; + workspaceGroupCleanup?: Function; +} + +export function launchWorkspaceGroup(args: LaunchWorkspaceGroupArg) { + const { groupName, state, onWorkspaceGroupLaunch, workspaceGroupCleanup } = args; + const store = getWorkspaceStore(); + if (store.getState().openWorkspaces.length) { + const workspaceGroup = store.getState().workspaceGroup; + if (workspaceGroup) { + closeWorkspaceGroup(workspaceGroup?.name, () => { + launchWorkspaceGroup(args); + }); + } else { + closeAllWorkspaces(() => { + launchWorkspaceGroup(args); + }); + } } else { - // TODO: Write code to close any independent workspace opened, or any other workspace group + store.setState((prev) => ({ + ...prev, + workspaceGroup: { + name: groupName, + cleanup: workspaceGroupCleanup, + }, + })); + getWorkspaceFamilyStore(groupName, state); + onWorkspaceGroupLaunch?.(); } } @@ -143,7 +199,7 @@ function promptBeforeLaunchingWorkspace( const newWorkspaceRegistration = getWorkspaceRegistration(name); const proceed = () => { - closeWorkspaceInternal(workspace.name, { + closeWorkspace(workspace.name, { ignoreChanges: true, // Calling the launchWorkspace again, since one of the `if` case // might resolve, but we need to check all the cases before launching the form. @@ -193,8 +249,15 @@ export function launchWorkspace< T extends DefaultWorkspaceProps | object = DefaultWorkspaceProps & { [key: string]: any }, >(name: string, additionalProps?: Omit & { workspaceTitle?: string }) { const store = getWorkspaceStore(); - const workspace = getWorkspaceRegistration(name); + const currentWorkspaceGroup = store.getState().workspaceGroup; + + if (currentWorkspaceGroup && !workspace.workspaceGroups?.includes(currentWorkspaceGroup?.name)) { + closeWorkspaceGroup(currentWorkspaceGroup?.name, () => { + launchWorkspace(name, additionalProps); + }); + return; + } const newWorkspace: OpenWorkspace = { ...workspace, title: getWorkspaceTitle(workspace, additionalProps), @@ -213,6 +276,7 @@ export function launchWorkspace< }; }); }, + currentWorkspaceGroup: store.getState().workspaceGroup?.name, additionalProps: additionalProps ?? {}, }; @@ -305,6 +369,7 @@ export function cancelPrompt() { const defaultOptions: CloseWorkspaceOptions = { ignoreChanges: false, onWorkspaceClose: () => {}, + closeWorkspaceGroup: true, }; /** @@ -312,11 +377,7 @@ const defaultOptions: CloseWorkspaceOptions = { * @param name Workspace registration name * @param options Options to close workspace */ -export function closeWorkspace(name: string, options: CloseWorkspaceOptions = {}) { - return closeWorkspaceInternal(name, { ...options, closeWorkspaceGroup: true }); -} - -function closeWorkspaceInternal(name: string, options: CloseWorkspaceInternalOptions = {}): boolean { +export function closeWorkspace(name: string, options: CloseWorkspaceOptions = {}): boolean { options = { ...defaultOptions, ...options }; const store = getWorkspaceStore(); @@ -324,32 +385,25 @@ function closeWorkspaceInternal(name: string, options: CloseWorkspaceInternalOpt const state = store.getState(); const workspaceToBeClosed = state.openWorkspaces.find((w) => w.name === name); const newOpenWorkspaces = state.openWorkspaces.filter((w) => w.name != name); - const workspaceGroupName = store.getState().currentGroupName; - let currentGroupName = state.currentGroupName; + + const workspaceGroupName = store.getState().workspaceGroup?.name; + if ( workspaceGroupName && options.closeWorkspaceGroup // !newOpenWorkspaces.some((w) => w.workspaceContainerName === workspaceSidebarFamilyName) ) { - currentGroupName = undefined; - // Clearing the workspace family store if there are no more workspaces with the same sidebar family name and the new workspace is not of the same sidebar family, which is handled in the `launchWorkspace` function. - const workspaceFamilyStore = getWorkspaceFamilyStore(workspaceGroupName); - if (workspaceFamilyStore) { - workspaceFamilyStore.setState({}, true); - const unsubscribe = workspaceFamilyStore.subscribe(() => {}); - unsubscribe?.(); - } + closeWorkspaceGroup(workspaceGroupName); } // ensure closed workspace will not prompt promptBeforeClosing(name, () => false); - store.setState({ - ...state, - currentGroupName, + store.setState((prev) => ({ + ...prev, prompt: null, openWorkspaces: newOpenWorkspaces, workspaceWindowState: getUpdatedWorkspaceWindowState(newOpenWorkspaces?.[0]), - }); + })); options?.onWorkspaceClose?.(); }; @@ -387,7 +441,7 @@ const initialState: WorkspaceStoreState = { openWorkspaces: [], prompt: null, workspaceWindowState: 'normal', - currentGroupName: undefined, + workspaceGroup: undefined, }; export const workspaceStore = createGlobalStore('workspace', initialState); @@ -405,13 +459,19 @@ export function updateWorkspaceWindowState(value: WorkspaceWindowState) { function getUpdatedWorkspaceWindowState(workspaceAtTop: OpenWorkspace) { return workspaceAtTop?.preferredWindowSize ?? 'normal'; } -export function closeAllWorkspaces(onClosingWorkspaces: () => void = () => {}) { +export function closeAllWorkspaces( + onClosingWorkspaces: () => void = () => {}, + filter: (workspace: OpenWorkspace) => boolean = () => true, +) { const store = getWorkspaceStore(); - const canCloseAllWorkspaces = store.getState().openWorkspaces.every(({ name }) => { - const canCloseWorkspace = canCloseWorkspaceWithoutPrompting(name); - return canCloseWorkspace; - }); + const canCloseAllWorkspaces = store + .getState() + .openWorkspaces.filter(filter) + .every(({ name }) => { + const canCloseWorkspace = canCloseWorkspaceWithoutPrompting(name); + return canCloseWorkspace; + }); const updateWorkspaceStore = () => { resetWorkspaceStore(); @@ -430,21 +490,20 @@ export interface WorkspacesInfo { prompt: Prompt | null; workspaceWindowState: WorkspaceWindowState; workspaces: Array; - currentGroupName?: string; + workspaceGroup?: WorkspaceStoreState['workspaceGroup']; } export function useWorkspaces(): WorkspacesInfo { - const { workspaceWindowState, openWorkspaces, prompt, currentGroupName } = useStore(workspaceStore); + const { workspaceWindowState, openWorkspaces, prompt, workspaceGroup } = useStore(workspaceStore); const memoisedResults: WorkspacesInfo = useMemo(() => { return { active: openWorkspaces.length > 0, prompt, workspaceWindowState, workspaces: openWorkspaces, - currentGroupName, + workspaceGroup, }; - }, [openWorkspaces, workspaceWindowState, prompt, currentGroupName]); - + }, [openWorkspaces, workspaceWindowState, prompt, workspaceGroup]); return memoisedResults; } From d58e5dd47c5e171fb96203c32f9b26d339e87f27 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 11:09:42 +0530 Subject: [PATCH 10/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 21 ++++++------ .../docs/interfaces/CloseWorkspaceOptions.md | 15 +++++++++ .../docs/interfaces/DefaultWorkspaceProps.md | 8 ++--- .../docs/interfaces/FeatureFlagDefinition.md | 6 ++-- .../docs/interfaces/OpenWorkspace.md | 33 ++++++++++++++----- .../docs/interfaces/OpenmrsAppRoutes.md | 16 ++++----- .../esm-framework/docs/interfaces/Prompt.md | 10 +++--- .../docs/interfaces/ResourceLoader.md | 2 +- .../docs/interfaces/WorkspaceRegistration.md | 11 +++++++ .../docs/interfaces/WorkspacesInfo.md | 27 +++++++++------ 10 files changed, 98 insertions(+), 51 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 4f7464e74..2f41fdd12 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -610,7 +610,7 @@ ___ #### Defined in -[packages/framework/esm-globals/src/types.ts:396](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L396) +[packages/framework/esm-globals/src/types.ts:397](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L397) ___ @@ -623,7 +623,7 @@ Basically, this is the same as the app routes, with each routes definition keyed #### Defined in -[packages/framework/esm-globals/src/types.ts:387](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L387) +[packages/framework/esm-globals/src/types.ts:388](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L388) ___ @@ -793,7 +793,7 @@ ___ ### WorkspaceDefinition -Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `hasOwnSidebar?`: `boolean` ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `sidebarFamily?`: `string` ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` } & { `component`: `string` } \| { `component?`: `never` } +Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `hasOwnSidebar?`: `boolean` ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `sidebarFamily?`: `string` ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` ; `workspaceGroups`: `string`[] } & { `component`: `string` } \| { `component?`: `never` } A definition of a workspace as extracted from an app's routes.json @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:315](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L315) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:380](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L380) ___ @@ -8100,20 +8100,19 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:192](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L192) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:248](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L248) ___ ### launchWorkspaceGroup -▸ **launchWorkspaceGroup**(`groupName`, `state`): `void` +▸ **launchWorkspaceGroup**(`args`): `void` #### Parameters | Name | Type | | :------ | :------ | -| `groupName` | `string` | -| `state` | `object` | +| `args` | `LaunchWorkspaceGroupArg` | #### Returns @@ -8121,7 +8120,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:125](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L125) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:167](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L167) ___ @@ -8147,7 +8146,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:273](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L273) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:337](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L337) ___ @@ -8161,4 +8160,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:436](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L436) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) diff --git a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md index cba18139c..2a0c95cf7 100644 --- a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md +++ b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md @@ -6,6 +6,7 @@ ### Workspace Properties +- [closeWorkspaceGroup](CloseWorkspaceOptions.md#closeworkspacegroup) - [ignoreChanges](CloseWorkspaceOptions.md#ignorechanges) ### Workspace Methods @@ -14,6 +15,20 @@ ## Workspace Properties +### closeWorkspaceGroup + +• `Optional` **closeWorkspaceGroup**: `boolean` + +Controls whether the workspace family store will be cleared when this workspace is closed. Defaults to true except when opening a new workspace of the same family. + +**`default`** true + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:31](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L31) + +___ + ### ignoreChanges • `Optional` **ignoreChanges**: `boolean` diff --git a/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md b/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md index 1ecd23b3e..57d80a2b7 100644 --- a/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md +++ b/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md @@ -43,7 +43,7 @@ closed, given the user forcefully closes the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:46](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L46) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L45) ___ @@ -66,7 +66,7 @@ will directly close the workspace without any prompt #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:56](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L56) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:55](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L55) ___ @@ -89,7 +89,7 @@ this workspace is closed; e.g. if there is unsaved data. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:51](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L51) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:50](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L50) ___ @@ -117,4 +117,4 @@ title needs to be set dynamically. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:71](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L71) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:70](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L70) diff --git a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md index 87c81cb85..751adc3dd 100644 --- a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md +++ b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md @@ -22,7 +22,7 @@ An explanation of what the flag does, which will be displayed in the Implementer #### Defined in -[packages/framework/esm-globals/src/types.ts:350](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L350) +[packages/framework/esm-globals/src/types.ts:351](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L351) ___ @@ -34,7 +34,7 @@ A code-friendly name for the flag, which will be used to reference it in code #### Defined in -[packages/framework/esm-globals/src/types.ts:346](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L346) +[packages/framework/esm-globals/src/types.ts:347](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L347) ___ @@ -46,4 +46,4 @@ A human-friendly name which will be displayed in the Implementer Tools #### Defined in -[packages/framework/esm-globals/src/types.ts:348](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L348) +[packages/framework/esm-globals/src/types.ts:349](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L349) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md index 147f03491..a327b6a40 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md @@ -23,11 +23,12 @@ - [titleNode](OpenWorkspace.md#titlenode) - [type](OpenWorkspace.md#type) - [width](OpenWorkspace.md#width) +- [workspaceGroups](OpenWorkspace.md#workspacegroups) ### Workspace Properties - [additionalProps](OpenWorkspace.md#additionalprops) -- [workspaceContainerName](OpenWorkspace.md#workspacecontainername) +- [currentWorkspaceGroup](OpenWorkspace.md#currentworkspacegroup) ### Methods @@ -165,6 +166,20 @@ ___ ___ +### workspaceGroups + +• `Optional` **workspaceGroups**: `string`[] + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[workspaceGroups](WorkspaceRegistration.md#workspacegroups) + +#### Defined in + +[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) + +___ + ## Workspace Properties ### additionalProps @@ -173,17 +188,17 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:107](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L107) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:109](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L109) ___ -### workspaceContainerName +### currentWorkspaceGroup -• `Optional` **workspaceContainerName**: `string` +• `Optional` **currentWorkspaceGroup**: `string` #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:108](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L108) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:110](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L110) ## Methods @@ -213,7 +228,7 @@ closed, given the user forcefully closes the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:46](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L46) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L45) ___ @@ -240,7 +255,7 @@ will directly close the workspace without any prompt #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:56](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L56) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:55](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L55) ___ @@ -285,7 +300,7 @@ this workspace is closed; e.g. if there is unsaved data. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:51](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L51) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:50](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L50) ___ @@ -317,4 +332,4 @@ title needs to be set dynamically. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:71](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L71) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:70](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L70) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md index 797c8579c..879a2817e 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md @@ -27,7 +27,7 @@ A list of backend modules necessary for this frontend module and the correspondi #### Defined in -[packages/framework/esm-globals/src/types.ts:358](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L358) +[packages/framework/esm-globals/src/types.ts:359](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L359) ___ @@ -39,7 +39,7 @@ An array of all extensions supported by this frontend module. Extensions can be #### Defined in -[packages/framework/esm-globals/src/types.ts:374](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L374) +[packages/framework/esm-globals/src/types.ts:375](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L375) ___ @@ -51,7 +51,7 @@ An array of all feature flags for any beta-stage features this module provides. #### Defined in -[packages/framework/esm-globals/src/types.ts:376](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L376) +[packages/framework/esm-globals/src/types.ts:377](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L377) ___ @@ -63,7 +63,7 @@ An array of all modals supported by this frontend module. Modals can be launched #### Defined in -[packages/framework/esm-globals/src/types.ts:378](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L378) +[packages/framework/esm-globals/src/types.ts:379](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L379) ___ @@ -81,7 +81,7 @@ The name of the backend dependency and either the required version or an object #### Defined in -[packages/framework/esm-globals/src/types.ts:360](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L360) +[packages/framework/esm-globals/src/types.ts:361](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L361) ___ @@ -93,7 +93,7 @@ An array of all pages supported by this frontend module. Pages are automatically #### Defined in -[packages/framework/esm-globals/src/types.ts:372](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L372) +[packages/framework/esm-globals/src/types.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L373) ___ @@ -105,7 +105,7 @@ The version of this frontend module. #### Defined in -[packages/framework/esm-globals/src/types.ts:356](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L356) +[packages/framework/esm-globals/src/types.ts:357](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L357) ___ @@ -117,4 +117,4 @@ An array of all workspaces supported by this frontend module. Workspaces can be #### Defined in -[packages/framework/esm-globals/src/types.ts:380](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L380) +[packages/framework/esm-globals/src/types.ts:381](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L381) diff --git a/packages/framework/esm-framework/docs/interfaces/Prompt.md b/packages/framework/esm-framework/docs/interfaces/Prompt.md index 468ad3480..c9e509fb7 100644 --- a/packages/framework/esm-framework/docs/interfaces/Prompt.md +++ b/packages/framework/esm-framework/docs/interfaces/Prompt.md @@ -23,7 +23,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:90](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L90) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:89](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L89) ___ @@ -35,7 +35,7 @@ Defaults to "Cancel" #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:95](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L95) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:94](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L94) ___ @@ -47,7 +47,7 @@ Defaults to "Confirm" #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:92](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L92) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:91](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L91) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:89](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L89) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:88](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L88) ## Methods @@ -71,4 +71,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:93](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L93) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:92](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L92) diff --git a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md index e7faed7bc..0793cc437 100644 --- a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md +++ b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md @@ -20,4 +20,4 @@ #### Defined in -[packages/framework/esm-globals/src/types.ts:390](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L390) +[packages/framework/esm-globals/src/types.ts:391](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L391) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md index b95f5e7c1..dff60c273 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md @@ -23,6 +23,7 @@ See [WorkspaceDefinition](../API.md#workspacedefinition) for more information ab - [titleNode](WorkspaceRegistration.md#titlenode) - [type](WorkspaceRegistration.md#type) - [width](WorkspaceRegistration.md#width) +- [workspaceGroups](WorkspaceRegistration.md#workspacegroups) ### Methods @@ -118,6 +119,16 @@ ___ [packages/framework/esm-extensions/src/workspaces.ts:16](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L16) +___ + +### workspaceGroups + +• `Optional` **workspaceGroups**: `string`[] + +#### Defined in + +[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) + ## Methods ### load diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 3af1bab2d..f693e00e2 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -7,8 +7,8 @@ ### Workspace Properties - [active](WorkspacesInfo.md#active) -- [currentGroupName](WorkspacesInfo.md#currentgroupname) - [prompt](WorkspacesInfo.md#prompt) +- [workspaceGroup](WorkspacesInfo.md#workspacegroup) - [workspaceWindowState](WorkspacesInfo.md#workspacewindowstate) - [workspaces](WorkspacesInfo.md#workspaces) @@ -20,27 +20,34 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:429](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L429) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:489](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L489) ___ -### currentGroupName +### prompt -• `Optional` **currentGroupName**: `string` +• **prompt**: ``null`` \| [`Prompt`](Prompt.md) #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:433](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L433) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:490](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L490) ___ -### prompt +### workspaceGroup -• **prompt**: ``null`` \| [`Prompt`](Prompt.md) +• `Optional` **workspaceGroup**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `cleanup?` | `Function` | +| `name` | `string` | #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:430](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L430) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) ___ @@ -50,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:431](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L431) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:491](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L491) ___ @@ -60,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:432](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L432) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:492](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L492) From 62fbe0fa0206ee956ee7afec43286c154551de37 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 14:29:26 +0530 Subject: [PATCH 11/22] Fix failing tests --- .../esm-extensions/src/workspaces.ts | 3 +- .../container/workspace-renderer.test.tsx | 1 - .../src/workspaces/workspaces.test.ts | 151 ++++++++++++------ .../src/workspaces/workspaces.ts | 6 +- 4 files changed, 110 insertions(+), 51 deletions(-) diff --git a/packages/framework/esm-extensions/src/workspaces.ts b/packages/framework/esm-extensions/src/workspaces.ts index 002c4ab82..6493371b0 100644 --- a/packages/framework/esm-extensions/src/workspaces.ts +++ b/packages/framework/esm-extensions/src/workspaces.ts @@ -39,7 +39,7 @@ export interface RegisterWorkspaceOptions { preferredWindowSize?: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; - workspaceGroups: Array; + workspaceGroups?: Array; } /** @@ -58,6 +58,7 @@ export function registerWorkspace(workspace: RegisterWorkspaceOptions) { canHide: workspace.canHide ?? false, canMaximize: workspace.canMaximize ?? false, width: workspace.width ?? 'narrow', + workspaceGroups: workspace.workspaceGroups ?? [], }, }, })); diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx index 71f128af0..1fba8027f 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx @@ -58,7 +58,6 @@ describe('WorkspaceRenderer', () => { setTitle: mockedSetTitle, foo: 'true', bar: 'true', - workspaceFamilyState: {}, }); }); }); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index c765df380..c7ea1e08a 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -5,6 +5,7 @@ import { getWorkspaceFamilyStore, getWorkspaceStore, launchWorkspace, + launchWorkspaceGroup, resetWorkspaceStore, } from './workspaces'; import { registerExtension, registerWorkspace } from '@openmrs/esm-extensions'; @@ -472,7 +473,7 @@ describe('workspace system', () => { }); describe('Testing workspace family store', () => { - it('should create store for workspaces with sidebarFamilyName', () => { + it('should create store for workspace groups', () => { registerWorkspace({ name: 'allergies', title: 'Allergies', @@ -485,8 +486,15 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: ['ward-patient-sidebar'], + }); + launchWorkspaceGroup({ + groupName: 'ward-patient-sidebar', + state: {}, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); - launchWorkspace('ward-patient-workspace'); const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); const workspaceStore = getWorkspaceStore(); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); @@ -499,16 +507,23 @@ describe('workspace system', () => { expect(workspaceFamilyStore?.getState()).toStrictEqual({}); }); - it('should clear workspace family store by default if the workspace is closed, since `clearWorkspaceFamilyStore` is true by default', async () => { + it('should clear workspace family store by default if the workspace is closed, since `closeWorkspaceGroup` is true by default', async () => { registerWorkspace({ name: 'ward-patient-workspace', title: 'Ward Patient Workspace', load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: ['ward-patient-sidebar'], }); - launchWorkspace('ward-patient-workspace', { - foo: true, + launchWorkspaceGroup({ + groupName: 'ward-patient-sidebar', + state: { + foo: true, + }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); expect(workspaceFamilyStore).toBeTruthy(); @@ -518,7 +533,7 @@ describe('workspace system', () => { expect(workspaceFamilyStore?.getState()).toStrictEqual({}); }); - it('should not clear the workspace store if the new workspace opened is of the same type as the already opened workspace', () => { + it('should not clear the workspace store if the new workspace opened can open in the same group', () => { const sidebarFamily = 'ward-patient-sidebar'; registerWorkspace({ name: 'ward-patient-workspace', @@ -526,6 +541,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: [sidebarFamily], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -533,16 +549,25 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: [sidebarFamily], }); - const workspaceStore = getWorkspaceStore(); - launchWorkspace('ward-patient-workspace', { - foo: true, + launchWorkspaceGroup({ + groupName: sidebarFamily, + state: { + foo: true, + }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); + const workspaceStore = getWorkspaceStore(); const sidebarFamilyStore = getWorkspaceFamilyStore(sidebarFamily); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(sidebarFamilyStore).toBeTruthy(); expect(sidebarFamilyStore?.getState()?.['foo']).toBe(true); - launchWorkspace('transfer-patient-workspace', { bar: false }); + launchWorkspace('transfer-patient-workspace', { + bar: false, + }); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); const transferPatientWorkspace = workspaceStore.getState().openWorkspaces[0]; expect(sidebarFamilyStore?.getState()?.['foo']).toBe(true); @@ -556,6 +581,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: ['ward-patient-sidebar'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -563,16 +589,32 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: ['another-sidebar-family'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspace('ward-patient-workspace', { - foo: true, + launchWorkspaceGroup({ + groupName: 'ward-patient-sidebar', + state: { + foo: true, + }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(wardPatientFamilyStore).toBeTruthy(); expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - launchWorkspace('transfer-patient-workspace', { bar: false }); + launchWorkspaceGroup({ + groupName: 'another-sidebar-family', + state: { + bar: false, + }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('transfer-patient-workspace'); + }, + }); + expect(workspaceStore.getState().workspaceGroup?.name).toBe('another-sidebar-family'); const anotherSidebarFamilyStore = getWorkspaceFamilyStore('another-sidebar-family'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(anotherSidebarFamilyStore?.getState()?.['bar']).toBe(false); @@ -580,36 +622,36 @@ describe('workspace system', () => { expect(wardPatientFamilyStore?.getState()).toStrictEqual({}); }); - it('should not clear the store when new workspace with different sidebar is opened, given the original workspace can hide', () => { - registerWorkspace({ - name: 'ward-patient-workspace', - title: 'Ward Patient Workspace', - load: jest.fn(), - type: 'ward-patient', - moduleName: '@openmrs/esm-ward-app', - canHide: true, - }); - registerWorkspace({ - name: 'transfer-patient-workspace', - title: 'Transfer Patient Workspace', - load: jest.fn(), - type: 'transfer-patient', - moduleName: '@openmrs/esm-ward-app', - }); - const workspaceStore = getWorkspaceStore(); - launchWorkspace('ward-patient-workspace', { - foo: true, - }); - const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); - expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - expect(wardPatientFamilyStore).toBeTruthy(); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - launchWorkspace('transfer-patient-workspace', { bar: false }); - const anotherSidebarFamilyStore = getWorkspaceFamilyStore('another-sidebar-family'); - expect(workspaceStore.getState().openWorkspaces.length).toBe(2); - expect(anotherSidebarFamilyStore?.getState()?.['bar']).toBe(false); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - }); + // it('should not clear the store when new workspace with different sidebar is opened, given the original workspace can hide', () => { + // registerWorkspace({ + // name: 'ward-patient-workspace', + // title: 'Ward Patient Workspace', + // load: jest.fn(), + // type: 'ward-patient', + // moduleName: '@openmrs/esm-ward-app', + // canHide: true, + // }); + // registerWorkspace({ + // name: 'transfer-patient-workspace', + // title: 'Transfer Patient Workspace', + // load: jest.fn(), + // type: 'transfer-patient', + // moduleName: '@openmrs/esm-ward-app', + // }); + // const workspaceStore = getWorkspaceStore(); + // launchWorkspace('ward-patient-workspace', { + // foo: true, + // }); + // const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + // expect(workspaceStore.getState().openWorkspaces.length).toBe(1); + // expect(wardPatientFamilyStore).toBeTruthy(); + // expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); + // launchWorkspace('transfer-patient-workspace', { bar: false }); + // const anotherSidebarFamilyStore = getWorkspaceFamilyStore('another-sidebar-family'); + // expect(workspaceStore.getState().openWorkspaces.length).toBe(2); + // expect(anotherSidebarFamilyStore?.getState()?.['bar']).toBe(false); + // expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); + // }); it('should not clear the workspace if a workspace of same sidebar family is opened', () => { registerWorkspace({ @@ -619,6 +661,7 @@ describe('workspace system', () => { type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', canHide: true, + workspaceGroups: ['ward-patient-sidebar'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -626,10 +669,17 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', + workspaceGroups: ['ward-patient-sidebar'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspace('ward-patient-workspace', { - foo: true, + launchWorkspaceGroup({ + groupName: 'ward-patient-sidebar', + state: { + foo: true, + }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); @@ -648,9 +698,14 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - }); - launchWorkspace('ward-patient-workspace', { - foo: true, + workspaceGroups: ['ward-patient-sidebar'], + }); + launchWorkspaceGroup({ + groupName: 'ward-patient-sidebar', + state: { foo: true }, + onWorkspaceGroupLaunch: () => { + launchWorkspace('ward-patient-workspace'); + }, }); const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); expect(workspaceFamilyStore).toBeTruthy(); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index c3bcfef82..966d7e4cc 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -258,6 +258,7 @@ export function launchWorkspace< }); return; } + const currentGroupName = store.getState().workspaceGroup?.name; const newWorkspace: OpenWorkspace = { ...workspace, title: getWorkspaceTitle(workspace, additionalProps), @@ -276,10 +277,13 @@ export function launchWorkspace< }; }); }, - currentWorkspaceGroup: store.getState().workspaceGroup?.name, + currentWorkspaceGroup: currentGroupName, additionalProps: additionalProps ?? {}, }; + if (currentGroupName) { + getWorkspaceFamilyStore(currentGroupName, additionalProps); + } function updateStoreWithNewWorkspace(workspaceToBeAdded: OpenWorkspace, restOfTheWorkspaces?: Array) { store.setState((state) => { const openWorkspaces = [workspaceToBeAdded, ...(restOfTheWorkspaces ?? state.openWorkspaces)]; From 49b62419553a6a5a89c6bacc64a82ecc0000de08 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 14:29:56 +0530 Subject: [PATCH 12/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 6 +++--- .../esm-framework/docs/interfaces/WorkspacesInfo.md | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 2f41fdd12..b5c919ae1 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:380](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L380) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:384](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L384) ___ @@ -8146,7 +8146,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:337](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L337) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:341](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L341) ___ @@ -8160,4 +8160,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:500](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L500) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index f693e00e2..0ab90518f 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -20,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:489](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L489) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:490](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L490) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:494](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L494) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:497](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L497) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:491](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L491) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:495](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L495) ___ @@ -67,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:492](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L492) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) From 3e4cbbc94499f7f3999ce0f8f992ddaecc071a66 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 14:39:02 +0530 Subject: [PATCH 13/22] Restore app-shell webpack config --- packages/shell/esm-app-shell/webpack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shell/esm-app-shell/webpack.config.js b/packages/shell/esm-app-shell/webpack.config.js index 11fabee0a..a3be9324a 100644 --- a/packages/shell/esm-app-shell/webpack.config.js +++ b/packages/shell/esm-app-shell/webpack.config.js @@ -23,7 +23,7 @@ const { ModuleFederationPlugin } = container; const openmrsAddCookie = process.env.OMRS_ADD_COOKIE; const openmrsApiUrl = removeTrailingSlash(process.env.OMRS_API_URL || '/openmrs'); const openmrsPublicPath = removeTrailingSlash(process.env.OMRS_PUBLIC_PATH || '/openmrs/spa'); -const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://kgh-test.pih-emr.org/'; +const openmrsProxyTarget = process.env.OMRS_PROXY_TARGET || 'https://dev3.openmrs.org/'; const openmrsPageTitle = process.env.OMRS_PAGE_TITLE || 'OpenMRS'; const openmrsFavicon = process.env.OMRS_FAVICON || `${openmrsPublicPath}/favicon.ico`; const openmrsEnvironment = process.env.OMRS_ENV || process.env.NODE_ENV || ''; @@ -34,7 +34,7 @@ const openmrsImportmapUrl = process.env.OMRS_ESM_IMPORTMAP_URL || `${openmrsPubl const openmrsRoutesDef = process.env.OMRS_ROUTES; const openmrsRoutesUrl = process.env.OMRS_ROUTES_URL || `${openmrsPublicPath}/routes.registry.json`; const openmrsCoreApps = process.env.OMRS_ESM_CORE_APPS_DIR || resolve(__dirname, '../../apps'); -const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '/openmrs/spa/site/config.json') +const openmrsConfigUrls = (process.env.OMRS_CONFIG_URLS || '') .split(';') .filter((url) => url.length > 0) .map((url) => JSON.stringify(url)) From d7b31009bc0b03a75580ac6b1581679de2401ab8 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 14:39:23 +0530 Subject: [PATCH 14/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 2 +- .../esm-framework/docs/interfaces/WorkspaceContainerProps.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index b5c919ae1..b255643ce 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -5855,7 +5855,7 @@ This component also provides everything needed for workspace notifications to be #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:68](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L68) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:69](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L69) ___ diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md index 660f1b2ac..86a58ac1b 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md @@ -21,7 +21,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L20) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:21](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L21) ___ From 96c1e62e18a8f86f244c63a89704023190a346e3 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 14:42:37 +0530 Subject: [PATCH 15/22] Update the API for launchWorkspaceGroup --- .../src/workspaces/workspaces.test.ts | 21 +++++++------------ .../src/workspaces/workspaces.ts | 9 ++++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index c7ea1e08a..342135c49 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -488,8 +488,7 @@ describe('workspace system', () => { moduleName: '@openmrs/esm-ward-app', workspaceGroups: ['ward-patient-sidebar'], }); - launchWorkspaceGroup({ - groupName: 'ward-patient-sidebar', + launchWorkspaceGroup('ward-patient-sidebar', { state: {}, onWorkspaceGroupLaunch: () => { launchWorkspace('ward-patient-workspace'); @@ -516,8 +515,7 @@ describe('workspace system', () => { moduleName: '@openmrs/esm-ward-app', workspaceGroups: ['ward-patient-sidebar'], }); - launchWorkspaceGroup({ - groupName: 'ward-patient-sidebar', + launchWorkspaceGroup('ward-patient-sidebar', { state: { foo: true, }, @@ -551,8 +549,7 @@ describe('workspace system', () => { moduleName: '@openmrs/esm-ward-app', workspaceGroups: [sidebarFamily], }); - launchWorkspaceGroup({ - groupName: sidebarFamily, + launchWorkspaceGroup(sidebarFamily, { state: { foo: true, }, @@ -592,8 +589,7 @@ describe('workspace system', () => { workspaceGroups: ['another-sidebar-family'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspaceGroup({ - groupName: 'ward-patient-sidebar', + launchWorkspaceGroup('ward-patient-sidebar', { state: { foo: true, }, @@ -605,8 +601,7 @@ describe('workspace system', () => { expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(wardPatientFamilyStore).toBeTruthy(); expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - launchWorkspaceGroup({ - groupName: 'another-sidebar-family', + launchWorkspaceGroup('another-sidebar-family', { state: { bar: false, }, @@ -672,8 +667,7 @@ describe('workspace system', () => { workspaceGroups: ['ward-patient-sidebar'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspaceGroup({ - groupName: 'ward-patient-sidebar', + launchWorkspaceGroup('ward-patient-sidebar', { state: { foo: true, }, @@ -700,8 +694,7 @@ describe('workspace system', () => { moduleName: '@openmrs/esm-ward-app', workspaceGroups: ['ward-patient-sidebar'], }); - launchWorkspaceGroup({ - groupName: 'ward-patient-sidebar', + launchWorkspaceGroup('ward-patient-sidebar', { state: { foo: true }, onWorkspaceGroupLaunch: () => { launchWorkspace('ward-patient-workspace'); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 966d7e4cc..4f7ced848 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -158,24 +158,23 @@ function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { } interface LaunchWorkspaceGroupArg { - groupName: string; state: object; onWorkspaceGroupLaunch?: Function; workspaceGroupCleanup?: Function; } -export function launchWorkspaceGroup(args: LaunchWorkspaceGroupArg) { - const { groupName, state, onWorkspaceGroupLaunch, workspaceGroupCleanup } = args; +export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGroupArg) { + const { state, onWorkspaceGroupLaunch, workspaceGroupCleanup } = args; const store = getWorkspaceStore(); if (store.getState().openWorkspaces.length) { const workspaceGroup = store.getState().workspaceGroup; if (workspaceGroup) { closeWorkspaceGroup(workspaceGroup?.name, () => { - launchWorkspaceGroup(args); + launchWorkspaceGroup(groupName, args); }); } else { closeAllWorkspaces(() => { - launchWorkspaceGroup(args); + launchWorkspaceGroup(groupName, args); }); } } else { From 99ae0dc6b8a90f38b96b5148528c660e159a12a4 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 15:55:55 +0530 Subject: [PATCH 16/22] Self review changes --- packages/framework/esm-framework/docs/API.md | 13 +-- .../docs/interfaces/WorkspacesInfo.md | 10 +- packages/framework/esm-globals/src/types.ts | 17 ++- .../workspace-container.component.tsx | 2 - .../workspace-renderer.component.tsx | 4 +- .../container/workspace-renderer.test.tsx | 5 +- ...milyStore.ts => useWorkspaceGroupStore.ts} | 19 ++-- .../src/workspaces/workspaces.test.ts | 101 ++++++------------ .../src/workspaces/workspaces.ts | 73 +++++++++---- 9 files changed, 117 insertions(+), 127 deletions(-) rename packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/{useWorkspaceFamilyStore.ts => useWorkspaceGroupStore.ts} (62%) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index b255643ce..913d6eb44 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:384](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L384) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:383](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L383) ___ @@ -8100,18 +8100,19 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:248](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L248) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:247](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L247) ___ ### launchWorkspaceGroup -▸ **launchWorkspaceGroup**(`args`): `void` +▸ **launchWorkspaceGroup**(`groupName`, `args`): `void` #### Parameters | Name | Type | | :------ | :------ | +| `groupName` | `string` | | `args` | `LaunchWorkspaceGroupArg` | #### Returns @@ -8120,7 +8121,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:167](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L167) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:166](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L166) ___ @@ -8146,7 +8147,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:341](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L341) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:340](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L340) ___ @@ -8160,4 +8161,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:500](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L500) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:499](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L499) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 0ab90518f..8289b0eb5 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -20,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:492](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L492) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:494](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L494) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:497](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L497) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:495](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L495) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:494](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L494) ___ @@ -67,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:495](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L495) diff --git a/packages/framework/esm-globals/src/types.ts b/packages/framework/esm-globals/src/types.ts index 53921ec1a..d1447dccf 100644 --- a/packages/framework/esm-globals/src/types.ts +++ b/packages/framework/esm-globals/src/types.ts @@ -302,19 +302,14 @@ export type WorkspaceDefinition = { * The width "extra-wide" is for workspaces that contain their own sidebar. */ width?: 'narrow' | 'wider' | 'extra-wide'; + preferredWindowSize?: WorkspaceWindowState; /** - * Controls whether the workspace has its own sidebar. If true, the sidebar will be displayed when the workspace is open. - */ - hasOwnSidebar?: boolean; - /** - * Sidebars have icons that representing workspaces. The sidebar family is the name of the - * sidebar that should contain the icon for this workspace. This is generally only needed if - * `hasOwnSidebar` is true, in which case this is the name of that sidebar. If multiple - * workspaces have `hasOwnSidebar` set to true and the same family name, then the sidebar - * within the workspace area will have icons for each of those workspaces. + * Workspaces can open either individually or in a group of workspaces. The workspace groups + * will define the groups in which a workspace can be opened. + * + * In case the currently opened workspace is not present in the workspaceGroups of a workspace, + * the current group will close and then the workspace will be launched. */ - sidebarFamily?: string; - preferredWindowSize?: WorkspaceWindowState; workspaceGroups: Array; } & ( | { diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index de895157d..8f37ecd09 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -14,7 +14,6 @@ import styles from './workspace.module.scss'; export interface WorkspaceContainerProps { contextKey: string; - containerName?: string; overlay?: boolean; showSiderailAndBottomNav?: boolean; additionalWorkspaceProps?: object; @@ -256,7 +255,6 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro additionalPropsFromPage={additionalWorkspaceProps} />
- {/* {hasOwnSidebar && } */} ) ); diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx index 3fa6fe936..2095ca765 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx @@ -5,7 +5,7 @@ import { InlineLoading } from '@carbon/react'; import { getCoreTranslation } from '@openmrs/esm-translations'; import styles from './workspace.module.scss'; import { type OpenWorkspace } from '../workspaces'; -import { useWorkspaceFamilyStore } from '../workspace-sidebar-store/useWorkspaceFamilyStore'; +import { useWorkspaceGroupStore } from '../workspace-sidebar-store/useWorkspaceGroupStore'; interface WorkspaceRendererProps { workspace: OpenWorkspace; @@ -14,7 +14,7 @@ interface WorkspaceRendererProps { export function WorkspaceRenderer({ workspace, additionalPropsFromPage }: WorkspaceRendererProps) { const [lifecycle, setLifecycle] = useState(); - const workspaceFamilyState = useWorkspaceFamilyStore(workspace.currentWorkspaceGroup); + const workspaceFamilyState = useWorkspaceGroupStore(workspace.currentWorkspaceGroup); useEffect(() => { let active = true; diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx index 1fba8027f..1b8cf6c5f 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { WorkspaceRenderer } from './workspace-renderer.component'; -import { getWorkspaceFamilyStore, OpenWorkspace } from '../workspaces'; +import { getWorkspaceGroupStore } from '../workspaces'; import Parcel from 'single-spa-react/parcel'; const mockFn = jest.fn(); @@ -20,7 +20,7 @@ describe('WorkspaceRenderer', () => { const mockedPromptBeforeClosing = jest.fn(); const mockedSetTitle = jest.fn(); const mockedLoadFn = jest.fn().mockImplementation(() => Promise.resolve({ default: 'file-content' })); - getWorkspaceFamilyStore('test-sidebar-family')?.setState({ + getWorkspaceGroupStore('test-sidebar-family')?.setState({ // Testing that the workspace family state should be overrided by additionalProps foo: false, workspaceFamilyState: {}, @@ -39,7 +39,6 @@ describe('WorkspaceRenderer', () => { additionalProps: { foo: 'true', }, - sidebarFamily: 'test-sidebar-family', }} additionalPropsFromPage={{ bar: 'true' }} />, diff --git a/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts b/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceGroupStore.ts similarity index 62% rename from packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts rename to packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceGroupStore.ts index e2460c261..1d1f14945 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceFamilyStore.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspace-sidebar-store/useWorkspaceGroupStore.ts @@ -1,6 +1,5 @@ -import { useEffect, useMemo, useState } from 'react'; -import { getWorkspaceFamilyStore } from '../workspaces'; -import type { StoreApi } from 'zustand/vanilla'; +import { useEffect, useState } from 'react'; +import { getWorkspaceGroupStore } from '../workspaces'; /** * This hook is used to interact with the store of a workspace family. @@ -12,18 +11,18 @@ import type { StoreApi } from 'zustand/vanilla'; * * @param {string} sidebarFamilyName The sidebarFamilyName of the workspace used when registering the workspace in the module's routes.json file. */ -export function useWorkspaceFamilyStore(sidebarFamilyName?: string) { +export function useWorkspaceGroupStore(workspaceGroupName?: string) { const [storeState, setStoreState] = useState({}); - const [currentSidebarFamilyName, setCurrentSidebarFamilyName] = useState(sidebarFamilyName); + const [currentWorkspaceGroupName, setCurrentWorkspaceGroupName] = useState(workspaceGroupName); useEffect(() => { - if (currentSidebarFamilyName !== sidebarFamilyName) { - setCurrentSidebarFamilyName(sidebarFamilyName); + if (currentWorkspaceGroupName !== workspaceGroupName) { + setCurrentWorkspaceGroupName(workspaceGroupName); } - }, [sidebarFamilyName]); + }, [workspaceGroupName]); useEffect(() => { - const store = getWorkspaceFamilyStore(currentSidebarFamilyName); + const store = getWorkspaceGroupStore(currentWorkspaceGroupName); let unsubscribe: () => void; if (store) { setStoreState(store.getState()); @@ -34,7 +33,7 @@ export function useWorkspaceFamilyStore(sidebarFamilyName?: string) { unsubscribe?.(); } }; - }, [currentSidebarFamilyName]); + }, [currentWorkspaceGroupName]); return storeState; } diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index 342135c49..9d6d4c282 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -2,7 +2,7 @@ import { type Prompt, cancelPrompt, closeWorkspace, - getWorkspaceFamilyStore, + getWorkspaceGroupStore, getWorkspaceStore, launchWorkspace, launchWorkspaceGroup, @@ -441,29 +441,29 @@ describe('workspace system', () => { expect(store.getState().openWorkspaces.length).toBe(0); }); - describe('Testing `getWorkspaceFamilyStore` function', () => { + describe('Testing `getWorkspaceGroupStore` function', () => { it('should return undefined if no workspace sidebar name is passed', () => { - let workspaceFamilyStore = getWorkspaceFamilyStore(undefined); + let workspaceFamilyStore = getWorkspaceGroupStore(undefined); expect(workspaceFamilyStore).toBeUndefined(); - workspaceFamilyStore = getWorkspaceFamilyStore('default'); + workspaceFamilyStore = getWorkspaceGroupStore('default'); expect(workspaceFamilyStore).toBeUndefined(); }); it('should return store if workspace sidebar name is passed', () => { - const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar', { + const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { foo: true, }); expect(workspaceFamilyStore).toBeTruthy(); expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); }); - it('should update the store state with new additionalProps if workspaces with same sidebarFamily name calls the function', () => { - let workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar', { + it('should update the store state with new additionalProps if workspaces with same workspaceGroup name calls the function', () => { + let workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { foo: true, }); expect(workspaceFamilyStore).toBeTruthy(); expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); - workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar', { + workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { bar: true, }); expect(workspaceFamilyStore).toBeTruthy(); @@ -486,15 +486,15 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); - launchWorkspaceGroup('ward-patient-sidebar', { + launchWorkspaceGroup('ward-patient-store', { state: {}, onWorkspaceGroupLaunch: () => { launchWorkspace('ward-patient-workspace'); }, }); - const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); const workspaceStore = getWorkspaceStore(); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(workspaceStore.getState().openWorkspaces[0].name).toBe('ward-patient-workspace'); @@ -513,9 +513,9 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); - launchWorkspaceGroup('ward-patient-sidebar', { + launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, @@ -523,7 +523,7 @@ describe('workspace system', () => { launchWorkspace('ward-patient-workspace'); }, }); - const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceFamilyStore).toBeTruthy(); expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); closeWorkspace('ward-patient-workspace'); @@ -532,14 +532,14 @@ describe('workspace system', () => { }); it('should not clear the workspace store if the new workspace opened can open in the same group', () => { - const sidebarFamily = 'ward-patient-sidebar'; + const workspaceGroup = 'ward-patient-store'; registerWorkspace({ name: 'ward-patient-workspace', title: 'Ward Patient Workspace', load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: [sidebarFamily], + workspaceGroups: [workspaceGroup], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -547,9 +547,9 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: [sidebarFamily], + workspaceGroups: [workspaceGroup], }); - launchWorkspaceGroup(sidebarFamily, { + launchWorkspaceGroup(workspaceGroup, { state: { foo: true, }, @@ -558,17 +558,17 @@ describe('workspace system', () => { }, }); const workspaceStore = getWorkspaceStore(); - const sidebarFamilyStore = getWorkspaceFamilyStore(sidebarFamily); + const workspaceGroupStore = getWorkspaceGroupStore(workspaceGroup); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - expect(sidebarFamilyStore).toBeTruthy(); - expect(sidebarFamilyStore?.getState()?.['foo']).toBe(true); + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); launchWorkspace('transfer-patient-workspace', { bar: false, }); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); const transferPatientWorkspace = workspaceStore.getState().openWorkspaces[0]; - expect(sidebarFamilyStore?.getState()?.['foo']).toBe(true); - expect(sidebarFamilyStore?.getState()?.['bar']).toBe(false); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); + expect(workspaceGroupStore?.getState()?.['bar']).toBe(false); }); it('should clear the store when new workspace with different sidebar is opened, given the original workspace cannot hide', () => { @@ -578,7 +578,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -589,7 +589,7 @@ describe('workspace system', () => { workspaceGroups: ['another-sidebar-family'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspaceGroup('ward-patient-sidebar', { + launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, @@ -597,7 +597,7 @@ describe('workspace system', () => { launchWorkspace('ward-patient-workspace'); }, }); - const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(wardPatientFamilyStore).toBeTruthy(); expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); @@ -610,44 +610,13 @@ describe('workspace system', () => { }, }); expect(workspaceStore.getState().workspaceGroup?.name).toBe('another-sidebar-family'); - const anotherSidebarFamilyStore = getWorkspaceFamilyStore('another-sidebar-family'); + const anotherWorkspaceGroupStore = getWorkspaceGroupStore('another-sidebar-family'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - expect(anotherSidebarFamilyStore?.getState()?.['bar']).toBe(false); + expect(anotherWorkspaceGroupStore?.getState()?.['bar']).toBe(false); expect(wardPatientFamilyStore?.getState()?.['foo']).toBeUndefined(); expect(wardPatientFamilyStore?.getState()).toStrictEqual({}); }); - // it('should not clear the store when new workspace with different sidebar is opened, given the original workspace can hide', () => { - // registerWorkspace({ - // name: 'ward-patient-workspace', - // title: 'Ward Patient Workspace', - // load: jest.fn(), - // type: 'ward-patient', - // moduleName: '@openmrs/esm-ward-app', - // canHide: true, - // }); - // registerWorkspace({ - // name: 'transfer-patient-workspace', - // title: 'Transfer Patient Workspace', - // load: jest.fn(), - // type: 'transfer-patient', - // moduleName: '@openmrs/esm-ward-app', - // }); - // const workspaceStore = getWorkspaceStore(); - // launchWorkspace('ward-patient-workspace', { - // foo: true, - // }); - // const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); - // expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - // expect(wardPatientFamilyStore).toBeTruthy(); - // expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - // launchWorkspace('transfer-patient-workspace', { bar: false }); - // const anotherSidebarFamilyStore = getWorkspaceFamilyStore('another-sidebar-family'); - // expect(workspaceStore.getState().openWorkspaces.length).toBe(2); - // expect(anotherSidebarFamilyStore?.getState()?.['bar']).toBe(false); - // expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - // }); - it('should not clear the workspace if a workspace of same sidebar family is opened', () => { registerWorkspace({ name: 'ward-patient-workspace', @@ -656,7 +625,7 @@ describe('workspace system', () => { type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', canHide: true, - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -664,10 +633,10 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); const workspaceStore = getWorkspaceStore(); - launchWorkspaceGroup('ward-patient-sidebar', { + launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, @@ -675,7 +644,7 @@ describe('workspace system', () => { launchWorkspace('ward-patient-workspace'); }, }); - const wardPatientFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(wardPatientFamilyStore).toBeTruthy(); expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); @@ -692,15 +661,15 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-sidebar'], + workspaceGroups: ['ward-patient-store'], }); - launchWorkspaceGroup('ward-patient-sidebar', { + launchWorkspaceGroup('ward-patient-store', { state: { foo: true }, onWorkspaceGroupLaunch: () => { launchWorkspace('ward-patient-workspace'); }, }); - const workspaceFamilyStore = getWorkspaceFamilyStore('ward-patient-sidebar'); + const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceFamilyStore).toBeTruthy(); expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); // test that default options are interpolated when providing options to `closeWorkspace` diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 4f7ced848..dbdc4c752 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -24,15 +24,15 @@ export interface CloseWorkspaceOptions { */ onWorkspaceClose?: () => void; /** - * Controls whether the workspace family store will be cleared when this workspace is closed. Defaults to true except when opening a new workspace of the same family. + * Controls whether the workspace group should be closed and store to be + * cleared when this workspace is closed. + * Defaults to true except when opening a new workspace of the same family. * * @default true */ closeWorkspaceGroup?: boolean; } -interface CloseWorkspaceInternalOptions extends CloseWorkspaceOptions {} - /** The default parameters received by all workspaces */ export interface DefaultWorkspaceProps { /** @@ -124,6 +124,22 @@ export function canCloseWorkspaceWithoutPrompting(name: string, ignoreChanges: b return !promptBeforeFn || !promptBeforeFn(); } +/** + * Closes a workspace group and performs cleanup operations. + * + * @param groupName - The name of the workspace group to close + * @param onWorkspaceCloseup - Optional callback function to execute after closing the workspace group + * @returns void, or exits early if the current workspace group name doesn't match the provided group name + * + * @remarks + * This function performs the following operations: + * - Validates if the provided group name matches the current workspace group + * - Closes all workspaces associated with the group + * - Clears the workspace group store state + * - Executes cleanup function if defined in the workspace group + * - Updates the main workspace store to remove the workspace group + * - Calls the optional closeup callback if provided + */ function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { const store = getWorkspaceStore(); const currentWorkspaceGroup = store.getState()?.workspaceGroup; @@ -136,8 +152,8 @@ function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { : () => true; closeAllWorkspaces(() => { - // Clearing the workspace family store if there are no more workspaces with the same sidebar family name and the new workspace is not of the same sidebar family, which is handled in the `launchWorkspace` function. - const workspaceFamilyStore = getWorkspaceFamilyStore(groupName); + // Clearing the workspace group and respective store if the new workspace is not part of the current group, which is handled in the `launchWorkspace` function. + const workspaceFamilyStore = getWorkspaceGroupStore(groupName); if (workspaceFamilyStore) { workspaceFamilyStore.setState({}, true); const unsubscribe = workspaceFamilyStore.subscribe(() => {}); @@ -163,6 +179,23 @@ interface LaunchWorkspaceGroupArg { workspaceGroupCleanup?: Function; } +/** + * Launches a workspace group with the specified name and configuration. + * If there are any open workspaces, it will first close them before launching the new workspace group. + * + * @param groupName - The name of the workspace group to launch + * @param args - Configuration object for launching the workspace group + * @param args.state - The initial state for the workspace group + * @param args.onWorkspaceGroupLaunch - Optional callback function to be executed after the workspace group is launched + * @param args.workspaceGroupCleanup - Optional cleanup function to be executed when the workspace group is closed + * + * @example + * launchWorkspaceGroup("myGroup", { + * state: initialState, + * onWorkspaceGroupLaunch: () => console.log("Workspace group launched"), + * workspaceGroupCleanup: () => console.log("Cleaning up workspace group") + * }); + */ export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGroupArg) { const { state, onWorkspaceGroupLaunch, workspaceGroupCleanup } = args; const store = getWorkspaceStore(); @@ -185,14 +218,14 @@ export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGro cleanup: workspaceGroupCleanup, }, })); - getWorkspaceFamilyStore(groupName, state); + getWorkspaceGroupStore(groupName, state); onWorkspaceGroupLaunch?.(); } } function promptBeforeLaunchingWorkspace( workspace: OpenWorkspace, - newWorkspaceDetails: { name: string; additionalProps?: object; workspaceContainerName?: string }, + newWorkspaceDetails: { name: string; additionalProps?: object }, ) { const { name, additionalProps } = newWorkspaceDetails; const newWorkspaceRegistration = getWorkspaceRegistration(name); @@ -281,7 +314,7 @@ export function launchWorkspace< }; if (currentGroupName) { - getWorkspaceFamilyStore(currentGroupName, additionalProps); + getWorkspaceGroupStore(currentGroupName, additionalProps); } function updateStoreWithNewWorkspace(workspaceToBeAdded: OpenWorkspace, restOfTheWorkspaces?: Array) { store.setState((state) => { @@ -391,11 +424,7 @@ export function closeWorkspace(name: string, options: CloseWorkspaceOptions = {} const workspaceGroupName = store.getState().workspaceGroup?.name; - if ( - workspaceGroupName && - options.closeWorkspaceGroup - // !newOpenWorkspaces.some((w) => w.workspaceContainerName === workspaceSidebarFamilyName) - ) { + if (workspaceGroupName && options.closeWorkspaceGroup) { closeWorkspaceGroup(workspaceGroupName); } @@ -606,23 +635,23 @@ export function resetWorkspaceStore() { } /** - * The workspace family store is a store that is specific to the workspace sidebar family. + * The workspace group store is a store that is specific to the workspace group. * If the workspace has its own sidebar, the store will be created. - * This store can be used to store data that is specific to the workspace sidebar family. - * The store will be same for all the workspaces with same sidebar family name. + * This store can be used to store data that is specific to the workspace group. + * The store will be same for all the workspaces with same group name. * - * For workspaces with no sidebarFamilyName or sidebarFamilyName as 'default', the store will be undefined. + * For workspaces launched without a group, the store will be undefined. * - * The store will be cleared when all the workspaces with the store's sidebarFamilyName are closed. + * The store will be cleared when all the workspaces with the store's group name are closed. */ -export function getWorkspaceFamilyStore( - sidebarFamilyName: string | undefined, +export function getWorkspaceGroupStore( + workspaceGroupName: string | undefined, additionalProps: object = {}, ): StoreApi | undefined { - if (!sidebarFamilyName || sidebarFamilyName === 'default') { + if (!workspaceGroupName || workspaceGroupName === 'default') { return undefined; } - const store = getGlobalStore(sidebarFamilyName, {}); + const store = getGlobalStore(workspaceGroupName, {}); if (additionalProps) { store.setState((prev) => ({ ...prev, From 632df6819251b4dc5d423f7eebbd50ee80bc5dd8 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 11 Nov 2024 15:56:15 +0530 Subject: [PATCH 17/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 36 ++++++++++++------- .../docs/interfaces/CloseWorkspaceOptions.md | 6 ++-- .../docs/interfaces/FeatureFlagDefinition.md | 6 ++-- .../docs/interfaces/OpenmrsAppRoutes.md | 16 ++++----- .../docs/interfaces/ResourceLoader.md | 2 +- .../interfaces/WorkspaceContainerProps.md | 19 +++------- .../docs/interfaces/WorkspacesInfo.md | 10 +++--- 7 files changed, 48 insertions(+), 47 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 913d6eb44..d0bc715cf 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -610,7 +610,7 @@ ___ #### Defined in -[packages/framework/esm-globals/src/types.ts:397](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L397) +[packages/framework/esm-globals/src/types.ts:392](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L392) ___ @@ -623,7 +623,7 @@ Basically, this is the same as the app routes, with each routes definition keyed #### Defined in -[packages/framework/esm-globals/src/types.ts:388](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L388) +[packages/framework/esm-globals/src/types.ts:383](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L383) ___ @@ -793,7 +793,7 @@ ___ ### WorkspaceDefinition -Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `hasOwnSidebar?`: `boolean` ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `sidebarFamily?`: `string` ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` ; `workspaceGroups`: `string`[] } & { `component`: `string` } \| { `component?`: `never` } +Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` ; `workspaceGroups`: `string`[] } & { `component`: `string` } \| { `component?`: `never` } A definition of a workspace as extracted from an app's routes.json @@ -5855,7 +5855,7 @@ This component also provides everything needed for workspace notifications to be #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:69](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L69) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:68](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L68) ___ @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:383](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L383) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:416](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L416) ___ @@ -8100,7 +8100,7 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:247](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L247) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:280](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L280) ___ @@ -8108,12 +8108,22 @@ ___ ▸ **launchWorkspaceGroup**(`groupName`, `args`): `void` +Launches a workspace group with the specified name and configuration. +If there are any open workspaces, it will first close them before launching the new workspace group. + +**`example`** +launchWorkspaceGroup("myGroup", { + state: initialState, + onWorkspaceGroupLaunch: () => console.log("Workspace group launched"), + workspaceGroupCleanup: () => console.log("Cleaning up workspace group") +}); + #### Parameters -| Name | Type | -| :------ | :------ | -| `groupName` | `string` | -| `args` | `LaunchWorkspaceGroupArg` | +| Name | Type | Description | +| :------ | :------ | :------ | +| `groupName` | `string` | The name of the workspace group to launch | +| `args` | `LaunchWorkspaceGroupArg` | Configuration object for launching the workspace group | #### Returns @@ -8121,7 +8131,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:166](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L166) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:199](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L199) ___ @@ -8147,7 +8157,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:340](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L340) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L373) ___ @@ -8161,4 +8171,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:499](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L499) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:528](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L528) diff --git a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md index 2a0c95cf7..3a0ae6112 100644 --- a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md +++ b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md @@ -19,13 +19,15 @@ • `Optional` **closeWorkspaceGroup**: `boolean` -Controls whether the workspace family store will be cleared when this workspace is closed. Defaults to true except when opening a new workspace of the same family. +Controls whether the workspace group should be closed and store to be +cleared when this workspace is closed. +Defaults to true except when opening a new workspace of the same family. **`default`** true #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:31](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L31) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:33](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L33) ___ diff --git a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md index 751adc3dd..42734ddef 100644 --- a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md +++ b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md @@ -22,7 +22,7 @@ An explanation of what the flag does, which will be displayed in the Implementer #### Defined in -[packages/framework/esm-globals/src/types.ts:351](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L351) +[packages/framework/esm-globals/src/types.ts:346](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L346) ___ @@ -34,7 +34,7 @@ A code-friendly name for the flag, which will be used to reference it in code #### Defined in -[packages/framework/esm-globals/src/types.ts:347](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L347) +[packages/framework/esm-globals/src/types.ts:342](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L342) ___ @@ -46,4 +46,4 @@ A human-friendly name which will be displayed in the Implementer Tools #### Defined in -[packages/framework/esm-globals/src/types.ts:349](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L349) +[packages/framework/esm-globals/src/types.ts:344](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L344) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md index 879a2817e..9cc90ad42 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md @@ -27,7 +27,7 @@ A list of backend modules necessary for this frontend module and the correspondi #### Defined in -[packages/framework/esm-globals/src/types.ts:359](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L359) +[packages/framework/esm-globals/src/types.ts:354](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L354) ___ @@ -39,7 +39,7 @@ An array of all extensions supported by this frontend module. Extensions can be #### Defined in -[packages/framework/esm-globals/src/types.ts:375](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L375) +[packages/framework/esm-globals/src/types.ts:370](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L370) ___ @@ -51,7 +51,7 @@ An array of all feature flags for any beta-stage features this module provides. #### Defined in -[packages/framework/esm-globals/src/types.ts:377](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L377) +[packages/framework/esm-globals/src/types.ts:372](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L372) ___ @@ -63,7 +63,7 @@ An array of all modals supported by this frontend module. Modals can be launched #### Defined in -[packages/framework/esm-globals/src/types.ts:379](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L379) +[packages/framework/esm-globals/src/types.ts:374](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L374) ___ @@ -81,7 +81,7 @@ The name of the backend dependency and either the required version or an object #### Defined in -[packages/framework/esm-globals/src/types.ts:361](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L361) +[packages/framework/esm-globals/src/types.ts:356](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L356) ___ @@ -93,7 +93,7 @@ An array of all pages supported by this frontend module. Pages are automatically #### Defined in -[packages/framework/esm-globals/src/types.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L373) +[packages/framework/esm-globals/src/types.ts:368](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L368) ___ @@ -105,7 +105,7 @@ The version of this frontend module. #### Defined in -[packages/framework/esm-globals/src/types.ts:357](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L357) +[packages/framework/esm-globals/src/types.ts:352](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L352) ___ @@ -117,4 +117,4 @@ An array of all workspaces supported by this frontend module. Workspaces can be #### Defined in -[packages/framework/esm-globals/src/types.ts:381](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L381) +[packages/framework/esm-globals/src/types.ts:376](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L376) diff --git a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md index 0793cc437..49fd7e499 100644 --- a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md +++ b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md @@ -20,4 +20,4 @@ #### Defined in -[packages/framework/esm-globals/src/types.ts:391](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L391) +[packages/framework/esm-globals/src/types.ts:386](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L386) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md index 86a58ac1b..1c1d62001 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceContainerProps.md @@ -8,7 +8,6 @@ - [actionMenuProps](WorkspaceContainerProps.md#actionmenuprops) - [additionalWorkspaceProps](WorkspaceContainerProps.md#additionalworkspaceprops) -- [containerName](WorkspaceContainerProps.md#containername) - [contextKey](WorkspaceContainerProps.md#contextkey) - [overlay](WorkspaceContainerProps.md#overlay) - [showSiderailAndBottomNav](WorkspaceContainerProps.md#showsiderailandbottomnav) @@ -21,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:21](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L21) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L20) ___ @@ -31,17 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L20) - -___ - -### containerName - -• `Optional` **containerName**: `string` - -#### Defined in - -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L17) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L19) ___ @@ -61,7 +50,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L18) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L17) ___ @@ -71,4 +60,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L19) +[packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx:18](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx#L18) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 8289b0eb5..65e426a8a 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -20,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:492](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L492) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:521](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L521) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:493](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L493) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:522](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L522) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:496](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L496) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:525](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L525) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:494](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L494) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:523](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L523) ___ @@ -67,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:495](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L495) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:524](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L524) From aeb60b6f54fb9e69385d9c933d0ad8eb540a064d Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 13 Nov 2024 18:30:51 +0530 Subject: [PATCH 18/22] Review changes --- .../esm-extensions/src/workspaces.ts | 8 ++-- packages/framework/esm-globals/src/types.ts | 4 +- .../esm-routes/src/loaders/components.ts | 2 +- .../src/workspaces/workspaces.test.ts | 46 +++++++------------ .../src/workspaces/workspaces.ts | 13 ++++-- 5 files changed, 33 insertions(+), 40 deletions(-) diff --git a/packages/framework/esm-extensions/src/workspaces.ts b/packages/framework/esm-extensions/src/workspaces.ts index 6493371b0..ba93fd993 100644 --- a/packages/framework/esm-extensions/src/workspaces.ts +++ b/packages/framework/esm-extensions/src/workspaces.ts @@ -17,7 +17,7 @@ export interface WorkspaceRegistration { preferredWindowSize: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; - workspaceGroups?: Array; + groups?: Array; } interface WorkspaceRegistrationStore { @@ -39,7 +39,7 @@ export interface RegisterWorkspaceOptions { preferredWindowSize?: WorkspaceWindowState; load: () => Promise<{ default?: LifeCycles } & LifeCycles>; moduleName: string; - workspaceGroups?: Array; + groups?: Array; } /** @@ -58,7 +58,7 @@ export function registerWorkspace(workspace: RegisterWorkspaceOptions) { canHide: workspace.canHide ?? false, canMaximize: workspace.canMaximize ?? false, width: workspace.width ?? 'narrow', - workspaceGroups: workspace.workspaceGroups ?? [], + groups: workspace.groups ?? [], }, }, })); @@ -94,7 +94,7 @@ export function getWorkspaceRegistration(name: string): WorkspaceRegistration { canHide: workspaceExtension.meta?.canHide ?? false, canMaximize: workspaceExtension.meta?.canMaximize ?? false, width: workspaceExtension.meta?.width ?? 'narrow', - workspaceGroups: workspaceExtension?.meta?.workspaceGroups ?? [], + groups: workspaceExtension?.meta?.groups ?? [], }; } else { throw new Error(`No workspace named '${name}' has been registered.`); diff --git a/packages/framework/esm-globals/src/types.ts b/packages/framework/esm-globals/src/types.ts index d1447dccf..536cb31ea 100644 --- a/packages/framework/esm-globals/src/types.ts +++ b/packages/framework/esm-globals/src/types.ts @@ -307,10 +307,10 @@ export type WorkspaceDefinition = { * Workspaces can open either individually or in a group of workspaces. The workspace groups * will define the groups in which a workspace can be opened. * - * In case the currently opened workspace is not present in the workspaceGroups of a workspace, + * In case the currently opened workspace is not present in the groups of a workspace, * the current group will close and then the workspace will be launched. */ - workspaceGroups: Array; + groups: Array; } & ( | { /** diff --git a/packages/framework/esm-routes/src/loaders/components.ts b/packages/framework/esm-routes/src/loaders/components.ts index bea38498e..3027946b2 100644 --- a/packages/framework/esm-routes/src/loaders/components.ts +++ b/packages/framework/esm-routes/src/loaders/components.ts @@ -194,7 +194,7 @@ supported, so the workspace will not be loaded.`, canMaximize: workspace.canMaximize, width: workspace.width, preferredWindowSize: workspace.preferredWindowSize, - workspaceGroups: workspace.workspaceGroups ?? [], + groups: workspace.groups ?? [], }); } } diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index 9d6d4c282..d612c8b64 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -486,13 +486,11 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); launchWorkspaceGroup('ward-patient-store', { state: {}, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); const workspaceStore = getWorkspaceStore(); @@ -513,15 +511,13 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceFamilyStore).toBeTruthy(); @@ -539,7 +535,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: [workspaceGroup], + groups: [workspaceGroup], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -547,15 +543,13 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: [workspaceGroup], + groups: [workspaceGroup], }); launchWorkspaceGroup(workspaceGroup, { state: { foo: true, }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const workspaceStore = getWorkspaceStore(); const workspaceGroupStore = getWorkspaceGroupStore(workspaceGroup); @@ -578,7 +572,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -586,16 +580,14 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['another-sidebar-family'], + groups: ['another-sidebar-family'], }); const workspaceStore = getWorkspaceStore(); launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); @@ -605,9 +597,7 @@ describe('workspace system', () => { state: { bar: false, }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('transfer-patient-workspace'); - }, + workspaceToLaunch: { name: 'transfer-patient-workspace' }, }); expect(workspaceStore.getState().workspaceGroup?.name).toBe('another-sidebar-family'); const anotherWorkspaceGroupStore = getWorkspaceGroupStore('another-sidebar-family'); @@ -625,7 +615,7 @@ describe('workspace system', () => { type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', canHide: true, - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); registerWorkspace({ name: 'transfer-patient-workspace', @@ -633,16 +623,14 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); const workspaceStore = getWorkspaceStore(); launchWorkspaceGroup('ward-patient-store', { state: { foo: true, }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); @@ -661,13 +649,11 @@ describe('workspace system', () => { load: jest.fn(), type: 'ward-patient', moduleName: '@openmrs/esm-ward-app', - workspaceGroups: ['ward-patient-store'], + groups: ['ward-patient-store'], }); launchWorkspaceGroup('ward-patient-store', { state: { foo: true }, - onWorkspaceGroupLaunch: () => { - launchWorkspace('ward-patient-workspace'); - }, + workspaceToLaunch: { name: 'ward-patient-workspace' }, }); const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceFamilyStore).toBeTruthy(); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index dbdc4c752..0e8fd87ff 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -26,7 +26,7 @@ export interface CloseWorkspaceOptions { /** * Controls whether the workspace group should be closed and store to be * cleared when this workspace is closed. - * Defaults to true except when opening a new workspace of the same family. + * Defaults to true except when opening a new workspace of the same group. * * @default true */ @@ -177,6 +177,10 @@ interface LaunchWorkspaceGroupArg { state: object; onWorkspaceGroupLaunch?: Function; workspaceGroupCleanup?: Function; + workspaceToLaunch?: { + name: string; + additionalProps?: object; + }; } /** @@ -197,7 +201,7 @@ interface LaunchWorkspaceGroupArg { * }); */ export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGroupArg) { - const { state, onWorkspaceGroupLaunch, workspaceGroupCleanup } = args; + const { state, onWorkspaceGroupLaunch, workspaceGroupCleanup, workspaceToLaunch } = args; const store = getWorkspaceStore(); if (store.getState().openWorkspaces.length) { const workspaceGroup = store.getState().workspaceGroup; @@ -220,6 +224,9 @@ export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGro })); getWorkspaceGroupStore(groupName, state); onWorkspaceGroupLaunch?.(); + if (workspaceToLaunch) { + launchWorkspace(workspaceToLaunch?.name, workspaceToLaunch?.additionalProps ?? {}); + } } } @@ -284,7 +291,7 @@ export function launchWorkspace< const workspace = getWorkspaceRegistration(name); const currentWorkspaceGroup = store.getState().workspaceGroup; - if (currentWorkspaceGroup && !workspace.workspaceGroups?.includes(currentWorkspaceGroup?.name)) { + if (currentWorkspaceGroup && !workspace.groups?.includes(currentWorkspaceGroup?.name)) { closeWorkspaceGroup(currentWorkspaceGroup?.name, () => { launchWorkspace(name, additionalProps); }); From 6b3e44178d48bbbf7f82fa01803383ed2cdde3fd Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 13 Nov 2024 18:31:08 +0530 Subject: [PATCH 19/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 12 ++++---- .../docs/interfaces/CloseWorkspaceOptions.md | 2 +- .../docs/interfaces/OpenWorkspace.md | 30 +++++++++---------- .../docs/interfaces/WorkspaceRegistration.md | 22 +++++++------- .../docs/interfaces/WorkspacesInfo.md | 10 +++---- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index d0bc715cf..28025a90d 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -793,7 +793,7 @@ ___ ### WorkspaceDefinition -Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` ; `workspaceGroups`: `string`[] } & { `component`: `string` } \| { `component?`: `never` } +Ƭ **WorkspaceDefinition**: { `canHide?`: `boolean` ; `canMaximize?`: `boolean` ; `groups`: `string`[] ; `name`: `string` ; `preferredWindowSize?`: [`WorkspaceWindowState`](API.md#workspacewindowstate) ; `title`: `string` ; `type`: `string` ; `width?`: ``"narrow"`` \| ``"wider"`` \| ``"extra-wide"`` } & { `component`: `string` } \| { `component?`: `never` } A definition of a workspace as extracted from an app's routes.json @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:416](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L416) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:423](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L423) ___ @@ -8100,7 +8100,7 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:280](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L280) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:287](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L287) ___ @@ -8131,7 +8131,7 @@ launchWorkspaceGroup("myGroup", { #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:199](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L199) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:203](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L203) ___ @@ -8157,7 +8157,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L373) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:380](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L380) ___ @@ -8171,4 +8171,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:528](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L528) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:535](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L535) diff --git a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md index 3a0ae6112..0b6851461 100644 --- a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md +++ b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md @@ -21,7 +21,7 @@ Controls whether the workspace group should be closed and store to be cleared when this workspace is closed. -Defaults to true except when opening a new workspace of the same family. +Defaults to true except when opening a new workspace of the same group. **`default`** true diff --git a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md index a327b6a40..8aab4ab19 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md @@ -16,6 +16,7 @@ - [canHide](OpenWorkspace.md#canhide) - [canMaximize](OpenWorkspace.md#canmaximize) +- [groups](OpenWorkspace.md#groups) - [moduleName](OpenWorkspace.md#modulename) - [name](OpenWorkspace.md#name) - [preferredWindowSize](OpenWorkspace.md#preferredwindowsize) @@ -23,7 +24,6 @@ - [titleNode](OpenWorkspace.md#titlenode) - [type](OpenWorkspace.md#type) - [width](OpenWorkspace.md#width) -- [workspaceGroups](OpenWorkspace.md#workspacegroups) ### Workspace Properties @@ -68,6 +68,20 @@ ___ ___ +### groups + +• `Optional` **groups**: `string`[] + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[groups](WorkspaceRegistration.md#groups) + +#### Defined in + +[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) + +___ + ### moduleName • **moduleName**: `string` @@ -166,20 +180,6 @@ ___ ___ -### workspaceGroups - -• `Optional` **workspaceGroups**: `string`[] - -#### Inherited from - -[WorkspaceRegistration](WorkspaceRegistration.md).[workspaceGroups](WorkspaceRegistration.md#workspacegroups) - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) - -___ - ## Workspace Properties ### additionalProps diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md index dff60c273..ada48462f 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md @@ -16,6 +16,7 @@ See [WorkspaceDefinition](../API.md#workspacedefinition) for more information ab - [canHide](WorkspaceRegistration.md#canhide) - [canMaximize](WorkspaceRegistration.md#canmaximize) +- [groups](WorkspaceRegistration.md#groups) - [moduleName](WorkspaceRegistration.md#modulename) - [name](WorkspaceRegistration.md#name) - [preferredWindowSize](WorkspaceRegistration.md#preferredwindowsize) @@ -23,7 +24,6 @@ See [WorkspaceDefinition](../API.md#workspacedefinition) for more information ab - [titleNode](WorkspaceRegistration.md#titlenode) - [type](WorkspaceRegistration.md#type) - [width](WorkspaceRegistration.md#width) -- [workspaceGroups](WorkspaceRegistration.md#workspacegroups) ### Methods @@ -51,6 +51,16 @@ ___ ___ +### groups + +• `Optional` **groups**: `string`[] + +#### Defined in + +[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) + +___ + ### moduleName • **moduleName**: `string` @@ -119,16 +129,6 @@ ___ [packages/framework/esm-extensions/src/workspaces.ts:16](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L16) -___ - -### workspaceGroups - -• `Optional` **workspaceGroups**: `string`[] - -#### Defined in - -[packages/framework/esm-extensions/src/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/workspaces.ts#L20) - ## Methods ### load diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 65e426a8a..36097c91f 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -20,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:521](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L521) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:528](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L528) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:522](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L522) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:529](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L529) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:525](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L525) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:532](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L532) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:523](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L523) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:530](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L530) ___ @@ -67,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:524](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L524) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:531](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L531) From 4261d342691538dc137515aa6e9af5548940500f Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Tue, 19 Nov 2024 12:51:20 +0530 Subject: [PATCH 20/22] Remove instances of word 'family' --- .../workspace-container.component.tsx | 2 +- .../workspace-renderer.component.tsx | 6 +- .../container/workspace-renderer.test.tsx | 6 +- .../useWorkspaceGroupStore.ts | 8 +- .../src/workspaces/workspaces.test.ts | 88 +++++++++---------- .../src/workspaces/workspaces.ts | 10 +-- 6 files changed, 60 insertions(+), 60 deletions(-) diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx index 8f37ecd09..0ba4b7afd 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-container.component.tsx @@ -183,7 +183,7 @@ function Workspace({ workspaceInstance, additionalWorkspaceProps }: WorkspacePro
diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx index 2095ca765..c44bc106d 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.component.tsx @@ -14,7 +14,7 @@ interface WorkspaceRendererProps { export function WorkspaceRenderer({ workspace, additionalPropsFromPage }: WorkspaceRendererProps) { const [lifecycle, setLifecycle] = useState(); - const workspaceFamilyState = useWorkspaceGroupStore(workspace.currentWorkspaceGroup); + const workspaceGroupState = useWorkspaceGroupStore(workspace.currentWorkspaceGroup); useEffect(() => { let active = true; @@ -36,10 +36,10 @@ export function WorkspaceRenderer({ workspace, additionalPropsFromPage }: Worksp promptBeforeClosing: workspace.promptBeforeClosing, setTitle: workspace.setTitle, ...additionalPropsFromPage, - ...workspaceFamilyState, + ...workspaceGroupState, ...workspace.additionalProps, }, - [workspace, additionalPropsFromPage, workspaceFamilyState], + [workspace, additionalPropsFromPage, workspaceGroupState], ); return lifecycle ? ( diff --git a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx index 1b8cf6c5f..e8bf5a028 100644 --- a/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx +++ b/packages/framework/esm-styleguide/src/workspaces/container/workspace-renderer.test.tsx @@ -20,10 +20,10 @@ describe('WorkspaceRenderer', () => { const mockedPromptBeforeClosing = jest.fn(); const mockedSetTitle = jest.fn(); const mockedLoadFn = jest.fn().mockImplementation(() => Promise.resolve({ default: 'file-content' })); - getWorkspaceGroupStore('test-sidebar-family')?.setState({ - // Testing that the workspace family state should be overrided by additionalProps + getWorkspaceGroupStore('test-sidebar-store')?.setState({ + // Testing that the workspace group state should be overrided by additionalProps foo: false, - workspaceFamilyState: {}, + workspaceGroupStore: {}, }); render( ({}); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts index d612c8b64..7e05d3a5a 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.test.ts @@ -443,36 +443,36 @@ describe('workspace system', () => { describe('Testing `getWorkspaceGroupStore` function', () => { it('should return undefined if no workspace sidebar name is passed', () => { - let workspaceFamilyStore = getWorkspaceGroupStore(undefined); - expect(workspaceFamilyStore).toBeUndefined(); - workspaceFamilyStore = getWorkspaceGroupStore('default'); - expect(workspaceFamilyStore).toBeUndefined(); + let workspaceGroupStore = getWorkspaceGroupStore(undefined); + expect(workspaceGroupStore).toBeUndefined(); + workspaceGroupStore = getWorkspaceGroupStore('default'); + expect(workspaceGroupStore).toBeUndefined(); }); it('should return store if workspace sidebar name is passed', () => { - const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { + const workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store', { foo: true, }); - expect(workspaceFamilyStore).toBeTruthy(); - expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); }); it('should update the store state with new additionalProps if workspaces with same workspaceGroup name calls the function', () => { - let workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { + let workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store', { foo: true, }); - expect(workspaceFamilyStore).toBeTruthy(); - expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); - workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store', { + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); + workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store', { bar: true, }); - expect(workspaceFamilyStore).toBeTruthy(); - expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); - expect(workspaceFamilyStore?.getState()?.['bar']).toBe(true); + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); + expect(workspaceGroupStore?.getState()?.['bar']).toBe(true); }); }); - describe('Testing workspace family store', () => { + describe('Testing workspace group store', () => { it('should create store for workspace groups', () => { registerWorkspace({ name: 'allergies', @@ -492,19 +492,19 @@ describe('workspace system', () => { state: {}, workspaceToLaunch: { name: 'ward-patient-workspace' }, }); - const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); + const workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store'); const workspaceStore = getWorkspaceStore(); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(workspaceStore.getState().openWorkspaces[0].name).toBe('ward-patient-workspace'); - expect(workspaceFamilyStore).toBeTruthy(); + expect(workspaceGroupStore).toBeTruthy(); workspaceStore.getState().openWorkspaces[0].closeWorkspace({ ignoreChanges: true }); launchWorkspace('allergies'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(workspaceStore.getState().openWorkspaces[0].name).toBe('allergies'); - expect(workspaceFamilyStore?.getState()).toStrictEqual({}); + expect(workspaceGroupStore?.getState()).toStrictEqual({}); }); - it('should clear workspace family store by default if the workspace is closed, since `closeWorkspaceGroup` is true by default', async () => { + it('should clear workspace group store by default if the workspace is closed, since `closeWorkspaceGroup` is true by default', async () => { registerWorkspace({ name: 'ward-patient-workspace', title: 'Ward Patient Workspace', @@ -519,12 +519,12 @@ describe('workspace system', () => { }, workspaceToLaunch: { name: 'ward-patient-workspace' }, }); - const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); - expect(workspaceFamilyStore).toBeTruthy(); - expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); + const workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store'); + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); closeWorkspace('ward-patient-workspace'); - expect(workspaceFamilyStore?.getState()?.['foo']).toBeUndefined(); - expect(workspaceFamilyStore?.getState()).toStrictEqual({}); + expect(workspaceGroupStore?.getState()?.['foo']).toBeUndefined(); + expect(workspaceGroupStore?.getState()).toStrictEqual({}); }); it('should not clear the workspace store if the new workspace opened can open in the same group', () => { @@ -580,7 +580,7 @@ describe('workspace system', () => { load: jest.fn(), type: 'transfer-patient', moduleName: '@openmrs/esm-ward-app', - groups: ['another-sidebar-family'], + groups: ['another-sidebar-group'], }); const workspaceStore = getWorkspaceStore(); launchWorkspaceGroup('ward-patient-store', { @@ -589,25 +589,25 @@ describe('workspace system', () => { }, workspaceToLaunch: { name: 'ward-patient-workspace' }, }); - const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); + const wardPatientGroupStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - expect(wardPatientFamilyStore).toBeTruthy(); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - launchWorkspaceGroup('another-sidebar-family', { + expect(wardPatientGroupStore).toBeTruthy(); + expect(wardPatientGroupStore?.getState()?.['foo']).toBe(true); + launchWorkspaceGroup('another-sidebar-group', { state: { bar: false, }, workspaceToLaunch: { name: 'transfer-patient-workspace' }, }); - expect(workspaceStore.getState().workspaceGroup?.name).toBe('another-sidebar-family'); - const anotherWorkspaceGroupStore = getWorkspaceGroupStore('another-sidebar-family'); + expect(workspaceStore.getState().workspaceGroup?.name).toBe('another-sidebar-group'); + const anotherWorkspaceGroupStore = getWorkspaceGroupStore('another-sidebar-group'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); expect(anotherWorkspaceGroupStore?.getState()?.['bar']).toBe(false); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBeUndefined(); - expect(wardPatientFamilyStore?.getState()).toStrictEqual({}); + expect(wardPatientGroupStore?.getState()?.['foo']).toBeUndefined(); + expect(wardPatientGroupStore?.getState()).toStrictEqual({}); }); - it('should not clear the workspace if a workspace of same sidebar family is opened', () => { + it('should not clear the workspace if a workspace of same sidebar group is opened', () => { registerWorkspace({ name: 'ward-patient-workspace', title: 'Ward Patient Workspace', @@ -632,14 +632,14 @@ describe('workspace system', () => { }, workspaceToLaunch: { name: 'ward-patient-workspace' }, }); - const wardPatientFamilyStore = getWorkspaceGroupStore('ward-patient-store'); + const wardPatientGroupStore = getWorkspaceGroupStore('ward-patient-store'); expect(workspaceStore.getState().openWorkspaces.length).toBe(1); - expect(wardPatientFamilyStore).toBeTruthy(); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); + expect(wardPatientGroupStore).toBeTruthy(); + expect(wardPatientGroupStore?.getState()?.['foo']).toBe(true); launchWorkspace('transfer-patient-workspace', { bar: false }); expect(workspaceStore.getState().openWorkspaces.length).toBe(2); - expect(wardPatientFamilyStore?.getState()?.['foo']).toBe(true); - expect(wardPatientFamilyStore?.getState()?.['bar']).toBe(false); + expect(wardPatientGroupStore?.getState()?.['foo']).toBe(true); + expect(wardPatientGroupStore?.getState()?.['bar']).toBe(false); }); it('should retain default closeWorkspace options in case workspace options are passed', () => { @@ -655,13 +655,13 @@ describe('workspace system', () => { state: { foo: true }, workspaceToLaunch: { name: 'ward-patient-workspace' }, }); - const workspaceFamilyStore = getWorkspaceGroupStore('ward-patient-store'); - expect(workspaceFamilyStore).toBeTruthy(); - expect(workspaceFamilyStore?.getState()?.['foo']).toBe(true); + const workspaceGroupStore = getWorkspaceGroupStore('ward-patient-store'); + expect(workspaceGroupStore).toBeTruthy(); + expect(workspaceGroupStore?.getState()?.['foo']).toBe(true); // test that default options are interpolated when providing options to `closeWorkspace` closeWorkspace('ward-patient-workspace', { ignoreChanges: true }); - expect(workspaceFamilyStore?.getState()?.['foo']).toBeUndefined(); - expect(workspaceFamilyStore?.getState()).toStrictEqual({}); + expect(workspaceGroupStore?.getState()?.['foo']).toBeUndefined(); + expect(workspaceGroupStore?.getState()).toStrictEqual({}); }); }); }); diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 0e8fd87ff..02865fc76 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -153,10 +153,10 @@ function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { closeAllWorkspaces(() => { // Clearing the workspace group and respective store if the new workspace is not part of the current group, which is handled in the `launchWorkspace` function. - const workspaceFamilyStore = getWorkspaceGroupStore(groupName); - if (workspaceFamilyStore) { - workspaceFamilyStore.setState({}, true); - const unsubscribe = workspaceFamilyStore.subscribe(() => {}); + const workspaceGroupStore = getWorkspaceGroupStore(groupName); + if (workspaceGroupStore) { + workspaceGroupStore.setState({}, true); + const unsubscribe = workspaceGroupStore.subscribe(() => {}); unsubscribe?.(); } if (currentWorkspaceGroup && typeof currentWorkspaceGroup?.cleanup === 'function') { @@ -243,7 +243,7 @@ function promptBeforeLaunchingWorkspace( // Calling the launchWorkspace again, since one of the `if` case // might resolve, but we need to check all the cases before launching the form. onWorkspaceClose: () => launchWorkspace(name, additionalProps), - // If the new workspace is of the same sidebar family, then we don't need to clear the workspace family store. + // If the new workspace is of the same sidebar group, then we don't need to clear the workspace group store. closeWorkspaceGroup: false, }); }; From d0049e2c06b0e7b562bfb388d8def249fd2dae8e Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 27 Nov 2024 00:47:36 +0530 Subject: [PATCH 21/22] Review changes --- packages/framework/esm-globals/src/types.ts | 25 ++++++++++++++++--- .../src/workspaces/workspaces.ts | 23 +++++++++-------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/packages/framework/esm-globals/src/types.ts b/packages/framework/esm-globals/src/types.ts index 536cb31ea..5675a6494 100644 --- a/packages/framework/esm-globals/src/types.ts +++ b/packages/framework/esm-globals/src/types.ts @@ -302,13 +302,30 @@ export type WorkspaceDefinition = { * The width "extra-wide" is for workspaces that contain their own sidebar. */ width?: 'narrow' | 'wider' | 'extra-wide'; + /** + * Launches the workspace in the preferred size, it defaults to the 'narrow' width + */ preferredWindowSize?: WorkspaceWindowState; + /** - * Workspaces can open either individually or in a group of workspaces. The workspace groups - * will define the groups in which a workspace can be opened. + * Workspaces can open either independently or as part of a "workspace group". A + * "workspace group" groups related workspaces together, so that only one is visible + * at a time. For example, + * + * @example + * + * { + * name: 'order-basket', + * type: 'order', + * groups: ['ward-patient'] + * } + * + * This means that the 'order-basket' workspace can be opened independently, or only + * in the 'ward-patient'. + * If a workspace group is already open and a new workspace is launched, and the + * groups in the newly launched workspace do not include the currently open group’s + * name, the entire workspace group will close, and the new workspace will launch independently. * - * In case the currently opened workspace is not present in the groups of a workspace, - * the current group will close and then the workspace will be launched. */ groups: Array; } & ( diff --git a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts index 02865fc76..3f3fd26b1 100644 --- a/packages/framework/esm-styleguide/src/workspaces/workspaces.ts +++ b/packages/framework/esm-styleguide/src/workspaces/workspaces.ts @@ -140,10 +140,10 @@ export function canCloseWorkspaceWithoutPrompting(name: string, ignoreChanges: b * - Updates the main workspace store to remove the workspace group * - Calls the optional closeup callback if provided */ -function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { +function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: () => void) { const store = getWorkspaceStore(); const currentWorkspaceGroup = store.getState()?.workspaceGroup; - const currentGroupName = store.getState()?.workspaceGroup?.name; + const currentGroupName = currentWorkspaceGroup?.name; if (!currentGroupName || groupName !== currentGroupName) { return; } @@ -157,18 +157,20 @@ function closeWorkspaceGroup(groupName: string, onWorkspaceCloseup?: Function) { if (workspaceGroupStore) { workspaceGroupStore.setState({}, true); const unsubscribe = workspaceGroupStore.subscribe(() => {}); - unsubscribe?.(); + unsubscribe(); } - if (currentWorkspaceGroup && typeof currentWorkspaceGroup?.cleanup === 'function') { - currentWorkspaceGroup?.cleanup?.(); + + if (typeof currentWorkspaceGroup?.cleanup === 'function') { + currentWorkspaceGroup.cleanup(); } store.setState((prev) => ({ ...prev, workspaceGroup: undefined, })); - if (onWorkspaceCloseup && typeof onWorkspaceCloseup === 'function') { - onWorkspaceCloseup?.(); + + if (typeof onWorkspaceCloseup === 'function') { + onWorkspaceCloseup(); } }, filter); } @@ -225,7 +227,7 @@ export function launchWorkspaceGroup(groupName: string, args: LaunchWorkspaceGro getWorkspaceGroupStore(groupName, state); onWorkspaceGroupLaunch?.(); if (workspaceToLaunch) { - launchWorkspace(workspaceToLaunch?.name, workspaceToLaunch?.additionalProps ?? {}); + launchWorkspace(workspaceToLaunch.name, workspaceToLaunch.additionalProps ?? {}); } } } @@ -292,7 +294,7 @@ export function launchWorkspace< const currentWorkspaceGroup = store.getState().workspaceGroup; if (currentWorkspaceGroup && !workspace.groups?.includes(currentWorkspaceGroup?.name)) { - closeWorkspaceGroup(currentWorkspaceGroup?.name, () => { + closeWorkspaceGroup(currentWorkspaceGroup.name, () => { launchWorkspace(name, additionalProps); }); return; @@ -508,8 +510,7 @@ export function closeAllWorkspaces( .getState() .openWorkspaces.filter(filter) .every(({ name }) => { - const canCloseWorkspace = canCloseWorkspaceWithoutPrompting(name); - return canCloseWorkspace; + return canCloseWorkspaceWithoutPrompting(name); }); const updateWorkspaceStore = () => { From deb79bde7e9b17a9eabe186bd23ea607f04525ad Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Wed, 27 Nov 2024 00:49:29 +0530 Subject: [PATCH 22/22] Update documentation --- packages/framework/esm-framework/docs/API.md | 14 +++++++------- .../docs/interfaces/FeatureFlagDefinition.md | 6 +++--- .../docs/interfaces/OpenmrsAppRoutes.md | 16 ++++++++-------- .../docs/interfaces/ResourceLoader.md | 2 +- .../docs/interfaces/WorkspacesInfo.md | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 28025a90d..d41eac208 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -610,7 +610,7 @@ ___ #### Defined in -[packages/framework/esm-globals/src/types.ts:392](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L392) +[packages/framework/esm-globals/src/types.ts:409](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L409) ___ @@ -623,7 +623,7 @@ Basically, this is the same as the app routes, with each routes definition keyed #### Defined in -[packages/framework/esm-globals/src/types.ts:383](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L383) +[packages/framework/esm-globals/src/types.ts:400](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L400) ___ @@ -8049,7 +8049,7 @@ Function to close an opened workspace #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:423](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L423) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:425](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L425) ___ @@ -8100,7 +8100,7 @@ prop named `workspaceTitle` will override the title of the workspace. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:287](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L287) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:289](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L289) ___ @@ -8131,7 +8131,7 @@ launchWorkspaceGroup("myGroup", { #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:203](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L203) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:205](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L205) ___ @@ -8157,7 +8157,7 @@ Use this function to navigate to a new page and launch a workspace on that page. #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:380](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L380) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:382](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L382) ___ @@ -8171,4 +8171,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:535](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L535) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:536](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L536) diff --git a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md index 42734ddef..4059543f4 100644 --- a/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md +++ b/packages/framework/esm-framework/docs/interfaces/FeatureFlagDefinition.md @@ -22,7 +22,7 @@ An explanation of what the flag does, which will be displayed in the Implementer #### Defined in -[packages/framework/esm-globals/src/types.ts:346](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L346) +[packages/framework/esm-globals/src/types.ts:363](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L363) ___ @@ -34,7 +34,7 @@ A code-friendly name for the flag, which will be used to reference it in code #### Defined in -[packages/framework/esm-globals/src/types.ts:342](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L342) +[packages/framework/esm-globals/src/types.ts:359](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L359) ___ @@ -46,4 +46,4 @@ A human-friendly name which will be displayed in the Implementer Tools #### Defined in -[packages/framework/esm-globals/src/types.ts:344](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L344) +[packages/framework/esm-globals/src/types.ts:361](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L361) diff --git a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md index 9cc90ad42..1080d7d7a 100644 --- a/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md +++ b/packages/framework/esm-framework/docs/interfaces/OpenmrsAppRoutes.md @@ -27,7 +27,7 @@ A list of backend modules necessary for this frontend module and the correspondi #### Defined in -[packages/framework/esm-globals/src/types.ts:354](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L354) +[packages/framework/esm-globals/src/types.ts:371](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L371) ___ @@ -39,7 +39,7 @@ An array of all extensions supported by this frontend module. Extensions can be #### Defined in -[packages/framework/esm-globals/src/types.ts:370](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L370) +[packages/framework/esm-globals/src/types.ts:387](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L387) ___ @@ -51,7 +51,7 @@ An array of all feature flags for any beta-stage features this module provides. #### Defined in -[packages/framework/esm-globals/src/types.ts:372](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L372) +[packages/framework/esm-globals/src/types.ts:389](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L389) ___ @@ -63,7 +63,7 @@ An array of all modals supported by this frontend module. Modals can be launched #### Defined in -[packages/framework/esm-globals/src/types.ts:374](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L374) +[packages/framework/esm-globals/src/types.ts:391](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L391) ___ @@ -81,7 +81,7 @@ The name of the backend dependency and either the required version or an object #### Defined in -[packages/framework/esm-globals/src/types.ts:356](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L356) +[packages/framework/esm-globals/src/types.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L373) ___ @@ -93,7 +93,7 @@ An array of all pages supported by this frontend module. Pages are automatically #### Defined in -[packages/framework/esm-globals/src/types.ts:368](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L368) +[packages/framework/esm-globals/src/types.ts:385](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L385) ___ @@ -105,7 +105,7 @@ The version of this frontend module. #### Defined in -[packages/framework/esm-globals/src/types.ts:352](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L352) +[packages/framework/esm-globals/src/types.ts:369](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L369) ___ @@ -117,4 +117,4 @@ An array of all workspaces supported by this frontend module. Workspaces can be #### Defined in -[packages/framework/esm-globals/src/types.ts:376](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L376) +[packages/framework/esm-globals/src/types.ts:393](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L393) diff --git a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md index 49fd7e499..e4535a5ca 100644 --- a/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md +++ b/packages/framework/esm-framework/docs/interfaces/ResourceLoader.md @@ -20,4 +20,4 @@ #### Defined in -[packages/framework/esm-globals/src/types.ts:386](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L386) +[packages/framework/esm-globals/src/types.ts:403](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L403) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md index 36097c91f..98149ebe4 100644 --- a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -20,7 +20,7 @@ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:528](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L528) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:529](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L529) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:529](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L529) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:530](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L530) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:532](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L532) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:533](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L533) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:530](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L530) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:531](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L531) ___ @@ -67,4 +67,4 @@ ___ #### Defined in -[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:531](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L531) +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:532](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L532)