From 787e2e126428ccab6d07beb959bd258ac6f8513d Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 22 Aug 2024 17:54:23 +0100 Subject: [PATCH] clean up dropdown menu and update logic --- .../src/app/tabs/locales/en/filePanel.json | 2 +- .../workspace/src/lib/remix-ui-workspace.tsx | 72 ++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json index 1e0a2e00df..3680b1b5c0 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -92,7 +92,7 @@ "filePanel.cancel": "Cancel", "filePanel.selectFolder": "Select or create folder", "filePanel.createNewWorkspace": "create a new workspace", - "filePanel.connectToLocalhost": "connect to Local Filesystem", + "filePanel.connectToLocalhost": "Connect to Local Filesystem", "filePanel.copiedToClipboard": "Copied to clipboard {path}", "filePanel.downloadFailed": "Download Failed", "filePanel.downloadFailedMsg": "Unexpected error while downloading: {error}", diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 254b4f1dc1..8293962193 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -933,6 +933,57 @@ export function Workspace() { ) } + const IsGitRepoDropDownMenuItem = (props: { isGitRepo: boolean, mName: string}) => { + return ( + <> + {props.isGitRepo ? ( +
+ {currentWorkspace === props.mName ? ✓ {props.mName} : {props.mName}} + +
+ ) : ( + {currentWorkspace === props.mName ? ✓ {props.mName} : {props.mName}} + )} + + ) + } + + const ShowNonLocalHostMenuItems = () => { + const cachedFilter = global.fs.browser.workspaces.filter(x => !x.name.includes('localhost')) + return ( + <> + { + currentWorkspace === LOCALHOST && cachedFilter.length > 0 ? cachedFilter.map(({ name, isGitRepo }, index) => ( + { + switchWorkspace(name) + }} + data-id={`dropdown-item-${name}`} + > + + + )) : + } + + ) + } + + const ShowAllMenuItems = () => { + return ( + <> + { global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( + { switchWorkspace(name) }} + data-id={`dropdown-item-${name}`} + > + + + ))} + + ) + } return (
{currentWorkspace === LOCALHOST ? ( - ✓ localhost + ✓ Connected to Local Filesystem ) : ( {' '} @@ -1060,24 +1111,7 @@ export function Workspace() { )} - {global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( - { - switchWorkspace(name) - }} - data-id={`dropdown-item-${name}`} - > - {isGitRepo ? ( -
- {currentWorkspace === name ? ✓ {name} : {name}} - -
- ) : ( - {currentWorkspace === name ? ✓ {name} : {name}} - )} -
- ))} + {(global.fs.browser.workspaces.length <= 0 || currentWorkspace === NO_WORKSPACE) && ( {