alwayd delete the code-sample workspace but propose to turn it into a normal workspace

pull/4410/head
yann300 12 months ago committed by Aniket
parent 33b50bfa49
commit 91f8df60a3
  1. 7
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  2. 1
      apps/remix-ide/src/app/panels/file-panel.js
  3. 3
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  4. 8
      libs/remix-ui/workspace/src/lib/actions/index.ts
  5. 10
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -9,6 +9,13 @@ class WorkspaceFileProvider extends FileProvider {
this.workspacesPath = '.workspaces'
this.workspace = null
this.event = new EventManager()
try {
// make sure "code-sample" has been removed
window.remixFileSystem.unlink(this.workspacesPath + '/code-sample')
} catch (e) {
console.error(e)
}
}
setWorkspace (workspace) {

@ -180,6 +180,7 @@ module.exports = class Filepanel extends ViewPlugin {
}
saveRecent(workspaceName) {
if (workspaceName === 'code-sample') return
if (!localStorage.getItem('recentWorkspaces')) {
localStorage.setItem('recentWorkspaces', JSON.stringify([ workspaceName ]))
} else {

@ -128,5 +128,6 @@
"filePanel.movingFileFailedMsg": "Unexpected error while moving file: {src}",
"filePanel.movingFolderFailed": "Moving Folder Failed",
"filePanel.movingFolderFailedMsg": "Unexpected error while moving folder: {src}",
"filePanel.workspaceActions": "Workspace actions"
"filePanel.workspaceActions": "Workspace actions",
"filePanel.saveCodeSample": "This code sample will not be persisted. Please click here to save this code as a persisted workspace."
}

@ -55,9 +55,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
const workspaces = await getWorkspaces() || []
dispatch(setWorkspaces(workspaces))
if (params.gist) {
await createWorkspaceTemplate('gist-sample', 'gist-template')
plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false })
dispatch(setCurrentWorkspace({ name: 'gist-sample', isGitRepo: false }))
await createWorkspaceTemplate('code-sample', 'gist-template')
plugin.setWorkspace({ name: 'code-sample', isLocalhost: false })
dispatch(setCurrentWorkspace({ name: 'code-sample', isGitRepo: false }))
await loadWorkspacePreset('gist-template')
} else if (params.code || params.url) {
await createWorkspaceTemplate('code-sample', 'code-template')
@ -82,7 +82,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
{id: 5, name: 'goerli'}
]
let found = false
const workspaceName = 'etherscan-code-sample'
const workspaceName = 'code-sample'
let filePath
const foundOnNetworks = []
for (const network of networks) {

@ -1,7 +1,7 @@
import React, {useState, useEffect, useRef, useContext, ChangeEvent} from 'react' // eslint-disable-line
import {FormattedMessage, useIntl} from 'react-intl'
import {Dropdown} from 'react-bootstrap'
import {CustomIconsToggle, CustomMenu, CustomToggle, extractNameFromKey, extractParentFromKey} from '@remix-ui/helper'
import {CustomIconsToggle, CustomMenu, CustomToggle, CustomTooltip, extractNameFromKey, extractParentFromKey} from '@remix-ui/helper'
import {FileExplorer} from './components/file-explorer' // eslint-disable-line
import {FileSystemContext} from './contexts'
import './css/remix-ui-workspace.css'
@ -943,6 +943,14 @@ export function Workspace() {
<label className="pl-2 form-check-label" style={{wordBreak: 'keep-all'}}>
<FormattedMessage id='filePanel.workspace' />
</label>
{selectedWorkspace && selectedWorkspace.name === 'code-sample' && <CustomTooltip
placement="right"
tooltipId="saveCodeSample"
tooltipClasses="text-nowrap"
tooltipText={<FormattedMessage id="filePanel.saveCodeSample" />}
>
<i onClick={() => renameCurrentWorkspace()} className="far fa-exclamation-triangle text-info ml-2 mt-1" aria-hidden="true"></i>
</CustomTooltip>}
</span>
</div>
<div className='mx-2'>

Loading…
Cancel
Save