Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statusbar git section fix #4930

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions libs/remix-ui/statusbar/src/lib/components/gitStatus.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand All @@ -37,6 +39,7 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
setGitBranchName(workspace)
}
})

}, [])

const lightDgitUp = async () => {
Expand All @@ -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 (
<CustomTooltip
tooltipText={`${gitBranchName === 'Not a git repo' ? 'Initialize as a git repo' : gitBranchName} (Git)`}
Expand All @@ -63,10 +70,10 @@ export default function GitStatus({ plugin, gitBranchName, setGitBranchName }: G
className="d-flex flex-row pl-3 text-white justify-content-center align-items-center remixui_statusbar_gitstatus"
onClick={async () => await lightDgitUp()}
>
{gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' ? <span className="fa-regular fa-code-branch ml-1"></span>
{checkBranchName() && isLocalHost === false ? <span className="fa-regular fa-code-branch ml-1"></span>
: <span className=" ml-1" onClick={initializeNewGitRepo}> Initialize as git repo</span>}
{gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' && <span className="ml-1">{gitBranchName}</span>}
{gitBranchName.length > 0 && gitBranchName !== 'Not a git repo' && <span className="fa-solid fa-arrows-rotate fa-1 ml-1"></span>}
{checkBranchName() && isLocalHost === false && <span className="ml-1">{gitBranchName}</span>}
{checkBranchName() && isLocalHost === false && <span className="fa-solid fa-arrows-rotate fa-1 ml-1"></span>}
</div>
</CustomTooltip>
)
Expand Down
Loading