Skip to content

Commit

Permalink
(feat) O3-1426: Modals should not be extensions (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandones authored Apr 5, 2024
1 parent b30501d commit 6ff9143
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 75 deletions.
2 changes: 1 addition & 1 deletion packages/apps/esm-devtools-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"offline": true
}
],
"extensions": [
"modals": [
{
"name": "importmap-override-modal",
"component": "importmapOverrideModal"
Expand Down
12 changes: 6 additions & 6 deletions packages/apps/esm-offline-tools-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"online": true,
"offline": true
},
{
"name": "offline-tools-confirmation-modal",
"component": "offlineToolsConfirmationModal",
"online": true,
"offline": true
},
{
"name": "offline-tools-dashboard-patients-card",
"slot": "offline-tools-dashboard-cards",
Expand Down Expand Up @@ -140,5 +134,11 @@
"offline": true,
"order": 1
}
],
"modals": [
{
"name": "offline-tools-confirmation-modal",
"component": "offlineToolsConfirmationModal"
}
]
}
12 changes: 6 additions & 6 deletions packages/apps/esm-primary-navigation-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@
"offline": true,
"order": 1
},
{
"name": "change-language-modal",
"component": "changeLanguageModal",
"online": true,
"offline": true
},
{
"name": "offline-banner",
"slot": "user-panel-slot",
Expand All @@ -56,5 +50,11 @@
"online": true,
"offline": true
}
],
"modals": [
{
"name": "change-language-modal",
"component": "changeLanguageModal"
}
]
}
37 changes: 26 additions & 11 deletions packages/framework/esm-framework/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:38](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L38)
[packages/framework/esm-config/src/types.ts:40](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L40)

___

Expand Down Expand Up @@ -468,6 +468,18 @@ ___

___

### ModalDefintion

Ƭ **ModalDefintion**: { `name`: `string` } & { `component`: `string` } \| { `component?`: `never` }

A definition of an modal as extracted from an app's routes.json

#### Defined in

[packages/framework/esm-globals/src/types.ts:237](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L237)

___

### OpenmrsRoutes

Ƭ **OpenmrsRoutes**: `Record`<`string`, [`OpenmrsAppRoutes`](interfaces/OpenmrsAppRoutes.md)\>
Expand All @@ -477,7 +489,7 @@ Basically, this is the same as the app routes, with each routes definition keyed

#### Defined in

[packages/framework/esm-globals/src/types.ts:260](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L260)
[packages/framework/esm-globals/src/types.ts:295](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L295)

___

Expand Down Expand Up @@ -506,7 +518,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:60](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L60)
[packages/framework/esm-config/src/types.ts:62](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L62)

___

Expand Down Expand Up @@ -562,7 +574,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:67](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L67)
[packages/framework/esm-config/src/types.ts:69](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L69)

___

Expand All @@ -586,7 +598,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:65](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L65)
[packages/framework/esm-config/src/types.ts:67](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L67)

___

Expand Down Expand Up @@ -4749,17 +4761,20 @@ ___

### showModal

**showModal**(`extensionId`, `props?`, `onClose?`): () => `void`
**showModal**(`modalName`, `props?`, `onClose?`): () => `void`

Shows a modal dialog.

Shows the provided extension component in a modal dialog.
The modal must have been registered by name. This should be done in the `routes.json` file of the
app that defines the modal.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `extensionId` | `string` | The id of the extension to show. |
| `props` | `Record`<`string`, `any`\> | The optional props to provide to the extension. |
| `onClose` | () => `void` | The optional notification to receive when the modal is closed. |
| `modalName` | `string` | The name of the modal to show. |
| `props` | `Record`<`string`, `any`\> | The optional props to provide to the modal. |
| `onClose` | () => `void` | The optional callback to call when the modal is closed. |

#### Returns

Expand All @@ -4775,7 +4790,7 @@ The dispose function to force closing the modal dialog.

#### Defined in

