From 3a2d8f6aca135abb0ad150a9f4de712091cf54b6 Mon Sep 17 00:00:00 2001 From: mariaozamiz Date: Wed, 29 May 2024 09:36:36 +0200 Subject: [PATCH 1/5] chore: revert to original name --- scripts/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run.ts b/scripts/run.ts index 2b6f336b2..22b30dc12 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -8,7 +8,7 @@ const variants = [ { type: "app", name: "core-app", - title: "MetaData Synchronization", + title: "MetaData Sync App", file: "metadata-synchronization", }, { From ac34fc9818442cf86556cccb44380241a6c5a5b8 Mon Sep 17 00:00:00 2001 From: mariaozamiz Date: Wed, 29 May 2024 09:52:00 +0200 Subject: [PATCH 2/5] chore: add function to update name in manifest.json file --- scripts/run.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/run.ts b/scripts/run.ts index 22b30dc12..5e6aff7ef 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -139,6 +139,7 @@ function build(args: BuildArgs): void { run(`react-scripts build && cp -r i18n icon.png build`); run(`d2-manifest package.json build/manifest.webapp -t ${manifestType} -n '${variant.title}'`); updateManifestNamespace(`build/manifest.webapp`, variant.file); + updateManifestJsonFile(`build/manifest.json`, variant.title); run(`rm -f ${fileName}`); run(`cd build && zip -r ../${fileName} *`); console.info(`Written: ${fileName}`); @@ -153,6 +154,14 @@ function updateManifestNamespace(manifestPath: string, variantFile: string) { } } +function updateManifestJsonFile(manifestJsonPath: string, variantTitle: string) { + if (fs.existsSync(manifestJsonPath)) { + const manifestJson = JSON.parse(fs.readFileSync(manifestJsonPath, "utf8")); + Object.assign(manifestJson, { name: variantTitle, short_name: variantTitle }); + fs.writeFileSync(manifestJsonPath, JSON.stringify(manifestJson, null, 2)); + } +} + /* Start server */ type StartServerArgs = { variant: string; port: number; verbose: boolean }; From dc752c1800df039428dcf06c9b1415bb20ef1f78 Mon Sep 17 00:00:00 2001 From: mariaozamiz Date: Wed, 29 May 2024 10:09:22 +0200 Subject: [PATCH 3/5] chore: add conditional so we only change the first package --- scripts/run.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/run.ts b/scripts/run.ts index 5e6aff7ef..ac35af635 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -138,8 +138,10 @@ function build(args: BuildArgs): void { run(`react-scripts build && cp -r i18n icon.png build`); run(`d2-manifest package.json build/manifest.webapp -t ${manifestType} -n '${variant.title}'`); + if (variant.file === "metadata-synchronization") { + updateManifestJsonFile(`build/manifest.json`, variant.title); + } updateManifestNamespace(`build/manifest.webapp`, variant.file); - updateManifestJsonFile(`build/manifest.json`, variant.title); run(`rm -f ${fileName}`); run(`cd build && zip -r ../${fileName} *`); console.info(`Written: ${fileName}`); From 90afc68cc8d9a0acf76b9ada535ac13ec584b09a Mon Sep 17 00:00:00 2001 From: Miquel Adell Date: Wed, 29 May 2024 13:47:16 +0200 Subject: [PATCH 4/5] change name --- scripts/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run.ts b/scripts/run.ts index ac35af635..32cad24e6 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -8,7 +8,7 @@ const variants = [ { type: "app", name: "core-app", - title: "MetaData Sync App", + title: "MetaData Synchronization", file: "metadata-synchronization", }, { From 53a16cba11887c6983a2f6676c6ad3d7a6f0cbe1 Mon Sep 17 00:00:00 2001 From: Eduardo Peredo Rivero Date: Wed, 5 Jun 2024 09:59:20 -0500 Subject: [PATCH 5/5] get feedback config from json instead ts file --- public/app-config.template.json | 20 ++++++++++++++++++++ src/app-config.template.ts | 1 + src/app-config.ts | 21 --------------------- src/presentation/webapp/WebApp.tsx | 15 ++++++++++----- 4 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 public/app-config.template.json delete mode 100644 src/app-config.ts diff --git a/public/app-config.template.json b/public/app-config.template.json new file mode 100644 index 000000000..e44b110b2 --- /dev/null +++ b/public/app-config.template.json @@ -0,0 +1,20 @@ +{ + "appKey": "metadata-synchronization", + "appearance": { + "showShareButton": false + }, + "feedback": { + "repositories": { + "clickUp": { + "listId": "170646828", + "title": "[User feedback] {title}", + "body": "## dhis2\n\nUsername: {username}\n\n{body}" + } + }, + "layoutOptions": { + "showContact": false, + "descriptionTemplate": "## Summary\n\n## Steps to reproduce\n\n## Actual results\n\n## Expected results\n\n" + } + }, + "encryptionKey": "" +} diff --git a/src/app-config.template.ts b/src/app-config.template.ts index 120a4f45a..05159355f 100644 --- a/src/app-config.template.ts +++ b/src/app-config.template.ts @@ -6,4 +6,5 @@ export interface AppConfig { showShareButton: boolean; }; feedback: FeedbackOptions; + encryptionKey: string; } diff --git a/src/app-config.ts b/src/app-config.ts deleted file mode 100644 index 7bc3f2334..000000000 --- a/src/app-config.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { AppConfig } from "./app-config.template"; - -export const appConfig: AppConfig = { - appKey: "metadata-synchronization", - appearance: { - showShareButton: false, - }, - feedback: { - repositories: { - clickUp: { - listId: "170646828", - title: "[User feedback] {title}", - body: "## dhis2\n\nUsername: {username}\n\n{body}", - }, - }, - layoutOptions: { - showContact: false, - descriptionTemplate: "## Summary\n\n## Steps to reproduce\n\n## Actual results\n\n## Expected results\n\n", - }, - }, -}; diff --git a/src/presentation/webapp/WebApp.tsx b/src/presentation/webapp/WebApp.tsx index f0f16d069..6df030d47 100644 --- a/src/presentation/webapp/WebApp.tsx +++ b/src/presentation/webapp/WebApp.tsx @@ -22,7 +22,8 @@ import { muiTheme } from "../react/core/themes/dhis2.theme"; import Root from "./Root"; import "./WebApp.css"; import { Feedback } from "@eyeseetea/feedback-component"; -import { appConfig } from "../../app-config"; +import { AppConfig } from "../../app-config.template"; +import { Maybe } from "../../types/utils"; const generateClassName = createGenerateClassName({ productionPrefix: "c", @@ -33,13 +34,17 @@ const App = () => { const [appContext, setAppContext] = useState(null); const [username, setUsername] = useState(""); const [showShareButton, setShowShareButton] = useState(false); + const [appConfig, setAppConfig] = useState>(); const migrations = useMigrations(appContext); const appTitle = process.env.REACT_APP_PRESENTATION_TITLE; useEffect(() => { const run = async () => { - const encryptionKey = appConfig?.appKey; + const configFromJson = (await fetch("app-config.json", { + credentials: "same-origin", + }).then(res => res.json())) as AppConfig; + const encryptionKey = configFromJson.encryptionKey; if (!encryptionKey) throw new Error("You need to provide a valid encryption key"); const d2 = await init({ baseUrl: `${baseUrl}/api` }); const api = new D2Api({ baseUrl, backend: "fetch" }); @@ -50,7 +55,6 @@ const App = () => { url: baseUrl, version, }); - const compositionRoot = new CompositionRoot(instance, encryptionKey); await compositionRoot.app.initialize(); const currentUser = await compositionRoot.user.current(); @@ -61,11 +65,12 @@ const App = () => { Object.assign(window, { d2, api }); setShowShareButton(_(appConfig).get("appearance.showShareButton") || false); setUsername(currentUser.username); + setAppConfig(configFromJson); await initializeAppRoles(baseUrl); }; run(); - }, [baseUrl]); + }, [appConfig, baseUrl]); if (migrations.state.type === "pending") { return ( @@ -91,7 +96,7 @@ const App = () => { - + {appConfig && }