From 8edc926533686a32702fde7c0117997ed6242f0f Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Mon, 16 Oct 2023 00:54:07 +0200 Subject: [PATCH] Fix compilation --- web/package.json | 2 ++ web/src/core/adapters/onyxiaApiMock.ts | 2 +- web/src/core/usecases/launcher/thunks.ts | 23 +++++++++++-------- .../core/usecases/restorablePackageConfigs.ts | 6 ++--- .../usecases/serviceManager/thunks/thunks.ts | 7 +++--- web/src/ui/App/App.tsx | 8 +++---- web/src/ui/i18n/resources/de.tsx | 3 ++- web/src/ui/i18n/resources/en.tsx | 3 ++- web/src/ui/i18n/resources/fi.tsx | 3 ++- web/src/ui/i18n/resources/fr.tsx | 3 ++- web/src/ui/i18n/resources/it.tsx | 3 ++- web/src/ui/i18n/resources/nl.tsx | 3 ++- web/src/ui/i18n/resources/no.tsx | 3 ++- web/src/ui/i18n/resources/zh-CN.tsx | 3 ++- web/src/ui/pages/home/Home.tsx | 4 ++-- web/src/ui/pages/launcher/Launcher.tsx | 2 +- .../NoLongerBookmarkedDialog.tsx | 2 +- web/src/ui/pages/myServices/MyServices.tsx | 16 +++++++------ web/yarn.lock | 10 ++++++++ 19 files changed, 67 insertions(+), 39 deletions(-) diff --git a/web/package.json b/web/package.json index b2954d1c8..6148191db 100644 --- a/web/package.json +++ b/web/package.json @@ -43,6 +43,7 @@ "zod": "^3.19.0", "yaml": "^2.0.1", "flexsearch": "0.7.21", + "@ungap/structured-clone": "^1.2.0", "minio": "^7.1.1", "axios": "^0.26.0", "buffer": "^6.0.3", @@ -93,6 +94,7 @@ "@types/react-router-dom": "^5.1.5", "@types/shell-quote": "^1.7.0", "@types/flexsearch": "^0.7.3", + "@types/ungap__structured-clone": "0.3.0", "@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/parser": "^5.36.2", "circular-dependency-plugin": "^5.2.2", diff --git a/web/src/core/adapters/onyxiaApiMock.ts b/web/src/core/adapters/onyxiaApiMock.ts index b1d5f1503..e95e0607f 100644 --- a/web/src/core/adapters/onyxiaApiMock.ts +++ b/web/src/core/adapters/onyxiaApiMock.ts @@ -65,7 +65,7 @@ export const onyxiaApi: OnyxiaApi = { }), { "promise": true } ), - ...createPropertyThatThrowIfAccessed("getCatalogs", "Not mocked"), + ...createPropertyThatThrowIfAccessed("getCatalogsAndCharts", "Not mocked"), ...createPropertyThatThrowIfAccessed("getPackageConfig", "Not mocked"), ...createPropertyThatThrowIfAccessed("launchPackage", "Not mocked"), ...createPropertyThatThrowIfAccessed("getRunningServices", "Not mocked"), diff --git a/web/src/core/usecases/launcher/thunks.ts b/web/src/core/usecases/launcher/thunks.ts index e2fcb0284..771dccd1a 100644 --- a/web/src/core/usecases/launcher/thunks.ts +++ b/web/src/core/usecases/launcher/thunks.ts @@ -581,19 +581,24 @@ export const thunks = { })(); const { catalogLocation, icon } = await (async () => { - const catalog = await onyxiaApi.getCatalogs().then(apiRequestResult => - //TODO: Sort in the adapter of even better, assumes version sorted - //and validate this assertion with zod - apiRequestResult.find(({ id }) => id === catalogId) - ); + const catalog = await onyxiaApi + .getCatalogsAndCharts() + .then(({ catalogs }) => + //TODO: Sort in the adapter of even better, assumes version sorted + //and validate this assertion with zod + catalogs.find(({ id }) => id === catalogId) + ); assert(catalog !== undefined); - return { - "catalogLocation": catalog.location, + const charts = await onyxiaApi + .getCatalogsAndCharts() + .then(({ chartsByCatalogId }) => chartsByCatalogId[catalog.id]); - "icon": catalog.charts.find(({ name }) => name === packageName)! - .versions[0].icon + return { + "catalogLocation": catalog.repositoryUrl, + "icon": charts.find(({ name }) => name === packageName)!.versions[0] + .icon }; })(); diff --git a/web/src/core/usecases/restorablePackageConfigs.ts b/web/src/core/usecases/restorablePackageConfigs.ts index 0ebc2c4ba..9bcd76080 100644 --- a/web/src/core/usecases/restorablePackageConfigs.ts +++ b/web/src/core/usecases/restorablePackageConfigs.ts @@ -163,14 +163,14 @@ export const thunks = { dispatch(actions.fetchIconStarted()); - const apiRequestForIconsResult = await onyxiaApi.getCatalogs(); + const apiRequestForIconsResult = await onyxiaApi.getCatalogsAndCharts(); const iconsUrl: IconsUrl = {}; - apiRequestForIconsResult.forEach(({ id: catalogId, charts }) => { + apiRequestForIconsResult.catalogs.forEach(({ id: catalogId }) => { const urlByPackageName: IconsUrl[string] = {}; - charts.forEach(chart => { + apiRequestForIconsResult.chartsByCatalogId[catalogId].forEach(chart => { for (const { icon } of chart.versions) { if (icon === undefined) { continue; diff --git a/web/src/core/usecases/serviceManager/thunks/thunks.ts b/web/src/core/usecases/serviceManager/thunks/thunks.ts index 45bfed7b4..5f8d8930a 100644 --- a/web/src/core/usecases/serviceManager/thunks/thunks.ts +++ b/web/src/core/usecases/serviceManager/thunks/thunks.ts @@ -56,13 +56,14 @@ export const thunks = { //NOTE: We do not have the catalog id so we search in every catalog. const { getLogoUrl } = await (async () => { - const apiRequestResult = await onyxiaApi.getCatalogs(); + const apiRequestResult = await onyxiaApi.getCatalogsAndCharts(); function getLogoUrl(params: { packageName: string }): string | undefined { const { packageName } = params; - for (const { charts } of apiRequestResult) { - for (const { name, versions } of charts) { + for (const { id: catalogId } of apiRequestResult.catalogs) { + for (const { name, versions } of apiRequestResult + .chartsByCatalogId[catalogId]) { if (name !== packageName) { continue; } diff --git a/web/src/ui/App/App.tsx b/web/src/ui/App/App.tsx index 83da28bbf..4328cc7c7 100644 --- a/web/src/ui/App/App.tsx +++ b/web/src/ui/App/App.tsx @@ -149,7 +149,7 @@ function ContextualizedApp() { "catalog": { "iconId": "catalog", "label": t("catalog"), - "link": routes.catalogExplorer().link + "link": routes.catalog().link }, "myServices": { "iconId": "services", @@ -250,9 +250,9 @@ function ContextualizedApp() { return "home" as const; case "account": return "account"; - case "catalogExplorer": + case "catalog": return "catalog"; - case "catalogLauncher": + case "launcher": return "catalog"; case "myServices": return "myServices"; @@ -627,7 +627,7 @@ function useRegionSelectProps() { } switch (route.name) { - case "catalogLauncher": + case "launcher": break; case "myFiles": break; diff --git a/web/src/ui/i18n/resources/de.tsx b/web/src/ui/i18n/resources/de.tsx index 5125bb1a3..6fd8dee3b 100644 --- a/web/src/ui/i18n/resources/de.tsx +++ b/web/src/ui/i18n/resources/de.tsx @@ -464,7 +464,8 @@ Fühlen Sie sich frei, Ihre Kubernetes-Bereitstellungen zu erkunden und die Kont "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Nicht gespeicherte Änderungen", "no longer bookmarked dialog body": - "Klicken Sie erneut auf das Lesezeichensymbol, um Ihre gespeicherte Konfiguration zu aktualisieren." + "Klicken Sie erneut auf das Lesezeichensymbol, um Ihre gespeicherte Konfiguration zu aktualisieren.", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Möchten Sie es ersetzen?", diff --git a/web/src/ui/i18n/resources/en.tsx b/web/src/ui/i18n/resources/en.tsx index 6772b6427..df537a6cd 100644 --- a/web/src/ui/i18n/resources/en.tsx +++ b/web/src/ui/i18n/resources/en.tsx @@ -455,7 +455,8 @@ Feel free to explore and take charge of your Kubernetes deployments! "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Your changes wont be saved", "no longer bookmarked dialog body": - "Click on the bookmark icon again to update your saved configuration" + "Click on the bookmark icon again to update your saved configuration", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Would you like to replace it?", diff --git a/web/src/ui/i18n/resources/fi.tsx b/web/src/ui/i18n/resources/fi.tsx index 663d5976c..23a982746 100644 --- a/web/src/ui/i18n/resources/fi.tsx +++ b/web/src/ui/i18n/resources/fi.tsx @@ -451,7 +451,8 @@ Tutustu vapaasti ja ota hallintaan Kubernetes-julkaisusi! "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Muutokset eivät tallennu", "no longer bookmarked dialog body": - "Päivitä tallennettu konfiguraatio napsauttamalla kirjanmerkkikuvaketta uudelleen." + "Päivitä tallennettu konfiguraatio napsauttamalla kirjanmerkkikuvaketta uudelleen.", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Haluatko korvata sen?", diff --git a/web/src/ui/i18n/resources/fr.tsx b/web/src/ui/i18n/resources/fr.tsx index 8a0c6c63b..7dc0310f2 100644 --- a/web/src/ui/i18n/resources/fr.tsx +++ b/web/src/ui/i18n/resources/fr.tsx @@ -467,7 +467,8 @@ N'hésitez pas à explorer et à prendre en main vos déploiements Kubernetes ! "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Changements non enregistrés", "no longer bookmarked dialog body": - "Cliquer une nouvelle fois sur le symbole marque-page pour mettre à jour votre configuration enregistrée." + "Cliquer une nouvelle fois sur le symbole marque-page pour mettre à jour votre configuration enregistrée.", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Souhaitez-vous le remplacer ?", diff --git a/web/src/ui/i18n/resources/it.tsx b/web/src/ui/i18n/resources/it.tsx index 05f8a3d56..0138b608a 100644 --- a/web/src/ui/i18n/resources/it.tsx +++ b/web/src/ui/i18n/resources/it.tsx @@ -459,7 +459,8 @@ Sentiti libero di esplorare e prendere il controllo dei tuoi deployment Kubernet "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Modifiche non salvate", "no longer bookmarked dialog body": - "Clicca nuovamente sull'icona del segnalibro per aggiornare la configurazione salvata." + "Clicca nuovamente sull'icona del segnalibro per aggiornare la configurazione salvata.", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Vuoi sostituirlo?", diff --git a/web/src/ui/i18n/resources/nl.tsx b/web/src/ui/i18n/resources/nl.tsx index d6167de0d..687e34750 100644 --- a/web/src/ui/i18n/resources/nl.tsx +++ b/web/src/ui/i18n/resources/nl.tsx @@ -462,7 +462,8 @@ Voel je vrij om te verkennen en de controle over je Kubernetes-implementaties te "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Niet opgeslagen wijzigingen", "no longer bookmarked dialog body": - "Klik opnieuw op het symbool van de bladwijzer om de opgeslagen configuratie bij te werken." + "Klik opnieuw op het symbool van de bladwijzer om de opgeslagen configuratie bij te werken.", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Wilt u het vervangen ?", diff --git a/web/src/ui/i18n/resources/no.tsx b/web/src/ui/i18n/resources/no.tsx index 26b474e21..1c4940a9b 100644 --- a/web/src/ui/i18n/resources/no.tsx +++ b/web/src/ui/i18n/resources/no.tsx @@ -458,7 +458,8 @@ Føl deg fri til å utforske og ta kontroll over dine Kubernetes-implementeringe "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "Endringene dine vil ikke bli lagret", "no longer bookmarked dialog body": - "Klikk på bokmerkeikonet igjen for å oppdatere den lagrede konfigurasjonen din" + "Klikk på bokmerkeikonet igjen for å oppdatere den lagrede konfigurasjonen din", + "ok": "Ok" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "Ønsker du å erstatte den?", diff --git a/web/src/ui/i18n/resources/zh-CN.tsx b/web/src/ui/i18n/resources/zh-CN.tsx index 45e38b0fb..88b4e34cb 100644 --- a/web/src/ui/i18n/resources/zh-CN.tsx +++ b/web/src/ui/i18n/resources/zh-CN.tsx @@ -395,7 +395,8 @@ ${ }, "NoLongerBookmarkedDialog": { "no longer bookmarked dialog title": "更改未保存", - "no longer bookmarked dialog body": "再次单击书签符号以更新您保存的配置." + "no longer bookmarked dialog body": "再次单击书签符号以更新您保存的配置.", + "ok": "是" }, "OverwriteConfigurationConfirmDialog": { "should overwrite configuration dialog title": "您想更换它吗?", diff --git a/web/src/ui/pages/home/Home.tsx b/web/src/ui/pages/home/Home.tsx index 3078e204e..07e2fc5c1 100644 --- a/web/src/ui/pages/home/Home.tsx +++ b/web/src/ui/pages/home/Home.tsx @@ -29,7 +29,7 @@ export default function Home(props: Props) { useConst(() => { if (getIsHomePageDisabled()) { - routes.catalogExplorer().replace(); + routes.catalog().replace(); } }); @@ -42,7 +42,7 @@ export default function Home(props: Props) { const { t } = useTranslation({ Home }); const myFilesLink = useMemo(() => routes.myFiles().link, []); - const catalogExplorerLink = useMemo(() => routes.catalogExplorer().link, []); + const catalogExplorerLink = useMemo(() => routes.catalog().link, []); return (
diff --git a/web/src/ui/pages/launcher/Launcher.tsx b/web/src/ui/pages/launcher/Launcher.tsx index 1477ec7c6..9ec97ff8a 100644 --- a/web/src/ui/pages/launcher/Launcher.tsx +++ b/web/src/ui/pages/launcher/Launcher.tsx @@ -207,7 +207,7 @@ export default function Launcher(props: Props) { }, [restorablePackageConfigs, restorablePackageConfig]); const onRequestCancel = useConstCallback(() => - routes.catalogExplorer({ "catalogId": route.params.catalogId }).push() + routes.catalog({ "catalogId": route.params.catalogId }).push() ); const onRequestCopyLaunchUrl = useConstCallback(() => diff --git a/web/src/ui/pages/launcher/LauncherDialogs/NoLongerBookmarkedDialog.tsx b/web/src/ui/pages/launcher/LauncherDialogs/NoLongerBookmarkedDialog.tsx index f82fc9ae8..05b0ac86a 100644 --- a/web/src/ui/pages/launcher/LauncherDialogs/NoLongerBookmarkedDialog.tsx +++ b/web/src/ui/pages/launcher/LauncherDialogs/NoLongerBookmarkedDialog.tsx @@ -38,5 +38,5 @@ export const NoLongerBookmarkedDialog = memo((props: Props) => { NoLongerBookmarkedDialog.displayName = symToStr({ NoLongerBookmarkedDialog }); export const { i18n } = declareComponentKeys< - "no longer bookmarked dialog title" | "no longer bookmarked dialog body" + "no longer bookmarked dialog title" | "no longer bookmarked dialog body" | "ok" >()({ NoLongerBookmarkedDialog }); diff --git a/web/src/ui/pages/myServices/MyServices.tsx b/web/src/ui/pages/myServices/MyServices.tsx index f4ae56ccb..1ef230e70 100644 --- a/web/src/ui/pages/myServices/MyServices.tsx +++ b/web/src/ui/pages/myServices/MyServices.tsx @@ -30,7 +30,7 @@ export default function MyServices(props: Props) { const { className, route } = props; const { t } = useTranslation({ MyServices }); - const { t: tCatalogLauncher } = useTranslation("CatalogLauncher"); + const { t: tCatalogLauncher } = useTranslation("Launcher"); /* prettier-ignore */ const { serviceManager, restorablePackageConfig, k8sCredentials, projectConfigs } = useCoreFunctions(); @@ -57,7 +57,7 @@ export default function MyServices(props: Props) { const onButtonBarClick = useConstCallback((buttonId: ButtonId) => { switch (buttonId) { case "launch": - routes.catalogExplorer().push(); + routes.catalog().push(); return; case "refresh": serviceManager.update(); @@ -118,8 +118,9 @@ export default function MyServices(props: Props) { restorablePackageConfig.deleteRestorablePackageConfig({ "restorablePackageConfig": displayableConfigs.find( ({ restorablePackageConfig }) => - routes.catalogLauncher({ - ...restorablePackageConfig, + routes.launcher({ + "catalogId": restorablePackageConfig.catalogId, + "chartName": restorablePackageConfig.packageName, "autoLaunch": true }).href === launchLinkHref )!.restorablePackageConfig @@ -133,8 +134,9 @@ export default function MyServices(props: Props) { displayableConfigs.map( ({ logoUrl, friendlyName, restorablePackageConfig }) => { const buildLink = (autoLaunch: boolean) => - routes.catalogLauncher({ - ...restorablePackageConfig, + routes.launcher({ + "catalogId": restorablePackageConfig.catalogId, + "chartName": restorablePackageConfig.packageName, autoLaunch }).link; @@ -219,7 +221,7 @@ export default function MyServices(props: Props) { }); }, [route.params.autoLaunchServiceId, runningServices]); - const catalogExplorerLink = useMemo(() => routes.catalogExplorer().link, []); + const catalogExplorerLink = useMemo(() => routes.catalog().link, []); const [serviceIdRequestedToBeDeleted, setServiceIdRequestedToBeDeleted] = useState< string | undefined diff --git a/web/yarn.lock b/web/yarn.lock index 48418bf2b..1cd99107e 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -4152,6 +4152,11 @@ dependencies: source-map "^0.6.1" +"@types/ungap__structured-clone@0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@types/ungap__structured-clone/-/ungap__structured-clone-0.3.0.tgz#39ef89de1f04bb1920ed99e549b885331295c47d" + integrity sha512-eBWREUhVUGPze+bUW22AgUr05k8u+vETzuYdLYSvWqGTUe0KOf+zVnOB1qER5wMcw8V6D9Ar4DfJmVvD1yu0kQ== + "@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3": version "2.0.6" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" @@ -4307,6 +4312,11 @@ "@typescript-eslint/types" "5.59.0" eslint-visitor-keys "^3.3.0" +"@ungap/structured-clone@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" + integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== + "@webassemblyjs/ast@1.11.5", "@webassemblyjs/ast@^1.11.5": version "1.11.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.5.tgz#6e818036b94548c1fb53b754b5cae3c9b208281c"