From c8496f7916908cf19c9dd304f1d5f0df0a53a20f Mon Sep 17 00:00:00 2001 From: Philip Zingmark Date: Tue, 4 Feb 2025 11:18:32 +0100 Subject: [PATCH 1/2] small fix for docker-cli command if user is on windows, escape $ with `instad of \ --- src/pages/edit/deployments/GHActions.tsx | 47 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/pages/edit/deployments/GHActions.tsx b/src/pages/edit/deployments/GHActions.tsx index eccc65d..2a4d3e9 100644 --- a/src/pages/edit/deployments/GHActions.tsx +++ b/src/pages/edit/deployments/GHActions.tsx @@ -13,11 +13,13 @@ import { Link, Paper, Stack, + Tab, TableBody, TableCell, TableContainer, TableHead, TableRow, + Tabs, TextareaAutosize, Typography, useTheme, @@ -34,17 +36,29 @@ type Secret = { value: string; }; +const MACOS_LINUX_INDEX: number = 0; +const WINDOWS_INDEX: number = 1; + const GHActions = ({ resource }: { resource: Deployment }) => { const { t } = useTranslation(); const { keycloak, initialized } = useKeycloak(); const [actionsFile, setActionsFile] = useState(""); const [cliCommands, setCliCommands] = useState(""); + const [cliCommandsPS, setCliCommandsPS] = useState(""); const [redacted, setRedacted] = useState(""); + const [redactedPS, setRedactedPS] = useState(""); const [secrets, setSecrets] = useState([]); const [showSecrets, setShowSecrets] = useState(false); const [showCliSecrets, setShowCliSecrets] = useState(false); const theme: CustomTheme = useTheme(); + const [tabIndex, setTabIndex] = useState(0); + + useEffect(() => { + const isWindows = navigator.platform.toLowerCase().includes("win"); + setTabIndex(isWindows ? WINDOWS_INDEX : MACOS_LINUX_INDEX); + }, []); + const loadYaml = async () => { if (!(initialized && keycloak.token)) return; try { @@ -66,7 +80,10 @@ const GHActions = ({ resource }: { resource: Deployment }) => { // escape $ for bash const commandString = commands.join("\n").replace(/\$/g, "\\$"); + // on windows use ` to escape it in powershell + const commandStringPS = commands.join("\n").replace(/\$/g, "`$"); setCliCommands(commandString); + setCliCommandsPS(commandStringPS); setRedacted( commandString .replace(password, "********") @@ -74,6 +91,13 @@ const GHActions = ({ resource }: { resource: Deployment }) => { .replace(registry, "********") .replace(tag, "********") ); + setRedactedPS( + commandStringPS + .replace(password, "********") + .replace(username, "********") + .replace(registry, "********") + .replace(tag, "********") + ); // Get the secrets const secrets = [ @@ -119,17 +143,29 @@ const GHActions = ({ resource }: { resource: Deployment }) => { return ( <> + setTabIndex(newIndex)} + > + + + + { }} /> + - +