migrate from homepage

pull/1021/head
yann300 4 years ago
parent baa1563c96
commit 01c2781f9b
  1. 4
      apps/remix-ide/src/app.js
  2. 9
      apps/remix-ide/src/app/ui/landing-page/landing-page.js
  3. 6
      apps/remix-ide/src/migrateFileSystem.js

@ -18,7 +18,7 @@ import { LandingPage } from './app/ui/landing-page/landing-page'
import { MainPanel } from './app/components/main-panel' import { MainPanel } from './app/components/main-panel'
import FetchAndCompile from './app/compiler/compiler-sourceVerifier-fetchAndCompile' import FetchAndCompile from './app/compiler/compiler-sourceVerifier-fetchAndCompile'
import migrateFileSystem, { migrateToWorkspace } from './migrateFileSystem' import migrateFileSystem from './migrateFileSystem'
const isElectron = require('is-electron') const isElectron = require('is-electron')
const csjs = require('csjs-inject') const csjs = require('csjs-inject')
@ -494,7 +494,5 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// get the file list from the parent iframe // get the file list from the parent iframe
loadFileFromParent(fileManager) loadFileFromParent(fileManager)
migrateToWorkspace(fileManager, filePanel)
if (params.embed) framingService.embed() if (params.embed) framingService.embed()
} }

@ -357,6 +357,11 @@ export class LandingPage extends ViewPlugin {
query.update({ appVersion: '0.7.7' }) query.update({ appVersion: '0.7.7' })
document.location.reload() document.location.reload()
} }
const migrateWorkspace = () => {
migrateToWorkspace(globalRegistry.get('fileManager').api, globalRegistry.get('filePanel').api)
}
const img = yo`<img class=${css.logoImg} src="assets/img/guitarRemiCroped.webp" onclick="${() => playRemi()}"></img>` const img = yo`<img class=${css.logoImg} src="assets/img/guitarRemiCroped.webp" onclick="${() => playRemi()}"></img>`
const playRemi = async () => { await document.getElementById('remiAudio').play() } const playRemi = async () => { await document.getElementById('remiAudio').play() }
// to retrieve medium posts // to retrieve medium posts
@ -435,6 +440,10 @@ export class LandingPage extends ViewPlugin {
<i class="fab fa-ethereum ${css.image}"></i> <i class="fab fa-ethereum ${css.image}"></i>
<span class="${css.text}" onclick=${() => switchToPreviousVersion()}>Old experience</span> <span class="${css.text}" onclick=${() => switchToPreviousVersion()}>Old experience</span>
</p> </p>
<p>
<i class="fab fa-ethereum ${css.image}"></i>
<span class="${css.text}" onclick=${() => migrateWorkspace()}>Migrate old filesystem to workspace</span>
</p>
</div> </div>
</div> </div>
</div> </div>

@ -24,19 +24,15 @@ export default (fileProvider) => {
export async function migrateToWorkspace (fileManager, filePanel) { export async function migrateToWorkspace (fileManager, filePanel) {
const browserProvider = fileManager.getProvider('browser') const browserProvider = fileManager.getProvider('browser')
const workspaceProvider = fileManager.getProvider('workspace') const workspaceProvider = fileManager.getProvider('workspace')
const flag = 'status'
const fileStorageBrowserWorkspace = new Storage('remix_browserWorkspace_migration:')
if (fileStorageBrowserWorkspace.get(flag) === 'done') return
const files = await browserProvider.copyFolderToJson('/') const files = await browserProvider.copyFolderToJson('/')
console.log(files) console.log(files)
if (Object.keys(files).length > 0) { if (Object.keys(files).length > 0) {
const workspaceName = 'default_workspace' const workspaceName = 'workspace_migrated_' + Date.now()
const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName) const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName)
await filePanel.processCreateWorkspace(workspaceName) await filePanel.processCreateWorkspace(workspaceName)
filePanel.getWorkspaces() // refresh list filePanel.getWorkspaces() // refresh list
await populateWorkspace(workspacePath, files, browserProvider) await populateWorkspace(workspacePath, files, browserProvider)
} }
fileStorageBrowserWorkspace.set(flag, 'done')
} }
const populateWorkspace = async (workspace, json, browserProvider) => { const populateWorkspace = async (workspace, json, browserProvider) => {

Loading…
Cancel
Save