remove recent folder

rdesktop
filip mertens 1 year ago
parent a69a6e648a
commit 5c8a92ac0f
  1. 9
      apps/remixdesktop/src/plugins/fsPlugin.ts
  2. 5
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  3. 15
      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',
displayName: '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 {
@ -295,6 +295,13 @@ class FSPluginClient extends ElectronBasePluginClient {
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> {
let dirs: string[] | undefined

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

@ -3,6 +3,7 @@ import { FileSystemContext } from "../contexts"
import isElectron from 'is-electron'
import { FormattedMessage } from "react-intl"
import '../css/electron-menu.css'
import { CustomTooltip } from '@remix-ui/helper'
export const ElectronMenu = () => {
const global = useContext(FileSystemContext)
@ -33,7 +34,7 @@ export const ElectronMenu = () => {
!isElectron() ? 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 ?
<>
<label className="py-2 pt-3 align-self-center m-0">
@ -42,18 +43,24 @@ export const ElectronMenu = () => {
<ul>
{global.fs.browser.recentFolders.map((folder, index) => {
return <li key={index}>
<CustomTooltip
tooltipText={folder}
tooltipId={`electron-recent-folder-${index}`}
placement='bottom'
>
<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>
<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>
</div>
</CustomTooltip>
</li>
})}
</ul>

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

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

Loading…
Cancel
Save