diff --git a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx index fa93315167c..07c299c1323 100644 --- a/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx +++ b/libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, Dispatch } from 'react' +import React, { useEffect, Dispatch, useState } from 'react' // eslint-disable-next-line @nrwl/nx/enforce-module-boundaries import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar' import '../../css/statusbar.css' @@ -11,10 +11,12 @@ export interface GitStatusProps { } export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: GitStatusProps) { + const [isLocalHost, setIsLocalHost] = useState(false) useEffect(() => { plugin.on('filePanel', 'setWorkspace', async (workspace) => { const isGit = await plugin.call('fileManager', 'isGitRepo') + setIsLocalHost(workspace.isLocalhost) if (isGit) { setGitBranchName(workspace.name) } else { @@ -37,6 +39,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G setGitBranchName(workspace) } }) + }, []) const lightDgitUp = async () => { @@ -51,10 +54,14 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G const initializeNewGitRepo = async () => { await plugin.call('dGitProvider', 'init') const isActive = await plugin.call('manager', 'isActive', 'dgit') - if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') - // plugin.verticalIcons.select('dgit') + if (isLocalHost === false) { + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') + } } + const checkBranchName = ()=> { + return gitBranchName && gitBranchName !== 'Not a git repo' && gitBranchName.length > 0 + } return ( await lightDgitUp()} > - {gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' ? + {checkBranchName() && isLocalHost === false ? : Initialize as git repo} - {gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' && {gitBranchName}} - {gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' && } + {checkBranchName() && isLocalHost === false && {gitBranchName}} + {checkBranchName() && isLocalHost === false && } )