@openmrs/esm-implementer-tools-app 10.0.1-pre.5263 → 10.0.1-pre.5299

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,9 @@ import { useTranslation } from 'react-i18next';
5
5
  import { Button } from '@carbon/react';
6
6
  import {
7
7
  CloseIcon,
8
- type ExtensionInfo,
8
+ type ExtensionRendering,
9
+ type ExtensionRenderingsStore,
10
+ getExtensionRenderingsStore,
9
11
  getExtensionInternalStore,
10
12
  useStore,
11
13
  useStoreWithActions,
@@ -31,31 +33,30 @@ export interface ExtensionOverlayTarget {
31
33
  extensionName: string;
32
34
  slotModuleName: string;
33
35
  slotName: string;
34
- extensionInstance: ExtensionInfo['instances'][number];
36
+ extensionRendering: ExtensionRendering;
35
37
  }
36
38
 
37
39
  /**
38
- * Flattens `extensions[name].instances` into a flat list of overlay targets. `instances` is an
39
- * `Array<ExtensionInstance>`, so it must be iterated directly. Treating it as a nested object (via
40
- * `Object.entries`) yields array indices as the module name and instance property names as the slot
41
- * name, so the generated selectors never match a real extension DOM node.
40
+ * Turns the rendering store's records into overlay targets, each naming a slot and extension to look
41
+ * for in the DOM. Not every rendering has a matching node.
42
42
  */
43
43
  export function getExtensionOverlayTargets(
44
- extensions: Record<string, ExtensionInfo> | undefined,
44
+ renderings: ExtensionRenderingsStore['renderings'] | undefined,
45
45
  ): Array<ExtensionOverlayTarget> {
46
- return Object.entries(extensions ?? {}).flatMap(([extensionName, extensionInfo]) =>
47
- (extensionInfo.instances ?? []).map((extensionInstance) => ({
48
- extensionName,
49
- slotModuleName: extensionInstance.slotModuleName,
50
- slotName: extensionInstance.slotName,
51
- extensionInstance,
52
- })),
53
- );
46
+ return Array.from(renderings?.values() ?? [], (extensionRendering) => ({
47
+ extensionName: extensionRendering.extensionName,
48
+ slotModuleName: extensionRendering.slotModuleName,
49
+ slotName: extensionRendering.slotName,
50
+ extensionRendering,
51
+ }));
54
52
  }
55
53
 
56
54
  export default function UiEditor() {
57
55
  const { t } = useTranslation();
58
56
  const { slots, extensions } = useStore(getExtensionInternalStore());
57
+ // Depended on as a whole below: the rendering map is mutated in place, so only the state
58
+ // object around it changes identity when an extension mounts or unmounts.
59
+ const renderingsState = useStore(getExtensionRenderingsStore());
59
60
  const { isOpen: areImplementerToolsOpen } = useStore(implementerToolsStore);
60
61
 
61
62
  const getExtensionCount = (slotName: string, moduleName: string) => {
@@ -94,16 +95,14 @@ export default function UiEditor() {
94
95
  .filter((x): x is NonNullable<typeof x> => Boolean(x));
95
96
  }, [slots]);
96
97
 
97
- const extensionElements = useMemo(
98
- () =>
99
- getExtensionOverlayTargets(extensions).map((target) => ({
100
- ...target,
101
- element: document.querySelector(
102
- `*[data-extension-slot-name="${target.slotName}"][data-extension-slot-module-name="${target.slotModuleName}"] *[data-extension-id="${target.extensionInstance.id}"]`,
103
- ) as HTMLElement | null,
104
- })),
105
- [extensions],
106
- );
98
+ const extensionElements = useMemo(() => {
99
+ return getExtensionOverlayTargets(renderingsState.renderings).map((target) => ({
100
+ ...target,
101
+ element: document.querySelector(
102
+ `*[data-extension-rendering-id="${CSS.escape(target.extensionRendering.renderingId)}"]`,
103
+ ) as HTMLElement | null,
104
+ }));
105
+ }, [renderingsState]);
107
106
 
108
107
  return (
109
108
  <>
@@ -123,12 +122,12 @@ export default function UiEditor() {
123
122
  ),
124
123
  )}
125
124
  {extensionElements.map(
126
- ({ extensionName, slotModuleName, slotName, extensionInstance, element }) =>
125
+ ({ extensionName, slotModuleName, slotName, extensionRendering, element }) =>
127
126
  element && (
128
127
  <ExtensionOverlay
129
128
  domElement={element}
130
129
  extensionName={extensionName}
131
- key={`${slotName}-${extensionInstance.id}`}
130
+ key={extensionRendering.renderingId}
132
131
  slotModuleName={slotModuleName}
133
132
  slotName={slotName}
134
133
  />
@@ -6,6 +6,8 @@
6
6
  "checkImplementerToolsMessage": "Check the Backend Modules tab in the Implementer Tools for more details",
7
7
  "clearConfig": "Clear local config",
8
8
  "close": "Close",
9
+ "configDerivationFailed": "This configuration is out of date",
10
+ "configDerivationFailedSubtitle": "The configuration could not be rebuilt, so what is shown below is the last version that did build.",
9
11
  "configuration": "Configuration",
10
12
  "description": "Description",
11
13
  "downloadConfig": "Download config",