mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Add version-history modal for nsite snapshots
Adds a History icon button next to the Deploy button (visible only when an nsite provider is selected). Opens NsiteVersionsDialog, which queries the configured relays for kind 5128 manifest snapshots authored by the logged-in user for the current site, listed newest-first with date and file count. Each row exposes an "open" link to `https://v<base36id>.<gateway>` (NIP-5A snapshot URL) and a delete action that publishes a NIP-09 kind 5 event scoped to the snapshot kind. Deletion is gated behind an AlertDialog confirm and removes the row optimistically. A new buildNsiteSnapshotUrl helper is added in lib/utils/nsite.ts, and the existing pubkeyToBase36 is renamed to hex32ToBase36 (its existing name is kept as a deprecated alias). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
1 parent
a588509ec6
commit
21e4da5fbe
3 files changed
+362
-33
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Rocket, ExternalLink, AlertCircle, Settings, Cloud } from 'lucide-react';
|
||||
import { Rocket, ExternalLink, AlertCircle, Settings, Cloud, History } from 'lucide-react';
|
||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -24,6 +24,7 @@ import { ShakespeareDeployForm } from '@/components/deploy/ShakespeareDeployForm
|
||||
import { NetlifyDeployForm } from '@/components/deploy/NetlifyDeployForm';
|
||||
import { VercelDeployForm } from '@/components/deploy/VercelDeployForm';
|
||||
import { NsiteSettingsDialog } from '@/components/deploy/NsiteSettingsDialog';
|
||||
import { NsiteVersionsDialog } from '@/components/deploy/NsiteVersionsDialog';
|
||||
import { CloudflareDeployForm } from '@/components/deploy/CloudflareDeployForm';
|
||||
import { DenoDeployForm } from '@/components/deploy/DenoDeployForm';
|
||||
import { RailwayDeployForm } from '@/components/deploy/RailwayDeployForm';
|
||||
@@ -177,6 +178,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
const [nsiteVfsConfig, setNsiteVfsConfig] = useState<NsiteVfsConfig | null>(null);
|
||||
const [nsiteVfsConfigLoading, setNsiteVfsConfigLoading] = useState(true);
|
||||
const [nsiteSettingsOpen, setNsiteSettingsOpen] = useState(false);
|
||||
const [nsiteVersionsOpen, setNsiteVersionsOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectId) {
|
||||
@@ -777,6 +779,17 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
/>
|
||||
)}
|
||||
|
||||
{nsiteVfsConfig && user && selectedProvider?.type === 'nsite' && (
|
||||
<NsiteVersionsDialog
|
||||
open={nsiteVersionsOpen}
|
||||
onOpenChange={setNsiteVersionsOpen}
|
||||
pubkey={user.pubkey}
|
||||
siteIdentifier={(nsiteVfsConfig.id != null && nsiteVfsConfig.id !== '') ? nsiteVfsConfig.id : undefined}
|
||||
gateway={selectedProvider.gateway}
|
||||
relayUrls={nsiteVfsConfig.relays}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<h3 className="font-semibold mb-1">Deploy your project</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
@@ -956,34 +969,49 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
)}
|
||||
|
||||
{selectedProvider && (
|
||||
<Button
|
||||
onClick={handleDeploy}
|
||||
disabled={
|
||||
isDeploying ||
|
||||
(selectedProvider.type === 'shakespeare' && !user) ||
|
||||
(selectedProvider.type === 'shakespeare' && !isShakespeareFormValid) ||
|
||||
(selectedProvider.type === 'nsite' && !user) ||
|
||||
(selectedProvider.type === 'nsite' && !nsiteVfsConfig) ||
|
||||
(selectedProvider.type === 'nsite' && (!nsiteVfsConfig?.relays?.length || !nsiteVfsConfig?.servers?.length)) ||
|
||||
(selectedProvider.type === 'netlify' && !netlifyForm.siteId && !netlifyForm.siteName) ||
|
||||
(selectedProvider.type === 'cloudflare' && !cloudflareForm.projectName) ||
|
||||
(selectedProvider.type === 'deno' && !denoDeployForm.projectName) ||
|
||||
(selectedProvider.type === 'railway' && !railwayForm.workspaceId)
|
||||
}
|
||||
className="w-full"
|
||||
>
|
||||
{isDeploying ? (
|
||||
<>
|
||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||
Deploying...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Rocket className="h-4 w-4 mr-2" />
|
||||
Deploy
|
||||
</>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={handleDeploy}
|
||||
disabled={
|
||||
isDeploying ||
|
||||
(selectedProvider.type === 'shakespeare' && !user) ||
|
||||
(selectedProvider.type === 'shakespeare' && !isShakespeareFormValid) ||
|
||||
(selectedProvider.type === 'nsite' && !user) ||
|
||||
(selectedProvider.type === 'nsite' && !nsiteVfsConfig) ||
|
||||
(selectedProvider.type === 'nsite' && (!nsiteVfsConfig?.relays?.length || !nsiteVfsConfig?.servers?.length)) ||
|
||||
(selectedProvider.type === 'netlify' && !netlifyForm.siteId && !netlifyForm.siteName) ||
|
||||
(selectedProvider.type === 'cloudflare' && !cloudflareForm.projectName) ||
|
||||
(selectedProvider.type === 'deno' && !denoDeployForm.projectName) ||
|
||||
(selectedProvider.type === 'railway' && !railwayForm.workspaceId)
|
||||
}
|
||||
className="flex-1"
|
||||
>
|
||||
{isDeploying ? (
|
||||
<>
|
||||
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||
Deploying...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Rocket className="h-4 w-4 mr-2" />
|
||||
Deploy
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{selectedProvider.type === 'nsite' && nsiteVfsConfig && user && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => setNsiteVersionsOpen(true)}
|
||||
title="Version history"
|
||||
aria-label="Version history"
|
||||
>
|
||||
<History className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user