Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTPS Portal Redirect + Add HTTPS Portal Calculated Path #1931

Draft
wants to merge 22 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2744972
Fix HTTPS Portal Redirect + Add HTTPS Portal Calculated Path
alexpeterson91 Apr 18, 2024
931c38a
fix linter error
alexpeterson91 Apr 18, 2024
75db796
debug
alexpeterson91 Apr 20, 2024
c293257
replace curly brackets on import from CI bug
alexpeterson91 Apr 22, 2024
95532a0
fix redirects involving joining rootPaths
alexpeterson91 Jun 14, 2024
2fba42c
remove erroneous / in subpath and fix https portal path
alexpeterson91 Jun 14, 2024
3fff0c0
revert vercel test and update wording
alexpeterson91 Jun 14, 2024
bf3e682
fix linter error
alexpeterson91 Jun 14, 2024
e445ccb
fix top bar notifications auto update installer links redirect
alexpeterson91 Jun 19, 2024
54914ac
revert using root path and modified url join
alexpeterson91 Jun 19, 2024
6fe42f8
fix import
alexpeterson91 Jun 19, 2024
d657ece
fix import
alexpeterson91 Jun 19, 2024
34591a6
fix import
alexpeterson91 Jun 19, 2024
7b4bb91
add full import with extension to comply with typescript
alexpeterson91 Jun 20, 2024
956c8cd
fix relative import path
alexpeterson91 Jun 20, 2024
01a2be3
change extension
alexpeterson91 Jun 20, 2024
be4d6df
remove extension in import
alexpeterson91 Jun 20, 2024
bde7321
fix install link import and function for top bar package auto update …
alexpeterson91 Jun 25, 2024
8afbc32
fix https portal UI link redirect
alexpeterson91 Jun 25, 2024
ab5f746
refactor paths to fix broken activity path for toast error alerts
alexpeterson91 Jun 25, 2024
0a50426
revert chnage to url join function
alexpeterson91 Jun 25, 2024
d00c509
add function dirextly and remove import breeaking build
alexpeterson91 Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useSelector } from "react-redux";
import { NavLink, useNavigate } from "react-router-dom";
import { getDappnodeIdentityClean } from "services/dappnodeStatus/selectors";
import { getInstallerPath } from "pages/installer";
import { pathName as systemPathName } from "pages/system";
import { subPaths as systemSubPaths } from "pages/system/data";
//import { httpsPortalPath } from "pages/system/data";
//import { subPaths as systemSubPaths } from "pages/system/data"
import Alert from "react-bootstrap/esm/Alert";
import { MdAdd } from "react-icons/md";
import { MdClose } from "react-icons/md";
Expand All @@ -21,10 +21,11 @@ import Ok from "components/Ok";
import { prettyFullName } from "utils/format";
import newTabProps from "utils/newTabProps";
import { HttpsPortalMapping } from "@dappnode/types";
import { httpsPortalDnpName } from "params";
import { httpsPortalDnpName, httpsPortalUIPath } from "params";
import "./https-mapping.scss";
import { urlJoin } from "utils/url";
//import { urlJoin } from "utils/url";
import { ReqStatus } from "types";
//import { rootPath as systemRootPath } from "pages/system/data";

export function HttpsMappings({
dnpName,
Expand Down Expand Up @@ -167,11 +168,11 @@ export function HttpsMappings({
<div className="network-mappings">
<p>
It recommended to only expose the pre-approved safe services listed in{" "}
<NavLink to={urlJoin(systemPathName, systemSubPaths.network)}>
<NavLink to={httpsPortalUIPath}>
System / Network
</NavLink>
. Please, only add custom mappings manually if you understand the
security risks
. Please, only add custom mappings manually if you Fully understand the
security risks involved.
</p>

<div className="list-grid">
Expand Down
7 changes: 4 additions & 3 deletions packages/admin-ui/src/pages/support/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This will be used later in our root reducer and selectors
export const relativePath = "support/auto-diagnose"; // default redirect to auto-diagnose
export const rootPath = "support/*";
export const pathName = "support"
export const relativePath = `${pathName}/auto-diagnose`; // default redirect to auto-diagnose
export const rootPath = `${pathName}/*`;
export const title = "Support";
export const activityPath = `${rootPath}/activity`;
export const activityPath = `${pathName}/activity`;
2 changes: 1 addition & 1 deletion packages/admin-ui/src/pages/system/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const subPaths = {
identity: "identity",
security: "security",
autoUpdates: "auto-updates",
repository: "/repository",
repository: "repository",
staticIp: "static-ip",
network: "network",
update: "update",
Expand Down
4 changes: 4 additions & 0 deletions packages/admin-ui/src/params.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//import { Network } from "pages/system/components/Network";
import { urlJoin } from "utils/url";

// JSON RPC API
Expand Down Expand Up @@ -41,6 +42,9 @@ export const wifiEnvSSID = "SSID";
// Local proxying
export const adminUiLocalDomain = "http://dappnode.local";

// HTTPS Portal UI Link (http://my.dappnode/system/network)
export const httpsPortalUIPath = urlJoin(apiUrl, "system", "network");

// DNP names
export const ethicalMetricsDnpName = "ethical-metrics.dnp.dappnode.eth";
export const httpsPortalDnpName = "https.dnp.dappnode.eth";
Expand Down
9 changes: 7 additions & 2 deletions packages/daemons/src/autoUpdates/formatNotificationBody.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { CoreUpdateDataAvailable } from "@dappnode/types";
import { urlJoin, prettyDnpName } from "@dappnode/utils";
//import { getInstallerPath } from "../../../admin-ui/src/pages/installer/data.js";

const adminUiUpdateCoreUrl = "http://my.dappnode/system/update";
const adminUiInstallPackageUrl = "http://my.dappnode/installer";
//const adminUiInstallPackageUrl = "http://my.dappnode";
const getInstallerPath = (dnpName: string) => {
if (dnpName.includes("public")) return "http://my.dappnode/installer/public";
return "http://my.dappnode/installer/dnp";
};

export function formatPackageUpdateNotification({
dnpName,
Expand All @@ -18,7 +23,7 @@ export function formatPackageUpdateNotification({
autoUpdatesEnabled: boolean;
}): string {
const prettyName = prettyDnpName(dnpName);
const installUrl = urlJoin(adminUiInstallPackageUrl, dnpName);
const installUrl = urlJoin(getInstallerPath(dnpName), dnpName);

return [
`New version ready to install for ${prettyName} (current version ${currentVersion})`,
Expand Down
9 changes: 8 additions & 1 deletion packages/utils/src/urlJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
* @returns "http://ipfs.io/ipfs/Qm"
*/
export function urlJoin(...args: string[]): string {
return args.join("/").replace(/([^:]\/)\/+/g, "$1");
return (
args
.join("/")
// Remove duplicated // expect for the protocol
.replace(/([^:]\/)\/+/g, "$1")
// Remove duplicated // at the start of the string, "//route" => "/route"
.replace(/^\/+/, "/")
);
}
Loading