mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Display dot indicator where there are unsynced changes
This commit is contained in:
2 files changed
+37
-3
No files matched your search
@@ -20,9 +20,14 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
||||
const originRemote = gitStatus?.remotes.find(r => r.name === 'origin');
|
||||
const hasRemote = !!originRemote;
|
||||
|
||||
// Check for unsynced changes (ahead or behind remote)
|
||||
const hasUnsyncedChanges = !isGitStatusLoading && hasRemote && gitStatus?.remoteBranchExists && ((gitStatus?.ahead ?? 0) > 0 || (gitStatus?.behind ?? 0) > 0);
|
||||
|
||||
// Determine if we need to show the indicator dot
|
||||
// Show indicator if no origin remote is configured, UNLESS there are less than 2 commits
|
||||
const showIndicator = !isGitStatusLoading && !hasRemote && (gitStatus?.totalCommits ?? 0) >= 2;
|
||||
// Yellow indicator for unsynced changes takes precedence
|
||||
// Purple indicator if no origin remote is configured, UNLESS there are less than 2 commits
|
||||
const showYellowIndicator = hasUnsyncedChanges;
|
||||
const showPurpleIndicator = !isGitStatusLoading && !hasRemote && (gitStatus?.totalCommits ?? 0) >= 2 && !showYellowIndicator;
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
@@ -34,7 +39,10 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
||||
aria-label="Sync with Git"
|
||||
>
|
||||
<CloudUpload className={cn("size-5 group-hover:text-foreground", open ? "text-foreground" : "text-muted-foreground")} />
|
||||
{showIndicator && (
|
||||
{showYellowIndicator && (
|
||||
<span className="absolute top-1 right-1 h-2 w-2 rounded-full bg-yellow-500" />
|
||||
)}
|
||||
{showPurpleIndicator && (
|
||||
<span className="absolute top-1 right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
|
||||
@@ -314,6 +314,32 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Unsynced changes notification */}
|
||||
{gitStatus?.remoteBranchExists && ((gitStatus?.ahead ?? 0) > 0 || (gitStatus?.behind ?? 0) > 0) && !error && (
|
||||
<div className="rounded-md bg-yellow-500/10 border border-yellow-500/20 p-3">
|
||||
<div className="flex items-start gap-2">
|
||||
<div className="h-2 w-2 rounded-full bg-yellow-500 shrink-0 mt-1.5" />
|
||||
<div className="flex-1">
|
||||
<p className="text-sm text-yellow-900 dark:text-yellow-100">
|
||||
This branch is{' '}
|
||||
{(gitStatus?.ahead ?? 0) > 0 && (
|
||||
<>
|
||||
<span className="font-medium">{gitStatus.ahead} commit{gitStatus.ahead !== 1 ? 's' : ''} ahead of</span>
|
||||
{(gitStatus?.behind ?? 0) > 0 ? ' and ' : ' '}
|
||||
</>
|
||||
)}
|
||||
{(gitStatus?.behind ?? 0) > 0 && (
|
||||
<>
|
||||
<span className="font-medium">{gitStatus.behind} commit{gitStatus.behind !== 1 ? 's' : ''} behind</span>{' '}
|
||||
</>
|
||||
)}
|
||||
<span className="font-medium">{ref}</span> on {remoteName}.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="rounded-md bg-primary">
|
||||
<div className="flex">
|
||||
<Button
|
||||
|
||||
Reference in new issue
Block a user