Delete workspace

pull/5370/head
lianahus 1 year ago
parent 05a8b13fff
commit 8761059746
  1. 6
      apps/remix-ide/src/app/panels/file-panel.js
  2. 39
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx
  3. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -179,12 +179,12 @@ module.exports = class Filepanel extends ViewPlugin {
const workspaceProvider = this.fileProviders.workspace const workspaceProvider = this.fileProviders.workspace
const current = this.currentWorkspaceMetadata const current = this.currentWorkspaceMetadata
this.currentWorkspaceMetadata = { name: workspace.name, isLocalhost: workspace.isLocalhost, absolutePath: `${workspaceProvider.workspacesPath}/${workspace.name}` } this.currentWorkspaceMetadata = { name: workspace.name, isLocalhost: workspace.isLocalhost, absolutePath: `${workspaceProvider.workspacesPath}/${workspace.name}` }
if (workspace.name !== " - connect to localhost - ") {
localStorage.setItem('currentWorkspace', workspace.name)
}
if (this.currentWorkspaceMetadata.name !== current) { if (this.currentWorkspaceMetadata.name !== current) {
this.saveRecent(workspace.name) this.saveRecent(workspace.name)
} }
if (workspace.name !== " - connect to localhost - ") {
localStorage.setItem('currentWorkspace', workspace.name)
}
this.emit('setWorkspace', workspace) this.emit('setWorkspace', workspace)
} }

@ -65,10 +65,32 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
return { ...prevState, recentWorkspaces: { first: recents.first, second: recents.second, third: recents.third } } return { ...prevState, recentWorkspaces: { first: recents.first, second: recents.second, third: recents.third } }
}) })
}) })
const updateWorkspaceName = (name, newName = '') => {
let recents = JSON.parse(localStorage.getItem('recentWorkspaces'))
const newRecents = recents
if (!recents) {
recents = {first:'', second: '', third: ''}
} else {
Object.keys(recents).map(key => {
if (recents[key] === name) newRecents[key] = newName
})
}
setState(prevState => {
return { ...prevState, recentWorkspaces: { first: newRecents.first, second: newRecents.second, third: newRecents.third } }
})
}
plugin.on('filePanel', 'workspaceDeleted', async (deletedName) => {
updateWorkspaceName(deletedName)
})
plugin.on('filePanel', 'workspaceRenamed', async (name, newName) => {
updateWorkspaceName(name, newName)
})
return () => { return () => {
plugin.off('filePanel', 'setWorkspace') plugin.off('filePanel', 'setWorkspace')
plugin.off('filePanel', 'workspaceDeleted')
} }
}, []) }, [state.recentWorkspaces])
const processLoading = (type: string) => { const processLoading = (type: string) => {
_paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type]) _paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type])
@ -121,7 +143,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault')
} }
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false })
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // don't ask why await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working.
const content = `// SPDX-License-Identifier: MIT const content = `// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0; pragma solidity >=0.7.0 <0.9.0;
@ -174,20 +196,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
const handleSwichToRecentWorkspace = async (e, workspaceName) => { const handleSwichToRecentWorkspace = async (e, workspaceName) => {
e.preventDefault(); e.preventDefault();
<<<<<<< HEAD
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false })
=======
<<<<<<< HEAD
<<<<<<< HEAD
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false })
console.log('The link was clicked.');
=======
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false })
>>>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace
=======
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false })
>>>>>>> 06483cab7... fix vreating workspace
>>>>>>> 1b238a875... fix vreating workspace
} }
const examples = state.modalInfo.examples.map((urlEl, key) => ( const examples = state.modalInfo.examples.map((urlEl, key) => (

@ -899,10 +899,10 @@ export function Workspace() {
</span> </span>
) : null} ) : null}
<span className="d-flex"> <span className="d-flex">
<label className="pl-1 form-check-label" htmlFor="workspacesSelect" style={{wordBreak: 'keep-all'}}> <label className="pl-2 form-check-label" htmlFor="workspacesSelect" style={{wordBreak: 'keep-all'}}>
<FormattedMessage id="filePanel.workspace" /> <FormattedMessage id='filePanel.workspace' />
</label> </label>
</span> </span>
</div> </div>
<div className='mx-2'> <div className='mx-2'>
<Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}> <Dropdown id="workspacesSelect" data-id="workspacesSelect" onToggle={toggleDropdown} show={showDropdown}>

Loading…
Cancel
Save