@exagone313/dsh-podman 1.6.1 → 1.8.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.
Files changed (117) hide show
  1. package/cordis.patch.yml +3 -1
  2. package/dist/approval-reasons.d.ts +37 -0
  3. package/dist/approval-reasons.js +128 -0
  4. package/dist/approval-template-summary.d.ts +8 -0
  5. package/dist/approval-template-summary.js +163 -0
  6. package/dist/approval.d.ts +8 -4
  7. package/dist/approval.js +104 -10
  8. package/dist/client/ContainerCard.js +8 -2
  9. package/dist/client/container-card-controller.d.ts +13 -5
  10. package/dist/client/container-card-controller.js +60 -24
  11. package/dist/client/container-card-create-config.d.ts +23 -0
  12. package/dist/client/container-card-create-config.js +48 -0
  13. package/dist/client/container-card-create-modal.d.ts +9 -1
  14. package/dist/client/container-card-create-modal.js +37 -41
  15. package/dist/client/container-card-create-volume.d.ts +10 -0
  16. package/dist/client/container-card-create-volume.js +34 -0
  17. package/dist/client/container-card-dialog-styles.d.ts +4 -2
  18. package/dist/client/container-card-dialog-styles.js +47 -4
  19. package/dist/client/container-card-edit-modal.d.ts +5 -1
  20. package/dist/client/container-card-edit-modal.js +55 -19
  21. package/dist/client/container-card-editors.d.ts +9 -0
  22. package/dist/client/container-card-editors.js +300 -43
  23. package/dist/client/container-card-form.d.ts +2 -1
  24. package/dist/client/container-card-form.js +26 -8
  25. package/dist/client/container-card-images.js +9 -31
  26. package/dist/client/container-card-mount-actions.d.ts +12 -0
  27. package/dist/client/container-card-mount-actions.js +35 -0
  28. package/dist/client/container-card-mount-sources.d.ts +34 -0
  29. package/dist/client/container-card-mount-sources.js +180 -0
  30. package/dist/client/container-card-names.d.ts +2 -0
  31. package/dist/client/container-card-names.js +12 -0
  32. package/dist/client/container-card-row.d.ts +16 -1
  33. package/dist/client/container-card-row.js +69 -25
  34. package/dist/client/container-card-secrets.d.ts +2 -0
  35. package/dist/client/container-card-secrets.js +60 -17
  36. package/dist/client/container-card-shared.d.ts +17 -9
  37. package/dist/client/container-card-shared.js +122 -93
  38. package/dist/client/container-card-styles.d.ts +6 -0
  39. package/dist/client/container-card-styles.js +22 -0
  40. package/dist/client/container-card-table-styles.d.ts +2 -1
  41. package/dist/client/container-card-table-styles.js +14 -0
  42. package/dist/client/container-card-templates.d.ts +81 -0
  43. package/dist/client/container-card-templates.js +1004 -0
  44. package/dist/client/container-card-toast.js +1 -1
  45. package/dist/client/container-card-volumes.js +6 -20
  46. package/dist/client/container-card-workspace.d.ts +10 -2
  47. package/dist/client/container-card-workspace.js +98 -5
  48. package/dist/client/container-template-ui.d.ts +163 -0
  49. package/dist/client/container-template-ui.js +579 -0
  50. package/dist/client/download.d.ts +1 -0
  51. package/dist/client/download.js +23 -0
  52. package/dist/client/image-facts.d.ts +18 -0
  53. package/dist/client/image-facts.js +44 -0
  54. package/dist/client/index.js +13478 -3438
  55. package/dist/client/locales.d.ts +1 -1
  56. package/dist/client/locales.js +120 -0
  57. package/dist/client/podman-containers.js +47 -18
  58. package/dist/client/podman-terminal-guide.js +4 -2
  59. package/dist/client/podman-terminal.js +4 -2
  60. package/dist/client/template-client.d.ts +9 -0
  61. package/dist/client/template-client.js +52 -0
  62. package/dist/client/template-protocol.d.ts +60 -0
  63. package/dist/client/template-protocol.js +4 -0
  64. package/dist/client/terminal-errors.d.ts +11 -0
  65. package/dist/client/terminal-errors.js +26 -0
  66. package/dist/client/terminal-protocol.d.ts +5 -0
  67. package/dist/client/terminal-protocol.js +5 -0
  68. package/dist/client/terminal-styles.d.ts +2 -1
  69. package/dist/client/terminal-styles.js +9 -1
  70. package/dist/client/terminal-transport.d.ts +17 -2
  71. package/dist/client/terminal-transport.js +31 -8
  72. package/dist/client/tool-presentations.d.ts +32 -0
  73. package/dist/client/tool-presentations.js +33 -0
  74. package/dist/client/tool-views.js +17 -7
  75. package/dist/client/workspace-target.d.ts +54 -0
  76. package/dist/client/workspace-target.js +86 -0
  77. package/dist/container-template.d.ts +153 -0
  78. package/dist/container-template.js +1058 -0
  79. package/dist/generated/version.d.ts +2 -2
  80. package/dist/generated/version.js +2 -2
  81. package/dist/grpc/proto/dshguest/v1/guest.proto +11 -0
  82. package/dist/guest-rpc.d.ts +1 -0
  83. package/dist/guest-rpc.js +12 -0
  84. package/dist/index.js +7 -1
  85. package/dist/mount-enums.d.ts +2 -0
  86. package/dist/mount-enums.js +17 -0
  87. package/dist/mount-order.d.ts +14 -0
  88. package/dist/mount-order.js +49 -0
  89. package/dist/project-path.d.ts +14 -0
  90. package/dist/project-path.js +25 -0
  91. package/dist/template-apply.d.ts +21 -0
  92. package/dist/template-apply.js +102 -0
  93. package/dist/template-files.d.ts +23 -0
  94. package/dist/template-files.js +186 -0
  95. package/dist/template-image.d.ts +22 -0
  96. package/dist/template-image.js +80 -0
  97. package/dist/template-route.d.ts +9 -0
  98. package/dist/template-route.js +278 -0
  99. package/dist/terminal-route.js +49 -7
  100. package/dist/tool-defs.js +27 -1
  101. package/dist/tool-handlers.js +69 -1
  102. package/dist/tool-params.d.ts +38 -0
  103. package/dist/tool-params.js +30 -0
  104. package/docs/README.md +4 -3
  105. package/docs/architecture.md +42 -12
  106. package/docs/architecture.zh.md +22 -8
  107. package/docs/configuration.md +19 -20
  108. package/docs/configuration.zh.md +3 -4
  109. package/docs/development-prompt.md +49 -45
  110. package/docs/development-prompt.zh.md +47 -43
  111. package/docs/development.md +45 -28
  112. package/docs/development.zh.md +59 -46
  113. package/docs/uninstall.md +3 -3
  114. package/docs/uninstall.zh.md +2 -2
  115. package/docs/usage.md +155 -23
  116. package/docs/usage.zh.md +104 -14
  117. package/package.json +34 -33
