mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Don't close GitSync menu after success
This commit is contained in:
1 file changed
+21
-28
@@ -38,7 +38,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||||
const [copiedUrl, setCopiedUrl] = useState(false);
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
||||||
|
|
||||||
const { data: gitStatus, isLoading: isGitStatusLoading } = useGitStatus(projectId);
|
const { data: gitStatus, isLoading: isGitStatusLoading, refetch: refetchGitStatus } = useGitStatus(projectId);
|
||||||
const { settings } = useGitSettings();
|
const { settings } = useGitSettings();
|
||||||
const { user } = useCurrentUser();
|
const { user } = useCurrentUser();
|
||||||
const { git } = useGit();
|
const { git } = useGit();
|
||||||
@@ -56,6 +56,16 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
// Determine if we need to show the indicator dot
|
// Determine if we need to show the indicator dot
|
||||||
const showIndicator = !isGitStatusLoading && !hasRemote;
|
const showIndicator = !isGitStatusLoading && !hasRemote;
|
||||||
|
|
||||||
|
// Auto-reset success state after 2 seconds
|
||||||
|
useEffect(() => {
|
||||||
|
if (syncState === 'success') {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setSyncState('default');
|
||||||
|
}, 2000);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}
|
||||||
|
}, [syncState])
|
||||||
|
|
||||||
// Reset state when popover opens/closes
|
// Reset state when popover opens/closes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
@@ -121,7 +131,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
setSyncState('configure-repo');
|
setSyncState('configure-repo');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePush = async () => {
|
const handlePushInitial = async () => {
|
||||||
if (!selectedProvider) return;
|
if (!selectedProvider) return;
|
||||||
|
|
||||||
setIsPushing(true);
|
setIsPushing(true);
|
||||||
@@ -142,8 +152,6 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
remote: 'origin',
|
remote: 'origin',
|
||||||
url: nostrUri,
|
url: nostrUri,
|
||||||
});
|
});
|
||||||
|
|
||||||
setSyncState('success');
|
|
||||||
} else {
|
} else {
|
||||||
// Validate repository URL
|
// Validate repository URL
|
||||||
if (!repositoryUrl.trim()) {
|
if (!repositoryUrl.trim()) {
|
||||||
@@ -173,15 +181,12 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
setSyncState('success');
|
|
||||||
|
|
||||||
// Auto-dismiss after 2 seconds
|
|
||||||
setTimeout(() => {
|
|
||||||
setOpen(false);
|
|
||||||
setSyncState('default');
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh git status before showing success
|
||||||
|
await refetchGitStatus();
|
||||||
|
// Display success state
|
||||||
|
setSyncState('success');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : 'Failed to push';
|
const message = error instanceof Error ? error.message : 'Failed to push';
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
@@ -216,12 +221,6 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setSyncState('success');
|
setSyncState('success');
|
||||||
|
|
||||||
// Auto-dismiss after 2 seconds
|
|
||||||
setTimeout(() => {
|
|
||||||
setOpen(false);
|
|
||||||
setSyncState('default');
|
|
||||||
}, 2000);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : 'Failed to pull';
|
const message = error instanceof Error ? error.message : 'Failed to pull';
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
@@ -231,7 +230,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePushConfigured = async () => {
|
const handlePush = async () => {
|
||||||
if (!originRemote) return;
|
if (!originRemote) return;
|
||||||
|
|
||||||
setIsPushing(true);
|
setIsPushing(true);
|
||||||
@@ -256,12 +255,6 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setSyncState('success');
|
setSyncState('success');
|
||||||
|
|
||||||
// Auto-dismiss after 2 seconds
|
|
||||||
setTimeout(() => {
|
|
||||||
setOpen(false);
|
|
||||||
setSyncState('default');
|
|
||||||
}, 2000);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : 'Failed to push';
|
const message = error instanceof Error ? error.message : 'Failed to push';
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
@@ -370,7 +363,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePushConfigured}
|
onClick={handlePush}
|
||||||
disabled={isPushing}
|
disabled={isPushing}
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
>
|
>
|
||||||
@@ -518,7 +511,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePush}
|
onClick={handlePushInitial}
|
||||||
disabled={isPushing}
|
disabled={isPushing}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
@@ -563,7 +556,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePush}
|
onClick={handlePushInitial}
|
||||||
disabled={isPushing || !repositoryUrl.trim()}
|
disabled={isPushing || !repositoryUrl.trim()}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user