Skip to content

Commit ac54985

Browse files
committed
fix
1 parent 9ed3229 commit ac54985

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

apps/remix-ide/src/app/files/fileProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class FileProvider {
200200
*/
201201
copyFolderToJson (path) {
202202
return new Promise((resolve, reject) => {
203-
let json = {}
203+
const json = {}
204204
path = this.removePrefix(path)
205205
if (window.remixFileSystem.existsSync(path)) {
206206
try {

apps/remix-ide/src/app/files/workspaceFileProvider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ class WorkspaceFileProvider extends FileProvider {
2020

2121
removePrefix (path) {
2222
path = super.removePrefix(path)
23-
return this.scopeWorkspace(path)
23+
return '.workspaces/' + this.scopeWorkspace(path)
2424
}
2525

2626
resolveDirectory (path, callback) {
2727
super.resolveDirectory(path, (error, files) => {
2828
if (error) return callback(error)
29-
let unscoped = {}
29+
const unscoped = {}
3030
for (const file in files) {
31-
unscoped[file.replace(this.workspace + '/', '')] = files[file]
31+
unscoped[file.replace('.workspaces/' + this.workspace + '/', '')] = files[file]
3232
}
3333
callback(null, unscoped)
3434
})

apps/remix-ide/src/app/panels/file-panel.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,20 @@ module.exports = class Filepanel extends ViewPlugin {
105105

106106
refreshWorkspacesList () {
107107
if (!document.getElementById('workspacesSelect')) return
108-
this._deps.fileProviders.browser.resolveDirectory('/', (error, fileTree) => {
108+
this._deps.fileProviders.browser.resolveDirectory('/.workspaces', (error, fileTree) => {
109109
if (error) console.error(error)
110110
const items = fileTree
111111
items[this.LOCALHOST] = { isLocalHost: true }
112112
ReactDOM.render(
113113
(
114114
Object.keys(items)
115115
.filter((item) => fileTree[item].isDirectory || fileTree[item].isLocalHost)
116-
.map((folder) => <option selected={this.currentWorkspace === folder} value={folder}>{folder}</option>)), document.getElementById('workspacesSelect')
116+
.map((folder) => {
117+
folder = folder.replace('.workspaces/', '')
118+
return <option selected={this.currentWorkspace === folder} value={folder}>{folder}</option>
119+
})), document.getElementById('workspacesSelect')
117120
)
118-
if (!this.currentWorkspace) this.setWorkspace(Object.keys(fileTree)[0])
121+
if (!this.currentWorkspace) this.setWorkspace(Object.keys(fileTree)[0].replace('.workspaces/', ''))
119122
})
120123
}
121124

@@ -149,12 +152,11 @@ module.exports = class Filepanel extends ViewPlugin {
149152
}
150153

151154
setWorkspace (name) {
155+
this.currentWorkspace = name
152156
if (name === this.LOCALHOST) {
153-
this.currentWorkspace = name
154157
this.call('manager', 'activatePlugin', 'remixd')
155158
} else {
156159
this._deps.fileProviders.workspace.setWorkspace(name)
157-
this.currentWorkspace = name
158160
this.call('manager', 'deactivatePlugin', 'remixd')
159161
}
160162
this.renderComponent()
@@ -176,7 +178,7 @@ module.exports = class Filepanel extends ViewPlugin {
176178

177179
renameWorkspace () {
178180
modalDialog.prompt('Rename Workspace', 'Please choose a name for the workspace', this.currentWorkspace, async (value) => {
179-
await this._deps.fileManager.rename('browser/' + this.currentWorkspace, 'browser/' + value)
181+
await this._deps.fileManager.rename('browser/.workspaces/' + this.currentWorkspace, 'browser/workspaces/' + value)
180182
setTimeout(async () => {
181183
this.setWorkspace(value)
182184
}, 2000)
@@ -186,7 +188,7 @@ module.exports = class Filepanel extends ViewPlugin {
186188
async createWorkspace () {
187189
const workspace = `workspace_${Date.now()}`
188190
modalDialog.prompt('New Workspace', 'Please choose a name for the workspace', workspace, (value) => {
189-
this._deps.fileProviders.browser.createDir(value, async () => {
191+
this._deps.fileProviders.browser.createDir('.workspaces/' + value, async () => {
190192
this.setWorkspace(value)
191193
setTimeout(async () => {
192194
for (const file in examples) {
@@ -200,7 +202,7 @@ module.exports = class Filepanel extends ViewPlugin {
200202
deleteCurrentWorkspace () {
201203
if (!this.currentWorkspace) return
202204
modalDialog.confirm('Delete Workspace', 'Please confirm workspace deletion', () => {
203-
this._deps.fileProviders.browser.remove(this.currentWorkspace)
205+
this._deps.fileProviders.browser.remove('.workspaces/' + this.currentWorkspace)
204206
this.currentWorkspace = null
205207
this.renderComponent()
206208
})

apps/remix-ide/src/migrateFileSystem.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ export async function migrateToWorkspace (fileManager) {
2828
if (fileStorageBrowserWorkspace.get(flag) === 'done') return
2929
const files = await browserProvider.copyFolderToJson('/')
3030
console.log(files)
31-
await browserProvider.remove('/')
32-
workspaceProvider.setWorkspace('workspace_1')
33-
await fileManager.mkdir('workspace_1')
34-
await populateWorkspace('workspace_1', files, fileManager)
31+
const workspaceName = 'workspace_1'
32+
const workspacePath = 'browser/.workspaces/' + workspaceName
33+
workspaceProvider.setWorkspace(workspaceName)
34+
await fileManager.mkdir(workspacePath)
35+
await populateWorkspace(workspacePath, files, fileManager)
3536
fileStorageBrowserWorkspace.set(flag, 'done')
3637
}
3738

0 commit comments

Comments
 (0)