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 6b02520e94d..4084b6a82f7 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -9,6 +9,7 @@ "filePanel.clone": "Clone", "filePanel.download": "Download", "filePanel.backup": "Backup", + "filePanel.localFileSystem": "Connect to Local Filesystem", "filePanel.restore": "Restore", "filePanel.name": "Name", "filePanel.save": "Save", @@ -28,6 +29,7 @@ "filePanel.workspace.chooseTemplate": "Choose a template", "filePanel.workspace.backup": "Backup All Workspaces", "filePanel.workspace.restore": "Restore Workspaces from the Backup", + "filePanel.workspace.localFileSystem": "Connect to Local Filesystem using Remixd", "filePanel.workspace.clone": "Clone Git Repository", "filePanel.workspace.cloneMessage": "Please provide a valid git repository url.", "filePanel.workspace.enterGitUrl": "Enter git repository url", @@ -92,7 +94,7 @@ "filePanel.cancel": "Cancel", "filePanel.selectFolder": "Select or create folder", "filePanel.createNewWorkspace": "create a new workspace", - "filePanel.connectToLocalhost": "connect to localhost", + "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/components/file-explorer-menu.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx index 63d8c92024f..71278a2a485 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer-menu.tsx @@ -53,6 +53,20 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { icon: 'fa-solid fa-link', placement: 'top', platforms: [appPlatformTypes.web, appPlatformTypes.desktop] + }, + { + action: 'connectToLocalFileSystem', + title: 'Connect to local filesystem using remixd', + icon: 'fa-solid fa-desktop', + placement: 'top', + platforms: [appPlatformTypes.web] + }, + { + action: 'initializeWorkspaceAsGitRepo', + title: 'Initialize workspace as a git repository', + icon: 'fa-brands fa-git-alt', + placement: 'top', + platforms: [appPlatformTypes.web, appPlatformTypes.desktop] } ].filter( (item) => @@ -136,6 +150,29 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => { ) + } else if (action === 'initializeWorkspaceAsGitRepo') { + return ( + } + key={`index-${action}-${placement}-${icon}`} + > + + + ) } else { return ( { props.createNewFolder() } else if (action === 'publishToGist' || action == 'updateGist') { props.publishToGist() + } else if (action === 'connectToLocalFileSystem') { + _paq.push(['trackEvent', 'fileExplorer', 'fileAction', action]) + props.connectToLocalFileSystem() } else if (action === 'importFromIpfs') { _paq.push(['trackEvent', 'fileExplorer', 'fileAction', action]) props.importFromIpfs('Ipfs', 'ipfs hash', ['ipfs://QmQQfBMkpDgmxKzYaoAtqfaybzfgGm9b2LWYyT56Chv6xH'], 'ipfs://') diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index 38ac14cd6de..21e318b4ead 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -581,6 +581,12 @@ export const FileExplorer = (props: FileExplorerProps) => { } + const handleGitInit = async () => { + const isActive = await plugin.call('manager', 'isActive', 'dgit') + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') + await plugin.call('dgitApi', 'init') + } + return (
{ uploadFolder={uploadFolder} importFromIpfs={props.importFromIpfs} importFromHttps={props.importFromHttps} + connectToLocalFileSystem={() => props.connectToLocalFileSystem()} + handleGitInit={handleGitInit} />
diff --git a/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx index 860ac4042ed..c83313cb655 100644 --- a/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx +++ b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger.tsx @@ -17,6 +17,7 @@ export interface HamburgerMenuProps { downloadWorkspaces: () => void restoreBackup: () => void hideIconsMenu: (showMenu: boolean) => void + handleRemixdWorkspace: () => void showIconsMenu: boolean hideWorkspaceOptions: boolean hideLocalhostOptions: boolean @@ -139,6 +140,17 @@ export function HamburgerMenu(props: HamburgerMenuProps) { }} platforms={[appPlatformTypes.web]} > + + { + props.handleRemixdWorkspace() + props.hideIconsMenu(!showIconsMenu) + }} + platforms={[appPlatformTypes.web]} + > ) } diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 47fba81fedb..04e1b7f8a38 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -2,6 +2,8 @@ import { branch } from '@remix-ui/git' import { customAction } from '@remixproject/plugin-api' import { createContext, SyntheticEvent } from 'react' import { BrowserState } from '../reducers/workspace' +import { Plugin } from '@remixproject/engine' +import { CustomRemixApi } from '@remix-api' export const FileSystemContext = createContext<{ fs: any, 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 3673851d110..1c424a442f1 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -917,6 +917,86 @@ export function Workspace() { _paq.push(['trackEvent', 'Workspace', 'GIT', 'login']) } + 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}`} + > + + + ))} + + ) + } + const [togglerText, setTogglerText] = useState<'Connecting' | 'Connected to Local FileSystem'>('Connecting') + + useEffect(() => { + setTimeout(() => { + setTogglerText('Connected to Local FileSystem') + }, 1000) + }, [selectedWorkspace]) + + const WorkspaceDropdownToggle = () => { + const [togglerText, setTogglerText] = useState<'Connecting' | 'Connected to Local FileSystem'>('Connecting') + + useEffect(() => { + setTimeout(() => { + setTogglerText('Connected to Local FileSystem') + }, 1000) + }, [selectedWorkspace]) + + return ( + + {selectedWorkspace ? selectedWorkspace.name === LOCALHOST ? togglerText : selectedWorkspace.name : currentWorkspace === LOCALHOST ? formatNameForReadonly('localhost') : NO_WORKSPACE} + + ) + } + return (
switchWorkspace(LOCALHOST)} createBlankWorkspace={createBlankWorkspace} renameCurrentWorkspace={renameCurrentWorkspace} downloadCurrentWorkspace={downloadCurrentWorkspace} @@ -1024,54 +1105,25 @@ export function Workspace() { className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control mt-1" icon={selectedWorkspace && selectedWorkspace.isGitRepo && !(currentWorkspace === LOCALHOST) ? 'far fa-code-branch' : null} > - {selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? formatNameForReadonly('localhost') : NO_WORKSPACE} + {selectedWorkspace ? selectedWorkspace.name === LOCALHOST ? togglerText : selectedWorkspace.name : currentWorkspace === LOCALHOST ? formatNameForReadonly('localhost') : NO_WORKSPACE} - - { - createWorkspace() - }} - > - { - - {' '} - - -{' '} - - } - { switchWorkspace(LOCALHOST) }} > {currentWorkspace === LOCALHOST ? ( - ✓ localhost + ✓ Connected to Local Filesystem ) : ( - - {' '} - {' '} - + // + // {' '} + // {' '} + // + null )} - {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) && ( { @@ -1105,8 +1157,7 @@ export function Workspace() { switchWorkspace(LOCALHOST)} canPaste={canPaste} hasCopied={hasCopied} setHasCopied={setHasCopied} diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index 214c1196b24..71fb5f7271f 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -159,6 +159,8 @@ export interface FileExplorerProps { dragStatus: (status: boolean) => void importFromIpfs: any importFromHttps: any + connectToLocalFileSystem?: any + handleGitInit?: () => Promise handleMultiCopies: any feTarget: { key: string, type: 'file' | 'folder' }[] setFeTarget: Dispatch void importFromIpfs: any importFromHttps: any + connectToLocalFileSystem?: any + handleGitInit?: () => Promise tooltipPlacement?: Placement } export interface FileExplorerContextMenuProps {