From b9ccc141feca471a18f87da6c0e541241cba3977 Mon Sep 17 00:00:00 2001 From: Dappnodedev Date: Wed, 14 Aug 2024 11:17:47 +0000 Subject: [PATCH 1/6] Add version to route --- packages/types/src/routes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/routes.ts b/packages/types/src/routes.ts index 76417058a..530115d82 100644 --- a/packages/types/src/routes.ts +++ b/packages/types/src/routes.ts @@ -259,7 +259,7 @@ export interface Routes { /** * Fetch extended info about a new DNP */ - fetchDnpRequest: (kwargs: { id: string }) => Promise; + fetchDnpRequest: (kwargs: { id: string, version?: string }) => Promise; /** * Returns the user action logs. This logs are stored in a different From 548abda2e8190e8dcb81407aade885632f60fff4 Mon Sep 17 00:00:00 2001 From: Dappnodedev Date: Wed, 14 Aug 2024 11:18:29 +0000 Subject: [PATCH 2/6] Add version to path --- .../admin-ui/src/pages/installer/components/InstallerRoot.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin-ui/src/pages/installer/components/InstallerRoot.tsx b/packages/admin-ui/src/pages/installer/components/InstallerRoot.tsx index 2d56d879f..cf28415ee 100644 --- a/packages/admin-ui/src/pages/installer/components/InstallerRoot.tsx +++ b/packages/admin-ui/src/pages/installer/components/InstallerRoot.tsx @@ -105,7 +105,7 @@ const InstallerRoot: React.FC = () => { element={ } /> - } /> + } /> } /> From a9dcebcc13ec66de0350db6730c1e1ebe640128a Mon Sep 17 00:00:00 2001 From: Dappnodedev Date: Wed, 14 Aug 2024 11:19:07 +0000 Subject: [PATCH 3/6] Fetch dnp request with version --- .../pages/installer/components/InstallDnpContainer.tsx | 10 ++++++++-- packages/dappmanager/src/calls/fetchDnpRequest.ts | 5 +++-- packages/installer/src/calls/packageGetData.ts | 8 ++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx index b5e07f0b0..3be883d00 100644 --- a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx +++ b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx @@ -13,13 +13,19 @@ import ErrorView from "components/ErrorView"; import { getProgressLogsByDnp } from "services/isInstallingLogs/selectors"; const InstallDnpContainer: React.FC = () => { - const { id } = useParams<{ id: string }>(); + const { id, version } = useParams<{ id: string, version: string }>(); const progressLogsByDnp = useSelector(getProgressLogsByDnp); + // Print the full URL + console.log("Full URL: ", window.location.href); + console.log("ID: ", id); + console.log("Version: ", version); + + // TODO: return a beautiful error page if (!id) return
No ID provided in route parameters.
; - const { data: dnp, error, isValidating } = useApi.fetchDnpRequest({ id }); + const { data: dnp, error, isValidating } = useApi.fetchDnpRequest({ id, version }); // Get progressLogs const dnpName = dnp?.dnpName; diff --git a/packages/dappmanager/src/calls/fetchDnpRequest.ts b/packages/dappmanager/src/calls/fetchDnpRequest.ts index e2fc356d8..d0f5a3736 100644 --- a/packages/dappmanager/src/calls/fetchDnpRequest.ts +++ b/packages/dappmanager/src/calls/fetchDnpRequest.ts @@ -19,8 +19,8 @@ import { import { Manifest, SetupWizardField } from "@dappnode/types"; import { logs } from "@dappnode/logger"; -export async function fetchDnpRequest({ id }: { id: string }): Promise { - const mainRelease = await dappnodeInstaller.getRelease(id); +export async function fetchDnpRequest({ id, version }: { id: string; version?: string }): Promise { + const mainRelease = await dappnodeInstaller.getRelease(id, version); const settings: UserSettingsAllDnps = {}; const specialPermissions: SpecialPermissionAllDnps = {}; @@ -69,6 +69,7 @@ export async function fetchDnpRequest({ id }: { id: string }): Promise ({ from: currentVersions[dnpName], to: nextVersion diff --git a/packages/installer/src/calls/packageGetData.ts b/packages/installer/src/calls/packageGetData.ts index 23557840a..216d1f6ea 100644 --- a/packages/installer/src/calls/packageGetData.ts +++ b/packages/installer/src/calls/packageGetData.ts @@ -8,14 +8,18 @@ import { DappnodeInstaller } from "../dappnodeInstaller.js"; // TODO: find a proper place for these functions. The functions inside this file // are not used as the other files within this same folder -export async function packageGetData(dappnodeInstaller: DappnodeInstaller, dnpName: string): Promise { +export async function packageGetData( + dappnodeInstaller: DappnodeInstaller, + dnpName: string, + version?: string +): Promise { const cachedDnp = db.pkgItemMetadata.get(dnpName); if (cachedDnp) { // Update cache in the background eventBus.runStakerCacheUpdate.emit({ dnpName }); return cachedDnp; } else { - const repository = await dappnodeInstaller.getRelease(dnpName); + const repository = await dappnodeInstaller.getRelease(dnpName, version); const dataDnp = packagePickItemData(repository); db.pkgItemMetadata.set(dnpName, dataDnp); return dataDnp; From 2d988dd9b8613d221dff7cb3c5824952206e058f Mon Sep 17 00:00:00 2001 From: Dappnodedev Date: Wed, 14 Aug 2024 11:26:20 +0000 Subject: [PATCH 4/6] Remove unnecessary logs --- .../src/pages/installer/components/InstallDnpContainer.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx index 3be883d00..b6671c5a9 100644 --- a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx +++ b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx @@ -16,12 +16,6 @@ const InstallDnpContainer: React.FC = () => { const { id, version } = useParams<{ id: string, version: string }>(); const progressLogsByDnp = useSelector(getProgressLogsByDnp); - // Print the full URL - console.log("Full URL: ", window.location.href); - console.log("ID: ", id); - console.log("Version: ", version); - - // TODO: return a beautiful error page if (!id) return
No ID provided in route parameters.
; From 78215d247ae03ad9e990b6380c529fe623addca6 Mon Sep 17 00:00:00 2001 From: Dappnodedev Date: Wed, 14 Aug 2024 11:39:27 +0000 Subject: [PATCH 5/6] Allow searching in Dappstore with :version --- .../components/dappnodeDappstore/InstallerDnp.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx index 03b085d7b..b96e336d4 100644 --- a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx +++ b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx @@ -82,7 +82,17 @@ export const InstallerDnp: React.FC = () => { } ] }); - } else navigate(encodeURIComponent(id)); + } else { + // Check if version has been defined like dnpName:version + const [dnpName, version] = id.split(":"); + + const encodedDnpName = encodeURIComponent(dnpName); + const encodedVersion = version ? encodeURIComponent(version) : null; + + const pkgPath = encodedVersion ? `${encodedDnpName}/${encodedVersion}` : encodedDnpName; + + navigate(pkgPath); + } } function onCategoryChange(category: string) { From 103d1a18147da76609ebe19c380f2a354282ace2 Mon Sep 17 00:00:00 2001 From: dappnodedev Date: Wed, 4 Sep 2024 11:42:29 +0200 Subject: [PATCH 6/6] Lint --- .../src/pages/installer/components/InstallDnpContainer.tsx | 2 +- .../installer/components/dappnodeDappstore/InstallerDnp.tsx | 6 +++--- packages/types/src/routes.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx index b6671c5a9..d12a2c9a5 100644 --- a/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx +++ b/packages/admin-ui/src/pages/installer/components/InstallDnpContainer.tsx @@ -13,7 +13,7 @@ import ErrorView from "components/ErrorView"; import { getProgressLogsByDnp } from "services/isInstallingLogs/selectors"; const InstallDnpContainer: React.FC = () => { - const { id, version } = useParams<{ id: string, version: string }>(); + const { id, version } = useParams<{ id: string; version: string }>(); const progressLogsByDnp = useSelector(getProgressLogsByDnp); // TODO: return a beautiful error page diff --git a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx index b96e336d4..8472b435e 100644 --- a/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx +++ b/packages/admin-ui/src/pages/installer/components/dappnodeDappstore/InstallerDnp.tsx @@ -88,10 +88,10 @@ export const InstallerDnp: React.FC = () => { const encodedDnpName = encodeURIComponent(dnpName); const encodedVersion = version ? encodeURIComponent(version) : null; - + const pkgPath = encodedVersion ? `${encodedDnpName}/${encodedVersion}` : encodedDnpName; - - navigate(pkgPath); + + navigate(pkgPath); } } diff --git a/packages/types/src/routes.ts b/packages/types/src/routes.ts index 530115d82..5173890dc 100644 --- a/packages/types/src/routes.ts +++ b/packages/types/src/routes.ts @@ -259,7 +259,7 @@ export interface Routes { /** * Fetch extended info about a new DNP */ - fetchDnpRequest: (kwargs: { id: string, version?: string }) => Promise; + fetchDnpRequest: (kwargs: { id: string; version?: string }) => Promise; /** * Returns the user action logs. This logs are stored in a different