diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index 019caec3c7..6f8abe3025 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -147,7 +147,6 @@ class DGitProvider extends Plugin { } async currentbranch (config) { - console.log('config: ', config) const cmd = config ? config : await this.getGitConfig() const name = await git.currentBranch(cmd) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index aa06fb7840..8c48726c98 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -53,6 +53,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const params = queryParams.get() as UrlParametersType const workspaces = await getWorkspaces() || [] dispatch(setWorkspaces(workspaces)) + // console.log('workspaces: ', workspaces) if (params.gist) { await createWorkspaceTemplate('gist-sample', 'gist-template') plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false }) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index f12fcd4209..9d7a1c5b1e 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -54,25 +54,6 @@ export const createWorkspace = async (workspaceName: string, workspaceTemplateNa const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) dispatch(createWorkspaceRequest(promise)) promise.then(async () => { - if (isGitRepo) { - let branches = [] - let currentBranch = null - - try { - branches = await getGitRepoBranches(`${plugin.fileProviders.workspace.workspacesPath}/${workspaceName}`) - } catch (e) { - console.error(e) - } - try { - currentBranch = await getGitRepoCurrentBranch(`${plugin.fileProviders.workspace.workspacesPath}/${workspaceName}`) - } catch (e) { - console.error(e) - } - - dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo, branches, currentBranch })) - } else { - dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) - } dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) @@ -338,9 +319,9 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, }) } -export const getWorkspaces = async (): Promise<{name: string, isGitRepo: boolean}[]> | undefined => { +export const getWorkspaces = async (): Promise<{name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }[]> | undefined => { try { - const workspaces: {name: string, isGitRepo: boolean}[] = await new Promise((resolve, reject) => { + const workspaces: {name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string}[] = await new Promise((resolve, reject) => { const workspacesPath = plugin.fileProviders.workspace.workspacesPath plugin.fileProviders.browser.resolveDirectory('/' + workspacesPath, (error, items) => { @@ -350,25 +331,15 @@ export const getWorkspaces = async (): Promise<{name: string, isGitRepo: boolean Promise.all(Object.keys(items) .filter((item) => items[item].isDirectory) .map(async (folder) => { - console.log('folder: ', folder) const isGitRepo: boolean = await plugin.fileProviders.browser.exists('/' + folder + '/.git') if (isGitRepo) { let branches = [] let currentBranch = null - - try { - branches = await getGitRepoBranches(folder) - } catch (e) { - console.error(e) - } - try { - currentBranch = await getGitRepoCurrentBranch(folder) - } catch (e) { - console.error(e) - } + branches = await getGitRepoBranches(folder) console.log('branches: ', branches) + currentBranch = await getGitRepoCurrentBranch(folder) return { name: folder.replace(workspacesPath + '/', ''), diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index ba78892d51..e664984eca 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -136,6 +136,7 @@ export const browserReducer = (state = browserInitialState, action: Action) => { } case 'SET_WORKSPACES': { + console.log('called SET_WORKSPACES') const payload = action.payload as { name: string; isGitRepo: boolean; branches?: { remote: any; name: string; }[], currentBranch?: string }[] return { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index e953fcbaea..061279be0e 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -13,7 +13,7 @@ export function Workspace () { const LOCALHOST = ' - connect to localhost - ' const NO_WORKSPACE = ' - none - ' const [currentWorkspace, setCurrentWorkspace] = useState(NO_WORKSPACE) - const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) + const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }>(null) const [showDropdown, setShowDropdown] = useState(false) const [showIconsMenu, hideIconsMenu] = useState(false) const displayOzCustomRef = useRef() @@ -679,22 +679,31 @@ export function Workspace () { -
-
-
DGIT
-
- - - Main - - - - setup - - + { + selectedWorkspace && +
+
+
DGIT
+
+ + + { selectedWorkspace.currentBranch || '-none-'} + + + + { + (selectedWorkspace.branches || []).map((branch, index) => { + return ( + { selectedWorkspace.currentBranch === branch.name ? ✓ { branch.name } : { branch.name } } + ) + }) + } + + +
-
+ } ) }