[packages/framework/esm-styleguide/src/modals/index.tsx:160](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/modals/index.tsx#L160)
[packages/framework/esm-styleguide/src/modals/index.tsx:208](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/modals/index.tsx#L208)

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,32 @@

### Properties

- [offline](DisplayConditionsConfigObject.md#offline)
- [online](DisplayConditionsConfigObject.md#online)
- [privileges](DisplayConditionsConfigObject.md#privileges)

## Properties

### offline

`Optional` **offline**: `boolean`

#### Defined in

[packages/framework/esm-config/src/types.ts:37](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L37)

___

### online

`Optional` **online**: `boolean`

#### Defined in

[packages/framework/esm-config/src/types.ts:36](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L36)

___

### privileges

`Optional` **privileges**: `string`[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#### Defined in

[packages/framework/esm-config/src/types.ts:41](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L41)
[packages/framework/esm-config/src/types.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L43)

___

Expand All @@ -29,7 +29,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:44](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L44)
[packages/framework/esm-config/src/types.ts:46](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L46)

___

Expand All @@ -39,7 +39,7 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L43)
[packages/framework/esm-config/src/types.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L45)

___

Expand All @@ -49,4 +49,4 @@ ___

#### Defined in

[packages/framework/esm-config/src/types.ts:42](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L42)
[packages/framework/esm-config/src/types.ts:44](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L44)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Additional extension IDs to assign to this slot, in addition to those `attach`ed

#### Defined in

[packages/framework/esm-config/src/types.ts:53](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L53)
[packages/framework/esm-config/src/types.ts:55](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L55)

___

Expand All @@ -32,7 +32,7 @@ Overrides the default ordering of extensions.

#### Defined in

[packages/framework/esm-config/src/types.ts:57](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L57)
[packages/framework/esm-config/src/types.ts:59](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L59)

___

Expand All @@ -44,4 +44,4 @@ Extension IDs which were `attach`ed to the slot but which should not be assigned

#### Defined in

[packages/framework/esm-config/src/types.ts:55](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L55)
[packages/framework/esm-config/src/types.ts:57](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-config/src/types.ts#L57)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This interface describes the format of the routes provided by an app

- [backendDependencies](OpenmrsAppRoutes.md#backenddependencies)
- [extensions](OpenmrsAppRoutes.md#extensions)
- [modals](OpenmrsAppRoutes.md#modals)
- [pages](OpenmrsAppRoutes.md#pages)
- [version](OpenmrsAppRoutes.md#version)

Expand All @@ -23,7 +24,7 @@ A list of backend modules necessary for this frontend module and the correspondi

#### Defined in

[packages/framework/esm-globals/src/types.ts:245](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L245)
[packages/framework/esm-globals/src/types.ts:276](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L276)

___

Expand All @@ -35,7 +36,19 @@ An array of all extensions supported by this frontend module. Extensions can be

#### Defined in

[packages/framework/esm-globals/src/types.ts:253](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L253)
[packages/framework/esm-globals/src/types.ts:284](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L284)

___

### modals

`Optional` **modals**: [`ModalDefintion`](../API.md#modaldefintion)[]

An array of all modals supported by this frontend module. Modals can be launched by name.

#### Defined in

[packages/framework/esm-globals/src/types.ts:288](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L288)

___

Expand All @@ -47,7 +60,7 @@ An array of all pages supported by this frontend module. Pages are automatically

#### Defined in

[packages/framework/esm-globals/src/types.ts:249](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L249)
[packages/framework/esm-globals/src/types.ts:280](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L280)

___

Expand All @@ -59,4 +72,4 @@ The version of this frontend module.

#### Defined in

[packages/framework/esm-globals/src/types.ts:241](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L241)
[packages/framework/esm-globals/src/types.ts:272](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L272)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

#### Defined in

[packages/framework/esm-globals/src/types.ts:263](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L263)
[packages/framework/esm-globals/src/types.ts:298](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-globals/src/types.ts#L298)
35 changes: 35 additions & 0 deletions packages/framework/esm-globals/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,37 @@ export type ExtensionDefinition = {
}
);

/**
* A definition of an modal as extracted from an app's routes.json
*/
export type ModalDefintion = {
/**
* The name of this modal. This is used to launch the modal.
*/
name: string;
} & (
| {
/**
* The name of the component exported by this frontend module.
*/
component: string;
/**
* @internal
*/
load?: never;
}
| {
/**
* The name of the component exported by this frontend module.
*/
component?: never;
/**
* @internal
*/
load: () => Promise<{ default?: LifeCycles } & LifeCycles>;
}
);

/**
* This interface describes the format of the routes provided by an app
*/
Expand All @@ -251,6 +282,10 @@ export interface OpenmrsAppRoutes {
* An array of all extensions supported by this frontend module. Extensions can be mounted in extension slots, either via declarations in this file or configuration.
*/
extensions?: Array<ExtensionDefinition>;
/**
* An array of all modals supported by this frontend module. Modals can be launched by name.
*/
modals?: Array<ModalDefintion>;
}

/**
Expand Down
Loading

0 comments on commit 6ff9143

Please sign in to comment.