Merge branch 'master' into refactoring-static-analyser

pull/1104/head
David Zagi 4 years ago committed by GitHub
commit 4d2db415ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      apps/remix-ide/src/app/panels/file-panel.js
  2. 4
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -136,6 +136,7 @@ module.exports = class Filepanel extends ViewPlugin {
} }
async initWorkspace () { async initWorkspace () {
this.renderComponent()
const queryParams = new QueryParams() const queryParams = new QueryParams()
const gistHandler = new GistHandler() const gistHandler = new GistHandler()
const params = queryParams.get() const params = queryParams.get()
@ -203,13 +204,13 @@ module.exports = class Filepanel extends ViewPlugin {
if (checkSpecialChars(workspaceName) || checkSlash(workspaceName)) throw new Error('special characters are not allowed') if (checkSpecialChars(workspaceName) || checkSlash(workspaceName)) throw new Error('special characters are not allowed')
if (await this.workspaceExists(workspaceName)) throw new Error('workspace already exists') if (await this.workspaceExists(workspaceName)) throw new Error('workspace already exists')
else { else {
this._deps.fileProviders.workspace.setWorkspace(workspaceName) const workspaceProvider = this._deps.fileProviders.workspace
const browserProvider = this._deps.fileProviders.browser
const workspacesPath = this._deps.fileProviders.workspace.workspacesPath
await this.processCreateWorkspace(workspaceName) await this.processCreateWorkspace(workspaceName)
workspaceProvider.setWorkspace(workspaceName)
await this.request.setWorkspace(workspaceName) // tells the react component to switch to that workspace
for (const file in examples) { for (const file in examples) {
try { try {
await browserProvider.set('browser/' + workspacesPath + '/' + workspaceName + '/' + examples[file].name, examples[file].content) await workspaceProvider.set(examples[file].name, examples[file].content)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }

@ -49,6 +49,10 @@ export const Workspace = (props: WorkspaceProps) => {
return createWorkspace() return createWorkspace()
} }
props.request.setWorkspace = (workspaceName) => {
return setWorkspace(workspaceName)
}
props.request.createNewFile = () => { props.request.createNewFile = () => {
if (!state.workspaces.length) createNewWorkspace('default_workspace') if (!state.workspaces.length) createNewWorkspace('default_workspace')
props.plugin.resetNewFile() props.plugin.resetNewFile()

Loading…
Cancel
Save