mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Add "Copy Edit with Shakespeare URL" button to repository section
- Added Copy icon import from lucide-react - Created handleCopyShakespeareURL function that: - Validates that a repository URL exists - Encodes the URL and formats it as a Shakespeare clone URL - Copies the formatted URL to clipboard - Shows success/error toast notifications - Added button below Git URL input that appears when URL is present - Button copies the properly formatted Shakespeare clone URL (https://shakespeare.diy/clone?url=...) - Works with GitHub, GitLab, NostrGit, and any other git repository URL
This commit is contained in:
1 parent
33a1747a65
commit
cab7d62b2e
1 file changed
+42
@@ -46,6 +46,7 @@ import {
|
||||
Settings2,
|
||||
GitPullRequest,
|
||||
ExternalLink,
|
||||
Copy,
|
||||
} from 'lucide-react';
|
||||
import { useGitStatus } from '@/hooks/useGitStatus';
|
||||
import { useGitSettings } from '@/hooks/useGitSettings';
|
||||
@@ -683,6 +684,34 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
||||
const [isGitManagementOpen, setIsGitManagementOpen] = useState(false);
|
||||
const [gitManagementDefaultTab, setGitManagementDefaultTab] = useState<string>('branches');
|
||||
|
||||
const handleCopyShakespeareURL = () => {
|
||||
if (!originUrl.trim()) {
|
||||
toast({
|
||||
title: "No repository URL",
|
||||
description: "Please enter a Git URL first",
|
||||
variant: "destructive",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the Shakespeare clone URL by encoding the origin URL
|
||||
const shakespeareURL = `https://shakespeare.diy/clone?url=${encodeURIComponent(originUrl.trim())}`;
|
||||
|
||||
// Copy to clipboard
|
||||
navigator.clipboard.writeText(shakespeareURL).then(() => {
|
||||
toast({
|
||||
title: "Copied to clipboard",
|
||||
description: "Edit with Shakespeare URL copied",
|
||||
});
|
||||
}).catch(() => {
|
||||
toast({
|
||||
title: "Failed to copy",
|
||||
description: "Could not copy to clipboard",
|
||||
variant: "destructive",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
@@ -752,6 +781,19 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Copy Shakespeare URL Button */}
|
||||
{originUrl.trim() && (
|
||||
<Button
|
||||
onClick={handleCopyShakespeareURL}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="w-full h-8 text-xs gap-2"
|
||||
>
|
||||
<Copy className="h-3 w-3" />
|
||||
Copy "Edit with Shakespeare" URL
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Credentials Warning */}
|
||||
{gitStatus.remotes.length > 0 && (
|
||||
(() => {
|
||||
|
||||
Reference in new issue
Block a user