From 981db607c6a3b9255ff487fb01e82d8ce3278723 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 26 Apr 2023 10:31:05 +0200 Subject: [PATCH 01/29] recent workspaces WIP --- apps/remix-ide/src/app/files/fileManager.ts | 6 +- apps/remix-ide/src/app/panels/file-panel.js | 19 +- .../src/app/tabs/locales/en/home.json | 1 + .../src/app/tabs/locales/zh/home.json | 1 + apps/remix-ide/src/remixAppManager.js | 6 +- .../src/lib/components/homeTabFile.tsx | 165 ++++++++++++------ .../src/lib/components/homeTabGetStarted.tsx | 22 +-- 7 files changed, 150 insertions(+), 70 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index cb4d5505af..a145a462d8 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -206,11 +206,11 @@ class FileManager extends Plugin { path = this.normalize(path) path = this.limitPluginScope(path) if (await this.exists(path)) { - await this._handleIsFile(path, `Cannot write file ${path}`) - return await this.setFileContent(path, data) + const newPath = await helper.createNonClashingNameAsync(path, this) + //await this._handleIsFile(path, `Cannot write file ${path}`) + return await this.setFileContent(newPath, data) } else { const ret = await this.setFileContent(path, data) - this.emit('fileAdded', path) return ret } } catch (e) { diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index b391daf5bd..a4336a0c2a 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -163,14 +163,31 @@ module.exports = class Filepanel extends ViewPlugin { }) } + saveRecent (workspace) { + console.log("recentWorkspaces - ", workspace) + if (!localStorage.getItem('recentWorkspaces')) { + localStorage.setItem('recentWorkspaces', JSON.stringify('"first": "", "second": "", "third": ""')) + } else { + console.log("recentWorkspaces workspace name - ", workspace.name) + + const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) + let newResents = '{"first": "' + workspace.name + '", "second":"' + recents.first + '", "third":"' + recents.second + '"}' + localStorage.setItem('recentWorkspaces', newResents) + } + } + setWorkspace (workspace) { const workspaceProvider = this.fileProviders.workspace - + const current = this.currentWorkspaceMetadata + this.currentWorkspaceMetadata = { name: workspace.name, isLocalhost: workspace.isLocalhost, absolutePath: `${workspaceProvider.workspacesPath}/${workspace.name}` } if (workspace.name !== " - connect to localhost - ") { localStorage.setItem('currentWorkspace', workspace.name) } this.emit('setWorkspace', workspace) + if (this.currentWorkspaceMetadata.name !== current) { + this.saveRecent(workspace) + } } workspaceRenamed (oldName, workspaceName) { diff --git a/apps/remix-ide/src/app/tabs/locales/en/home.json b/apps/remix-ide/src/app/tabs/locales/en/home.json index dc76b8d547..d652b3597e 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/home.json +++ b/apps/remix-ide/src/app/tabs/locales/en/home.json @@ -56,6 +56,7 @@ "home.searchDocumentation": "Search Documentation", "home.files": "Files", "home.newFile": "New File", + "home.startCoding": "Start Coding", "home.openFile": "Open File", "home.accessFileSystem": "Access File System", "home.loadFrom": "Load from", diff --git a/apps/remix-ide/src/app/tabs/locales/zh/home.json b/apps/remix-ide/src/app/tabs/locales/zh/home.json index 17ad8bb36c..9341b7894b 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/home.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/home.json @@ -54,6 +54,7 @@ "home.searchDocumentation": "搜索文档", "home.files": "文件", "home.newFile": "新建文件", + "home.startCoding": "Start Coding", "home.openFile": "打开本地文件", "home.connectToLocalhost": "连接本地主机", "home.loadFrom": "从以下来源导入", diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 8f31a868bc..b90344fdce 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -5,8 +5,7 @@ import {IframePlugin} from '@remixproject/engine-web' const _paq = (window._paq = window._paq || []) // requiredModule removes the plugin from the plugin manager list on UI -const requiredModules = [ - // services + layout views + system views +const requiredModules = [ // services + layout views + system views 'manager', 'config', 'compilerArtefacts', @@ -73,7 +72,8 @@ const requiredModules = [ 'solidityumlgen', 'contractflattener', 'solidity-script', - 'openaigpt' + 'openaigpt', + 'home' ] // dependentModules shouldn't be manually activated (e.g hardhat is activated by remixd) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 3f187e57d5..fdcba77dee 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import React, {useState, useRef, useReducer} from 'react' +import React, {useState, useRef, useReducer, useEffect} from 'react' import {FormattedMessage} from 'react-intl' import {ModalDialog} from '@remix-ui/modal-dialog' // eslint-disable-line import {Toaster} from '@remix-ui/toaster' // eslint-disable-line -const _paq = (window._paq = window._paq || []) // eslint-disable-line -import {CustomTooltip} from '@remix-ui/helper' +const _paq = window._paq = window._paq || [] // eslint-disable-line +import {CustomTooltip} from '@remix-ui/helper'; -interface HomeTabFileProps { +interface HomeTabFileProps { plugin: any } @@ -27,28 +27,50 @@ const loadingReducer = (state = loadingInitialState, action) => { function HomeTabFile({plugin}: HomeTabFileProps) { const [state, setState] = useState<{ - searchInput: string - showModalDialog: boolean + searchInput: string, + showModalDialog: boolean, modalInfo: { - title: string - loadItem: string - examples: Array + title: string, + loadItem: string, + examples: Array, prefix?: string + }, + importSource: string, + toasterMsg: string, + recentWorkspaces: { + first: string, + second: string, + third: string } - importSource: string - toasterMsg: string }>({ searchInput: '', showModalDialog: false, modalInfo: {title: '', loadItem: '', examples: [], prefix: ''}, importSource: '', - toasterMsg: '' + toasterMsg: '', + recentWorkspaces: {first: '', second: '', third: ''} }) const [, dispatch] = useReducer(loadingReducer, loadingInitialState) const inputValue = useRef(null) + useEffect(() => { + console.log("useEffHomeFile") + plugin.on('filePanel', 'setWorkspace', async () => { + let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) + console.log("useEffHomeFilerecents ", recents) + + if (!recents) recents = {first:'', second: '', third: ''} + setState(prevState => { + return { ...prevState, recentWorkspaces: { first: recents.first, second: recents.second, third: recents.third } } + }) + }) + return () => { + plugin.off('filePanel', 'setWorkspace') + } + }, []) + const processLoading = (type: string) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type]) const contentImport = plugin.contentImport @@ -90,10 +112,18 @@ function HomeTabFile({plugin}: HomeTabFileProps) { }) } - const createNewFile = async () => { - _paq.push(['trackEvent', 'hometab', 'filesSection', 'createNewFile']) + const startCoding = async () => { + _paq.push(['trackEvent', 'hometab', 'filesSection', 'startCoding']) plugin.verticalIcons.select('filePanel') - await plugin.call('filePanel', 'createNewFile') + const content = ` + // SPDX-License-Identifier: MIT + pragma solidity >=0.7.0 <0.9.0; + + contract helloWorld { + } + ` + await plugin.call('fileManager', 'writeFile', '/helloWorld.sol', content) + await plugin.call('fileManager', 'open', '/helloWorld.sol') } const uploadFile = async (target) => { @@ -133,11 +163,16 @@ function HomeTabFile({plugin}: HomeTabFileProps) { }) } + const handleSwichToRecentWorkspace = async (e, workspaceName) => { + e.preventDefault(); + await plugin.call('filePanel', 'setWorkspace', { name: workspaceName, isLocalhost: false }) + console.log('The link was clicked.'); + } + const examples = state.modalInfo.examples.map((urlEl, key) => (
{urlEl} -
- )) + )) return ( <> @@ -178,42 +213,68 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
- -
- - - { - event.stopPropagation() - plugin.verticalIcons.select('filePanel') - uploadFile(event.target) - }} - multiple - /> - } - tooltipTextClasses="border bg-light text-dark p-1 pr-3" - > - - + +
+
+ + } + tooltipTextClasses="border bg-light text-dark p-1 pr-3" + > + + + { + event.stopPropagation() + plugin.verticalIcons.select('filePanel') + uploadFile(event.target) + }} + multiple + /> + + + + } + tooltipTextClasses="border bg-light text-dark p-1 pr-3" + > + + +
+
- +
+ { !(state.recentWorkspaces.first == '' && + state.recentWorkspaces.second == '' && + state.recentWorkspaces.third == '') && + } +
}
From 02b76ad5007605cd2613af51b5e5def845c21652 Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 25 May 2023 15:04:06 +0200 Subject: [PATCH 06/29] e2e, buttons style fix --- apps/remix-ide-e2e/src/tests/homeTab.test.ts | 9 +++---- apps/remix-ide/src/app/panels/file-panel.js | 2 +- .../src/lib/components/homeTabFile.tsx | 24 ++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/homeTab.test.ts b/apps/remix-ide-e2e/src/tests/homeTab.test.ts index 81f78be22a..af0c77e7f5 100644 --- a/apps/remix-ide-e2e/src/tests/homeTab.test.ts +++ b/apps/remix-ide-e2e/src/tests/homeTab.test.ts @@ -10,11 +10,8 @@ module.exports = { 'Should create new file': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[data-id="homeTabNewFile"]') - .click('*[data-id="homeTabNewFile"]') - .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) - .sendKeys('*[data-id$="/blank"] .remixui_items', 'newTestFile') - .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) - .waitForElementVisible('li[data-id="treeViewLitreeViewItemnewTestFile.sol"]') + .waitForElementVisible('*[data-id="homeTabStartCoding"]') + .click('*[data-id="homeTabStartCoding"]') + .waitForElementVisible('li[data-path="contracts/helloWorld.sol"]') } } \ No newline at end of file diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 259aaf1017..528f291e37 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -104,7 +104,7 @@ module.exports = class Filepanel extends ViewPlugin { } getAvailableWorkspaceName (name) { - if(!this.workspaces) return name + if (!this.workspaces) return name let index = 1 let workspace = this.workspaces.find(workspace => workspace.name === name + ' - ' + index) while (workspace) { diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 59f5165257..d9419174fc 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -173,12 +173,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const handleSwichToRecentWorkspace = async (e, workspaceName) => { e.preventDefault(); -<<<<<<< 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 } const examples = state.modalInfo.examples.map((urlEl, key) => ( @@ -208,26 +203,15 @@ function HomeTabFile({plugin}: HomeTabFileProps) { {state.modalInfo.prefix && ipfs://} >>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace className="w-100 mt-1 form-control" data-id="homeTabModalDialogCustomPromptText" value={state.importSource} onInput={(e) => { -<<<<<<< HEAD - setState((prevState) => { - return {...prevState, importSource: inputValue.current.value} -======= setState(prevState => { return { ...prevState, importSource: inputValue.current.value } ->>>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace }) }} /> @@ -240,6 +224,12 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
+ + { + event.stopPropagation() + plugin.verticalIcons.select('filePanel') + uploadFile(event.target) + }} multiple /> } tooltipTextClasses="border bg-light text-dark p-1 pr-3" > - From bd81116ed365dd585b2fb8abef8ba84c8b289acf Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 31 May 2023 22:04:37 +0200 Subject: [PATCH 07/29] fix vreating workspace --- apps/remix-ide/src/app/panels/file-panel.js | 2 +- .../src/lib/components/homeTabFile.tsx | 33 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 528f291e37..b90fb73760 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -165,7 +165,7 @@ module.exports = class Filepanel extends ViewPlugin { saveRecent (workspace) { if (!localStorage.getItem('recentWorkspaces')) { - localStorage.setItem('recentWorkspaces', JSON.stringify('"first": "", "second": "", "third": ""')) + localStorage.setItem('recentWorkspaces', JSON.stringify(workspace)) } else { const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) if (recents.first !== workspace.name && recents.second !== workspace.name && recents.third !== workspace.name) { diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index d9419174fc..55d8223886 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -115,21 +115,22 @@ function HomeTabFile({plugin}: HomeTabFileProps) { _paq.push(['trackEvent', 'hometab', 'filesSection', 'startCoding']) plugin.verticalIcons.select('filePanel') - const wName = 'Coding playground' + const wName = 'Playground' const workspaces = await plugin.call('filePanel', 'getWorkspaces') if (!workspaces.find(workspace => workspace.name === wName)) { await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') + await plugin.call('filePanel', 'setWorkspace', wName) + } else { + 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 - const content = ` - // SPDX-License-Identifier: MIT - pragma solidity >=0.7.0 <0.9.0; + const content = `// SPDX-License-Identifier: MIT +pragma solidity >=0.7.0 <0.9.0; + +contract helloWorld { +} +` - contract helloWorld { - } - ` const {newContent, newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) } @@ -173,7 +174,20 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const handleSwichToRecentWorkspace = async (e, workspaceName) => { 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 }) +>>>>>>> 06483cab7... fix vreating workspace +>>>>>>> 1b238a875... fix vreating workspace } const examples = state.modalInfo.examples.map((urlEl, key) => ( @@ -255,7 +269,6 @@ function HomeTabFile({plugin}: HomeTabFileProps) { /> - Date: Thu, 1 Jun 2023 08:51:46 +0200 Subject: [PATCH 08/29] fix json structure --- apps/remix-ide/src/app/panels/file-panel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index b90fb73760..6057665998 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -165,11 +165,11 @@ module.exports = class Filepanel extends ViewPlugin { saveRecent (workspace) { if (!localStorage.getItem('recentWorkspaces')) { - localStorage.setItem('recentWorkspaces', JSON.stringify(workspace)) + localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspace, second:'', third:''})) } else { const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) if (recents.first !== workspace.name && recents.second !== workspace.name && recents.third !== workspace.name) { - let newResents = '{"first": "' + workspace.name + '", "second":"' + recents.first + '", "third":"' + recents.second + '"}' + let newResents = {first: workspace.name, second: recents.first, third: recents.second} localStorage.setItem('recentWorkspaces', newResents) } } From 4a13b36e4841c387d74c3bced0e60ce092ff1472 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 5 Jun 2023 10:11:34 +0200 Subject: [PATCH 09/29] fixed switch to workspace --- .../src/lib/components/homeTabFile.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 55d8223886..3c42debe4e 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -119,22 +119,20 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const workspaces = await plugin.call('filePanel', 'getWorkspaces') if (!workspaces.find(workspace => workspace.name === wName)) { await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') - await plugin.call('filePanel', 'setWorkspace', wName) - } else { - 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 - const content = `// SPDX-License-Identifier: MIT -pragma solidity >=0.7.0 <0.9.0; + const content = ` + // SPDX-License-Identifier: MIT + pragma solidity >=0.7.0 <0.9.0; -contract helloWorld { -} -` - - const {newContent, newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + contract helloWorld { + } + ` + const {newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) } - const uploadFile = async (target) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'uploadFile']) await plugin.call('filePanel', 'uploadFile', target) From a6bab6744794e3e7ddfdc2bc32eb6914f7b0e26d Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 5 Jun 2023 10:48:53 +0200 Subject: [PATCH 10/29] fixed recentWorkpaces in localstorage for json format --- apps/remix-ide/src/app/panels/file-panel.js | 2 +- .../home-tab/src/lib/components/homeTabFile.tsx | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 6057665998..2dce01fd78 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -169,7 +169,7 @@ module.exports = class Filepanel extends ViewPlugin { } else { const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) if (recents.first !== workspace.name && recents.second !== workspace.name && recents.third !== workspace.name) { - let newResents = {first: workspace.name, second: recents.first, third: recents.second} + let newResents = JSON.stringify({first: workspace.name, second: recents.first, third: recents.second}) localStorage.setItem('recentWorkspaces', newResents) } } diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 3c42debe4e..108632e5b4 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -123,14 +123,12 @@ function HomeTabFile({plugin}: HomeTabFileProps) { await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // don't ask why - const content = ` - // SPDX-License-Identifier: MIT - pragma solidity >=0.7.0 <0.9.0; - - contract helloWorld { - } - ` - const {newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + const content = `// SPDX-License-Identifier: MIT + pragma solidity >=0.7.0 <0.9.0; + contract helloWorld { + } + ` + const {newContent, newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) } const uploadFile = async (target) => { From 2133b314533f9b5b85bbf46eaef3c0370112cb0d Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 6 Jun 2023 09:52:35 +0200 Subject: [PATCH 11/29] fixing save workspace --- apps/remix-ide/src/app/panels/file-panel.js | 10 +++++----- .../home-tab/src/lib/components/homeTabFile.tsx | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 2dce01fd78..fefbf92ad9 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -163,13 +163,13 @@ module.exports = class Filepanel extends ViewPlugin { }) } - saveRecent (workspace) { + saveRecent (workspaceName) { if (!localStorage.getItem('recentWorkspaces')) { - localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspace, second:'', third:''})) + localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspaceName, second:'', third:''})) } else { const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) - if (recents.first !== workspace.name && recents.second !== workspace.name && recents.third !== workspace.name) { - let newResents = JSON.stringify({first: workspace.name, second: recents.first, third: recents.second}) + if (recents.first !== workspaceName && recents.second !== workspaceName && recents.third !== workspaceName) { + let newResents = JSON.stringify({first: workspaceName, second: recents.first, third: recents.second}) localStorage.setItem('recentWorkspaces', newResents) } } @@ -183,7 +183,7 @@ module.exports = class Filepanel extends ViewPlugin { localStorage.setItem('currentWorkspace', workspace.name) } if (this.currentWorkspaceMetadata.name !== current) { - this.saveRecent(workspace) + this.saveRecent(workspace.name) } this.emit('setWorkspace', workspace) } diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 108632e5b4..01d4719f11 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -125,10 +125,14 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const content = `// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; + contract helloWorld { + function print() public pure returns (string memory) { + return "Hello World!"; + } } ` - const {newContent, newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + const {newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) } const uploadFile = async (target) => { From 8d6a2b2e2cf06837a322174c8886a96a66b205db Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 6 Jun 2023 12:12:53 +0200 Subject: [PATCH 12/29] e2e fix --- apps/remix-ide-e2e/src/tests/homeTab.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/homeTab.test.ts b/apps/remix-ide-e2e/src/tests/homeTab.test.ts index af0c77e7f5..9d4fa20bf4 100644 --- a/apps/remix-ide-e2e/src/tests/homeTab.test.ts +++ b/apps/remix-ide-e2e/src/tests/homeTab.test.ts @@ -12,6 +12,6 @@ module.exports = { browser .waitForElementVisible('*[data-id="homeTabStartCoding"]') .click('*[data-id="homeTabStartCoding"]') - .waitForElementVisible('li[data-path="contracts/helloWorld.sol"]') + .waitForElementVisible('div[data-id="treeViewDivtreeViewItemcontracts/helloWorld.sol"]') } } \ No newline at end of file From 05a8b13fffde0ed942b1b3404886a07e97c1e572 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 7 Jun 2023 11:46:31 +0200 Subject: [PATCH 13/29] capitalizing contract name --- apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts | 4 ++-- libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts index 1b382a4290..b602f8e1e0 100644 --- a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts +++ b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts @@ -235,7 +235,7 @@ const sources = [ content: ` pragma solidity ^0.8.0; - contract helloWorld { + contract HelloWorld { string public message; fallback () external { @@ -249,7 +249,7 @@ const sources = [ }, 'checkBalance.sol': { content: `pragma solidity ^0.8.0; - contract checkBalance { + contract CheckBalance { constructor () payable {} function sendSomeEther(uint256 num) public { diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 01d4719f11..7491a00167 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -126,7 +126,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const content = `// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; - contract helloWorld { + contract HelloWorld { function print() public pure returns (string memory) { return "Hello World!"; } From 87610597461a52974ac35ce9959260d9f8247ffd Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Jun 2023 10:52:07 +0200 Subject: [PATCH 14/29] Delete workspace --- apps/remix-ide/src/app/panels/file-panel.js | 6 +-- .../src/lib/components/homeTabFile.tsx | 39 ++++++++++++------- .../workspace/src/lib/remix-ui-workspace.tsx | 6 +-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index fefbf92ad9..38f5e1da6c 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -179,12 +179,12 @@ module.exports = class Filepanel extends ViewPlugin { const workspaceProvider = this.fileProviders.workspace const current = this.currentWorkspaceMetadata 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) { this.saveRecent(workspace.name) } + if (workspace.name !== " - connect to localhost - ") { + localStorage.setItem('currentWorkspace', workspace.name) + } this.emit('setWorkspace', workspace) } diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 7491a00167..21de735878 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -65,10 +65,32 @@ function HomeTabFile({plugin}: HomeTabFileProps) { 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 () => { plugin.off('filePanel', 'setWorkspace') + plugin.off('filePanel', 'workspaceDeleted') } - }, []) + }, [state.recentWorkspaces]) const processLoading = (type: string) => { _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', '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 pragma solidity >=0.7.0 <0.9.0; @@ -174,20 +196,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const handleSwichToRecentWorkspace = async (e, workspaceName) => { 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 }) ->>>>>>> 06483cab7... fix vreating workspace ->>>>>>> 1b238a875... fix vreating workspace } const examples = state.modalInfo.examples.map((urlEl, key) => ( diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index e19799971d..6e6fef7373 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -899,10 +899,10 @@ export function Workspace() { ) : null} - +
From 9fa1955c79e157419350f1954b4a7e509f292cef Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 29 Jun 2023 16:08:22 +0200 Subject: [PATCH 15/29] indent --- libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 21de735878..706c6df5da 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -293,7 +293,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { { !(state.recentWorkspaces.first == '' && state.recentWorkspaces.second == '' && state.recentWorkspaces.third == '') && -
+
{(state.recentWorkspaces.first !== 'undefined' && state.recentWorkspaces.first !== '') && handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}>{state.recentWorkspaces.third} } -
} +
+ }
From 12b42cd765caac3e264d4883061b2ddb1f65672c Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 4 Sep 2023 17:20:41 +0200 Subject: [PATCH 16/29] fixing rename workspace --- apps/remix-ide/src/app/panels/file-panel.js | 81 ++- .../src/lib/components/homeTabFile.tsx | 172 +++--- .../workspace/src/lib/actions/workspace.ts | 515 ++++++++++-------- .../remix-ui/workspace/src/lib/types/index.ts | 303 ++++++----- 4 files changed, 605 insertions(+), 466 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 38f5e1da6c..951497c1f0 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -30,7 +30,19 @@ const { SlitherHandle } = require('../files/slither-handle.js') const profile = { name: 'filePanel', displayName: 'File explorer', - methods: ['createNewFile', 'uploadFile', 'getCurrentWorkspace', 'getAvailableWorkspaceName', 'getWorkspaces', 'createWorkspace', 'switchToWorkspace', 'setWorkspace', 'registerContextMenuItem', 'renameWorkspace', 'deleteWorkspace'], + methods: [ + 'createNewFile', + 'uploadFile', + 'getCurrentWorkspace', + 'getAvailableWorkspaceName', + 'getWorkspaces', + 'createWorkspace', + 'switchToWorkspace', + 'setWorkspace', + 'registerContextMenuItem', + 'renameWorkspace', + 'deleteWorkspace', + ], events: ['setWorkspace', 'workspaceRenamed', 'workspaceDeleted', 'workspaceCreated'], icon: 'assets/img/fileManager.webp', description: 'Remix IDE file explorer', @@ -38,10 +50,10 @@ const profile = { location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/file_explorer.html', version: packageJson.version, - maintainedBy: 'Remix' + maintainedBy: 'Remix', } module.exports = class Filepanel extends ViewPlugin { - constructor (appManager) { + constructor(appManager) { super(profile) this.registry = Registry.getInstance() this.fileProviders = this.registry.get('fileproviders').api @@ -60,13 +72,17 @@ module.exports = class Filepanel extends ViewPlugin { this.currentWorkspaceMetadata = null } - render () { - return
+ render() { + return ( +
+ +
+ ) } /** * @param item { id: string, name: string, type?: string[], path?: string[], extension?: string[], pattern?: string[] } - * typically: + * typically: * group 0 for file manipulations * group 1 for download operations * group 2 for running operations (script for instance) @@ -77,7 +93,7 @@ module.exports = class Filepanel extends ViewPlugin { * group 7 for generating resource files (UML, documentation, ...) * @param callback (...args) => void */ - registerContextMenuItem (item) { + registerContextMenuItem(item) { return new Promise((resolve, reject) => { this.emit('registerContextMenuItemReducerEvent', item, (err, data) => { if (err) reject(err) @@ -86,7 +102,7 @@ module.exports = class Filepanel extends ViewPlugin { }) } - removePluginActions (plugin) { + removePluginActions(plugin) { return new Promise((resolve, reject) => { this.emit('removePluginActionsReducerEvent', plugin, (err, data) => { if (err) reject(err) @@ -95,30 +111,30 @@ module.exports = class Filepanel extends ViewPlugin { }) } - getCurrentWorkspace () { + getCurrentWorkspace() { return this.currentWorkspaceMetadata } - getWorkspaces () { + getWorkspaces() { 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) + workspace = this.workspaces.find((workspace) => workspace.name === name + ' - ' + index) } return name + ' - ' + index } - setWorkspaces (workspaces) { + setWorkspaces(workspaces) { this.workspaces = workspaces } - createNewFile () { + createNewFile() { return new Promise((resolve, reject) => { this.emit('createNewFileInputReducerEvent', '/', (err, data) => { if (err) reject(err) @@ -127,7 +143,7 @@ module.exports = class Filepanel extends ViewPlugin { }) } - uploadFile (target) { + uploadFile(target) { return new Promise((resolve, reject) => { return this.emit('uploadFileReducerEvent', '/', target, (err, data) => { if (err) reject(err) @@ -136,7 +152,7 @@ module.exports = class Filepanel extends ViewPlugin { }) } - createWorkspace (workspaceName, workspaceTemplateName, isEmpty) { + createWorkspace(workspaceName, workspaceTemplateName, isEmpty) { return new Promise((resolve, reject) => { this.emit('createWorkspaceReducerEvent', workspaceName, workspaceTemplateName, isEmpty, (err, data) => { if (err) reject(err) @@ -145,7 +161,7 @@ module.exports = class Filepanel extends ViewPlugin { }) } - renameWorkspace (oldName, workspaceName) { + renameWorkspace(oldName, workspaceName) { return new Promise((resolve, reject) => { this.emit('renameWorkspaceReducerEvent', oldName, workspaceName, (err, data) => { if (err) reject(err) @@ -154,7 +170,7 @@ module.exports = class Filepanel extends ViewPlugin { }) } - deleteWorkspace (workspaceName) { + deleteWorkspace(workspaceName) { return new Promise((resolve, reject) => { this.emit('deleteWorkspaceReducerEvent', workspaceName, (err, data) => { if (err) reject(err) @@ -163,26 +179,35 @@ module.exports = class Filepanel extends ViewPlugin { }) } - saveRecent (workspaceName) { + saveRecent(workspaceName) { if (!localStorage.getItem('recentWorkspaces')) { - localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspaceName, second:'', third:''})) + localStorage.setItem('recentWorkspaces', JSON.stringify({ first: workspaceName, second: '', third: '' })) } else { const recents = JSON.parse(localStorage.getItem('recentWorkspaces')) + // checking if we have a duplication if (recents.first !== workspaceName && recents.second !== workspaceName && recents.third !== workspaceName) { - let newResents = JSON.stringify({first: workspaceName, second: recents.first, third: recents.second}) + // filtering removed records + const firstW = workspaceName + const secondW = recents.first != '' ? recents.first : recents.second != '' ? recents.second : recents.third + const thirdW = recents.second != '' ? recents.second : recents.third + const newResents = JSON.stringify({ first: firstW, second: secondW, third: thirdW }) localStorage.setItem('recentWorkspaces', newResents) } } } - setWorkspace (workspace) { + setWorkspace(workspace) { const workspaceProvider = this.fileProviders.workspace 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 (this.currentWorkspaceMetadata.name !== current) { this.saveRecent(workspace.name) } - if (workspace.name !== " - connect to localhost - ") { + if (workspace.name !== ' - connect to localhost - ') { localStorage.setItem('currentWorkspace', workspace.name) } this.emit('setWorkspace', workspace) @@ -192,15 +217,15 @@ module.exports = class Filepanel extends ViewPlugin { this.emit('switchToWorkspace', workspaceName) } - workspaceRenamed (oldName, workspaceName) { + workspaceRenamed(oldName, workspaceName) { this.emit('workspaceRenamed', oldName, workspaceName) } - workspaceDeleted (workspace) { + workspaceDeleted(workspace) { this.emit('workspaceDeleted', workspace) } - workspaceCreated (workspace) { + workspaceCreated(workspace) { this.emit('workspaceCreated', workspace) } /** end section */ diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 706c6df5da..d450cf95fe 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -1,20 +1,20 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import React, {useState, useRef, useReducer, useEffect} from 'react' -import {FormattedMessage} from 'react-intl' -import {ModalDialog} from '@remix-ui/modal-dialog' // eslint-disable-line -import {Toaster} from '@remix-ui/toaster' // eslint-disable-line -const _paq = window._paq = window._paq || [] // eslint-disable-line -import {CustomTooltip} from '@remix-ui/helper'; -import {TEMPLATE_NAMES} from '@remix-ui/workspace' +import React, { useState, useRef, useReducer, useEffect } from 'react' +import { FormattedMessage } from 'react-intl' +import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line +import { Toaster } from '@remix-ui/toaster' // eslint-disable-line +const _paq = (window._paq = window._paq || []) // eslint-disable-line +import { CustomTooltip } from '@remix-ui/helper' +import { TEMPLATE_NAMES } from '@remix-ui/workspace' -interface HomeTabFileProps { +interface HomeTabFileProps { plugin: any } const loadingInitialState = { tooltip: '', showModalDialog: false, - importSource: '' + importSource: '', } const loadingReducer = (state = loadingInitialState, action) => { @@ -22,34 +22,34 @@ const loadingReducer = (state = loadingInitialState, action) => { ...state, tooltip: action.tooltip, showModalDialog: false, - importSource: '' + importSource: '', } } -function HomeTabFile({plugin}: HomeTabFileProps) { +function HomeTabFile({ plugin }: HomeTabFileProps) { const [state, setState] = useState<{ - searchInput: string, - showModalDialog: boolean, + searchInput: string + showModalDialog: boolean modalInfo: { - title: string, - loadItem: string, - examples: Array, + title: string + loadItem: string + examples: Array prefix?: string - }, - importSource: string, - toasterMsg: string, + } + importSource: string + toasterMsg: string recentWorkspaces: { - first: string, - second: string, + first: string + second: string third: string } }>({ searchInput: '', showModalDialog: false, - modalInfo: {title: '', loadItem: '', examples: [], prefix: ''}, + modalInfo: { title: '', loadItem: '', examples: [], prefix: '' }, importSource: '', toasterMsg: '', - recentWorkspaces: {first: '', second: '', third: ''} + recentWorkspaces: { first: '', second: '', third: '' }, }) const [, dispatch] = useReducer(loadingReducer, loadingInitialState) @@ -60,37 +60,36 @@ function HomeTabFile({plugin}: HomeTabFileProps) { plugin.on('filePanel', 'setWorkspace', async () => { let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) - if (!recents) recents = {first:'', second: '', third: ''} - setState(prevState => { + if (!recents) recents = { first: '', second: '', third: '' } + setState((prevState) => { return { ...prevState, recentWorkspaces: { first: recents.first, second: recents.second, third: recents.third } } }) }) - const updateWorkspaceName = (name, newName = '') => { + const deleteSavedWorkspace = (name) => { + console.log('deleted ', name) let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) const newRecents = recents if (!recents) { - recents = {first:'', second: '', third: ''} + recents = { first: '', second: '', third: '' } } else { - Object.keys(recents).map(key => { - if (recents[key] === name) newRecents[key] = newName + Object.keys(recents).map((key) => { + if (recents[key] === name) newRecents[key] = '' }) + localStorage.setItem('recentWorkspaces', JSON.stringify(newRecents)) } - setState(prevState => { + 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) + deleteSavedWorkspace(deletedName) }) return () => { plugin.off('filePanel', 'setWorkspace') plugin.off('filePanel', 'workspaceDeleted') } - }, [state.recentWorkspaces]) + }, [plugin]) const processLoading = (type: string) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type]) @@ -100,12 +99,12 @@ function HomeTabFile({plugin}: HomeTabFileProps) { if ((type === 'ipfs' || type === 'IPFS') && startsWith !== 'ipfs' && startsWith !== 'IPFS') { setState((prevState) => { - return {...prevState, importSource: startsWith + state.importSource} + return { ...prevState, importSource: startsWith + state.importSource } }) } contentImport.import( state.modalInfo.prefix + state.importSource, - (loadingMsg) => dispatch({tooltip: loadingMsg}), + (loadingMsg) => dispatch({ tooltip: loadingMsg }), async (error, content, cleanUrl, type, url) => { if (error) { toast(error.message || error) @@ -123,13 +122,13 @@ function HomeTabFile({plugin}: HomeTabFileProps) { } ) setState((prevState) => { - return {...prevState, showModalDialog: false, importSource: ''} + return { ...prevState, showModalDialog: false, importSource: '' } }) } const toast = (message: string) => { setState((prevState) => { - return {...prevState, toasterMsg: message} + return { ...prevState, toasterMsg: message } }) } @@ -139,7 +138,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const wName = 'Playground' const workspaces = await plugin.call('filePanel', 'getWorkspaces') - if (!workspaces.find(workspace => workspace.name === wName)) { + if (!workspaces.find((workspace) => workspace.name === wName)) { await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') } await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) @@ -154,7 +153,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { } } ` - const {newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) } const uploadFile = async (target) => { @@ -181,8 +180,8 @@ function HomeTabFile({plugin}: HomeTabFileProps) { title: title, loadItem: loadItem, examples: examples, - prefix - } + prefix, + }, } }) } @@ -190,19 +189,20 @@ function HomeTabFile({plugin}: HomeTabFileProps) { const hideFullMessage = () => { //eslint-disable-line setState((prevState) => { - return {...prevState, showModalDialog: false, importSource: ''} + return { ...prevState, showModalDialog: false, importSource: '' } }) } const handleSwichToRecentWorkspace = async (e, workspaceName) => { - e.preventDefault(); + e.preventDefault() await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) } const examples = state.modalInfo.examples.map((urlEl, key) => ( )) +
+ )) return ( <> @@ -233,7 +233,7 @@ function HomeTabFile({plugin}: HomeTabFileProps) { data-id="homeTabModalDialogCustomPromptText" value={state.importSource} onInput={(e) => { - setState(prevState => { + setState((prevState) => { return { ...prevState, importSource: inputValue.current.value } }) }} @@ -243,16 +243,28 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
- +
-
- - - { - event.stopPropagation() - plugin.verticalIcons.select('filePanel') - uploadFile(event.target) - }} multiple /> +
+ + + { + event.stopPropagation() + plugin.verticalIcons.select('filePanel') + uploadFile(event.target) + }} + multiple + />
- { !(state.recentWorkspaces.first == '' && - state.recentWorkspaces.second == '' && - state.recentWorkspaces.third == '') && -
- - {(state.recentWorkspaces.first !== 'undefined' && state.recentWorkspaces.first !== '') && handleSwichToRecentWorkspace(e, state.recentWorkspaces.first)}>{state.recentWorkspaces.first} - } - {(state.recentWorkspaces.second !== 'undefined' && state.recentWorkspaces.second !== '') && handleSwichToRecentWorkspace(e, state.recentWorkspaces.second)}>{state.recentWorkspaces.second} - } - {(state.recentWorkspaces.third !== 'undefined' && state.recentWorkspaces.third !== '') && handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}>{state.recentWorkspaces.third} - } + {!(state.recentWorkspaces.first == '' && state.recentWorkspaces.second == '' && state.recentWorkspaces.third == '') && ( +
+ + {state.recentWorkspaces.first !== 'undefined' && state.recentWorkspaces.first !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces.first)}> + {state.recentWorkspaces.first} + + )} + {state.recentWorkspaces.second !== 'undefined' && state.recentWorkspaces.second !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces.second)}> + {state.recentWorkspaces.second} + + )} + {state.recentWorkspaces.third !== 'undefined' && state.recentWorkspaces.third !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}> + {state.recentWorkspaces.third} + + )}
- } + )}
- +
- {!(state.recentWorkspaces.first == '' && state.recentWorkspaces.second == '' && state.recentWorkspaces.third == '') && ( + {(state.recentWorkspaces[0] || state.recentWorkspaces[1] || state.recentWorkspaces[2]) && (
- {state.recentWorkspaces.first !== 'undefined' && state.recentWorkspaces.first !== '' && ( - handleSwichToRecentWorkspace(e, state.recentWorkspaces.first)}> - {state.recentWorkspaces.first} + {state.recentWorkspaces[0] && state.recentWorkspaces[0] !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces[0])}> + {state.recentWorkspaces[0]} )} - {state.recentWorkspaces.second !== 'undefined' && state.recentWorkspaces.second !== '' && ( - handleSwichToRecentWorkspace(e, state.recentWorkspaces.second)}> - {state.recentWorkspaces.second} + {state.recentWorkspaces[1] && state.recentWorkspaces[1] !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces[1])}> + {state.recentWorkspaces[1]} )} - {state.recentWorkspaces.third !== 'undefined' && state.recentWorkspaces.third !== '' && ( - handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}> - {state.recentWorkspaces.third} + {state.recentWorkspaces[2] && state.recentWorkspaces[2] !== '' && ( + handleSwichToRecentWorkspace(e, state.recentWorkspaces[2])}> + {state.recentWorkspaces[2]} )}
diff --git a/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx b/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx index 9c7e4d60c2..3dfcd6587d 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx @@ -265,7 +265,7 @@ function LocalPluginForm({closeModal, visible, pluginManager}: LocalPluginFormPr checked={location === 'sidePanel'} onChange={(e) => setLocation(e.target.value as 'sidePanel' | 'mainPanel' | 'none')} /> -
@@ -280,7 +280,7 @@ function LocalPluginForm({closeModal, visible, pluginManager}: LocalPluginFormPr checked={location === 'mainPanel'} onChange={(e) => setLocation(e.target.value as 'sidePanel' | 'mainPanel' | 'none')} /> -
@@ -295,7 +295,7 @@ function LocalPluginForm({closeModal, visible, pluginManager}: LocalPluginFormPr checked={location === 'none'} onChange={(e) => setLocation(e.target.value as 'sidePanel' | 'mainPanel' | 'none')} /> -
diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index c9e445cd90..cf2613bfb2 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -650,7 +650,6 @@ export const getGitRepoCurrentBranch = async (workspaceName: string) => { } export const showAllBranches = async () => { - console.log('showAllBranches') const isActive = await plugin.call('manager', 'isActive', 'dgit') if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') plugin.call('menuicons', 'select', 'dgit') diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 6e6fef7373..5d04139e0b 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -899,7 +899,7 @@ export function Workspace() { ) : null} - From 0971e3b6911ff26151a5adba7e37d6d28bda2984 Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 21 Sep 2023 11:19:19 +0200 Subject: [PATCH 18/29] adding tooltips to home buttons --- .../src/app/tabs/locales/en/home.json | 2 + .../src/app/tabs/locales/es/home.json | 1 + .../src/app/tabs/locales/fr/home.json | 1 + .../src/app/tabs/locales/zh/home.json | 2 + .../src/lib/components/homeTabFile.tsx | 47 ++++++++----------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/home.json b/apps/remix-ide/src/app/tabs/locales/en/home.json index d652b3597e..9c4045eae2 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/home.json +++ b/apps/remix-ide/src/app/tabs/locales/en/home.json @@ -57,7 +57,9 @@ "home.files": "Files", "home.newFile": "New File", "home.startCoding": "Start Coding", + "home.startCodingPlayground": "Open a playground for prototyping and simply learning", "home.openFile": "Open File", + "home.openFileTooltip": "Open a File from you File System", "home.accessFileSystem": "Access File System", "home.loadFrom": "Load from", "home.resources": "Resources", diff --git a/apps/remix-ide/src/app/tabs/locales/es/home.json b/apps/remix-ide/src/app/tabs/locales/es/home.json index 802d22bef4..62b3d68e6c 100644 --- a/apps/remix-ide/src/app/tabs/locales/es/home.json +++ b/apps/remix-ide/src/app/tabs/locales/es/home.json @@ -55,6 +55,7 @@ "home.files": "Files", "home.newFile": "New File", "home.openFile": "Open File", + "home.openFileTooltip": "Open a File from you File System", "home.connectToLocalhost": "Access File System", "home.loadFrom": "Load from", "home.resources": "Resources" diff --git a/apps/remix-ide/src/app/tabs/locales/fr/home.json b/apps/remix-ide/src/app/tabs/locales/fr/home.json index 802d22bef4..62b3d68e6c 100644 --- a/apps/remix-ide/src/app/tabs/locales/fr/home.json +++ b/apps/remix-ide/src/app/tabs/locales/fr/home.json @@ -55,6 +55,7 @@ "home.files": "Files", "home.newFile": "New File", "home.openFile": "Open File", + "home.openFileTooltip": "Open a File from you File System", "home.connectToLocalhost": "Access File System", "home.loadFrom": "Load from", "home.resources": "Resources" diff --git a/apps/remix-ide/src/app/tabs/locales/zh/home.json b/apps/remix-ide/src/app/tabs/locales/zh/home.json index 9341b7894b..369db761b4 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/home.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/home.json @@ -55,7 +55,9 @@ "home.files": "文件", "home.newFile": "新建文件", "home.startCoding": "Start Coding", + "home.startCodingPlayground": "Open a playground for prototyping and simply learning", "home.openFile": "打开本地文件", + "home.openFileTooltip": "Open a File from you File System", "home.connectToLocalhost": "连接本地主机", "home.loadFrom": "从以下来源导入", "home.resources": "资源" diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index e467b2795f..36ac6572de 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -244,44 +244,37 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
- - - { - event.stopPropagation() - plugin.verticalIcons.select('filePanel') - uploadFile(event.target) - }} - multiple - /> } + tooltipText={} + tooltipTextClasses="border bg-light text-dark p-1 pr-3" + > + + + } tooltipTextClasses="border bg-light text-dark p-1 pr-3" > - From 14cbe39f070ff26be935bed78eab7ba24f6387bf Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 21 Sep 2023 17:50:31 +0200 Subject: [PATCH 19/29] reconstructed playground --- .../src/lib/components/homeTabFile.tsx | 15 +------- .../remix-ui/workspace/src/lib/types/index.ts | 2 +- .../workspace/src/lib/utils/constants.ts | 3 +- libs/remix-ws-templates/src/index.ts | 3 +- .../src/templates/playground/.prettierrc | 38 +++++++++++++++++++ .../src/templates/playground/README.txt | 28 ++++++++++++++ .../playground/contracts/helloWorld.sol | 8 ++++ .../src/templates/playground/index.ts | 16 ++++++++ .../playground/scripts/deploy_with_ethers.ts | 14 +++++++ .../playground/scripts/deploy_with_web3.ts | 14 +++++++ .../playground/scripts/ethers-lib.ts | 29 ++++++++++++++ .../templates/playground/scripts/web3-lib.ts | 36 ++++++++++++++++++ 12 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 libs/remix-ws-templates/src/templates/playground/.prettierrc create mode 100644 libs/remix-ws-templates/src/templates/playground/README.txt create mode 100644 libs/remix-ws-templates/src/templates/playground/contracts/helloWorld.sol create mode 100644 libs/remix-ws-templates/src/templates/playground/index.ts create mode 100644 libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_ethers.ts create mode 100644 libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_web3.ts create mode 100644 libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts create mode 100644 libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 36ac6572de..9659d7cbed 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -135,22 +135,11 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { const wName = 'Playground' const workspaces = await plugin.call('filePanel', 'getWorkspaces') if (!workspaces.find((workspace) => workspace.name === wName)) { - await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') + await plugin.call('filePanel', 'createWorkspace', wName, 'playground') } await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working. - - const content = `// SPDX-License-Identifier: MIT - pragma solidity >=0.7.0 <0.9.0; - - contract HelloWorld { - function print() public pure returns (string memory) { - return "Hello World!"; - } - } - ` - const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) - await plugin.call('fileManager', 'open', newPath) + await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol') } const uploadFile = async (target) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'uploadFile']) diff --git a/libs/remix-ui/workspace/src/lib/types/index.ts b/libs/remix-ui/workspace/src/lib/types/index.ts index 5ae27eca3e..5df9b0dc4e 100644 --- a/libs/remix-ui/workspace/src/lib/types/index.ts +++ b/libs/remix-ui/workspace/src/lib/types/index.ts @@ -28,7 +28,7 @@ export interface JSONStandardInput { } } export type MenuItems = action[] -export type WorkspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault' | 'blank' | 'ozerc20' | 'zeroxErc20' | 'ozerc721' +export type WorkspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault' | 'blank' | 'ozerc20' | 'zeroxErc20' | 'ozerc721' | 'playground' export interface WorkspaceProps { plugin: FilePanelType } diff --git a/libs/remix-ui/workspace/src/lib/utils/constants.ts b/libs/remix-ui/workspace/src/lib/utils/constants.ts index 688c4731d6..904f03d1f3 100644 --- a/libs/remix-ui/workspace/src/lib/utils/constants.ts +++ b/libs/remix-ui/workspace/src/lib/utils/constants.ts @@ -80,5 +80,6 @@ export const TEMPLATE_NAMES = { 'ozerc721': 'OpenZeppelin ERC721', 'ozerc1155': 'OpenZeppelin ERC1155', 'zeroxErc20': '0xProject ERC20', - 'gnosisSafeMultisig': 'Gnosis Safe' + 'gnosisSafeMultisig': 'Gnosis Safe', + 'playground': 'Playground' } diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index e11a422750..d97d0c3fdf 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,10 +1,11 @@ -export { default as remixDefault } from './templates/remixDefault' +export { default as remixDefault } from './templates/playground' export { default as blank } from './templates/blank' export { default as ozerc20 } from './templates/ozerc20' export { default as ozerc721 } from './templates/ozerc721' export { default as ozerc1155 } from './templates/ozerc1155' export { default as zeroxErc20 } from './templates/zeroxErc20' export { default as gnosisSafeMultisig } from './templates/gnosisSafeMultisig' +export { default as playground } from './templates/playground' export { contractDeployerScripts } from './script-templates/contract-deployer' export { etherscanScripts } from './script-templates/etherscan' diff --git a/libs/remix-ws-templates/src/templates/playground/.prettierrc b/libs/remix-ws-templates/src/templates/playground/.prettierrc new file mode 100644 index 0000000000..b2a56f2371 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/.prettierrc @@ -0,0 +1,38 @@ +{ + "overrides": [ + { + "files": "*.sol", + "options": { + "printWidth": 80, + "tabWidth": 4, + "useTabs": false, + "singleQuote": false, + "bracketSpacing": false + } + }, + { + "files": "*.yml", + "options": {} + }, + { + "files": "*.yaml", + "options": {} + }, + { + "files": "*.toml", + "options": {} + }, + { + "files": "*.json", + "options": {} + }, + { + "files": "*.js", + "options": {} + }, + { + "files": "*.ts", + "options": {} + } + ] +} diff --git a/libs/remix-ws-templates/src/templates/playground/README.txt b/libs/remix-ws-templates/src/templates/playground/README.txt new file mode 100644 index 0000000000..e27de83769 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/README.txt @@ -0,0 +1,28 @@ +REMIX DEFAULT WORKSPACE + +Remix default workspace is present when: +i. Remix loads for the very first time +ii. A new workspace is created with 'Default' template +iii. There are no files existing in the File Explorer + +This workspace contains 3 directories: + +1. 'contracts': Holds three contracts with increasing levels of complexity. +2. 'scripts': Contains four typescript files to deploy a contract. It is explained below. +3. 'tests': Contains one Solidity test file for 'Ballot' contract & one JS test file for 'Storage' contract. + +SCRIPTS + +The 'scripts' folder has four typescript files which help to deploy the 'Storage' contract using 'web3.js' and 'ethers.js' libraries. + +For the deployment of any other contract, just update the contract's name from 'Storage' to the desired contract and provide constructor arguments accordingly +in the file `deploy_with_ethers.ts` or `deploy_with_web3.ts` + +In the 'tests' folder there is a script containing Mocha-Chai unit tests for 'Storage' contract. + +To run a script, right click on file name in the file explorer and click 'Run'. Remember, Solidity file must already be compiled. +Output from script will appear in remix terminal. + +Please note, require/import is supported in a limited manner for Remix supported modules. +For now, modules supported by Remix are ethers, web3, swarmgw, chai, multihashes, remix and hardhat only for hardhat.ethers object/plugin. +For unsupported modules, an error like this will be thrown: ' module require is not supported by Remix IDE' will be shown. diff --git a/libs/remix-ws-templates/src/templates/playground/contracts/helloWorld.sol b/libs/remix-ws-templates/src/templates/playground/contracts/helloWorld.sol new file mode 100644 index 0000000000..47fabd793a --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/contracts/helloWorld.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.6.12 <0.9.0; + +contract HelloWorld { + function print() public pure returns (string memory) { + return "Hello World!"; + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/index.ts b/libs/remix-ws-templates/src/templates/playground/index.ts new file mode 100644 index 0000000000..52e33a5a43 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/index.ts @@ -0,0 +1,16 @@ +export default async () => { + return { + // @ts-ignore + 'contracts/helloWorld.sol': (await import('raw-loader!./contracts/helloWorld.sol')).default, + // @ts-ignore + 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, + // @ts-ignore + 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, + // @ts-ignore + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, + // @ts-ignore + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, + // @ts-ignore + '.prettierrc.json': (await import('raw-loader!./.prettierrc')).default, + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_ethers.ts new file mode 100644 index 0000000000..d190d654f0 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_ethers.ts @@ -0,0 +1,14 @@ +// This script can be used to deploy the "Storage" contract using ethers.js library. +// Please make sure to compile "./contracts/1_Storage.sol" file before running this script. +// And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S + +import { deploy } from './ethers-lib' + +(async () => { + try { + const result = await deploy('HelloWorld', []) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } +})() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_web3.ts new file mode 100644 index 0000000000..1378a92657 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_web3.ts @@ -0,0 +1,14 @@ +// This script can be used to deploy the "Storage" contract using Web3 library. +// Please make sure to compile "./contracts/1_Storage.sol" file before running this script. +// And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S + +import { deploy } from './web3-lib' + +(async () => { + try { + const result = await deploy('HelloWorld', []) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } +})() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts new file mode 100644 index 0000000000..2753f9bcd0 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts @@ -0,0 +1,29 @@ +import { ethers } from 'ethers' + +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} accountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { + + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + // 'web3Provider' is a remix global variable object + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) + + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) + + const contract = await factory.deploy(...args) + + // The contract is NOT deployed yet; we must wait until it is mined + await contract.deployed() + return contract +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts new file mode 100644 index 0000000000..c57e501039 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/playground/scripts/web3-lib.ts @@ -0,0 +1,36 @@ +import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' + +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + + const web3 = new Web3(web3Provider) + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + + const accounts = await web3.eth.getAccounts() + + const contract: Contract = new web3.eth.Contract(metadata.abi) + + const contractSend: ContractSendMethod = contract.deploy({ + data: metadata.data.bytecode.object, + arguments: args + }) + + const newContractInstance = await contractSend.send({ + from: from || accounts[0], + gas: gas || 1500000 + }) + return newContractInstance.options +} \ No newline at end of file From d5b2acd9977e3f313f2404df997d350938291e57 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 18 Oct 2023 13:45:36 +0200 Subject: [PATCH 20/29] cleanup --- apps/remix-ide/src/app/files/fileManager.ts | 1 - apps/remix-ide/src/app/tabs/locales/es/home.json | 1 - apps/remix-ide/src/app/tabs/locales/zh/home.json | 3 --- libs/remix-ws-templates/src/index.ts | 2 +- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 7022e34bc2..de6ec7d910 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -264,7 +264,6 @@ class FileManager extends Plugin { if (await this.exists(path)) { const newPath = await helper.createNonClashingNameAsync(path, this) const content = await this.setFileContent(newPath, data) - console.log("newp in write ", newPath) return {newContent: content, newPath} } else { const ret = await this.setFileContent(path, data) diff --git a/apps/remix-ide/src/app/tabs/locales/es/home.json b/apps/remix-ide/src/app/tabs/locales/es/home.json index 62b3d68e6c..802d22bef4 100644 --- a/apps/remix-ide/src/app/tabs/locales/es/home.json +++ b/apps/remix-ide/src/app/tabs/locales/es/home.json @@ -55,7 +55,6 @@ "home.files": "Files", "home.newFile": "New File", "home.openFile": "Open File", - "home.openFileTooltip": "Open a File from you File System", "home.connectToLocalhost": "Access File System", "home.loadFrom": "Load from", "home.resources": "Resources" diff --git a/apps/remix-ide/src/app/tabs/locales/zh/home.json b/apps/remix-ide/src/app/tabs/locales/zh/home.json index 369db761b4..17ad8bb36c 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/home.json +++ b/apps/remix-ide/src/app/tabs/locales/zh/home.json @@ -54,10 +54,7 @@ "home.searchDocumentation": "搜索文档", "home.files": "文件", "home.newFile": "新建文件", - "home.startCoding": "Start Coding", - "home.startCodingPlayground": "Open a playground for prototyping and simply learning", "home.openFile": "打开本地文件", - "home.openFileTooltip": "Open a File from you File System", "home.connectToLocalhost": "连接本地主机", "home.loadFrom": "从以下来源导入", "home.resources": "资源" diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index d97d0c3fdf..10e4a984ed 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,4 +1,4 @@ -export { default as remixDefault } from './templates/playground' +export { default as remixDefault } from './templates/remixDefault' export { default as blank } from './templates/blank' export { default as ozerc20 } from './templates/ozerc20' export { default as ozerc721 } from './templates/ozerc721' From 9dd68b4d95da095b56fc6d0581217d72106b9a7b Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 20 Oct 2023 15:06:41 +0200 Subject: [PATCH 21/29] createing new file every time user clickes on start coding --- .../home-tab/src/lib/components/homeTabFile.tsx | 14 +++++++++++++- .../src/templates/playground/index.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 9659d7cbed..90d2fcec9f 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -139,7 +139,19 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { } await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working. - await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol') + const content = `// SPDX-License-Identifier: MIT + pragma solidity >=0.6.12 <0.9.0; + + contract HelloWorld { + function print() public pure returns (string memory) { + return "Hello World!"; + } + } + ` + const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + await plugin.call('fileManager', 'open', newPath) + + //await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol') } const uploadFile = async (target) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'uploadFile']) diff --git a/libs/remix-ws-templates/src/templates/playground/index.ts b/libs/remix-ws-templates/src/templates/playground/index.ts index 52e33a5a43..c3a7fc6f7f 100644 --- a/libs/remix-ws-templates/src/templates/playground/index.ts +++ b/libs/remix-ws-templates/src/templates/playground/index.ts @@ -1,7 +1,7 @@ export default async () => { return { // @ts-ignore - 'contracts/helloWorld.sol': (await import('raw-loader!./contracts/helloWorld.sol')).default, + //'contracts/helloWorld.sol': (await import('raw-loader!./contracts/helloWorld.sol')).default, // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, // @ts-ignore From f8bb581c197dfd7c53fef434cff8d186f97023cb Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 20 Oct 2023 16:19:30 +0200 Subject: [PATCH 22/29] updated e2e name and cleanup --- apps/remix-ide-e2e/src/tests/homeTab.test.ts | 20 +++++++++---------- apps/remix-ide/src/app/panels/file-panel.js | 2 +- .../src/app/tabs/locales/en/home.json | 2 +- .../src/lib/components/homeTabFile.tsx | 9 ++++----- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/homeTab.test.ts b/apps/remix-ide-e2e/src/tests/homeTab.test.ts index 9d4fa20bf4..7285556078 100644 --- a/apps/remix-ide-e2e/src/tests/homeTab.test.ts +++ b/apps/remix-ide-e2e/src/tests/homeTab.test.ts @@ -4,14 +4,14 @@ import init from '../helpers/init' module.exports = { - before: function (browser: NightwatchBrowser, done: VoidFunction) { - init(browser, done) - }, - - 'Should create new file': function (browser: NightwatchBrowser) { - browser - .waitForElementVisible('*[data-id="homeTabStartCoding"]') - .click('*[data-id="homeTabStartCoding"]') - .waitForElementVisible('div[data-id="treeViewDivtreeViewItemcontracts/helloWorld.sol"]') - } + before: function (browser: NightwatchBrowser, done: VoidFunction) { + init(browser, done) + }, + + 'Should start coding': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="homeTabStartCoding"]') + .click('*[data-id="homeTabStartCoding"]') + .waitForElementVisible('div[data-id="treeViewDivtreeViewItemcontracts/helloWorld.sol"]') + } } \ No newline at end of file diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index c8c0c26dbe..3b03cd4c25 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -50,7 +50,7 @@ const profile = { location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/file_explorer.html', version: packageJson.version, - maintainedBy: 'Remix', + maintainedBy: 'Remix' } module.exports = class Filepanel extends ViewPlugin { constructor(appManager) { diff --git a/apps/remix-ide/src/app/tabs/locales/en/home.json b/apps/remix-ide/src/app/tabs/locales/en/home.json index 9c4045eae2..76578a4db8 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/home.json +++ b/apps/remix-ide/src/app/tabs/locales/en/home.json @@ -59,7 +59,7 @@ "home.startCoding": "Start Coding", "home.startCodingPlayground": "Open a playground for prototyping and simply learning", "home.openFile": "Open File", - "home.openFileTooltip": "Open a File from you File System", + "home.openFileTooltip": "Open a File from your File System", "home.accessFileSystem": "Access File System", "home.loadFrom": "Load from", "home.resources": "Resources", diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 90d2fcec9f..769d31daeb 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -14,7 +14,7 @@ interface HomeTabFileProps { const loadingInitialState = { tooltip: '', showModalDialog: false, - importSource: '', + importSource: '' } const loadingReducer = (state = loadingInitialState, action) => { @@ -22,7 +22,7 @@ const loadingReducer = (state = loadingInitialState, action) => { ...state, tooltip: action.tooltip, showModalDialog: false, - importSource: '', + importSource: '' } } @@ -45,7 +45,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { modalInfo: { title: '', loadItem: '', examples: [], prefix: '' }, importSource: '', toasterMsg: '', - recentWorkspaces: [], + recentWorkspaces: [] }) const [, dispatch] = useReducer(loadingReducer, loadingInitialState) @@ -150,9 +150,8 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { ` const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) await plugin.call('fileManager', 'open', newPath) - - //await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol') } + const uploadFile = async (target) => { _paq.push(['trackEvent', 'hometab', 'filesSection', 'uploadFile']) await plugin.call('filePanel', 'uploadFile', target) From 9137a4f08f18ea1909d65debeb94e3a91ba9ca85 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 20 Oct 2023 16:21:59 +0200 Subject: [PATCH 23/29] fixed the filtering of empty warkspaces --- apps/remix-ide/src/app/panels/file-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 3b03cd4c25..7b813aea1c 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -189,7 +189,7 @@ module.exports = class Filepanel extends ViewPlugin { return el === workspaceName })) { recents = ([workspaceName, ...recents]) - recents.filter((el) => { return el != "" }) + recents = recents.filter((el) => { return el != "" }) localStorage.setItem('recentWorkspaces', JSON.stringify(recents)) } } From 7e1afb4e40df6d29b2ff1d87aca96b18aed28c74 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 25 Oct 2023 17:08:35 +0200 Subject: [PATCH 24/29] fix open default file --- .../src/lib/components/homeTabFile.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx index 769d31daeb..41d0e13f23 100644 --- a/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx +++ b/libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx @@ -134,22 +134,29 @@ function HomeTabFile({ plugin }: HomeTabFileProps) { const wName = 'Playground' const workspaces = await plugin.call('filePanel', 'getWorkspaces') + let createFile = true if (!workspaces.find((workspace) => workspace.name === wName)) { await plugin.call('filePanel', 'createWorkspace', wName, 'playground') + createFile = false } await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working. const content = `// SPDX-License-Identifier: MIT - pragma solidity >=0.6.12 <0.9.0; + pragma solidity >=0.6.12 <0.9.0; - contract HelloWorld { - function print() public pure returns (string memory) { - return "Hello World!"; + contract HelloWorld { + function print() public pure returns (string memory) { + return "Hello World!"; + } } + ` + if (createFile) { + const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) + await plugin.call('fileManager', 'open', newPath) + } else { + await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol') } - ` - const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) - await plugin.call('fileManager', 'open', newPath) + } const uploadFile = async (target) => { From 834c6134ec7a537287c00730b69d3037d0beb756 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 30 Oct 2023 10:01:59 +0100 Subject: [PATCH 25/29] e2e wait longer (this use a remote api) --- apps/remix-ide-e2e/src/tests/transactionExecution.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index c5fc0d8815..656aead7e4 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -237,7 +237,7 @@ module.exports = { .setSolidityCompilerVersion('soljson-v0.8.17+commit.8df45f5f.js') .clickLaunchIcon('udapp') .switchEnvironment('vm-mainnet-fork') - .waitForElementPresent('select[data-id="runTabSelectAccount"] option[value="0xdD870fA1b7C4700F2BD7f44238821C26f7392148"]') // wait for the udapp to load the list of accounts + .waitForElementPresent('select[data-id="runTabSelectAccount"] option[value="0xdD870fA1b7C4700F2BD7f44238821C26f7392148"]', 30000) // wait for the udapp to load the list of accounts .selectContract('MyResolver') .createContract('') .clickInstance(0) From bd0fcf795db9a41520f11d8cec60a73431ace61d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 30 Oct 2023 10:22:44 +0100 Subject: [PATCH 26/29] add file from template --- libs/remix-ws-templates/src/templates/playground/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/templates/playground/index.ts b/libs/remix-ws-templates/src/templates/playground/index.ts index c3a7fc6f7f..52e33a5a43 100644 --- a/libs/remix-ws-templates/src/templates/playground/index.ts +++ b/libs/remix-ws-templates/src/templates/playground/index.ts @@ -1,7 +1,7 @@ export default async () => { return { // @ts-ignore - //'contracts/helloWorld.sol': (await import('raw-loader!./contracts/helloWorld.sol')).default, + 'contracts/helloWorld.sol': (await import('raw-loader!./contracts/helloWorld.sol')).default, // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, // @ts-ignore From 101b506d612b7dfab52756c33117d3650faad82f Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Oct 2023 17:52:31 +0100 Subject: [PATCH 27/29] linting --- .../workspace/src/lib/actions/workspace.ts | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 98cc1e6c81..7e3fa7259b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -121,62 +121,62 @@ export const createWorkspace = async ( const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) dispatch(createWorkspaceRequest()) promise.then(async () => { - dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) - await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) - await plugin.workspaceCreated(workspaceName) - - if (isGitRepo && createCommit) { - const name = await plugin.call('settings', 'get', 'settings/github-user-name') - const email = await plugin.call('settings', 'get', 'settings/github-email') - const currentBranch = await plugin.call('dGitProvider', 'currentbranch') - - if (!currentBranch) { - if (!name || !email) { - await plugin.call('notification', 'toast', 'To use Git features, add username and email to the Github section of the Settings panel.') - } else { - // commit the template as first commit - plugin.call('notification', 'toast', 'Creating initial git commit ...') - - await plugin.call('dGitProvider', 'init') - if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName, opts) - const status = await plugin.call('dGitProvider', 'status', { ref: 'HEAD' }) - - Promise.all( - status.map(([filepath, , worktreeStatus]) => - worktreeStatus - ? plugin.call('dGitProvider', 'add', { - filepath: removeSlash(filepath), - }) - : plugin.call('dGitProvider', 'rm', { - filepath: removeSlash(filepath), - }) - ) - ).then(async () => { - await plugin.call('dGitProvider', 'commit', { - author: { - name, - email, - }, - message: `Initial commit: remix template ${workspaceTemplateName}`, - }) + dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) + await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) + await plugin.workspaceCreated(workspaceName) + + if (isGitRepo && createCommit) { + const name = await plugin.call('settings', 'get', 'settings/github-user-name') + const email = await plugin.call('settings', 'get', 'settings/github-email') + const currentBranch = await plugin.call('dGitProvider', 'currentbranch') + + if (!currentBranch) { + if (!name || !email) { + await plugin.call('notification', 'toast', 'To use Git features, add username and email to the Github section of the Settings panel.') + } else { + // commit the template as first commit + plugin.call('notification', 'toast', 'Creating initial git commit ...') + + await plugin.call('dGitProvider', 'init') + if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName, opts) + const status = await plugin.call('dGitProvider', 'status', { ref: 'HEAD' }) + + Promise.all( + status.map(([filepath, , worktreeStatus]) => + worktreeStatus + ? plugin.call('dGitProvider', 'add', { + filepath: removeSlash(filepath), + }) + : plugin.call('dGitProvider', 'rm', { + filepath: removeSlash(filepath), + }) + ) + ).then(async () => { + await plugin.call('dGitProvider', 'commit', { + author: { + name, + email, + }, + message: `Initial commit: remix template ${workspaceTemplateName}`, }) - } + }) } } - if (!isEmpty && !(isGitRepo && createCommit)) await loadWorkspacePreset(workspaceTemplateName, opts) - cb && cb(null, workspaceName) - if (isGitRepo) { - await checkGit() - const isActive = await plugin.call('manager', 'isActive', 'dgit') - if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') - } - // this call needs to be here after the callback because it calls dGitProvider which also calls this function and that would cause an infinite loop - await plugin.setWorkspaces(await getWorkspaces()) - }) - .catch((error) => { - dispatch(createWorkspaceError(error.message)) - cb && cb(error) - }) + } + if (!isEmpty && !(isGitRepo && createCommit)) await loadWorkspacePreset(workspaceTemplateName, opts) + cb && cb(null, workspaceName) + if (isGitRepo) { + await checkGit() + const isActive = await plugin.call('manager', 'isActive', 'dgit') + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') + } + // this call needs to be here after the callback because it calls dGitProvider which also calls this function and that would cause an infinite loop + await plugin.setWorkspaces(await getWorkspaces()) + }) + .catch((error) => { + dispatch(createWorkspaceError(error.message)) + cb && cb(error) + }) return promise } From 0c9cb3c5ad838e1fbb193fa0ddec67ff1aa0c34e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Oct 2023 17:57:37 +0100 Subject: [PATCH 28/29] readd circom activation --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 7e3fa7259b..13a718c7a9 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -170,6 +170,10 @@ export const createWorkspace = async ( const isActive = await plugin.call('manager', 'isActive', 'dgit') if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') } + if (workspaceTemplateName === 'semaphore') { + const isCircomActive = await plugin.call('manager', 'isActive', 'circuit-compiler') + if (!isCircomActive) await plugin.call('manager', 'activatePlugin', 'circuit-compiler') + } // this call needs to be here after the callback because it calls dGitProvider which also calls this function and that would cause an infinite loop await plugin.setWorkspaces(await getWorkspaces()) }) From 02d82f4ccad407e1ef79621f6a9217d5c51f1bdd Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Oct 2023 18:07:26 +0100 Subject: [PATCH 29/29] linting --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 13a718c7a9..c4818c8d90 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -176,8 +176,7 @@ export const createWorkspace = async ( } // this call needs to be here after the callback because it calls dGitProvider which also calls this function and that would cause an infinite loop await plugin.setWorkspaces(await getWorkspaces()) - }) - .catch((error) => { + }).catch((error) => { dispatch(createWorkspaceError(error.message)) cb && cb(error) })