@@ -2,46 +2,24 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
3
  //
4
4
  // SPDX-License-Identifier: MIT
5
- import { Chip, ConfirmButton, Field, imageIdPattern, imageStatusLabel, imageStatusTone, StatusChip, TagInput, } from "./container-card-shared.js";
5
+ import { ConfirmButton, Field, imageIdPattern, StatusChip, TagInput, } from "./container-card-shared.js";
6
+ import { ImageFacts, ImageField } from "./image-facts.js";
6
7
  import { bareActionKey, scopedActionKey } from "./card-protocol.js";
7
8
  import { buildParentImages, ptcImageRow } from "./container-card-ptc.js";
8
- import { FIELD_ROW_CLASS } from "./container-card-table-styles.js";
9
- import { actionRow, cardBlockRow, containerNameHeading, hint, imageFieldLabel, imageFieldOwnLine, imageFields, imageFieldValue, imageSelect, rowActions, rowDivider, rowMain, } from "./container-card-styles.js";
9
+ import { actionRow, cardBlockRow, containerNameHeading, hint, imageFields, imageSelect, rowActions, rowDivider, rowMain, } from "./container-card-styles.js";
10
10
  import { relativeTimeLabel } from "./relative-time.js";
11
- import { Button, Input, Modal, Pill, } from "@deepseek-ai/dsh-client-ui-primitives";
11
+ import { Button, Input, Modal } from "@deepseek-ai/dsh-client-ui-primitives";
12
12
  import { useId } from "react";
13
- // The packages an image was built with, or the fact that none were recorded:
14
- // chips on their own line under the Packages label.
15
- function Packages(props) {
16
- const { t, image } = props;
17
- if (image.packages.length === 0)
18
- return t("noPackages");
19
- return (_jsx(_Fragment, { children: image.packages.map((pkg) => _jsx(Chip, { t: t, label: pkg }, pkg)) }));
20
- }
21
- // One labelled line of an image's block: the field's label, then its value. The
22
- // class keeps the label beside the value while the card has room and stacks it
23
- // above once the card is narrow.
24
- function ImageField(props) {
25
- const { label, ownLine, children } = props;
26
- return (_jsxs("div", { className: FIELD_ROW_CLASS, children: [_jsx("span", { style: imageFieldLabel, children: label }), ownLine === true
27
- ? _jsx("div", { style: imageFieldOwnLine, children: children })
28
- : _jsx("span", { style: imageFieldValue, children: children })] }));
29
- }
30
- // The image's own block: line one is the name (14/600) with its status chip and
31
- // the image's own actions at the line's right end, then one labelled line per
32
- // field. The block's action group drops below the name when it no longer fits
33
- // beside it; the destructive Remove is part of that same group, so a custom
34
- // image's three actions read together.
13
+ // The image's own block: the shared facts, then the image's own actions at the
14
+ // line's right end. The block's action group drops below the name when it no
15
+ // longer fits beside it; the destructive Remove is part of that same group, so a
16
+ // custom image's three actions read together.
35
17
  function ImageBlock(props) {
36
18
  const { t, image, defaultImage, locale, actions } = props;
37
19
  // The upstream image a base image is built from lives in `primitive`, while a
38
20
  // custom image names its parent; both are the image this one descends from.
39
21
  const source = image.parent !== "" ? image.parent : image.primitive;
40
- return (_jsxs("div", { children: [_jsxs("div", { style: actionRow, children: [_jsxs("div", { style: rowMain, children: [_jsx("span", { style: containerNameHeading, children: image.imageId }), image.imageId === defaultImage
41
- ? _jsx(Pill, { children: t("defaultImage") })
42
- : null, _jsx(StatusChip, { tone: imageStatusTone(image.status), label: imageStatusLabel(t, image.status) })] }), _jsx("div", { style: rowActions, children: actions })] }), _jsxs("div", { style: imageFields, children: [image.builtAt === "" ? null : (_jsx(ImageField, { label: t("built"), children: _jsx("span", { title: image.builtAt, children: relativeTimeLabel(image.builtAt, locale) }) })), source === ""
43
- ? null
44
- : _jsx(ImageField, { label: t("parentImage"), children: source }), _jsx(ImageField, { label: t("packages"), ownLine: true, children: _jsx(Packages, { t: t, image: image }) })] })] }));
22
+ return (_jsx(ImageFacts, { t: t, locale: locale, imageId: image.imageId, status: image.status, builtAt: image.builtAt, source: source, packages: image.packages, isDefault: image.imageId === defaultImage, actions: actions }));
45
23
  }
