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',
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

@ -772,6 +772,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)
@ -31,35 +32,41 @@ export const ElectronMenu = () => {
return (
!isElectron() ? null :
(global.fs.browser.isSuccessfulWorkspace ? null :
<>
<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">
<FormattedMessage id="electron.recentFolders" />
</label>
<ul>
{global.fs.browser.recentFolders.map((folder, index) => {
return <li key={index}>
<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={() => {
}}
className="fas fa-times recentfolder_delete pr-2"
(global.fs.browser.isSuccessfulWorkspace ? null :
<>
<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">
<FormattedMessage id="electron.recentFolders" />
</label>
<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>
<i
onClick={() => {
global.dispatchRemoveRecentFolder(folder)
}}
className="fas fa-times recentfolder_delete pr-2"
>
</i>
</div>
</li>
})}
</ul>
</>
: null}
</>
)
</i>
</div>
</CustomTooltip>
</li>
})}
</ul>
</>
: null}
</>
)
)
}

@ -47,6 +47,7 @@ export const FileSystemContext = createContext<{
dispatchCreateSlitherGithubAction: () => 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, openElectronFolder, getElectronRecentFolders
showAllBranches, switchBranch, createNewBranch, checkoutRemoteBranch, createSolidityGithubAction, createTsSolGithubAction, createSlitherGithubAction, openElectronFolder, getElectronRecentFolders, removeRecentElectronFolder
} from '../actions'
import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -193,6 +193,11 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await getElectronRecentFolders()
}
const dispatchRemoveRecentFolder = async (path: string) => {
console.log('remove recent folder')
await removeRecentElectronFolder(path)
}
useEffect(() => {
dispatchInitWorkspace()
@ -312,7 +317,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchCreateTsSolGithubAction,
dispatchCreateSlitherGithubAction,
dispatchOpenElectronFolder,
dispatchGetElectronRecentFolders
dispatchGetElectronRecentFolders,
dispatchRemoveRecentFolder
}
return (
<FileSystemContext.Provider value={value}>

Loading…
Cancel
Save