Skip to content
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
38 changes: 29 additions & 9 deletions apps/geolibre-desktop/src/components/layout/ShareProjectDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ export function ShareProjectDialog({
const [error, setError] = useState<string | null>(null);
const [errorCode, setErrorCode] = useState<ShareUploadErrorCode | null>(null);
const [result, setResult] = useState<ShareUploadResult | null>(null);
const [copied, setCopied] = useState(false);
// Which copy button last succeeded: "result" for the post-create view, else a
// share id. One slot so only the clicked button shows the checkmark.
const [copiedKey, setCopiedKey] = useState<string | null>(null);
const [redactedCount, setRedactedCount] = useState(0);
const [readiness, setReadiness] = useState<ShareReadinessReport | null>(null);
const [readinessState, setReadinessState] = useState<"idle" | "checking" | "failed">("idle");
Expand Down Expand Up @@ -413,7 +415,7 @@ export function ShareProjectDialog({
setError(null);
setErrorCode(null);
setResult(null);
setCopied(false);
setCopiedKey(null);
setRedactedCount(0);
setOauthError(null);
setTab("create");
Expand Down Expand Up @@ -660,7 +662,7 @@ export function ShareProjectDialog({
openSettingsSection("environment", { focus: "shareToken" });
};

const handleCopy = (url?: string) => {
const handleCopy = (key: string, url?: string) => {
const targetUrl = url || result?.projectUrl;
if (!targetUrl) return;
// Only show the "copied" checkmark if the write actually succeeds; the
Expand All @@ -672,8 +674,8 @@ export function ShareProjectDialog({
if (copyTimeoutRef.current !== null) {
window.clearTimeout(copyTimeoutRef.current);
}
setCopied(true);
copyTimeoutRef.current = window.setTimeout(() => setCopied(false), 2000);
setCopiedKey(key);
copyTimeoutRef.current = window.setTimeout(() => setCopiedKey(null), 2000);
})
.catch(() => {
// Clipboard unavailable; leave the icon unchanged.
Expand Down Expand Up @@ -805,9 +807,13 @@ export function ShareProjectDialog({
type="button"
variant="secondary"
aria-label={t("share.copyLink")}
onClick={() => handleCopy()}
onClick={() => handleCopy("result")}
>
{copied ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
{copiedKey === "result" ? (
<Check className="h-3.5 w-3.5" />
) : (
<Copy className="h-3.5 w-3.5" />
)}
</Button>
</div>
<div className="flex justify-end gap-2">
Expand Down Expand Up @@ -1233,9 +1239,23 @@ export function ShareProjectDialog({
size="sm"
aria-label={t("share.copyLink")}
title={t("share.copyLink")}
onClick={() => handleCopy(s.projectUrl)}
onClick={() => handleCopy(s.id, s.projectUrl)}
>
{copiedKey === s.id ? (
<Check className="h-3.5 w-3.5" />
) : (
<Copy className="h-3.5 w-3.5" />
)}
</Button>
<Button
type="button"
variant="secondary"
size="sm"
aria-label={t("share.open")}
title={t("share.open")}
onClick={() => void openExternalLink(s.projectUrl)}
>
<Copy className="h-3.5 w-3.5" />
<ExternalLink className="h-3.5 w-3.5" />
</Button>
<Button
type="button"
Expand Down
Loading