diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 1bfa289212..5f3ded1f77 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -49,9 +49,8 @@ module.exports = { .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > span') // eslint-disable-next-line dot-notation .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_name_1' }) - .waitForElementVisible('[data-id="fileSystem-modal-footer-ok-react"]') - .click('[data-id="fileSystemModalDialogModalFooter-react"]') // focus on footer to ensure ok click - .click('[data-id="fileSystem-modal-footer-ok-react"]') + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]') .pause(2000) .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index ed2e9b6f85..7cb7653d1d 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -58,7 +58,7 @@ module.exports = class Filepanel extends ViewPlugin { } onActivation () { - this.renderComponent() + this.on('editor', 'editorMounted', () => this.renderComponent()) } render () { diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 19d2b72597..a640285566 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -115,14 +115,16 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA async onActivation () { super.onActivation() - this.call('filePanel', 'registerContextMenuItem', { - id: 'solidity', - name: 'compileFile', - label: 'Compile', - type: [], - extension: ['.sol'], - path: [], - pattern: [] + this.on('filePanel', 'workspaceInitializationCompleted', () => { + this.call('filePanel', 'registerContextMenuItem', { + id: 'solidity', + name: 'compileFile', + label: 'Compile', + type: [], + extension: ['.sol'], + path: [], + pattern: [] + }) }) try { this.currentFile = await this.call('fileManager', 'file') diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 1b61786e2b..f461081fc4 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -27,20 +27,20 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. dispatch(setWorkspaces(workspaces)) if (params.gist) { await createWorkspaceTemplate('gist-sample', 'gist-template') - await loadWorkspacePreset('gist-template') plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('gist-sample')) + await loadWorkspacePreset('gist-template') } else if (params.code || params.url) { await createWorkspaceTemplate('code-sample', 'code-template') - await loadWorkspacePreset('code-template') plugin.setWorkspace({ name: 'code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('code-sample')) + await loadWorkspacePreset('code-template') } else { if (workspaces.length === 0) { await createWorkspaceTemplate('default_workspace', 'default-template') - await loadWorkspacePreset('default-template') plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) dispatch(setCurrentWorkspace('default_workspace')) + await loadWorkspacePreset('default-template') } else { if (workspaces.length > 0) { workspaceProvider.setWorkspace(workspaces[workspaces.length - 1]) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index cc8cc3de6a..5b861d88fd 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -84,16 +84,21 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol' content = atob(params.code) - await workspaceProvider.set(path, content) + workspaceProvider.set(path, content, async (error) => { + if (error) throw new Error(error) + await plugin.fileManager.openFile(path) + }) } if (params.url) { const data = await plugin.call('contentImport', 'resolve', params.url) path = data.cleanUrl content = data.content - await workspaceProvider.set(path, content) + workspaceProvider.set(path, content, async (error) => { + if (error) throw new Error(error) + await plugin.fileManager.openFile(path) + }) } - await plugin.fileManager.openFile(path) } catch (e) { console.error(e) }