diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 09d220f369..829a635104 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -325,11 +325,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // those views depend on app_manager const menuicons = new VerticalIcons(appManager) - const landingPage = new LandingPage(appManager, menuicons) const sidePanel = new SidePanel(appManager, menuicons) const hiddenPanel = new HiddenPanel() const pluginManagerComponent = new PluginManagerComponent(appManager, engine) const filePanel = new FilePanel(appManager) + const landingPage = new LandingPage(appManager, menuicons, fileManager, filePanel) const settings = new SettingsTab( registry.get('config').api, editor, diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 9bb49141cc..6eb7e90135 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,5 +1,6 @@ import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' +import { migrateToWorkspace } from '../../../migrateFileSystem' const yo = require('yo-yo') const csjs = require('csjs-inject') @@ -112,9 +113,11 @@ const profile = { } export class LandingPage extends ViewPlugin { - constructor (appManager, verticalIcons) { + constructor (appManager, verticalIcons, fileManager, filePanel) { super(profile) this.profile = profile + this.fileManager = fileManager + this.filePanel = filePanel this.appManager = appManager this.verticalIcons = verticalIcons this.gistHandler = new GistHandler() @@ -385,8 +388,12 @@ export class LandingPage extends ViewPlugin { const migrateWorkspace = async () => { tooltip('migrating workspace...') - await migrateToWorkspace(globalRegistry.get('fileManager').api, globalRegistry.get('filePanel').api) - tooltip('done.') + try { + const workspaceName = await migrateToWorkspace(this.fileManager, this.filePanel) + tooltip('done. ' + workspaceName + ' created.') + } catch (e) { + return tooltip(e.message) + } } const img = yo`` diff --git a/apps/remix-ide/src/migrateFileSystem.js b/apps/remix-ide/src/migrateFileSystem.js index c15bea2b39..9eaac38bd7 100644 --- a/apps/remix-ide/src/migrateFileSystem.js +++ b/apps/remix-ide/src/migrateFileSystem.js @@ -26,13 +26,14 @@ export async function migrateToWorkspace (fileManager, filePanel) { const workspaceProvider = fileManager.getProvider('workspace') const files = await browserProvider.copyFolderToJson('/') console.log(files) - if (Object.keys(files).length > 0) { - const workspaceName = 'workspace_migrated_' + Date.now() + const workspaceName = 'workspace_migrated_' + Date.now() + if (Object.keys(files).length > 0) { const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName) await filePanel.processCreateWorkspace(workspaceName) filePanel.getWorkspaces() // refresh list await populateWorkspace(workspacePath, files, browserProvider) - } + } + return workspaceName } const populateWorkspace = async (workspace, json, browserProvider) => {