Merge branch 'master' of https://github.com/ethereum/remix-project into newFEdesktop

pull/4422/head
filip mertens 1 year ago
commit b75a90779e
  1. 24
      apps/remix-ide-e2e/src/tests/url.test.ts
  2. 7
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  3. 5
      apps/remix-ide/src/app/panels/file-panel.js
  4. 4
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  5. 8
      libs/remix-ui/workspace/src/lib/actions/index.ts
  6. 25
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -91,25 +91,12 @@ module.exports = {
})
},
'Should load Etherscan verified contracts from URL "address" param)': !function (browser: NightwatchBrowser) {
'Should load Etherscan verified contracts from URL "address" param)': function (browser: NightwatchBrowser) {
browser
.url('http://127.0.0.1:8080/#address=0x56db08fb78bc6689a1ef66efd079083fed0e4915')
.refreshPage()
.currentWorkspaceIs('etherscan-code-sample')
.assert.elementPresent('*[data-id=treeViewLitreeViewItemropsten]')
.assert.elementPresent('*[data-id=treeViewLitreeViewItemrinkeby]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemrinkeby/0x56db08fb78bc6689a1ef66efd079083fed0e4915"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemrinkeby/0x56db08fb78bc6689a1ef66efd079083fed0e4915/Sample.sol"]')
.getEditorValue((content) => {
browser.assert.ok(content && content.indexOf(
'contract Sample {') !== -1)
})
.url('http://127.0.0.1:8080/#address=0xdac17f958d2ee523a2206206994597c13d831ec7')
.refreshPage()
.pause(7000)
.currentWorkspaceIs('etherscan-code-sample')
.currentWorkspaceIs('code-sample')
.assert.elementPresent('*[data-id=treeViewLitreeViewItemmainnet]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemmainnet/0xdac17f958d2ee523a2206206994597c13d831ec7"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemmainnet/0xdac17f958d2ee523a2206206994597c13d831ec7/TetherToken.sol"]')
@ -137,6 +124,13 @@ module.exports = {
'proposals.length = _numProposals;') !== -1,
'code has been loaded')
})
.url('http://127.0.0.1:8080') // refresh without loading the code sample
.currentWorkspaceIs('default_workspace')
.execute(() => {
return document.querySelector('[data-id="dropdown-item-code-sample"]') === null
}, [], (result) => {
browser.assert.ok((result as any).value, 'sample template has not be persisted.') // code-sample should not be kept.
})
},
'Should load the code from language & code params #group1': function (browser: NightwatchBrowser) {

@ -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) {
// we don't need to log error if this throws an error
}
}
setWorkspace (workspace) {

@ -139,10 +139,10 @@ module.exports = class Filepanel extends ViewPlugin {
return this.workspaces
}
getAvailableWorkspaceName(name) {
getAvailableWorkspaceName(name) {
if (!this.workspaces) return name
let index = 1
let workspace = this.workspaces.find((workspace) => workspace.name === name + ' - ' + index)
let workspace = this.workspaces.find((workspace) => workspace.name === name + ' - ' + index)
while (workspace) {
index++
workspace = this.workspaces.find((workspace) => workspace.name === name + ' - ' + index)
@ -200,6 +200,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 {

@ -10,6 +10,7 @@
"filePanel.workspace.create": "Create Workspace",
"filePanel.workspace.create.desktop": "Create project in new folder",
"filePanel.workspace.rename": "Rename Workspace",
"filePanel.workspace.save_workspace": "Save Workspace",
"filePanel.workspace.delete": "Delete Workspace",
"filePanel.workspace.deleteConfirm": "Are you sure to delete the current workspace?",
"filePanel.workspace.download": "Download Workspace",
@ -131,5 +132,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 workspace will not be persisted. Click here to save it."
}

@ -60,9 +60,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
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')
@ -87,7 +87,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'
@ -170,6 +170,17 @@ export function Workspace() {
)
}
const saveSampleCodeWorkspace = () => {
const workspaceName = global.plugin.getAvailableWorkspaceName('code-sample')
global.modal(
intl.formatMessage({id: 'filePanel.workspace.save_workspace'}),
renameModalMessage(workspaceName),
intl.formatMessage({id: 'filePanel.ok'}),
onFinishRenameWorkspace,
intl.formatMessage({id: 'filePanel.cancel'})
)
}
const downloadCurrentWorkspace = () => {
global.modal(
intl.formatMessage({id: 'filePanel.workspace.download'}),
@ -878,10 +889,10 @@ export function Workspace() {
)
}
const renameModalMessage = () => {
const renameModalMessage = (workspaceName?: string) => {
return (
<>
<input type="text" data-id="modalDialogCustomPromptTextRename" defaultValue={currentWorkspace} ref={workspaceRenameInput} className="form-control" />
<input type="text" data-id="modalDialogCustomPromptTextRename" defaultValue={workspaceName || currentWorkspace} ref={workspaceRenameInput} className="form-control" />
</>
)
}
@ -963,6 +974,14 @@ export function Workspace() {
<ElectronWorkspaceName plugin={global.plugin} path={global.fs.browser.currentLocalFilePath} />
) : <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={() => saveSampleCodeWorkspace()} className="far fa-exclamation-triangle text-warning ml-2 align-self-center" aria-hidden="true"></i>
</CustomTooltip>}
</span>
</div>
<div className='mx-2'>

Loading…
Cancel
Save