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 0316c1f463..a4eafc90e6 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/filePanel.json +++ b/apps/remix-ide/src/app/tabs/locales/en/filePanel.json @@ -2,11 +2,13 @@ "filePanel.displayName": "File explorer", "filePanel.workspace": "WORKSPACES", "filePanel.create": "Create", + "filePanel.create.desktop": "Create Project", "filePanel.clone": "Clone", "filePanel.download": "Download", "filePanel.backup": "Backup", "filePanel.restore": "Restore", "filePanel.workspace.create": "Create Workspace", + "filePanel.workspace.create.desktop": "Create Project in new Folder", "filePanel.workspace.rename": "Rename Workspace", "filePanel.workspace.delete": "Delete Workspace", "filePanel.workspace.deleteConfirm": "Are you sure to delete the current workspace?", diff --git a/apps/remixdesktop/src/plugins/fsPlugin.ts b/apps/remixdesktop/src/plugins/fsPlugin.ts index 0fcfc769d1..73e869b38b 100644 --- a/apps/remixdesktop/src/plugins/fsPlugin.ts +++ b/apps/remixdesktop/src/plugins/fsPlugin.ts @@ -84,7 +84,7 @@ const clientProfile: Profile = { name: 'fs', displayName: 'fs', description: 'fs', - methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode', 'openInVSCode'], + methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'getWorkingDir', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode', 'openInVSCode', 'currentPath'], } class FSPluginClient extends ElectronBasePluginClient { @@ -204,6 +204,10 @@ class FSPluginClient extends ElectronBasePluginClient { return process.cwd() } + async getWorkingDir(): Promise { + return this.workingDir + } + async watch(): Promise { try { this.off('filePanel' as any, 'expandPathChanged') diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index bcad5bd98a..5cf8d02166 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -2,7 +2,7 @@ import React from 'react' import { extractNameFromKey, createNonClashingNameAsync } from '@remix-ui/helper' import Gists from 'gists' import { customAction } from '@remixproject/plugin-api' -import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryRequest, fetchDirectorySuccess, focusElement, fsInitializationCompleted, hidePopUp, removeInputFieldSuccess, setCurrentWorkspace, setExpandPath, setMode, setWorkspaces } from './payload' +import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryRequest, fetchDirectorySuccess, focusElement, fsInitializationCompleted, hidePopUp, removeInputFieldSuccess, setCurrentLocalFilePath, setCurrentWorkspace, setExpandPath, setMode, setWorkspaces } from './payload' import { listenOnPluginEvents, listenOnProviderEvents } from './events' import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin, workspaceExists } from './workspace' import { QueryParams } from '@remix-project/remix-lib' @@ -124,8 +124,14 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. plugin.call('notification', 'toast', `opening ${params.opendir}...`) await plugin.call('fs', 'setWorkingDir', params.opendir) } - plugin.setWorkspace({ name: 'electron', isLocalhost: false }) + plugin.on('fs', 'workingDirChanged', async (dir) => { + dispatch(setCurrentLocalFilePath(dir)) + }) + const currentPath = await plugin.call('fs', 'getWorkingDir') + dispatch(setCurrentLocalFilePath(currentPath)) + plugin.setWorkspace({ name: 'electron', isLocalhost: false }) + dispatch(setCurrentWorkspace({ name: 'electron', isGitRepo: false })) electrOnProvider.init() listenOnProviderEvents(electrOnProvider)(dispatch) diff --git a/libs/remix-ui/workspace/src/lib/actions/payload.ts b/libs/remix-ui/workspace/src/lib/actions/payload.ts index 91966e8af3..c19e93f4c5 100644 --- a/libs/remix-ui/workspace/src/lib/actions/payload.ts +++ b/libs/remix-ui/workspace/src/lib/actions/payload.ts @@ -308,9 +308,16 @@ export const setGitConfig = (config: {username: string, token: string, email: st } } -export const setElectronRecentFolders = (folders: string[]) => { +export const setElectronRecentFolders = (folders: string[]): Action<'SET_ELECTRON_RECENT_FOLDERS'> => { return { type: 'SET_ELECTRON_RECENT_FOLDERS', payload: folders } } + +export const setCurrentLocalFilePath = (path: string): Action<'SET_CURRENT_LOCAL_FILE_PATH'> => { + return { + type: 'SET_CURRENT_LOCAL_FILE_PATH', + payload: path + } +} diff --git a/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx b/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx new file mode 100644 index 0000000000..1e25c5dcd1 --- /dev/null +++ b/libs/remix-ui/workspace/src/lib/components/electron-workspace-name.tsx @@ -0,0 +1,45 @@ +import { CustomTooltip } from "@remix-ui/helper" +import React, { MouseEventHandler, useContext, useEffect, useState } from "react" + +interface ElectronWorkspaceNameProps { + path: string + plugin: any +} + +export const ElectronWorkspaceName = (props: ElectronWorkspaceNameProps) => { + const { path } = props + + const parsePath = (path: string) => { + const pathArray = path.split('/') + return pathArray[pathArray.length - 1] + } + + const openInExplorer = () => { + props.plugin.call('fs', 'revealInExplorer', { + path + }) + } + + return ( + (path === undefined || path === '') ? <> : +
+ +
{parsePath(path)}
+
+ + + +
+ + ) +} diff --git a/libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx index 930f48ef00..82a873c4bc 100644 --- a/libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx +++ b/libs/remix-ui/workspace/src/lib/components/workspace-hamburger-item.tsx @@ -19,7 +19,7 @@ export function HamburgerMenuItem(props: HamburgerMenuItemProps) { const uid = 'workspace' + props.kind return ( <> - {props.platforms.includes(platform)?( + {props.platforms.includes(platform) && !hideOption?( }>
+ { + props.createWorkspace() + props.hideIconsMenu(!showIconsMenu) + }} + platforms={[appPlatformTypes.desktop]} > { props.addGithubAction() props.hideIconsMenu(!showIconsMenu) @@ -121,7 +132,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) { { props.addTsSolTestGithubAction() props.hideIconsMenu(!showIconsMenu) @@ -131,7 +142,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) { { props.addSlitherGithubAction() props.hideIconsMenu(!showIconsMenu) @@ -142,7 +153,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) { { props.addHelperScripts('etherscan') props.hideIconsMenu(!showIconsMenu) @@ -152,7 +163,7 @@ export function HamburgerMenu(props: HamburgerMenuProps) { { props.addHelperScripts('deployer') props.hideIconsMenu(!showIconsMenu) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 8be20bf784..195a6d168c 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -35,6 +35,7 @@ export interface BrowserState { } fileState: fileDecoration[] recentFolders: string[] + currentLocalFilePath?: string } localhost: { sharedFolder: string @@ -90,7 +91,8 @@ export const browserInitialState: BrowserState = { error: null }, fileState: [], - recentFolders: [] + recentFolders: [], + currentLocalFilePath: '' }, localhost: { sharedFolder: '', @@ -872,6 +874,17 @@ export const browserReducer = (state = browserInitialState, action: Actions) => } } + case 'SET_CURRENT_LOCAL_FILE_PATH': { + const payload: string = action.payload + return { + ...state, + browser: { + ...state.browser, + currentLocalFilePath: payload + } + } + } + default: throw new 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 76c4da55ea..61211e81bb 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -14,6 +14,7 @@ import FileExplorerContextMenu from './components/file-explorer-context-menu' import { customAction } from '@remixproject/plugin-api' import { appPlatformTypes, platformContext } from '@remix-ui/app' import { ElectronMenu } from './components/electron-menu' +import { ElectronWorkspaceName } from './components/electron-workspace-name' const _paq = (window._paq = window._paq || []) @@ -24,7 +25,6 @@ export function Workspace() { const platform = useContext(platformContext) const LOCALHOST = ' - connect to localhost - ' const NO_WORKSPACE = ' - none - ' - const ELECTRON = 'electron' const [currentWorkspace, setCurrentWorkspace] = useState(NO_WORKSPACE) const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string @@ -945,14 +945,17 @@ export function Workspace() { showIconsMenu={showIconsMenu} hideWorkspaceOptions={currentWorkspace === LOCALHOST} hideLocalhostOptions={currentWorkspace === NO_WORKSPACE} + hideFileOperations={(platform == appPlatformTypes.desktop)? (global.fs.browser.currentLocalFilePath && global.fs.browser.currentLocalFilePath !== ''? false:true):false} /> ) : null} -
diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index df9b2b5d6b..4fa498eabf 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -303,6 +303,7 @@ export interface ActionPayloadTypes { email: string }, SET_ELECTRON_RECENT_FOLDERS: string[] + SET_CURRENT_LOCAL_FILE_PATH: string } export interface Action {