46
24
  // One custom image row: the image block with its Rebuild, Set default and
47
25
  // destructive Remove together on the name line. The card's rows are hairline
@@ -0,0 +1,12 @@
1
+ import type { Translate } from "./locales.js";
2
+ import { type ReactNode } from "react";
3
+ export declare function MountSourceActions(props: {
4
+ t: Translate;
5
+ kind: string;
6
+ writable: boolean;
7
+ busy: boolean;
8
+ disabled: boolean;
9
+ onBrowse?: () => void;
10
+ onCreateVolume?: (name: string) => Promise<boolean>;
11
+ onCreateSecret?: (name: string, length?: number, charset?: string) => Promise<boolean>;
12
+ }): ReactNode;
@@ -0,0 +1,35 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
3
+ //
4
+ // SPDX-License-Identifier: MIT
5
+ // The action a mount row offers beside its source field. It is decided by the
6
+ // kind alone: a project path is browsed for on the host, a volume opens the
7
+ // create-volume form and a secret the create-secret one, while tmpfs offers
8
+ // nothing. Creating from the row is what lets a volume or a secret mount be
9
+ // pointed at a storage that does not exist yet; both dialogs are the settings
10
+ // ones, so the validation and the host commands are the same everywhere.
11
+ import { CreateVolumeModal } from "./container-card-create-volume.js";
12
+ import { mountSourceAffordance, mountSourceCreationDisabled, } from "./container-card-mount-sources.js";
13
+ import { SecretModal } from "./container-card-secrets.js";
14
+ import { Button } from "@deepseek-ai/dsh-client-ui-primitives";
15
+ import { useState } from "react";
16
+ export function MountSourceActions(props) {
17
+ const { t, kind, writable, busy, disabled, onBrowse, onCreateVolume, onCreateSecret, } = props;
18
+ const [volumeOpen, setVolumeOpen] = useState(false);
19
+ const [secretOpen, setSecretOpen] = useState(false);
20
+ const affordance = mountSourceAffordance(kind);
21
+ if (affordance === "browse") {
22
+ return onBrowse === undefined ? null : (_jsx(Button, { variant: "outline", size: "sm", disabled: disabled, onClick: onBrowse, children: t("browse") }));
23
+ }
24
+ if (affordance === "create-volume") {
25
+ return onCreateVolume === undefined ? null : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", disabled: mountSourceCreationDisabled(writable, busy), onClick: () => setVolumeOpen(true), children: t("createVolume") }), _jsx(CreateVolumeModal, { t: t, open: volumeOpen, busy: busy, writable: writable, onCreate: (name) => {
26
+ void onCreateVolume(name);
27
+ }, onClose: () => setVolumeOpen(false) })] }));
28
+ }
29
+ if (affordance === "create-secret") {
30
+ return onCreateSecret === undefined ? null : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", disabled: mountSourceCreationDisabled(writable, busy), onClick: () => setSecretOpen(true), children: t("createSecret") }), _jsx(SecretModal, { t: t, mode: "create", open: secretOpen, busy: busy, writable: writable, onCreate: (name, length, charset) => {
31
+ void onCreateSecret(name, length, charset);
32
+ }, onClose: () => setSecretOpen(false) })] }));
33
+ }
34
+ return null;
35
+ }
@@ -0,0 +1,34 @@
1
+ import type { MountInput } from "./card-protocol.js";
2
+ import type { Translation } from "./locales.js";
3
+ export type MountSourceAffordance = "browse" | "create-volume" | "create-secret" | "none";
4
+ export declare function mountSourceAffordance(kind: unknown): MountSourceAffordance;
5
+ export declare function mountSourceCreationDisabled(writable: boolean, busy: boolean): boolean;
6
+ export declare function mountRowBrowseOffered(mode: "view" | "edit", kind: unknown, onProjectBrowse: (() => void) | undefined): boolean;
7
+ export declare function mountRowBrowseDisabled(disabled: boolean, writable: boolean, busy: boolean): boolean;
8
+ export declare function createdMountSource(kind: unknown, name: string): Partial<MountInput> | undefined;
9
+ export declare function withPreselectedStorageSource(draft: MountInput, volumes: readonly {
10
+ name: string;
11
+ }[], secrets: readonly {
12
+ name: string;
13
+ }[]): MountInput;
14
+ export declare function revertCreatedMountSource(current: Pick<MountInput, "kind" | "volume" | "secret">, created: string, previous: string): Partial<MountInput> | undefined;
15
+ export interface MountDestinationRejection {
16
+ ok: false;
17
+ key: "mountDestinationRequired" | "mountDestinationAbsolute" | "mountDestinationClean" | "mountDestinationReserved";
18
+ params?: {
19
+ path: string;
20
+ };
21
+ }
22
+ export type MountDestinationCheck = {
23
+ ok: true;
24
+ } | MountDestinationRejection;
25
+ export declare function validateMountDestination(destination: string, projectsRoot: string): MountDestinationCheck;
26
+ export declare function nonProjectDestinationError(kind: unknown, destination: string, projectsRoot: string): Translation | undefined;
27
+ export declare function firstMountDestinationError(mounts: readonly Pick<MountInput, "kind" | "destination">[], projectsRoot: string): Translation | undefined;
28
+ export interface MountSourceOptions {
29
+ missing: boolean;
30
+ names: readonly string[];
31
+ }
32
+ export declare function mountSourceOptions(selected: string, storages: readonly {
33
+ name: string;
34
+ }[]): MountSourceOptions;
@@ -0,0 +1,180 @@
1
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+ // What a mount row offers beside its source field, per kind. A project path is
5
+ // browsed for on the host; a volume or a secret is created from the row itself
6
+ // because the settings storages may not hold one yet; tmpfs mounts no source, so
7
+ // its row offers nothing.
8
+ import { normalizeMountKind } from "../mount-enums.js";
9
+ // The one affordance a kind gets. An unknown kind reads as a project mount,
10
+ // exactly like normalizeMountKind, so a decoded row cannot end up with none.
11
+ export function mountSourceAffordance(kind) {
12
+ switch (normalizeMountKind(kind)) {
13
+ case "project":
14
+ return "browse";
15
+ case "volume":
16
+ return "create-volume";
17
+ case "secret":
18
+ return "create-secret";
19
+ default:
20
+ return "none";
21
+ }
22
+ }
23
+ // Whether a creation affordance is refused: the snapshot must let the workspace
24
+ // write and no command may be in flight, the same gates the settings storage
25
+ // tab applies to its own Create actions.
26
+ export function mountSourceCreationDisabled(writable, busy) {
27
+ return !writable || busy;
28
+ }
29
+ // Whether a mount row offers Browse among its own actions rather than beside
30
+ // its source field: only an editor row for a project mount whose caller
31
+ // threaded a host directory browser down to it. The container block and the
32
+ // editor dialogs pass none, so their rows keep exactly the actions they had.
33
+ export function mountRowBrowseOffered(mode, kind, onProjectBrowse) {
34
+ return mode === "edit" &&
35
+ normalizeMountKind(kind) === "project" &&
36
+ onProjectBrowse !== undefined;
37
+ }
38
+ // Whether a row's Browse is disabled: the row's own gate, a read-only workspace
39
+ // or a command in flight, the same gates the row's other write actions carry.
40
+ export function mountRowBrowseDisabled(disabled, writable, busy) {
41
+ return disabled || !writable || busy;
42
+ }
43
+ // The source a row adopts after a create succeeds, before the refreshed snapshot
44
+ // lists it. An empty name clears the source again, which is how a refused create
45
+ // restores what the row carried before. A kind without a source — project,
46
+ // tmpfs — adopts nothing.
47
+ export function createdMountSource(kind, name) {
48
+ switch (normalizeMountKind(kind)) {
49
+ case "volume":
50
+ return { volume: name };
51
+ case "secret":
52
+ return { secret: name };
53
+ default:
54
+ return undefined;
55
+ }
56
+ }
57
+ // The draft a volume or secret mount adopts when its source is still empty: the
58
+ // first listed storage of that kind. A picker with a non-empty list renders no
59
+ // "" option, so the browser would show the first entry while the draft stayed
60
+ // empty and Add stayed disabled. Preselecting it stores what the field shows.
61
+ // Every other kind, a draft that already carries a value — including one the
62
+ // snapshot no longer lists — and an empty list are returned untouched.
63
+ export function withPreselectedStorageSource(draft, volumes, secrets) {
64
+ switch (normalizeMountKind(draft.kind)) {
65
+ case "volume": {
66
+ const first = volumes[0];
67
+ return draft.volume === "" && first !== undefined
68
+ ? { ...draft, volume: first.name }
69
+ : draft;
70
+ }
71
+ case "secret": {
72
+ const first = secrets[0];
73
+ return draft.secret === "" && first !== undefined
74
+ ? { ...draft, secret: first.name }
75
+ : draft;
76
+ }
77
+ default:
78
+ return draft;
79
+ }
80
+ }
81
+ // What a refused create restores: the source the row carried before it adopted
82
+ // the created name. Nothing is restored when the row no longer carries that
83
+ // name, so a selection the user changed in the meantime is never clobbered.
84
+ export function revertCreatedMountSource(current, created, previous) {
85
+ const value = normalizeMountKind(current.kind) === "volume"
86
+ ? current.volume
87
+ : current.secret;
88
+ return value === created
89
+ ? createdMountSource(current.kind, previous)
90
+ : undefined;
91
+ }
92
+ // The reserved container paths this client checks itself: /tmp, which podman
93
+ // mounts as the writable tmpfs the guest file API reaches, and the projects
94
+ // root, which is reserved for project mounts. The sockets root and the guest
95
+ // agent's mount stay server-enforced.
96
+ const TMPFS_ROOT = "/tmp";
97
+ // withTrailingSlash returns path with a trailing separator, so a prefix
98
+ // comparison matches whole path components. A path that already ends in one,
99
+ // the filesystem root included, is returned unchanged. Plain string operations:
100
+ // this module is bundled for the browser, so node:path is not available.
101
+ function withTrailingSlash(path) {
102
+ return path.endsWith("/") ? path : `${path}/`;
103
+ }
104
+ // pathsOverlap reports whether two absolute POSIX paths are equal or whether
105
+ // either contains the other, mirroring the orchestrator's nonProjectDestination.
106
+ function pathsOverlap(a, b) {
107
+ return a === b || a.startsWith(withTrailingSlash(b)) ||
108
+ b.startsWith(withTrailingSlash(a));
109
+ }
110
+ // validateMountDestination checks a volume, secret or tmpfs destination the way
111
+ // the orchestrator does, minus the paths only the server knows: it must be
112
+ // non-empty, absolute and already POSIX-clean (no ".." or "." segment, no
113
+ // doubled separator, no trailing slash), and it must not be, contain or sit
114
+ // inside /tmp or the container projects root. Project mounts derive their
115
+ // destination from the project path and are never checked here.
116
+ export function validateMountDestination(destination, projectsRoot) {
117
+ if (destination === "") {
118
+ return { ok: false, key: "mountDestinationRequired" };
119
+ }
120
+ if (!destination.startsWith("/")) {
121
+ return { ok: false, key: "mountDestinationAbsolute" };
122
+ }
123
+ // "/" is its own clean form; the overlap check refuses it as an ancestor of
124
+ // /tmp, exactly as the orchestrator does.
125
+ if (destination !== "/" &&
126
+ (destination.endsWith("/") ||
127
+ destination.includes("//") ||
128
+ destination
129
+ .slice(1)
130
+ .split("/")
131
+ .some((segment) => segment === "." || segment === ".."))) {
132
+ return { ok: false, key: "mountDestinationClean" };
133
+ }
134
+ // The projects root is empty before the snapshot arrives, and a deployment
135
+ // may configure none; only an absolute root can reserve a container path.
136
+ for (const reserved of [TMPFS_ROOT, projectsRoot]) {
137
+ if (reserved === "" || !reserved.startsWith("/"))
138
+ continue;
139
+ if (pathsOverlap(destination, reserved)) {
140
+ return {
141
+ ok: false,
142
+ key: "mountDestinationReserved",
143
+ params: { path: reserved },
144
+ };
145
+ }
146
+ }
147
+ return { ok: true };
148
+ }
149
+ // The untranslated reason a non-project mount destination is refused, or
150
+ // undefined when it is acceptable. A project mount derives its destination, and
151
+ // an unknown kind reads as a project mount like normalizeMountKind, so neither
152
+ // is checked.
153
+ export function nonProjectDestinationError(kind, destination, projectsRoot) {
154
+ if (normalizeMountKind(kind) === "project")
155
+ return undefined;
156
+ const check = validateMountDestination(destination, projectsRoot);
157
+ if (check.ok)
158
+ return undefined;
159
+ return check.params === undefined
160
+ ? { key: check.key }
161
+ : { key: check.key, params: check.params };
162
+ }
163
+ // The first refused destination among a form's mounts, in list order, so the
164
+ // footer names the row that has to be fixed first.
165
+ export function firstMountDestinationError(mounts, projectsRoot) {
166
+ for (const mount of mounts) {
167
+ const error = nonProjectDestinationError(mount.kind, mount.destination, projectsRoot);
168
+ if (error !== undefined)
169
+ return error;
170
+ }
171
+ return undefined;
172
+ }
173
+ // The options a volume or secret picker offers: the listed names, and the name
174
+ // the row already carries when the snapshot does not know it yet. That keeps a
175
+ // just-created source selected instead of replacing it with the first candidate.
176
+ export function mountSourceOptions(selected, storages) {
177
+ const names = storages.map((storage) => storage.name);
178
+ const missing = selected !== "" && !names.includes(selected);
179
+ return { missing, names: missing ? [selected, ...names] : names };
180
+ }
@@ -0,0 +1,2 @@
1
+ export declare const namePattern: RegExp;
2
+ export declare function createdName(raw: string): string | undefined;
@@ -0,0 +1,12 @@
1
+ // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+ // The one name rule the storage dialogs enforce: the names a volume or a secret
5
+ // may carry, valid from the first character to the last.
6
+ export const namePattern = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,63}$/;
7
+ // The name a create form submits: undefined while the field still breaks the
8
+ // rule, so a caller can refuse it without repeating the expression, and the
9
+ // trimmed name the host actually receives once it passes.
10
+ export function createdName(raw) {
11
+ return namePattern.test(raw) ? raw.trim() : undefined;
12
+ }
@@ -3,6 +3,13 @@ import { type ContainerConfig } from "./container-card-config.js";
3
3
  import { type DirectoryPickerFace } from "./directory-picker.js";
