From 856a2e12647a3256d19b115ead923b1d1e1e3a01 Mon Sep 17 00:00:00 2001 From: Misha Bragin Date: Mon, 21 Mar 2022 16:39:32 +0100 Subject: [PATCH] Add WIRETRUSTEE_MGMT_GRPC_API_ENDPOINT endpoint to display in the UI (#20) --- docker/init_react_envs.sh | 3 ++- src/components/addpeer/LinuxTab.js | 5 +++-- src/components/addpeer/MacTab.js | 4 +++- src/components/addpeer/WindowsTab.js | 6 +++--- src/config.js | 1 + src/config.json | 3 ++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docker/init_react_envs.sh b/docker/init_react_envs.sh index 86ef1ab..ef1ab9f 100644 --- a/docker/init_react_envs.sh +++ b/docker/init_react_envs.sh @@ -25,9 +25,10 @@ AUTH0_DOMAIN=${AUTH0_DOMAIN} AUTH0_CLIENT_ID=${AUTH0_CLIENT_ID} AUTH0_AUDIENCE=${AUTH0_AUDIENCE} WIRETRUSTEE_MGMT_API_ENDPOINT=${WIRETRUSTEE_MGMT_API_ENDPOINT} +WIRETRUSTEE_MGMT_GRPC_API_ENDPOINT=${WIRETRUSTEE_MGMT_GRPC_API_ENDPOINT} # replace ENVs in the config -ENV_STR="\$\$AUTH0_DOMAIN \$\$AUTH0_CLIENT_ID \$\$AUTH0_AUDIENCE \$\$WIRETRUSTEE_MGMT_API_ENDPOINT" +ENV_STR="\$\$AUTH0_DOMAIN \$\$AUTH0_CLIENT_ID \$\$AUTH0_AUDIENCE \$\$WIRETRUSTEE_MGMT_API_ENDPOINT \$\$WIRETRUSTEE_MGMT_GRPC_API_ENDPOINT" MAIN_JS=$(find /usr/share/nginx/html/static/js/main.*js) cp "$MAIN_JS" "$MAIN_JS".copy envsubst "$ENV_STR" < "$MAIN_JS".copy > "$MAIN_JS" diff --git a/src/components/addpeer/LinuxTab.js b/src/components/addpeer/LinuxTab.js index 1d149e9..79dc91f 100644 --- a/src/components/addpeer/LinuxTab.js +++ b/src/components/addpeer/LinuxTab.js @@ -3,7 +3,8 @@ import Highlight from "../Highlight"; import CopyButton from "../CopyButton"; import {classNames} from "../../utils/common"; import PropTypes from "prop-types"; -import WindowsTab from "./WindowsTab"; +import {getConfig} from "../../config"; +const {grpcApiOrigin} = getConfig(); const LinuxTab = ({setupKey}) => { @@ -33,7 +34,7 @@ const LinuxTab = ({setupKey}) => { iconBackground: 'bg-gray-600', content: null, copy: true, - commands: ["sudo wiretrustee up --setup-key "] + commands: grpcApiOrigin === '' ? ["sudo wiretrustee up --setup-key "] : ["sudo wiretrustee up --setup-key --management-url " + grpcApiOrigin] }, { id: 4, diff --git a/src/components/addpeer/MacTab.js b/src/components/addpeer/MacTab.js index c005545..5f413a8 100644 --- a/src/components/addpeer/MacTab.js +++ b/src/components/addpeer/MacTab.js @@ -3,6 +3,8 @@ import Highlight from "../Highlight"; import CopyButton from "../CopyButton"; import {classNames} from "../../utils/common"; import PropTypes from "prop-types"; +import {getConfig} from "../../config"; +const {grpcApiOrigin} = getConfig(); const MacTab = ({setupKey}) => { @@ -32,7 +34,7 @@ const MacTab = ({setupKey}) => { iconBackground: 'bg-gray-600', content: null, copy: true, - commands: ["sudo wiretrustee up --setup-key "] + commands: grpcApiOrigin === '' ? ["sudo wiretrustee up --setup-key "] : ["sudo wiretrustee up --setup-key --management-url " + grpcApiOrigin] }, { id: 4, diff --git a/src/components/addpeer/WindowsTab.js b/src/components/addpeer/WindowsTab.js index 26697b8..bba8186 100644 --- a/src/components/addpeer/WindowsTab.js +++ b/src/components/addpeer/WindowsTab.js @@ -3,7 +3,8 @@ import Highlight from "../Highlight"; import CopyButton from "../CopyButton"; import {classNames} from "../../utils/common"; import PropTypes from "prop-types"; -import SetupKeySelect from "./SetupKeySelect"; +import {getConfig} from "../../config"; +const {grpcApiOrigin} = getConfig(); const WindowsTab = ({setupKey}) => { @@ -14,7 +15,6 @@ const WindowsTab = ({setupKey}) => { icon: ArrowCircleRightIcon, iconBackground: 'bg-gray-600', content: , - //content: Wiretrustee GitHub Releases, commands: [], copy: false }, @@ -35,7 +35,7 @@ const WindowsTab = ({setupKey}) => { iconBackground: 'bg-gray-600', content: null, copy: true, - commands: ["wiretrustee.exe up --setup-key "] + commands: grpcApiOrigin === '' ? ["wiretrustee.exe --setup-key "] : ["wiretrustee.exe --setup-key --management-url " + grpcApiOrigin] }, { id: 4, diff --git a/src/config.js b/src/config.js index 334e4fa..5425b7b 100644 --- a/src/config.js +++ b/src/config.js @@ -23,6 +23,7 @@ export function getConfig() { domain: configJson.domain, clientId: configJson.clientId, apiOrigin: configJson.apiOrigin, + grpcApiOrigin: configJson.grpcApiOrigin, ...(audience ? { audience } : null), }; } diff --git a/src/config.json b/src/config.json index cd0d96b..36d6edc 100644 --- a/src/config.json +++ b/src/config.json @@ -2,5 +2,6 @@ "domain": "$AUTH0_DOMAIN", "clientId": "$AUTH0_CLIENT_ID", "audience": "$AUTH0_AUDIENCE", - "apiOrigin": "$WIRETRUSTEE_MGMT_API_ENDPOINT" + "apiOrigin": "$WIRETRUSTEE_MGMT_API_ENDPOINT", + "grpcApiOrigin": "$WIRETRUSTEE_MGMT_GRPC_API_ENDPOINT" } \ No newline at end of file