Skip to content

Commit 67f4843

Browse files
joeizangAniket-Engg
authored andcommitted
add localhost check
1 parent be42165 commit 67f4843

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, Dispatch } from 'react'
1+
import React, { useEffect, Dispatch, useState } from 'react'
22
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
33
import { StatusBar } from 'apps/remix-ide/src/app/components/status-bar'
44
import '../../css/statusbar.css'
@@ -11,10 +11,12 @@ export interface GitStatusProps {
1111
}
1212

1313
export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: GitStatusProps) {
14+
const [isLocalHost, setIsLocalHost] = useState(false)
1415

1516
useEffect(() => {
1617
plugin.on('filePanel', 'setWorkspace', async (workspace) => {
1718
const isGit = await plugin.call('fileManager', 'isGitRepo')
19+
setIsLocalHost(workspace.isLocalhost)
1820
if (isGit) {
1921
setGitBranchName(workspace.name)
2022
} else {
@@ -23,6 +25,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
2325
})
2426
plugin.on('filePanel', 'workspaceInitializationCompleted', async () => {
2527
const isGit = await plugin.call('fileManager', 'isGitRepo')
28+
console.log('complete', gitBranchName)
2629
if (isGit) {
2730
const workspace = localStorage.getItem('currentWorkspace')
2831
setGitBranchName(workspace)
@@ -37,6 +40,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
3740
setGitBranchName(workspace)
3841
}
3942
})
43+
4044
}, [])
4145

4246
const lightDgitUp = async () => {
@@ -51,9 +55,14 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
5155
const initializeNewGitRepo = async () => {
5256
await plugin.call('dGitProvider', 'init')
5357
const isActive = await plugin.call('manager', 'isActive', 'dgit')
54-
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
58+
if (isLocalHost === false) {
59+
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
60+
}
5561
}
5662

63+
const checkBranchName = ()=> {
64+
return gitBranchName && gitBranchName !== 'Not a git repo' && gitBranchName.length > 0
65+
}
5766
return (
5867
<CustomTooltip
5968
tooltipText={`${gitBranchName === 'Not a git repo' ? 'Initialize as a git repo' : gitBranchName} (Git)`}
@@ -62,10 +71,10 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
6271
className="d-flex flex-row pl-3 text-white justify-content-center align-items-center remixui_statusbar_gitstatus"
6372
onClick={async () => await lightDgitUp()}
6473
>
65-
{gitBranchName && gitBranchName !== 'Not a git repo' && gitBranchName.length > 0 ? <span className="fa-regular fa-code-branch ml-1"></span>
74+
{checkBranchName() && isLocalHost === false ? <span className="fa-regular fa-code-branch ml-1"></span>
6675
: <span className=" ml-1" onClick={initializeNewGitRepo}> Initialize as git repo</span>}
67-
{gitBranchName && gitBranchName !== 'Not a git repo' && gitBranchName.length > 0 && <span className="ml-1">{gitBranchName}</span>}
68-
{gitBranchName && gitBranchName !== 'Not a git repo' && gitBranchName.length > 0 && <span className="fa-solid fa-arrows-rotate fa-1 ml-1"></span>}
76+
{checkBranchName() && isLocalHost === false && <span className="ml-1">{gitBranchName}</span>}
77+
{checkBranchName() && isLocalHost === false && <span className="fa-solid fa-arrows-rotate fa-1 ml-1"></span>}
6978
</div>
7079
</CustomTooltip>
7180
)

0 commit comments

Comments
 (0)