@kidecms/core 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,15 +34,14 @@ export default function InternalLinkPicker({
|
|
|
34
34
|
}, [editHref, linkOptions]);
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
|
-
<div className="min-w-0 flex-
|
|
37
|
+
<div className="min-w-0 flex-1">
|
|
38
38
|
<Popover open={open} onOpenChange={setOpen}>
|
|
39
39
|
<PopoverTrigger asChild>
|
|
40
40
|
<Button
|
|
41
41
|
variant="input"
|
|
42
42
|
role="combobox"
|
|
43
43
|
aria-expanded={open}
|
|
44
|
-
|
|
45
|
-
className="bg-background w-full justify-between text-sm font-normal"
|
|
44
|
+
className="h-9 w-full min-w-0 justify-between rounded-lg px-3 text-sm font-normal"
|
|
46
45
|
>
|
|
47
46
|
<span className={cn("truncate", !selectedLabel && "text-muted-foreground")}>
|
|
48
47
|
{selectedLabel || "Search documents..."}
|
|
@@ -8,10 +8,12 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa
|
|
|
8
8
|
import InternalLinkPicker, { type LinkOptionGroup } from "./InternalLinkPicker";
|
|
9
9
|
|
|
10
10
|
// A structured link control: URL + label + open-in-new-tab, stored as
|
|
11
|
-
// { type, url, label, newTab }. A leading "/" is treated as an internal
|
|
12
|
-
// When linkOptions are provided, internal links are chosen with a document
|
|
11
|
+
// { type, url, label, title, newTab }. A leading "/" is treated as an internal
|
|
12
|
+
// link. When linkOptions are provided, internal links are chosen with a document
|
|
13
13
|
// picker instead of a hand-typed path (which silently breaks on slug edits).
|
|
14
|
-
|
|
14
|
+
// `title` is the picked document's title — renderers use it as the link text
|
|
15
|
+
// when `label` is left empty.
|
|
16
|
+
type LinkValue = { type?: string; url?: string; label?: string; title?: string; newTab?: boolean };
|
|
15
17
|
|
|
16
18
|
type Props = {
|
|
17
19
|
name?: string;
|
|
@@ -64,53 +66,59 @@ export default function LinkField({ name, value: initial, onChange, linkOptions
|
|
|
64
66
|
return (
|
|
65
67
|
<div className="space-y-2 rounded-md border p-3">
|
|
66
68
|
{name && <input type="hidden" name={name} value={value.url ? JSON.stringify(value) : ""} ref={hiddenRef} />}
|
|
67
|
-
<div className="grid gap-
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
69
|
+
<div className="grid gap-2 sm:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]">
|
|
70
|
+
<div className="grid gap-1">
|
|
71
|
+
<Label className="text-xs">{hasPicker ? "Link" : "URL"}</Label>
|
|
72
|
+
{hasPicker ? (
|
|
73
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
74
|
+
<Select
|
|
75
|
+
items={[
|
|
76
|
+
{ value: "internal", label: "Internal" },
|
|
77
|
+
{ value: "external", label: "External" },
|
|
78
|
+
]}
|
|
79
|
+
value={linkType}
|
|
80
|
+
onValueChange={(v) => setLinkType((v as "internal" | "external") ?? "internal")}
|
|
81
|
+
>
|
|
82
|
+
<SelectTrigger className="w-28 shrink-0 text-sm">
|
|
83
|
+
<SelectValue />
|
|
84
|
+
</SelectTrigger>
|
|
85
|
+
<SelectContent>
|
|
86
|
+
<SelectGroup>
|
|
87
|
+
<SelectItem value="internal">Internal</SelectItem>
|
|
88
|
+
<SelectItem value="external">External</SelectItem>
|
|
89
|
+
</SelectGroup>
|
|
90
|
+
</SelectContent>
|
|
91
|
+
</Select>
|
|
92
|
+
{linkType === "internal" ? (
|
|
93
|
+
<InternalLinkPicker
|
|
94
|
+
editHref={value.url ?? ""}
|
|
95
|
+
linkOptions={linkOptions}
|
|
96
|
+
onSelect={(item) => set({ url: item.href, title: item.label })}
|
|
97
|
+
/>
|
|
98
|
+
) : (
|
|
99
|
+
<Input
|
|
100
|
+
value={value.url ?? ""}
|
|
101
|
+
placeholder="https://example.com"
|
|
102
|
+
onChange={(e) => set({ url: e.target.value, title: undefined })}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
) : (
|
|
107
|
+
<Input
|
|
108
|
+
value={value.url ?? ""}
|
|
109
|
+
placeholder="https://example.com or /about"
|
|
110
|
+
onChange={(e) => set({ url: e.target.value, title: undefined })}
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
<div className="grid gap-1">
|
|
115
|
+
<Label className="text-xs">Label</Label>
|
|
104
116
|
<Input
|
|
105
|
-
value={value.
|
|
106
|
-
placeholder=
|
|
107
|
-
onChange={(e) => set({
|
|
117
|
+
value={value.label ?? ""}
|
|
118
|
+
placeholder={value.title || "Link text"}
|
|
119
|
+
onChange={(e) => set({ label: e.target.value })}
|
|
108
120
|
/>
|
|
109
|
-
|
|
110
|
-
</div>
|
|
111
|
-
<div className="grid gap-1">
|
|
112
|
-
<Label className="text-xs">Label</Label>
|
|
113
|
-
<Input value={value.label ?? ""} placeholder="Link text" onChange={(e) => set({ label: e.target.value })} />
|
|
121
|
+
</div>
|
|
114
122
|
</div>
|
|
115
123
|
<label className="text-muted-foreground group inline-flex cursor-pointer items-center gap-2 text-sm">
|
|
116
124
|
<Checkbox
|
|
@@ -119,7 +127,6 @@ export default function LinkField({ name, value: initial, onChange, linkOptions
|
|
|
119
127
|
onCheckedChange={(checked) => set({ newTab: Boolean(checked) })}
|
|
120
128
|
/>
|
|
121
129
|
Open in new tab
|
|
122
|
-
{value.url && <span className="ml-auto text-xs">({value.type})</span>}
|
|
123
130
|
</label>
|
|
124
131
|
</div>
|
|
125
132
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { ArrowLeft, ArrowUpRight, Dot, Lock } from "lucide-react";
|
|
2
|
+
import { Archive, ArrowLeft, ArrowUpRight, Dot, Lock } from "lucide-react";
|
|
3
3
|
|
|
4
4
|
import AdminCard from "../components/AdminCard.astro";
|
|
5
5
|
import AiGenerateButton from "../components/AiGenerateButton";
|
|
@@ -122,6 +122,12 @@ const formTab = "edit" as "edit" | "submissions";
|
|
|
122
122
|
|
|
123
123
|
// --- Form-submissions-specific: custom read-only view ---
|
|
124
124
|
const isSubmissionView = collection.slug === "form-submissions" && mode === "edit";
|
|
125
|
+
// Opening a new submission marks it read, like email. System write: the
|
|
126
|
+
// read-only `data` field's access rule must not block the status flip.
|
|
127
|
+
if (isSubmissionView && doc && documentId && doc.status === "new") {
|
|
128
|
+
await collectionApi.update(documentId, { status: "read" }, { _system: true });
|
|
129
|
+
doc.status = "read";
|
|
130
|
+
}
|
|
125
131
|
const parentFormTitle =
|
|
126
132
|
isSubmissionView && doc?.form ? await loadParentFormTitle(String(doc.form), cmsRuntime, runtimeContext) : null;
|
|
127
133
|
const submissionData = (isSubmissionView && doc?.data ? doc.data : {}) as Record<string, unknown>;
|
|
@@ -284,6 +290,16 @@ const publishBlocked =
|
|
|
284
290
|
>
|
|
285
291
|
Save translation
|
|
286
292
|
</button>
|
|
293
|
+
) : isSubmissionView && documentId ? (
|
|
294
|
+
<form method="post" action={getFormAction(collection.slug, documentId)}>
|
|
295
|
+
<input type="hidden" name="_action" value="update" />
|
|
296
|
+
<input type="hidden" name="status" value={doc?.status === "archived" ? "read" : "archived"} />
|
|
297
|
+
<input type="hidden" name="redirectTo" value={`/admin/${collection.slug}`} />
|
|
298
|
+
<button class={buttonVariants({ variant: "outline" })} type="submit">
|
|
299
|
+
<Archive className="size-3.5" />
|
|
300
|
+
{doc?.status === "archived" ? "Unarchive" : "Archive"}
|
|
301
|
+
</button>
|
|
302
|
+
</form>
|
|
287
303
|
) : (
|
|
288
304
|
<>
|
|
289
305
|
<button
|