@spunto/design-system 0.11.0 → 0.11.1
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.
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type { ReactNode } from "react"
|
|
|
4
4
|
import { ChevronDownIcon, Settings2Icon } from "lucide-react"
|
|
5
5
|
|
|
6
6
|
import { cn } from "../../utils"
|
|
7
|
-
import type { ProjectFormSectionId, ProjectFormValue } from "./types"
|
|
7
|
+
import type { ProjectFormSectionId, ProjectFormValue, ProjectSecretRef } from "./types"
|
|
8
8
|
|
|
9
9
|
export interface AdvancedDisclosureProps {
|
|
10
10
|
open: boolean
|
|
@@ -101,7 +101,17 @@ export function AdvancedDisclosure({
|
|
|
101
101
|
* `lifecycle`, `3 secrets`. Pure, and exported, because a caller rendering its
|
|
102
102
|
* own fold needs the same sentence.
|
|
103
103
|
*/
|
|
104
|
-
export function advancedSummary(
|
|
104
|
+
export function advancedSummary(
|
|
105
|
+
value: ProjectFormValue,
|
|
106
|
+
sections: ProjectFormSectionId[],
|
|
107
|
+
/**
|
|
108
|
+
* Secrets already stored server-side. They count: a project whose only
|
|
109
|
+
* advanced setting is three secrets would otherwise show an empty summary and
|
|
110
|
+
* keep the fold shut over them — exactly the "hides configuration you didn't
|
|
111
|
+
* set yourself" failure this component exists to avoid.
|
|
112
|
+
*/
|
|
113
|
+
savedSecrets: ProjectSecretRef[] = []
|
|
114
|
+
): string[] {
|
|
105
115
|
const out: string[] = []
|
|
106
116
|
for (const id of sections) {
|
|
107
117
|
switch (id) {
|
|
@@ -124,9 +134,11 @@ export function advancedSummary(value: ProjectFormValue, sections: ProjectFormSe
|
|
|
124
134
|
case "docker":
|
|
125
135
|
if (value.dockerInDocker) out.push("docker-in-docker")
|
|
126
136
|
break
|
|
127
|
-
case "secrets":
|
|
128
|
-
|
|
137
|
+
case "secrets": {
|
|
138
|
+
const n = value.secrets.length + savedSecrets.filter((x) => !value.removedSecretIds.includes(x.id)).length
|
|
139
|
+
if (n) out.push(`${n} secret${n > 1 ? "s" : ""}`)
|
|
129
140
|
break
|
|
141
|
+
}
|
|
130
142
|
// Identity, image and repositories are never advanced — they're the form.
|
|
131
143
|
default:
|
|
132
144
|
break
|
|
@@ -182,11 +182,11 @@ export function ProjectForm({
|
|
|
182
182
|
}: ProjectFormProps) {
|
|
183
183
|
const patch = (next: Partial<ProjectFormValue>) => onChange({ ...value, ...next })
|
|
184
184
|
|
|
185
|
-
const rows = manifestRows(value, sections)
|
|
185
|
+
const rows = manifestRows(value, sections, savedSecrets)
|
|
186
186
|
|
|
187
187
|
const advanced = sections.filter((id) => advancedSections.includes(id))
|
|
188
188
|
const primary = sections.filter((id) => !advancedSections.includes(id))
|
|
189
|
-
const summary = advancedSummary(value, advanced)
|
|
189
|
+
const summary = advancedSummary(value, advanced, savedSecrets)
|
|
190
190
|
// Start open when there's already something in there — the initial value is
|
|
191
191
|
// read once, on mount, so a later edit can't yank the fold open under the
|
|
192
192
|
// user's cursor.
|
|
@@ -450,7 +450,12 @@ function parsePorts(raw: string): number[] {
|
|
|
450
450
|
* actually shown get a line: a creation form that hides ports shouldn't recap
|
|
451
451
|
* an empty "ports" row.
|
|
452
452
|
*/
|
|
453
|
-
export function manifestRows(
|
|
453
|
+
export function manifestRows(
|
|
454
|
+
value: ProjectFormValue,
|
|
455
|
+
sections: ProjectFormSectionId[],
|
|
456
|
+
/** Counted alongside the drafts — an existing secret is still a secret. */
|
|
457
|
+
savedSecrets: ProjectSecretRef[] = []
|
|
458
|
+
): ManifestRow[] {
|
|
454
459
|
const shown = new Set(sections)
|
|
455
460
|
const rows: ManifestRow[] = []
|
|
456
461
|
|
|
@@ -481,8 +486,10 @@ export function manifestRows(value: ProjectFormValue, sections: ProjectFormSecti
|
|
|
481
486
|
rows.push({ label: "prewarm", value: `${value.prewarmImages.length}`, done: value.prewarmImages.length > 0 })
|
|
482
487
|
if (shown.has("docker"))
|
|
483
488
|
rows.push({ label: "docker", value: value.dockerInDocker ? "in-docker" : "off", done: value.dockerInDocker })
|
|
484
|
-
if (shown.has("secrets"))
|
|
485
|
-
|
|
489
|
+
if (shown.has("secrets")) {
|
|
490
|
+
const n = value.secrets.length + savedSecrets.filter((x) => !value.removedSecretIds.includes(x.id)).length
|
|
491
|
+
rows.push({ label: "secrets", value: `${n}`, done: n > 0 })
|
|
492
|
+
}
|
|
486
493
|
|
|
487
494
|
return rows
|
|
488
495
|
}
|