remove recent folder

rdesktop^2
filip mertens 1 year ago
parent f170b08344
commit 6c0ffc29af
  1. 9
      apps/remixdesktop/src/plugins/fsPlugin.ts
  2. 5
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  3. 63
      libs/remix-ui/workspace/src/lib/components/electron-menu.tsx
  4. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  5. 10
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx

@ -72,7 +72,7 @@ const clientProfile: Profile = {
name: 'fs', name: 'fs',
displayName: 'fs', displayName: 'fs',
description: 'fs', description: 'fs',
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'getRecentFolders', 'glob', 'openWindow', 'selectFolder'] methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'getRecentFolders', 'removeRecentFolder', 'glob', 'openWindow', 'selectFolder']
} }
class FSPluginClient extends ElectronBasePluginClient { class FSPluginClient extends ElectronBasePluginClient {
@ -295,6 +295,13 @@ class FSPluginClient extends ElectronBasePluginClient {
return config.recentFolders || [] return config.recentFolders || []
} }
async removeRecentFolder(path: string): Promise<void> {
const config = await this.call('electronconfig' as any, 'readConfig')
config.recentFolders = config.recentFolders || []
config.recentFolders = config.recentFolders.filter((p: string) => p !== path)
writeConfig(config)
}
async selectFolder(path?: string): Promise<string> { async selectFolder(path?: string): Promise<string> {
let dirs: string[] | undefined let dirs: string[] | undefined

@ -772,6 +772,11 @@ export const getElectronRecentFolders = async () => {
return folders return folders
} }
export const removeRecentElectronFolder = async (path: string) => {
await plugin.call('fs', 'removeRecentFolder', path)
await getElectronRecentFolders()
}
export const hasLocalChanges = async () => { export const hasLocalChanges = async () => {
const filesStatus = await plugin.call('dGitProvider', 'status') const filesStatus = await plugin.call('dGitProvider', 'status')
const uncommittedFiles = getUncommittedFiles(filesStatus) const uncommittedFiles = getUncommittedFiles(filesStatus)

@ -3,6 +3,7 @@ import { FileSystemContext } from "../contexts"
import isElectron from 'is-electron' import isElectron from 'is-electron'
import { FormattedMessage } from "react-intl" import { FormattedMessage } from "react-intl"
import '../css/electron-menu.css' import '../css/electron-menu.css'
import { CustomTooltip } from '@remix-ui/helper'
export const ElectronMenu = () => { export const ElectronMenu = () => {
const global = useContext(FileSystemContext) const global = useContext(FileSystemContext)
@ -31,35 +32,41 @@ export const ElectronMenu = () => {
return ( return (
!isElectron() ? null : !isElectron() ? null :
(global.fs.browser.isSuccessfulWorkspace ? null : (global.fs.browser.isSuccessfulWorkspace ? null :
<> <>
<div onClick={async()=>{await openFolderElectron(null)}} className='btn btn-primary'><FormattedMessage id="electron.openFolder" /></div> <div onClick={async () => { await openFolderElectron(null) }} className='btn btn-primary'><FormattedMessage id="electron.openFolder" /></div>
{global.fs.browser.recentFolders.length > 0 ? {global.fs.browser.recentFolders.length > 0 ?
<> <>
<label className="py-2 pt-3 align-self-center m-0"> <label className="py-2 pt-3 align-self-center m-0">
<FormattedMessage id="electron.recentFolders" /> <FormattedMessage id="electron.recentFolders" />
</label> </label>
<ul> <ul>
{global.fs.browser.recentFolders.map((folder, index) => { {global.fs.browser.recentFolders.map((folder, index) => {
return <li key={index}> return <li key={index}>
<div className="recentfolder pb-1"> <CustomTooltip
<span onClick={async()=>{await openFolderElectron(folder)}} className="pl-2 recentfolder_name pr-2">{lastFolderName(folder)}</span> tooltipText={folder}
<span onClick={async()=>{await openFolderElectron(folder)}} data-id={{folder}} className="recentfolder_path pr-2">{folder}</span> tooltipId={`electron-recent-folder-${index}`}
<i placement='bottom'
onClick={() => {
}}
className="fas fa-times recentfolder_delete pr-2"
> >
<div className="recentfolder pb-1">
<span onClick={async () => { await openFolderElectron(folder) }} className="pl-2 recentfolder_name pr-2">{lastFolderName(folder)}</span>
<span onClick={async () => { await openFolderElectron(folder) }} data-id={{ folder }} className="recentfolder_path pr-2">{folder}</span>
<i
onClick={() => {
global.dispatchRemoveRecentFolder(folder)
}}
className="fas fa-times recentfolder_delete pr-2"
>
</i> </i>
</div> </div>
</li> </CustomTooltip>
})} </li>
</ul> })}
</> </ul>
: null} </>
</> : null}
) </>
)
) )
} }

@ -47,6 +47,7 @@ export const FileSystemContext = createContext<{
dispatchCreateSlitherGithubAction: () => Promise<void> dispatchCreateSlitherGithubAction: () => Promise<void>
dispatchOpenElectronFolder: (path: string) => Promise<void> dispatchOpenElectronFolder: (path: string) => Promise<void>
dispatchGetElectronRecentFolders: () => Promise<void> dispatchGetElectronRecentFolders: () => Promise<void>
dispatchRemoveRecentFolder: (path: string) => Promise<void>
}>(null) }>(null)

@ -8,7 +8,7 @@ import { browserReducer, browserInitialState } from '../reducers/workspace'
import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, deleteAllWorkspaces, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, deleteAllWorkspaces, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder,
deletePath, renamePath, downloadPath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, deletePath, renamePath, downloadPath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace,
fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, uploadFolder, handleDownloadWorkspace, handleDownloadFiles, restoreBackupZip, cloneRepository, moveFile, moveFolder, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, uploadFolder, handleDownloadWorkspace, handleDownloadFiles, restoreBackupZip, cloneRepository, moveFile, moveFolder,
showAllBranches, switchBranch, createNewBranch, checkoutRemoteBranch, createSolidityGithubAction, createTsSolGithubAction, createSlitherGithubAction, openElectronFolder, getElectronRecentFolders showAllBranches, switchBranch, createNewBranch, checkoutRemoteBranch, createSolidityGithubAction, createTsSolGithubAction, createSlitherGithubAction, openElectronFolder, getElectronRecentFolders, removeRecentElectronFolder
} from '../actions' } from '../actions'
import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types' import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -193,6 +193,11 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await getElectronRecentFolders() await getElectronRecentFolders()
} }
const dispatchRemoveRecentFolder = async (path: string) => {
console.log('remove recent folder')
await removeRecentElectronFolder(path)
}
useEffect(() => { useEffect(() => {
dispatchInitWorkspace() dispatchInitWorkspace()
@ -312,7 +317,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchCreateTsSolGithubAction, dispatchCreateTsSolGithubAction,
dispatchCreateSlitherGithubAction, dispatchCreateSlitherGithubAction,
dispatchOpenElectronFolder, dispatchOpenElectronFolder,
dispatchGetElectronRecentFolders dispatchGetElectronRecentFolders,
dispatchRemoveRecentFolder
} }
return ( return (
<FileSystemContext.Provider value={value}> <FileSystemContext.Provider value={value}>

Loading…
Cancel
Save