4
4
  import { type Translate } from "./locales.js";
5
5
  import { type ReactNode } from "react";
6
+ export declare function FieldGroup(props: {
7
+ label: string;
8
+ children: ReactNode;
9
+ }): ReactNode;
10
+ export declare function NoEntries(props: {
11
+ t: Translate;
12
+ }): ReactNode;
6
13
  export declare function ContainerRow(props: {
7
14
  t: Translate;
8
15
  container: ContainerView;
@@ -19,8 +26,16 @@ export declare function ContainerRow(props: {
19
26
  writable: boolean;
20
27
  onRemove: (workspace: string, container: string) => void;
21
28
  onRecreate: (workspace: string, container: string, image: string) => void;
22
- onCreateSecret: (name: string, length?: number, charset?: string) => void;
29
+ createVolume: (name: string) => Promise<boolean>;
30
+ onCreateSecret: (name: string, length?: number, charset?: string) => Promise<boolean>;
23
31
  onApplyContainerConfig: (workspace: string, container: string, base: ContainerConfig, next: ContainerConfig) => void;
32
+ prefill?: {
33
+ token: number;
34
+ config: ContainerConfig;
35
+ };
36
+ forcedProject?: string;
37
+ onEditClosed?: () => void;
38
+ onEditBack?: () => void;
24
39
  gatewayUnavailable: boolean;
25
40
  projectName: string;
26
41
  projectsRoot: string;
@@ -2,8 +2,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { containerActionKey, containerActionPending } from "./card-protocol.js";
3
3
  import { configChangedKeys, configGroupLabels, configRebuildsContainer, configsEqual, containerConfigFrom, } from "./container-card-config.js";
4
4
  import { ContainerEditModal } from "./container-card-edit-modal.js";
5
- import { ConfirmButton, containerStatusLabel, containerStatusTone, CopyButton, EnvRow, ImageRow, MountRow, mountViewToInput, orderedMounts, PathRow, PortRow, SecretEnvRow, StatusChip, } from "./container-card-shared.js";
6
- import { actionRow, blockFields, blockWrapper, cardBlockRow, cardTitle, fieldGroup, fieldGroupLabel, missingValue, rowActions, rowDivider, rowMain, rowMeta, } from "./container-card-styles.js";
5
+ import { exportContainerTemplate } from "../container-template.js";
6
+ import { orderedMounts } from "../mount-order.js";
7
+ import { downloadTextFile } from "./download.js";
8
+ import { ConfirmButton, containerStatusLabel, containerStatusTone, CopyButton, EnvRow, ImageRow, MountRow, mountViewToInput, PathRow, PortRow, SecretEnvRow, StatusChip, } from "./container-card-shared.js";
9
+ import { actionRow, blockFields, blockWrapper, cardBlockRow, cardTitle, fieldGroup, fieldGroupLabel, missingValue, rowActions, rowDivider, rowMain, rowMeta, templateAction, } from "./container-card-styles.js";
7
10
  import { ROW_LIST_CLASS } from "./container-card-table-styles.js";
8
11
  import { orderedEnvEntries } from "../env-rows.js";
9
12
  import { relativeTimeLabel } from "./relative-time.js";
@@ -13,16 +16,18 @@ import { useEffect, useRef, useState } from "react";
13
16
  // it holds, so a long list only makes the block taller. A group with no rows at
14
17
  // all renders nothing, so its label and gap never reserve empty height. It
15
18
  // carries the shared list marker, so the narrow query separates its consecutive
16
- // rows the way it does in the editor that changes the same list.
17
- function FieldGroup(props) {
19
+ // rows the way it does in the editor that changes the same list. The template
20
+ // preview reuses it, so both read a spec in the same groups.
21
+ export function FieldGroup(props) {
18
22
  const { label, children } = props;
19
23
  if (children === null || children === undefined || children === false) {
20
24
  return null;
21
25
  }
22
26
  return (_jsxs("div", { className: ROW_LIST_CLASS, style: fieldGroup, children: [_jsx("span", { style: fieldGroupLabel, children: label }), children] }));
23
27
  }
24
- // The placeholder one empty list of a container block reads with.
25
- function NoEntries(props) {
28
+ // The placeholder one empty list of a container block reads with; the template
29
+ // preview states an empty group with it too.
30
+ export function NoEntries(props) {
26
31
  return _jsx("span", { style: missingValue, children: props.t("valueMissing") });
27
32
  }
28
33
  // One container of a workspace: a stacked block whose identity line is the
@@ -36,7 +41,7 @@ function NoEntries(props) {
36
41
  // Recreate rebuilds the container as it is, without touching the draft. The
37
42
  // orchestrator-owned PTC container is rendered by its own card, never here.
38
43
  export function ContainerRow(props) {
39
- const { t, container, images, volumes, secrets, pendingActions, locale, last, writable, onRemove, onRecreate, onCreateSecret, onApplyContainerConfig, gatewayUnavailable, projectName, projectsRoot, directoryPicker, } = props;
44
+ const { t, container, images, volumes, secrets, pendingActions, locale, last, writable, onRemove, onRecreate, createVolume, onCreateSecret, onApplyContainerConfig, prefill, forcedProject, onEditClosed, onEditBack, gatewayUnavailable, projectName, projectsRoot, directoryPicker, } = props;
40
45
  // The row edits one draft of the container's whole configuration and applies
41
46
  // it with the dialog's one primary action. The draft starts from the snapshot
42
47
  // and resyncs only while the user has nothing local, so a refresh never
@@ -82,6 +87,21 @@ export function ContainerRow(props) {
82
87
  : t(blockingError.key, blockingError.params);
83
88
  const rebuilds = configRebuildsContainer(server, draft);
84
89
  const [open, setOpen] = useState(false);
90
+ // A failed export names its reason in the row instead of replacing the file
91
+ // with nothing.
92
+ const [exportError, setExportError] = useState("");
93
+ // A prefill is opened once per token: a snapshot refresh must not reopen the
94
+ // dialog or clobber an edit the user has already started.
95
+ const openedPrefill = useRef(0);
96
+ useEffect(() => {
97
+ if (prefill === undefined || prefill.token === openedPrefill.current) {
98
+ return;
99
+ }
100
+ openedPrefill.current = prefill.token;
101
+ setDraft(prefill.config);
102
+ setStaged(server);
103
+ setOpen(true);
104
+ }, [prefill, server]);
85
105
  // The editors share the container-scoped commands, so any of them in flight
86
106
  // gates the whole row; the staged commands run from the apply action.
87
107
  const containerBusy = containerActionPending(pendingActions, container.workspaceSlug, container.containerName);
@@ -113,23 +133,47 @@ export function ContainerRow(props) {
113
133
  setStaged(server);
114
134
  }
115
135
  };
116
- return (_jsxs(_Fragment, { children: [_jsx("div", { style: last ? cardBlockRow : { ...cardBlockRow, ...rowDivider }, children: _jsxs("div", { style: blockWrapper, children: [_jsxs("div", { style: actionRow, children: [_jsxs("div", { style: rowMain, children: [_jsx("h4", { style: { ...cardTitle, overflowWrap: "anywhere" }, children: container.containerName }), _jsx(StatusChip, { tone: containerStatusTone(container.status), label: containerStatusLabel(t, container.status) }), _jsx("span", { style: rowMeta, title: container.createdAt, children: relativeTimeLabel(container.createdAt, locale) }), _jsx(CopyButton, { t: t, value: container.createdAt, label: t("copyCreated") })] }), _jsxs("div", { style: rowActions, children: [_jsx(Button, { variant: "outline", size: "sm", disabled: !usable, onClick: () => setOpen(true), children: t("edit") }), _jsx(ConfirmButton, { t: t, emphasis: "business", label: t("recreate"), title: t("recreate"), description: t("confirmRecreate", {
117
- workspace: projectName,
118
- container: container.containerName,
119
- }), confirmLabel: t("recreate"), disabled: !usable || containerBusy, pending: recreatePending, onConfirm: () => onRecreate(container.workspaceSlug, container.containerName, container.imageId) }), _jsx(ConfirmButton, { t: t, destructive: true, label: t("remove"), title: t("removeContainerTitle"), description: t("confirmRemoveContainer", {
120
- workspace: projectName,
121
- container: container.containerName,
122
- }), confirmLabel: t("removeContainerTitle"), disabled: !usable, pending: removePending, onConfirm: () => onRemove(container.workspaceSlug, container.containerName) })] })] }), _jsxs("div", { style: blockFields, children: [_jsx(ImageRow, { t: t, mode: "view", image: container.imageId }), _jsx(FieldGroup, { label: t("envTitle"), children: envEntries.length === 0
123
- ? _jsx(NoEntries, { t: t })
124
- : envEntries.map(([name, value]) => (_jsx(EnvRow, { t: t, mode: "view", name: name, value: value }, name))) }), _jsx(FieldGroup, { label: t("mountsTitle"), children: mounts.length === 0
125
- ? _jsx(NoEntries, { t: t })
126
- : mounts.map(({ mount, index }) => (_jsx(MountRow, { t: t, mode: "view", mount: mount, destination: container.mounts[index]?.destination ??
127
- "" }, index))) }), _jsx(FieldGroup, { label: t("pathsTitle"), children: container.paths.length === 0
128
- ? _jsx(NoEntries, { t: t })
129
- : container.paths.map((path, index) => (_jsx(PathRow, { t: t, mode: "view", path: path }, index))) }), _jsx(FieldGroup, { label: t("containerSecretsTitle"), children: secretEnvEntries.length === 0
130
- ? _jsx(NoEntries, { t: t })
131
- : secretEnvEntries.map(([name, value]) => (_jsx(SecretEnvRow, { t: t, mode: "view", name: name, secret: value }, name))) }), _jsx(FieldGroup, { label: t("portsTitle"), children: container.publishedPorts.length === 0
132
- ? _jsx(NoEntries, { t: t })
133
- : container.publishedPorts.map((port) => (_jsx(PortRow, { t: t, mode: "view", port: port.port, protocol: port.protocol, hostPort: port.hostPort }, `${port.protocol}/${port.port}`))) })] })] }) }), _jsx(ContainerEditModal, { t: t, open: open, container: container, images: images, volumes: volumes, secrets: secrets, busy: containerBusy, enabled: enabled, usable: usable, canPublish: canPublish, gatewayUnavailable: gatewayUnavailable, projectName: projectName, projectsRoot: projectsRoot, directoryPicker: directoryPicker, writable: writable, draft: draft, dirty: dirty, pending: pending, marker: marker, markerError: markerError, onBlockingError: setBlockingError, rebuilds: rebuilds, recreatePending: recreatePending, onCreateSecret: onCreateSecret, onChange: setDraft, onDiscard: discard, onApply: apply, onClose: () => setOpen(false) })] }));
136
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { style: last ? cardBlockRow : { ...cardBlockRow, ...rowDivider }, children: [_jsxs("div", { style: blockWrapper, children: [_jsxs("div", { style: actionRow, children: [_jsxs("div", { style: rowMain, children: [_jsx("h4", { style: { ...cardTitle, overflowWrap: "anywhere" }, children: container.containerName }), _jsx(StatusChip, { tone: containerStatusTone(container.status), label: containerStatusLabel(t, container.status) }), _jsx("span", { style: rowMeta, title: container.createdAt, children: relativeTimeLabel(container.createdAt, locale) }), _jsx(CopyButton, { t: t, value: container.createdAt, label: t("copyCreated") })] }), _jsxs("div", { style: rowActions, children: [_jsx(Button, { variant: "outline", size: "sm", disabled: !usable, onClick: () => setOpen(true), children: t("edit") }), _jsx(ConfirmButton, { t: t, emphasis: "business", label: t("recreate"), title: t("recreate"), description: t("confirmRecreate", {
137
+ workspace: projectName,
138
+ container: container.containerName,
139
+ }), confirmLabel: t("recreate"), disabled: !usable || containerBusy, pending: recreatePending, onConfirm: () => onRecreate(container.workspaceSlug, container.containerName, container.imageId) }), _jsx(Button, { variant: "outline", size: "sm", disabled: !usable, style: templateAction, onClick: () => {
140
+ try {
141
+ const exported = exportContainerTemplate(container, images, projectName);
142
+ downloadTextFile(exported.filename, exported.yaml);
143
+ setExportError("");
144
+ }
145
+ catch (error) {
146
+ setExportError(error instanceof Error ? error.message : String(error));
147
+ }
148
+ }, children: t("exportTemplate") }), _jsx(ConfirmButton, { t: t, destructive: true, label: t("remove"), title: t("removeContainerTitle"), description: t("confirmRemoveContainer", {
149
+ workspace: projectName,
150
+ container: container.containerName,
151
+ }), confirmLabel: t("removeContainerTitle"), disabled: !usable, pending: removePending, onConfirm: () => onRemove(container.workspaceSlug, container.containerName) })] })] }), _jsxs("div", { style: blockFields, children: [_jsx(ImageRow, { t: t, mode: "view", image: container.imageId }), _jsx(FieldGroup, { label: t("envTitle"), children: envEntries.length === 0
152
+ ? _jsx(NoEntries, { t: t })
153
+ : envEntries.map(([name, value]) => (_jsx(EnvRow, { t: t, mode: "view", name: name, value: value }, name))) }), _jsx(FieldGroup, { label: t("mountsTitle"), children: mounts.length === 0
154
+ ? _jsx(NoEntries, { t: t })
155
+ : mounts.map(({ mount, index }) => (_jsx(MountRow, { t: t, mode: "view", mount: mount, destination: container.mounts[index]?.destination ??
156
+ "" }, index))) }), _jsx(FieldGroup, { label: t("pathsTitle"), children: container.paths.length === 0
157
+ ? _jsx(NoEntries, { t: t })
158
+ : container.paths.map((path, index) => (_jsx(PathRow, { t: t, mode: "view", path: path }, index))) }), _jsx(FieldGroup, { label: t("containerSecretsTitle"), children: secretEnvEntries.length === 0
159
+ ? _jsx(NoEntries, { t: t })
160
+ : secretEnvEntries.map(([name, value]) => (_jsx(SecretEnvRow, { t: t, mode: "view", name: name, secret: value }, name))) }), _jsx(FieldGroup, { label: t("portsTitle"), children: container.publishedPorts.length === 0
161
+ ? _jsx(NoEntries, { t: t })
162
+ : container.publishedPorts.map((port) => (_jsx(PortRow, { t: t, mode: "view", port: port.port, protocol: port.protocol, hostPort: port.hostPort }, `${port.protocol}/${port.port}`))) })] })] }), exportError === "" ? null : (_jsx("p", { role: "alert", style: {
163
+ margin: 0,
164
+ color: "var(--dsw-alias-state-error)",
165
+ fontSize: "12px",
166
+ }, children: t("exportTemplateFailed", { message: exportError }) }))] }), _jsx(ContainerEditModal, { t: t, open: open, container: container, images: images, volumes: volumes, secrets: secrets, busy: containerBusy, enabled: enabled, usable: usable, canPublish: canPublish, gatewayUnavailable: gatewayUnavailable, projectName: projectName, projectsRoot: projectsRoot, directoryPicker: directoryPicker, forcedProject: forcedProject, writable: writable, draft: draft, dirty: dirty, pending: pending, marker: marker, markerError: markerError, onBlockingError: setBlockingError, rebuilds: rebuilds, recreatePending: recreatePending, createVolume: createVolume, onCreateSecret: onCreateSecret, onChange: setDraft, onDiscard: discard, onApply: apply, onClose: () => {
167
+ setOpen(false);
168
+ onEditClosed?.();
169
+ }, onBack: prefill === undefined || onEditBack === undefined
170
+ ? undefined
171
+ : () => {
172
+ // Back drops the editor's draft without applying, and the parent
173
+ // clears the one-shot prefill and reopens the template popup.
174
+ discard();
175
+ setOpen(false);
176
+ onEditBack();
177
+ }, backBaseline: prefill?.config })] }));
134
178
  }
135
179
  export { CreateContainerModal } from "./container-card-create-modal.js";
@@ -13,6 +13,7 @@ export declare function SecretModal(props: {
13
13
  t: Translate;
14
14
  mode: "create" | "edit";
15
15
  name?: string;
16
+ initialName?: string;
16
17
  open: boolean;
17
18
  busy: boolean;
18
19
  writable: boolean;
@@ -34,6 +35,7 @@ export declare function SecretEnvEditor(props: {
34
35
  onBlockingError?: (error: Translation | undefined) => void;
35
36
  otherNames?: readonly string[];
36
37
  onNames?: (names: readonly string[]) => void;
38
+ rowError?: (name: string, secret: string) => string | undefined;
37
39
  }): ReactNode;
38
40
  export declare function SecretsSection(props: {
39
41
  t: Translate;