mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Remove root site option from nsite deploy form, always use named sites
This commit is contained in:
4 files changed
+14
-124
No files matched your search
@@ -108,7 +108,6 @@ interface NsiteFormData {
|
||||
siteTitle: string;
|
||||
siteDescription: string;
|
||||
dTag: string;
|
||||
siteType: 'named' | 'root';
|
||||
}
|
||||
|
||||
interface NetlifyFormData {
|
||||
@@ -174,12 +173,10 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
// If a config already exists, seed the form from it and stay in summary mode.
|
||||
// If not, show the full form so the user can configure for the first time.
|
||||
if (cfg) {
|
||||
const derivedSiteType = cfg.id === null ? 'root' : 'named';
|
||||
setNsiteForm({
|
||||
siteTitle: cfg.title ?? '',
|
||||
siteDescription: cfg.description ?? '',
|
||||
dTag: (cfg.id != null && cfg.id !== '') ? cfg.id : '',
|
||||
siteType: derivedSiteType,
|
||||
});
|
||||
setNsiteShowFullForm(false);
|
||||
} else {
|
||||
@@ -197,7 +194,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteTitle: '',
|
||||
siteDescription: '',
|
||||
dTag: '',
|
||||
siteType: 'named',
|
||||
});
|
||||
const [netlifyForm, setNetlifyForm] = useState<NetlifyFormData>({
|
||||
siteId: '',
|
||||
@@ -283,9 +279,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteTitle: nsiteForm.siteTitle || undefined,
|
||||
siteDescription: nsiteForm.siteDescription || undefined,
|
||||
sourceUrl,
|
||||
siteIdentifier: nsiteForm.siteType === 'named' && nsiteForm.dTag
|
||||
? nsiteForm.dTag
|
||||
: undefined,
|
||||
siteIdentifier: nsiteForm.dTag || undefined,
|
||||
});
|
||||
} else if (selectedProvider.type === 'netlify') {
|
||||
const netlifyProvider = selectedProvider;
|
||||
@@ -397,7 +391,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteTitle: nsiteForm.siteTitle || undefined,
|
||||
siteDescription: nsiteForm.siteDescription || undefined,
|
||||
dTag: nsiteForm.dTag || undefined,
|
||||
siteType: nsiteForm.siteType,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -407,7 +400,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
const newNsiteVfsConfig: NsiteVfsConfig = {
|
||||
relays: nsiteProvider.relayUrls,
|
||||
servers: nsiteProvider.blossomServers,
|
||||
id: nsiteForm.siteType === 'root' ? null : (nsiteForm.dTag || undefined),
|
||||
id: nsiteForm.dTag || undefined,
|
||||
title: nsiteForm.siteTitle || undefined,
|
||||
description: nsiteForm.siteDescription || undefined,
|
||||
fallback: '/index.html',
|
||||
@@ -524,7 +517,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
setError(null);
|
||||
// Reset forms
|
||||
setShakespeareForm({ subdomain: projectId });
|
||||
setNsiteForm({ siteTitle: '', siteDescription: '', dTag: '', siteType: 'named' });
|
||||
setNsiteForm({ siteTitle: '', siteDescription: '', dTag: '' });
|
||||
setNetlifyForm({ siteId: '', siteName: '' });
|
||||
setVercelForm({ projectName: projectName || projectId, teamId: '' });
|
||||
setCloudflareForm({ projectName: projectName || projectId });
|
||||
@@ -556,10 +549,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
setNsiteForm(prev => ({ ...prev, siteDescription }));
|
||||
}, []);
|
||||
|
||||
const handleNsiteSiteTypeChange = useCallback((siteType: 'named' | 'root') => {
|
||||
setNsiteForm(prev => ({ ...prev, siteType }));
|
||||
}, []);
|
||||
|
||||
const handleNetlifySiteChange = useCallback((siteId: string, siteName: string) => {
|
||||
setNetlifyForm({ siteId, siteName });
|
||||
}, []);
|
||||
@@ -611,12 +600,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
|
||||
// Summary view: shown when .nsite/config.json already exists and user hasn't clicked Edit
|
||||
if (nsiteVfsConfig && !nsiteShowFullForm) {
|
||||
const isRoot = nsiteVfsConfig.id === null;
|
||||
const siteLabel = isRoot
|
||||
? 'Root site'
|
||||
: nsiteVfsConfig.id
|
||||
? `Named site: ${nsiteVfsConfig.id}`
|
||||
: 'Named site';
|
||||
const relayCount = nsiteVfsConfig.relays?.length ?? 0;
|
||||
const serverCount = nsiteVfsConfig.servers?.length ?? 0;
|
||||
|
||||
@@ -629,10 +612,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
<span className="font-medium">{nsiteVfsConfig.title}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between">
|
||||
<span className="text-muted-foreground">Type</span>
|
||||
<span className="font-medium">{siteLabel}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-muted-foreground">Relays</span>
|
||||
<span className="font-medium">{relayCount} configured</span>
|
||||
@@ -660,9 +639,6 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
// .nsite/config.json wins; .git/shakespeare/deploy.json is the legacy fallback
|
||||
const savedSiteTitle = nsiteVfsConfig?.title ?? legacy?.siteTitle;
|
||||
const savedSiteDescription = nsiteVfsConfig?.description ?? legacy?.siteDescription;
|
||||
const savedSiteType = nsiteVfsConfig
|
||||
? (nsiteVfsConfig.id === null ? 'root' : 'named')
|
||||
: legacy?.siteType;
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
@@ -672,10 +648,8 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
savedNsec={legacy?.nsec}
|
||||
savedSiteTitle={savedSiteTitle}
|
||||
savedSiteDescription={savedSiteDescription}
|
||||
savedSiteType={savedSiteType}
|
||||
onSiteTitleChange={handleNsiteSiteTitleChange}
|
||||
onSiteDescriptionChange={handleNsiteSiteDescriptionChange}
|
||||
onSiteTypeChange={handleNsiteSiteTypeChange}
|
||||
/>
|
||||
{nsiteVfsConfig && (
|
||||
<button
|
||||
@@ -977,7 +951,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
(selectedProvider.type === 'shakespeare' && !user) ||
|
||||
(selectedProvider.type === 'shakespeare' && !isShakespeareFormValid) ||
|
||||
(selectedProvider.type === 'nsite' && !user) ||
|
||||
(selectedProvider.type === 'nsite' && nsiteForm.siteType === 'named' && !nsiteForm.dTag) ||
|
||||
(selectedProvider.type === 'nsite' && !nsiteForm.dTag) ||
|
||||
(selectedProvider.type === 'netlify' && !netlifyForm.siteId && !netlifyForm.siteName) ||
|
||||
(selectedProvider.type === 'cloudflare' && !cloudflareForm.projectName) ||
|
||||
(selectedProvider.type === 'deno' && !denoDeployForm.projectName) ||
|
||||
|
||||
@@ -1,39 +1,31 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { AlertCircle, Globe, Tag } from 'lucide-react';
|
||||
import { AlertCircle } from 'lucide-react';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
|
||||
|
||||
interface NsiteDeployFormProps {
|
||||
/** Human-readable project name — used to default the title for named sites */
|
||||
/** Human-readable project name — used to default the title */
|
||||
projectName: string;
|
||||
/** Persisted values from a previous deployment */
|
||||
savedSiteTitle?: string;
|
||||
savedSiteDescription?: string;
|
||||
savedSiteType?: 'named' | 'root';
|
||||
/** Present only when the project was previously deployed with a dedicated keypair (v1) */
|
||||
savedNsec?: string;
|
||||
onSiteTitleChange: (title: string) => void;
|
||||
onSiteDescriptionChange: (description: string) => void;
|
||||
onSiteTypeChange: (type: 'named' | 'root') => void;
|
||||
}
|
||||
|
||||
export function NsiteDeployForm({
|
||||
projectName,
|
||||
savedSiteTitle,
|
||||
savedSiteDescription,
|
||||
savedSiteType,
|
||||
savedNsec,
|
||||
onSiteTitleChange,
|
||||
onSiteDescriptionChange,
|
||||
onSiteTypeChange,
|
||||
}: NsiteDeployFormProps) {
|
||||
const [siteType, setSiteType] = useState<'named' | 'root'>(savedSiteType ?? 'named');
|
||||
const [siteTitle, setSiteTitle] = useState(
|
||||
savedSiteTitle ?? (savedSiteType === 'root' ? '' : projectName),
|
||||
);
|
||||
const [siteTitle, setSiteTitle] = useState(savedSiteTitle ?? projectName);
|
||||
const [siteDescription, setSiteDescription] = useState(savedSiteDescription ?? '');
|
||||
|
||||
// On mount: sync all saved values to parent and set defaults.
|
||||
@@ -44,40 +36,17 @@ export function NsiteDeployForm({
|
||||
if (initializedRef.current) return;
|
||||
initializedRef.current = true;
|
||||
|
||||
if (savedSiteType) onSiteTypeChange(savedSiteType);
|
||||
if (savedSiteDescription) onSiteDescriptionChange(savedSiteDescription);
|
||||
|
||||
const initialTitle = savedSiteTitle ?? (siteType === 'named' ? projectName : '');
|
||||
const initialTitle = savedSiteTitle ?? projectName;
|
||||
if (initialTitle !== siteTitle) setSiteTitle(initialTitle);
|
||||
onSiteTitleChange(initialTitle);
|
||||
}, [savedSiteType, savedSiteDescription, savedSiteTitle, siteType, siteTitle, projectName, onSiteTypeChange, onSiteDescriptionChange, onSiteTitleChange]);
|
||||
}, [savedSiteDescription, savedSiteTitle, siteTitle, projectName, onSiteDescriptionChange, onSiteTitleChange]);
|
||||
|
||||
useEffect(() => {
|
||||
stableSyncToParent();
|
||||
}, [stableSyncToParent]);
|
||||
|
||||
// When the user switches site type, update the title default only if
|
||||
// the current title still matches the previous type's auto-fill value.
|
||||
const prevSiteTypeRef = useRef(siteType);
|
||||
useEffect(() => {
|
||||
const prev = prevSiteTypeRef.current;
|
||||
prevSiteTypeRef.current = siteType;
|
||||
if (prev === siteType) return;
|
||||
|
||||
if (siteType === 'named' && siteTitle === '') {
|
||||
setSiteTitle(projectName);
|
||||
onSiteTitleChange(projectName);
|
||||
} else if (siteType === 'root' && siteTitle === projectName) {
|
||||
setSiteTitle('');
|
||||
onSiteTitleChange('');
|
||||
}
|
||||
}, [siteType, siteTitle, projectName, onSiteTitleChange]);
|
||||
|
||||
const handleSiteTypeChange = (value: 'named' | 'root') => {
|
||||
setSiteType(value);
|
||||
onSiteTypeChange(value);
|
||||
};
|
||||
|
||||
const handleSiteTitleChange = (value: string) => {
|
||||
setSiteTitle(value);
|
||||
onSiteTitleChange(value);
|
||||
@@ -103,52 +72,6 @@ export function NsiteDeployForm({
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* Site type */}
|
||||
<div className="space-y-2">
|
||||
<Label>Site Type</Label>
|
||||
<RadioGroup
|
||||
value={siteType}
|
||||
onValueChange={handleSiteTypeChange}
|
||||
className="space-y-2"
|
||||
>
|
||||
<div className="flex items-start gap-3 p-3 rounded-md border cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<RadioGroupItem value="named" id="nsite-type-named" className="mt-0.5" />
|
||||
<label htmlFor="nsite-type-named" className="flex-1 cursor-pointer">
|
||||
<div className="flex items-center gap-2 font-medium text-sm">
|
||||
<Tag className="h-3.5 w-3.5" />
|
||||
Named site
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
A site with a unique identifier. You can have many named sites.
|
||||
</p>
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-start gap-3 p-3 rounded-md border cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<RadioGroupItem value="root" id="nsite-type-root" className="mt-0.5" />
|
||||
<label htmlFor="nsite-type-root" className="flex-1 cursor-pointer">
|
||||
<div className="flex items-center gap-2 font-medium text-sm">
|
||||
<Globe className="h-3.5 w-3.5" />
|
||||
Root site
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
Your personal site at your npub address. You can only have one.
|
||||
</p>
|
||||
</label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
{/* Root site warning */}
|
||||
{siteType === 'root' && (
|
||||
<Alert>
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertDescription>
|
||||
You only have one root site per Nostr identity. Deploying here will replace any
|
||||
existing root site published under your key.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* Site title */}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="nsite-title">Site Title</Label>
|
||||
|
||||
@@ -15,14 +15,13 @@ const nsiteProjectConfigSchema = z.object({
|
||||
type: z.literal('nsite'),
|
||||
url: z.string(),
|
||||
data: z.object({
|
||||
/** Kept optional — only present on configs created before the signer migration */
|
||||
/** Kept optional — only present on configs created before the signer migration */
|
||||
nsec: z.string().optional(),
|
||||
siteTitle: z.string().optional(),
|
||||
siteDescription: z.string().optional(),
|
||||
/** Named-site dTag identifier (kind 35128). Absent → root site (kind 15128). */
|
||||
/** Named-site dTag identifier (kind 35128). */
|
||||
dTag: z.string().optional(),
|
||||
/** 'named' | 'root'. Absent on legacy configs — treated as 'named' by the form. */
|
||||
/** @deprecated — Shakespeare always deploys named sites now. Kept for backward compat. */
|
||||
siteType: z.enum(['named', 'root']).optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
+3
-9
@@ -98,18 +98,12 @@ export async function buildAppEvent(
|
||||
}
|
||||
}
|
||||
|
||||
// If an nsite deployment exists, add an "a" tag referencing the site manifest event
|
||||
// If an nsite deployment exists, add an "a" tag referencing the kind 35128 site manifest event
|
||||
if (opts?.fs && opts.cwd && opts.pubkey) {
|
||||
try {
|
||||
const nsiteConfig = await readNsiteVfsConfig(opts.fs, opts.cwd);
|
||||
if (nsiteConfig) {
|
||||
if (nsiteConfig.id) {
|
||||
// Named site: kind 35128 addressable event
|
||||
tags.push(['a', `35128:${opts.pubkey}:${nsiteConfig.id}`]);
|
||||
} else {
|
||||
// Root site: kind 15128 replaceable event
|
||||
tags.push(['a', `15128:${opts.pubkey}:`]);
|
||||
}
|
||||
if (nsiteConfig?.id) {
|
||||
tags.push(['a', `35128:${opts.pubkey}:${nsiteConfig.id}`]);
|
||||
}
|
||||
} catch {
|
||||
// No nsite config found, skip
|
||||
|
||||
Reference in new issue
Block a user