From 889a7f1603d2ff54ebc1bf6a4ba318be8f0a3610 Mon Sep 17 00:00:00 2001 From: Brandon Istenes Date: Mon, 14 Mar 2022 10:23:26 -0700 Subject: [PATCH 1/3] App not hot updating with slot config changes --- .../configuration/configuration.component.tsx | 9 ++- .../src/ui-editor/ui-editor.tsx | 13 +++- .../src/module-config/module-config.test.ts | 8 +- .../src/module-config/module-config.ts | 18 +++-- .../esm-config/src/module-config/state.ts | 39 ++++++---- .../__mocks__/openmrs-esm-config.mock.tsx | 2 +- .../esm-extensions/src/extensions.ts | 56 +++++++++++--- packages/framework/esm-framework/docs/API.md | 16 ++-- packages/framework/esm-framework/mock.tsx | 12 ++- .../extension-config.test.tsx | 76 ++++++++++++++++++- .../esm-react-utils/src/createUseStore.ts | 1 + .../framework/esm-react-utils/src/index.ts | 2 - .../src/useAssignedExtensions.ts | 2 +- .../src/useExtensionInternalStore.ts | 4 +- .../src/useExtensionSlotConfig.ts | 24 ------ .../framework/esm-react-utils/src/useStore.ts | 57 ++++++++++++-- .../esm-react-utils/src/useStoreState.ts | 11 --- 17 files changed, 256 insertions(+), 94 deletions(-) delete mode 100644 packages/framework/esm-react-utils/src/useExtensionSlotConfig.ts delete mode 100644 packages/framework/esm-react-utils/src/useStoreState.ts diff --git a/packages/apps/esm-implementer-tools-app/src/configuration/configuration.component.tsx b/packages/apps/esm-implementer-tools-app/src/configuration/configuration.component.tsx index 319007b53..36f6e4e89 100644 --- a/packages/apps/esm-implementer-tools-app/src/configuration/configuration.component.tsx +++ b/packages/apps/esm-implementer-tools-app/src/configuration/configuration.component.tsx @@ -7,10 +7,11 @@ import { Config, ConfigInternalStore, configInternalStore, + getExtensionInternalStore, implementerToolsConfigStore, temporaryConfigStore, - useExtensionInternalStore, useStore, + useStoreWithActions, } from "@openmrs/esm-framework"; import { Button, @@ -89,13 +90,13 @@ export const Configuration: React.FC = () => { toggleIsJsonModeEnabled, isConfigToolbarOpen, toggleIsToolbarOpen, - } = useStore(implementerToolsStore, actions); - const { devDefaultsAreOn, toggleDevDefaults } = useStore( + } = useStoreWithActions(implementerToolsStore, actions); + const { devDefaultsAreOn, toggleDevDefaults } = useStoreWithActions( configInternalStore, configActions ); const { config } = useStore(implementerToolsConfigStore); - const extensionStore = useExtensionInternalStore(); + const extensionStore = useStore(getExtensionInternalStore()); const tempConfigStore = useStore(temporaryConfigStore); const [filterText, setFilterText] = useState(""); const tempConfig = tempConfigStore.config; diff --git a/packages/apps/esm-implementer-tools-app/src/ui-editor/ui-editor.tsx b/packages/apps/esm-implementer-tools-app/src/ui-editor/ui-editor.tsx index 516101cd4..50cabac89 100644 --- a/packages/apps/esm-implementer-tools-app/src/ui-editor/ui-editor.tsx +++ b/packages/apps/esm-implementer-tools-app/src/ui-editor/ui-editor.tsx @@ -1,14 +1,18 @@ import React from "react"; import styles from "./styles.css"; import Close16 from "@carbon/icons-react/es/close/16"; -import { useExtensionInternalStore, useStore } from "@openmrs/esm-framework"; +import { + getExtensionInternalStore, + useStore, + useStoreWithActions, +} from "@openmrs/esm-framework"; import { Button } from "carbon-components-react"; import { Portal } from "./portal"; import { ExtensionOverlay } from "./extension-overlay.component"; import { ImplementerToolsStore, implementerToolsStore } from "../store"; export default function UiEditor() { - const { slots, extensions } = useExtensionInternalStore(); + const { slots, extensions } = useStore(getExtensionInternalStore()); const { isOpen: implementerToolsIsOpen } = useStore(implementerToolsStore); return ( @@ -66,7 +70,10 @@ const actions = { }; export function ExitButton() { - const { toggleIsUIEditorEnabled } = useStore(implementerToolsStore, actions); + const { toggleIsUIEditorEnabled } = useStoreWithActions( + implementerToolsStore, + actions + ); return (