Activate dgit for git workspaces

pull/2879/head
David Disu 2 years ago
parent 42d49b1de1
commit 74e0505070
  1. 4
      apps/remix-ide/src/app/files/fileManager.ts
  2. 14
      libs/remix-ui/workspace/src/lib/actions/index.ts
  3. 7
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -818,8 +818,8 @@ class FileManager extends Plugin {
}
}
async isGitRepo (directory: string): Promise<boolean> {
const path = directory + '/.git'
async isGitRepo (): Promise<boolean> {
const path = '.git'
const exists = await this.exists(path)
return exists

@ -38,6 +38,11 @@ const basicWorkspaceInit = async (workspaces: { name: string; isGitRepo: boolean
workspaceProvider.setWorkspace(workspaceName)
plugin.setWorkspace({ name: workspaceName, isLocalhost: false })
if (workspace.isGitRepo) {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
dispatch(setCurrentWorkspace(workspace))
}
}
@ -123,7 +128,14 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
const name = localStorage.getItem("currentWorkspace")
workspaceProvider.setWorkspace(name)
plugin.setWorkspace({ name: name, isLocalhost: false })
dispatch(setCurrentWorkspace({ name: name, isGitRepo: false }))
const isGitRepo = await plugin.fileManager.isGitRepo()
if (isGitRepo) {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
dispatch(setCurrentWorkspace({ name: name, isGitRepo }))
}
} else {
await basicWorkspaceInit(workspaces, workspaceProvider)

@ -277,8 +277,13 @@ export const switchToWorkspace = async (name: string) => {
if (isActive) await plugin.call('manager', 'deactivatePlugin', 'remixd')
await plugin.fileProviders.workspace.setWorkspace(name)
await plugin.setWorkspace({ name, isLocalhost: false })
const isGitRepo = await plugin.fileManager.isGitRepo(name)
const isGitRepo = await plugin.fileManager.isGitRepo()
if (isGitRepo) {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
dispatch(setMode('browser'))
dispatch(setCurrentWorkspace({ name, isGitRepo }))
dispatch(setReadOnlyMode(false))

Loading…
Cancel
Save