@exagone313/dsh-podman 1.2.1 → 1.4.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.
- package/dist/card-route.d.ts +8 -0
- package/dist/card-route.js +19 -8
- package/dist/client/ContainerCard.js +147 -110
- package/dist/client/card-protocol.d.ts +4 -0
- package/dist/client/card-protocol.js +34 -0
- package/dist/client/container-card-caches.d.ts +1 -1
- package/dist/client/container-card-caches.js +19 -17
- package/dist/client/container-card-config.d.ts +47 -0
- package/dist/client/container-card-config.js +160 -0
- package/dist/client/container-card-controller.d.ts +35 -3
- package/dist/client/container-card-controller.js +263 -41
- package/dist/client/container-card-create-modal.d.ts +5 -1
- package/dist/client/container-card-create-modal.js +111 -94
- package/dist/client/container-card-defaults.d.ts +16 -0
- package/dist/client/container-card-defaults.js +147 -0
- package/dist/client/container-card-dialog-styles.d.ts +7 -0
- package/dist/client/container-card-dialog-styles.js +70 -0
- package/dist/client/container-card-dialog.d.ts +12 -0
- package/dist/client/container-card-dialog.js +47 -0
- package/dist/client/container-card-directory-styles.d.ts +1 -1
- package/dist/client/container-card-directory-styles.js +5 -5
- package/dist/client/container-card-directory.js +8 -7
- package/dist/client/container-card-edit-modal.d.ts +39 -0
- package/dist/client/container-card-edit-modal.js +29 -0
- package/dist/client/container-card-editors.d.ts +5 -2
- package/dist/client/container-card-editors.js +109 -134
- package/dist/client/container-card-field-styles.d.ts +7 -0
- package/dist/client/container-card-field-styles.js +63 -0
- package/dist/client/container-card-form.d.ts +47 -0
- package/dist/client/container-card-form.js +61 -0
- package/dist/client/container-card-group.d.ts +9 -0
- package/dist/client/container-card-group.js +22 -0
- package/dist/client/container-card-images.d.ts +6 -2
- package/dist/client/container-card-images.js +63 -23
- package/dist/client/container-card-paths.js +43 -52
- package/dist/client/container-card-ports.d.ts +3 -4
- package/dist/client/container-card-ports.js +74 -38
- package/dist/client/container-card-resources.d.ts +38 -0
- package/dist/client/container-card-resources.js +73 -0
- package/dist/client/container-card-row.d.ts +11 -19
- package/dist/client/container-card-row.js +122 -122
- package/dist/client/container-card-secrets.d.ts +31 -3
- package/dist/client/container-card-secrets.js +174 -56
- package/dist/client/container-card-shared.d.ts +173 -6
- package/dist/client/container-card-shared.js +616 -57
- package/dist/client/container-card-status.d.ts +18 -0
- package/dist/client/container-card-status.js +166 -0
- package/dist/client/container-card-styles.d.ts +49 -7
- package/dist/client/container-card-styles.js +396 -40
- package/dist/client/container-card-table-styles.d.ts +15 -0
- package/dist/client/container-card-table-styles.js +237 -0
- package/dist/client/container-card-tabs-styles.d.ts +5 -0
- package/dist/client/container-card-tabs-styles.js +46 -0
- package/dist/client/container-card-toast.d.ts +5 -0
- package/dist/client/container-card-toast.js +10 -0
- package/dist/client/container-card-volumes.d.ts +1 -0
- package/dist/client/container-card-volumes.js +14 -19
- package/dist/client/container-card-workspace.d.ts +8 -12
- package/dist/client/container-card-workspace.js +76 -14
- package/dist/client/index.js +6491 -3474
- package/dist/client/locales.d.ts +10 -1
- package/dist/client/locales.js +270 -114
- package/dist/client/relative-time.d.ts +10 -0
- package/dist/client/relative-time.js +74 -0
- package/dist/client/slot-contract.d.ts +8 -0
- package/dist/client/tool-views.js +2 -1
- package/dist/container-env.js +1 -1
- package/dist/env-rows.d.ts +9 -11
- package/dist/env-rows.js +72 -40
- package/dist/generated/version.d.ts +2 -2
- package/dist/generated/version.js +2 -2
- package/dist/guest-terminal.js +1 -1
- package/dist/mount-enums.d.ts +11 -0
- package/dist/mount-enums.js +60 -0
- package/dist/subprocess.js +1 -1
- package/dist/terminal-sessions.js +2 -2
- package/dist/terminal-shells.js +1 -1
- package/dist/tool-handlers.js +1 -1
- package/dist/workspace-binding.js +2 -2
- package/docs/architecture.md +4 -4
- package/docs/architecture.zh.md +1 -1
- package/docs/configuration.md +26 -25
- package/docs/configuration.zh.md +13 -11
- package/docs/development-prompt.md +7 -7
- package/docs/development-prompt.zh.md +7 -7
- package/docs/development.md +20 -16
- package/docs/development.zh.md +17 -16
- package/docs/install-dsh-and-dsh-podman.md +13 -12
- package/docs/install-dsh-and-dsh-podman.zh.md +13 -9
- package/docs/usage.md +189 -39
- package/docs/usage.zh.md +148 -29
- package/package.json +35 -31
- package/dist/client/container-card-default-env.d.ts +0 -10
- package/dist/client/container-card-default-env.js +0 -69
|
@@ -2,54 +2,585 @@ 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 { hint } from "./container-card-styles.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { destructiveAction, editorGroup, emphasisAction, envField, envFieldLabel, envRow, fieldHint, fieldLine, hint, imageSelect, mountField, mountKindField, rowActions, sectionTitle, slotSelect, statusChip, } from "./container-card-styles.js";
|
|
6
|
+
import { FIELD_CLASS, SLOT_CLASS, SLOT_INVALID_CLASS, } from "./container-card-field-styles.js";
|
|
7
|
+
import { MOUNT_ACTIONS_CLASS, MOUNT_DESTINATION_CLASS, MOUNT_FIELD_CLASS, MOUNT_KIND_CLASS, MOUNT_KIND_VALUE_CLASS, MOUNT_ROW_CLASS, } from "./container-card-table-styles.js";
|
|
8
|
+
import { normalizeMountKind, normalizeMountMode } from "../mount-enums.js";
|
|
9
|
+
import { Button, IconCheckOutlineRegular, IconCopyOutlineRegular, Input, Modal, writeClipboard, } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
10
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
11
|
+
// Localized cardinal count: the singular key renders only at exactly one, so
|
|
12
|
+
// both languages can word the count their own way.
|
|
13
|
+
export function countLabel(t, n, one, many) {
|
|
14
|
+
return t(n === 1 ? one : many, { n: String(n) });
|
|
10
15
|
}
|
|
11
16
|
export function Field(props) {
|
|
12
17
|
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [_jsx("label", { htmlFor: props.htmlFor, style: { fontSize: "13px", color: "var(--dsw-alias-label-secondary)" }, children: props.label }), props.children] }));
|
|
13
18
|
}
|
|
19
|
+
// The lock a fixed value carries at the leading edge of its field: a rounded
|
|
20
|
+
// body under a shackle arc, drawn in the field's own muted colour through the
|
|
21
|
+
// input's leading-icon slot. The icon set carries no lock glyph, so it is drawn
|
|
22
|
+
// here; it repeats the fact the tinted surface states — the value is shown, not
|
|
23
|
+
// chosen — and carries no wording of its own, which is why it is hidden from
|
|
24
|
+
// assistive technology.
|
|
25
|
+
export function LockGlyph() {
|
|
26
|
+
return (_jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1", strokeLinecap: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "2.5", y: "5.5", width: "7", height: "5", rx: "1.5" }), _jsx("path", { d: "M4 5.5V4a2 2 0 0 1 4 0v1.5" })] }));
|
|
27
|
+
}
|
|
28
|
+
// The value line of a read-only field: the value itself, which the caller owns,
|
|
29
|
+
// and that field's own copy control. `copyValue` overrides what the control
|
|
30
|
+
// writes when the shown value is a wording of the real one (a relative creation
|
|
31
|
+
// time still copies its instant), `hint` states a fact beside the value without
|
|
32
|
+
// replacing it, and an empty value reads as the shared placeholder with nothing
|
|
33
|
+
// to copy. It is the value slot of CopyField and of a mount row's read-only
|
|
34
|
+
// fields, so a mount reads the same in the block and in the Mounts editor. Every
|
|
35
|
+
// value it renders is fixed, so it always leads with the lock.
|
|
36
|
+
export function ReadOnlyValue(props) {
|
|
37
|
+
const { t, id, value, copyLabel, copyValue, hint } = props;
|
|
38
|
+
return (_jsxs("div", { style: fieldLine, children: [_jsx(Input, { id: id, className: `${SLOT_CLASS} ${FIELD_CLASS}`, icon: _jsx(LockGlyph, {}), readOnly: true, value: value, placeholder: value === "" ? t("valueMissing") : undefined }), _jsx(CopyButton, { t: t, value: copyValue ?? value, label: copyLabel }), hint === undefined ? null : _jsx("span", { style: fieldHint, children: hint })] }));
|
|
39
|
+
}
|
|
40
|
+
// One read-only field of a container block: a visible label above the value and
|
|
41
|
+
// that field's own copy control.
|
|
42
|
+
export function CopyField(props) {
|
|
43
|
+
const { t, label, value, copyLabel, copyValue } = props;
|
|
44
|
+
const id = useId();
|
|
45
|
+
return (_jsxs("div", { style: envField, children: [_jsx("label", { htmlFor: id, style: envFieldLabel, children: label }), _jsx(ReadOnlyValue, { t: t, id: id, value: value, copyLabel: copyLabel, copyValue: copyValue })] }));
|
|
46
|
+
}
|
|
47
|
+
// The copy control a field carries: a discreet icon button whose accessible
|
|
48
|
+
// name says what it copies, and whose check — with its own "copied" wording —
|
|
49
|
+
// confirms the write for a moment.
|
|
50
|
+
export function CopyButton(props) {
|
|
51
|
+
const { t, value, label } = props;
|
|
52
|
+
const [copied, setCopied] = useState(false);
|
|
53
|
+
const resetTimer = useRef();
|
|
54
|
+
const copy = () => {
|
|
55
|
+
void writeClipboard(value).then((ok) => {
|
|
56
|
+
if (!ok)
|
|
57
|
+
return;
|
|
58
|
+
setCopied(true);
|
|
59
|
+
if (resetTimer.current !== undefined)
|
|
60
|
+
clearTimeout(resetTimer.current);
|
|
61
|
+
resetTimer.current = setTimeout(() => setCopied(false), 1500);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
// The reset timer is cancelled on unmount, so it cannot fire against an
|
|
65
|
+
// unmounted component.
|
|
66
|
+
useEffect(() => () => {
|
|
67
|
+
if (resetTimer.current !== undefined)
|
|
68
|
+
clearTimeout(resetTimer.current);
|
|
69
|
+
}, []);
|
|
70
|
+
const name = copied ? t("copied") : label;
|
|
71
|
+
return (_jsx(Button, { variant: "ghost", size: "sm", icon: copied ? _jsx(IconCheckOutlineRegular, {}) : _jsx(IconCopyOutlineRegular, {}), "aria-label": name, disabled: value === "", onClick: copy }));
|
|
72
|
+
}
|
|
14
73
|
export const namePattern = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,63}$/;
|
|
15
74
|
export const imageIdPattern = /^[a-zA-Z0-9_][a-zA-Z0-9_.\-/:]{0,127}$/;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
75
|
+
// Each tone's foreground and fill come from the design system's state palette.
|
|
76
|
+
// No error- or business-tertiary fill exists, so those tones tint their own
|
|
77
|
+
// primary; violet has no token at all, so it tints its own literal.
|
|
78
|
+
const STATUS_TONES = {
|
|
79
|
+
ok: {
|
|
80
|
+
color: "var(--dsw-alias-state-success-primary)",
|
|
81
|
+
background: "var(--dsw-alias-state-success-tertiary)",
|
|
82
|
+
},
|
|
83
|
+
warn: {
|
|
84
|
+
color: "var(--dsw-alias-state-warn-primary)",
|
|
85
|
+
background: "var(--dsw-alias-state-warn-tertiary)",
|
|
86
|
+
},
|
|
87
|
+
error: {
|
|
88
|
+
color: "var(--dsw-alias-state-error-primary)",
|
|
89
|
+
background: "color-mix(in srgb, var(--dsw-alias-state-error-primary) 14%, transparent)",
|
|
90
|
+
},
|
|
91
|
+
business: {
|
|
92
|
+
color: "var(--dsw-alias-state-business-primary)",
|
|
93
|
+
background: "color-mix(in srgb, var(--dsw-alias-state-business-primary) 12%, transparent)",
|
|
94
|
+
},
|
|
95
|
+
violet: {
|
|
96
|
+
color: "#a78bfa",
|
|
97
|
+
background: "color-mix(in srgb, #a78bfa 12%, transparent)",
|
|
98
|
+
},
|
|
99
|
+
muted: {
|
|
100
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
101
|
+
background: "var(--dsw-alias-bg-layer-3)",
|
|
102
|
+
},
|
|
26
103
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
104
|
+
// A state chip: the words state the fact and the tone repeats it in colour, so
|
|
105
|
+
// a failure is visible without relying on colour alone.
|
|
106
|
+
export function StatusChip(props) {
|
|
107
|
+
const { tone, label } = props;
|
|
108
|
+
return _jsx("span", { style: { ...statusChip, ...STATUS_TONES[tone] }, children: label });
|
|
109
|
+
}
|
|
110
|
+
// The short kind chip a mount row leads with. Its tone repeats the kind in
|
|
111
|
+
// colour at a glance, while the chip's word still names it outright.
|
|
112
|
+
export function MountKindChip(props) {
|
|
113
|
+
const { label, tone } = props;
|
|
114
|
+
return _jsx("span", { style: { ...statusChip, ...STATUS_TONES[tone] }, children: label });
|
|
115
|
+
}
|
|
116
|
+
// The Kind field a mount row leads with: the same label-over-value stack a
|
|
117
|
+
// read-only field uses, with the chip in the value slot so it reads on the same
|
|
118
|
+
// line as the fields beside it. The value line reserves an input's own height
|
|
119
|
+
// while the row has room, so the chip sits on the inputs' line; the field's own
|
|
120
|
+
// class gives it a full line on a narrow row, where the container query drops
|
|
121
|
+
// that height again because no input is left to align with. A chip is not a form
|
|
122
|
+
// control, so its label is a span rather than a `<label>`. While a mount is
|
|
123
|
+
// being added the value slot holds the kind picker instead of the chip.
|
|
124
|
+
export function MountKindField(props) {
|
|
125
|
+
const { t, kind, children } = props;
|
|
126
|
+
return (_jsxs("div", { className: MOUNT_KIND_CLASS, style: mountKindField, children: [_jsx("span", { style: envFieldLabel, children: t("mountKind") }), _jsx("div", { className: MOUNT_KIND_VALUE_CLASS, style: fieldLine, children: children ?? (_jsx(MountKindChip, { label: mountKindLabel(t, kind), tone: mountKindTone(kind) })) })] }));
|
|
127
|
+
}
|
|
128
|
+
// One labelled value slot of a shared field row: the field's label above
|
|
129
|
+
// whatever the caller puts in the value position — a read-only value with its
|
|
130
|
+
// copy control in the container block, an editable control in an editor — with
|
|
131
|
+
// the label naming that control through its id.
|
|
132
|
+
export function FieldSlot(props) {
|
|
133
|
+
const { className } = props;
|
|
134
|
+
return (_jsxs("div", { className: className === undefined
|
|
135
|
+
? MOUNT_FIELD_CLASS
|
|
136
|
+
: `${MOUNT_FIELD_CLASS} ${className}`, style: mountField, children: [_jsx("label", { htmlFor: props.htmlFor, style: envFieldLabel, children: props.label }), props.children] }));
|
|
137
|
+
}
|
|
138
|
+
// The canonical field row the container block, the Mounts editor and the three
|
|
139
|
+
// other editors all render through: an optional leading Kind slot, the labelled
|
|
140
|
+
// value slots in order, and the row's own trailing actions. The container block
|
|
141
|
+
// fills each slot with a read-only value and an editor fills it with an editable
|
|
142
|
+
// control, so both render one layout and cannot drift. The row is its own
|
|
143
|
+
// containment context (the class), so its slots share the line while there is
|
|
144
|
+
// room and stack identically on a narrow row, in a card and in a dialog alike.
|
|
145
|
+
export function FieldRow(props) {
|
|
146
|
+
const { leading, fields, actions } = props;
|
|
147
|
+
const base = useId();
|
|
148
|
+
return (_jsxs("div", { className: MOUNT_ROW_CLASS, style: envRow, children: [leading, fields.map((field, index) => {
|
|
149
|
+
const id = `${base}-${index}`;
|
|
150
|
+
return (_jsx(FieldSlot, { label: field.label, htmlFor: id, className: field.className, children: field.render(id) }, index));
|
|
151
|
+
}), actions === undefined
|
|
152
|
+
? null
|
|
153
|
+
: (_jsx("div", { className: MOUNT_ACTIONS_CLASS, style: rowActions, children: actions }))] }));
|
|
154
|
+
}
|
|
155
|
+
// The value slot of a shared row: the container's own value as a read-only
|
|
156
|
+
// field in the block, the caller's control in an editor — each with that
|
|
157
|
+
// field's own copy control, so a value is copyable wherever it is rendered.
|
|
158
|
+
// `below` carries a line that belongs under the control (a browse error) and
|
|
159
|
+
// `hint` states a fact beside the value itself, so neither ever replaces the
|
|
160
|
+
// value; `trailing` is a control the row itself owns (an editor's Remove),
|
|
161
|
+
// placed after the copy control at the line's end so the row keeps the block's
|
|
162
|
+
// field widths.
|
|
163
|
+
function ValueField(props) {
|
|
164
|
+
const { t, mode, id, value, copyLabel, copyValue, hint, below, trailing, children, } = props;
|
|
165
|
+
if (mode === "view") {
|
|
166
|
+
return (_jsx(ReadOnlyValue, { t: t, id: id, value: value, copyLabel: copyLabel, copyValue: copyValue, hint: hint }));
|
|
167
|
+
}
|
|
168
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { style: fieldLine, children: [children, _jsx(CopyButton, { t: t, value: copyValue ?? value, label: copyLabel }), trailing ?? null] }), below ?? null] }));
|
|
169
|
+
}
|
|
170
|
+
// The Image field, shared by the container block and every dialog that edits a
|
|
171
|
+
// container: the block states the image the container runs, the editors offer
|
|
172
|
+
// the image picker. The candidates are listed base images first, custom ones
|
|
173
|
+
// after, and an image the snapshot no longer lists stays selectable rather than
|
|
174
|
+
// being silently replaced by the first candidate.
|
|
175
|
+
export function ImageRow(props) {
|
|
176
|
+
const { t, mode, image, candidates, disabled, onChange } = props;
|
|
177
|
+
const options = candidates ?? [];
|
|
178
|
+
return (_jsx(FieldRow, { fields: [{
|
|
179
|
+
label: t("image"),
|
|
180
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: image, copyLabel: t("copyImage"), children: _jsxs("select", { id: id, style: imageSelect, value: image, disabled: disabled === true, "aria-label": t("image"), onChange: (event) => onChange?.(event.target.value), children: [image !== "" && options.includes(image)
|
|
181
|
+
? null
|
|
182
|
+
: (_jsx("option", { value: image, children: image === "" ? t("none") : image })), options.map((candidate) => (_jsx("option", { value: candidate, children: candidate }, candidate)))] }) })),
|
|
183
|
+
}] }));
|
|
184
|
+
}
|
|
185
|
+
// One environment variable's row, shared by the container block and the
|
|
186
|
+
// environment editor: its Key and Value as separate fields, never a merged
|
|
187
|
+
// KEY=value string. The block shows both as read-only copyable fields; the
|
|
188
|
+
// editor shows the two controls that change them and the row's own Remove,
|
|
189
|
+
// which sits at the value line's end exactly where the block puts that field's
|
|
190
|
+
// copy control, so both render the same two fields at the same widths.
|
|
191
|
+
export function EnvRow(props) {
|
|
192
|
+
const { t, mode, name, value, disabled, autoFocus, onChangeName, onChangeValue, onRemove, removeLabel, keyInvalid, } = props;
|
|
193
|
+
const disabledField = disabled === true;
|
|
194
|
+
const keyClass = keyInvalid === true
|
|
195
|
+
? `${SLOT_CLASS} ${SLOT_INVALID_CLASS}`
|
|
196
|
+
: SLOT_CLASS;
|
|
197
|
+
const removeControl = mode === "edit" && onRemove !== undefined
|
|
198
|
+
? (_jsx(Button, { variant: "outline", size: "sm", "aria-label": removeLabel ?? t("removeEnv"), disabled: disabledField, style: destructiveAction, onClick: onRemove, children: t("removeEnv") }))
|
|
199
|
+
: undefined;
|
|
200
|
+
return (_jsx(FieldRow, { fields: [
|
|
201
|
+
{
|
|
202
|
+
label: t("envKey"),
|
|
203
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: name, copyLabel: t("copyEnvKey", { key: name }), children: _jsx(Input, { id: id, className: keyClass, value: name, disabled: disabledField, placeholder: t("envKey"), autoFocus: autoFocus, onChange: (event) => onChangeName?.(event.target.value) }) })),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
label: t("envValue"),
|
|
207
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: value, copyLabel: t("copyEnvValue", { key: name }), trailing: removeControl, children: _jsx(Input, { id: id, className: SLOT_CLASS, value: value, disabled: disabledField, placeholder: t("envValue"), onChange: (event) => onChangeValue?.(event.target.value) }) })),
|
|
208
|
+
},
|
|
209
|
+
] }));
|
|
210
|
+
}
|
|
211
|
+
// The short mode one mount carries, in the words the mode pickers use.
|
|
212
|
+
const mountModeLabel = (t, mode) => normalizeMountMode(mode) === "read_only" ? t("readOnly") : t("readWrite");
|
|
213
|
+
// The source control a mount kind takes, in a mount row's source slot: the
|
|
214
|
+
// project path, the volume picker or the secret picker. A tmpfs row never asks
|
|
215
|
+
// for it, since tmpfs mounts no source. The select fills its slot exactly like
|
|
216
|
+
// the text field beside it, so switching a mount's kind never resizes the row.
|
|
217
|
+
function MountSourceControl(props) {
|
|
218
|
+
const { t, id, kind, disabled } = props;
|
|
219
|
+
const normalized = normalizeMountKind(kind);
|
|
220
|
+
if (normalized === "volume") {
|
|
221
|
+
// A volume the snapshot no longer lists stays selectable rather than being
|
|
222
|
+
// silently replaced by the first candidate.
|
|
223
|
+
const missing = props.volume !== "" &&
|
|
224
|
+
!props.volumes.some((volume) => volume.name === props.volume);
|
|
225
|
+
return (_jsxs("select", { id: id, style: slotSelect, value: props.volume, disabled: disabled, onChange: (event) => props.onVolume(event.target.value), children: [missing ? _jsx("option", { value: props.volume, children: props.volume }) : null, props.volumes.length === 0
|
|
226
|
+
? _jsx("option", { value: "", children: t("none") })
|
|
227
|
+
: null, props.volumes.map((volume) => (_jsx("option", { value: volume.name, children: volume.name }, volume.name)))] }));
|
|
228
|
+
}
|
|
229
|
+
if (normalized === "secret") {
|
|
230
|
+
const missing = props.secret !== "" &&
|
|
231
|
+
!props.secrets.some((secret) => secret.name === props.secret);
|
|
232
|
+
return (_jsxs("select", { id: id, style: slotSelect, value: props.secret, disabled: disabled, onChange: (event) => props.onSecret(event.target.value), children: [missing ? _jsx("option", { value: props.secret, children: props.secret }) : null, props.secrets.length === 0
|
|
233
|
+
? _jsx("option", { value: "", children: t("none") })
|
|
234
|
+
: null, props.secrets.map((secret) => (_jsx("option", { value: secret.name, children: secret.name }, secret.name)))] }));
|
|
235
|
+
}
|
|
236
|
+
return (_jsx(Input, { id: id, className: props.projectReadOnlyReason === undefined
|
|
237
|
+
? SLOT_CLASS
|
|
238
|
+
: `${SLOT_CLASS} ${FIELD_CLASS}`, icon: props.projectReadOnlyReason === undefined
|
|
239
|
+
? undefined
|
|
240
|
+
: _jsx(LockGlyph, {}), value: props.project,
|
|
241
|
+
// The path of a mount that cannot be removed cannot be typed into either:
|
|
242
|
+
// it stays readable and selectable, on the fixed value's own surface, with
|
|
243
|
+
// the reason as its tooltip.
|
|
244
|
+
readOnly: props.projectReadOnlyReason !== undefined, title: props.projectReadOnlyReason, disabled: disabled, onChange: (event) => props.onProject(event.target.value) }));
|
|
245
|
+
}
|
|
246
|
+
// The canonical mount row: Kind, Destination, the source field the kind takes
|
|
247
|
+
// and Mode, in that order, plus the editor's own trailing actions, through the
|
|
248
|
+
// one shared field row. The row itself decides which fields a kind carries:
|
|
249
|
+
// tmpfs mounts no source, and a secret or tmpfs carries no mode. The block
|
|
250
|
+
// fills each field with the container's own value; an editor fills it with the
|
|
251
|
+
// control that changes it.
|
|
252
|
+
export function MountRow(props) {
|
|
253
|
+
const { t, mode, mount, destination, kindValue, disabled, volumes, secrets, onUpdate, onBrowse, browseError, onRemove, confirmRemove, removeDisabledReason, } = props;
|
|
254
|
+
const disabledField = disabled === true;
|
|
255
|
+
const update = (patch) => onUpdate?.(patch);
|
|
256
|
+
// A project mount never takes a destination of its own — the host derives its
|
|
257
|
+
// mirror under the projects root — so the preview of it is a fixed value.
|
|
258
|
+
const destinationFixed = normalizeMountKind(mount.kind) === "project";
|
|
259
|
+
const fields = [
|
|
260
|
+
{
|
|
261
|
+
label: t("mountDestination"),
|
|
262
|
+
className: MOUNT_DESTINATION_CLASS,
|
|
263
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: destination, copyLabel: t("copyMountPath", {
|
|
264
|
+
path: destination === "" ? t("valueMissing") : destination,
|
|
265
|
+
}), children: _jsx(Input, { id: id, className: destinationFixed
|
|
266
|
+
? `${SLOT_CLASS} ${FIELD_CLASS}`
|
|
267
|
+
: SLOT_CLASS, icon: destinationFixed ? _jsx(LockGlyph, {}) : undefined, value: destination, readOnly: destinationFixed, disabled: disabledField, onChange: (event) => update({ destination: event.target.value }), style: { width: "100%" } }) })),
|
|
268
|
+
},
|
|
269
|
+
];
|
|
270
|
+
const source = mountSourceName(mount);
|
|
271
|
+
if (mountHasSource(mount.kind)) {
|
|
272
|
+
fields.push({
|
|
273
|
+
label: mountSourceLabel(t, mount.kind),
|
|
274
|
+
render: (id) => (_jsxs(ValueField, { t: t, mode: mode, id: id, value: source, copyLabel: t("copyMountName", { name: source }), below: browseError === undefined || browseError === ""
|
|
275
|
+
? undefined
|
|
276
|
+
: (_jsx("p", { style: { margin: 0, fontSize: "13px" }, role: "alert", children: browseError })), children: [_jsx(MountSourceControl, { t: t, id: id, kind: mount.kind, project: mount.project, volume: mount.volume, secret: mount.secret, volumes: volumes ?? [], secrets: secrets ?? [], disabled: disabledField, projectReadOnlyReason: removeDisabledReason, onProject: (project) => update({ project }), onVolume: (volume) => update({ volume }), onSecret: (secret) => update({ secret }) }), onBrowse === undefined ? null : (_jsx(Button, { variant: "outline", size: "sm",
|
|
277
|
+
// The path that cannot be typed into cannot be browsed to either:
|
|
278
|
+
// the Browse stays in place, greyed out and disabled, with the
|
|
279
|
+
// reason as its tooltip.
|
|
280
|
+
disabled: disabledField || removeDisabledReason !== undefined, title: removeDisabledReason, "aria-label": removeDisabledReason, onClick: onBrowse, children: t("browse") }))] })),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const modeLabel = mountModeLabel(t, mount.mode);
|
|
284
|
+
if (mountHasMode(mount.kind)) {
|
|
285
|
+
fields.push({
|
|
286
|
+
label: t("mountMode"),
|
|
287
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: modeLabel, copyLabel: t("copyMountMode", { mode: modeLabel }), children: _jsxs("select", { id: id, style: slotSelect, value: normalizeMountMode(mount.mode), disabled: disabledField, onChange: (event) => update({ mode: event.target.value }), children: [_jsx("option", { value: "read_only", children: t("readOnly") }), _jsx("option", { value: "read_write", children: t("readWrite") })] }) })),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
const actions = mode === "view"
|
|
291
|
+
? undefined
|
|
292
|
+
: removeDisabledReason !== undefined
|
|
293
|
+
? (_jsx(Button, { variant: "outline", size: "sm", disabled: true, title: removeDisabledReason, "aria-label": removeDisabledReason, children: t("remove") }))
|
|
294
|
+
: onRemove === undefined
|
|
295
|
+
? undefined
|
|
296
|
+
: confirmRemove === true
|
|
297
|
+
? (_jsx(ConfirmButton, { t: t, destructive: true, label: t("remove"), title: t("removeMountTitle"), description: t("confirmRemoveMount", {
|
|
298
|
+
mount: mountLabel(t, mount, false),
|
|
299
|
+
}), confirmLabel: t("removeMountTitle"), disabled: disabledField, onConfirm: onRemove }))
|
|
300
|
+
: (_jsx(Button, { variant: "outline", size: "sm", disabled: disabledField, style: destructiveAction, onClick: onRemove, children: t("remove") }));
|
|
301
|
+
return (_jsx(FieldRow, { leading: _jsx(MountKindField, { t: t, kind: mount.kind, children: kindValue }), fields: fields, actions: actions }));
|
|
302
|
+
}
|
|
303
|
+
// The compact controls a PATH row carries beside its field: the drag handle and
|
|
304
|
+
// the move/remove buttons are symbols, so their meaning lives in the title and
|
|
305
|
+
// the accessible name instead of a visible label.
|
|
306
|
+
const rowButton = {
|
|
307
|
+
padding: 0,
|
|
308
|
+
minWidth: "28px",
|
|
309
|
+
};
|
|
310
|
+
const dragHandle = {
|
|
311
|
+
cursor: "grab",
|
|
312
|
+
background: "none",
|
|
313
|
+
border: "none",
|
|
314
|
+
padding: 0,
|
|
315
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
316
|
+
};
|
|
317
|
+
// One PATH addition, shared by the container block and the PATH editor: the
|
|
318
|
+
// block shows the entry as a read-only copyable field, the editor shows the
|
|
319
|
+
// input and the row's own reorder and remove controls.
|
|
320
|
+
export function PathRow(props) {
|
|
321
|
+
const { t, mode, path, disabled, autoFocus, first, last, onChange, onMove, onRemove, onDragStart, onDrop, } = props;
|
|
322
|
+
const disabledField = disabled === true;
|
|
323
|
+
return (_jsx(FieldRow, { fields: [{
|
|
324
|
+
label: t("path"),
|
|
325
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: path, copyLabel: t("copyPathEntry", { path }), children: _jsx(Input, { id: id, value: path, disabled: disabledField, autoFocus: autoFocus, onChange: (event) => onChange?.(event.target.value), style: { width: "100%" } }) })),
|
|
326
|
+
}], actions: mode === "edit"
|
|
327
|
+
? (_jsxs(_Fragment, { children: [onDragStart === undefined ? null : (_jsx("button", { type: "button", title: t("dragToReorder"), "aria-label": t("dragToReorder"), draggable: !disabledField, onDragStart: onDragStart, onDragOver: (event) => event.preventDefault(), onDrop: onDrop, style: dragHandle, children: "\u2261" })), onMove === undefined ? null : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", title: t("moveUp"), "aria-label": t("moveUp"), disabled: disabledField || first === true, onClick: () => onMove(-1), style: rowButton, children: "\u2191" }), _jsx(Button, { variant: "outline", size: "sm", title: t("moveDown"), "aria-label": t("moveDown"), disabled: disabledField || last === true, onClick: () => onMove(1), style: rowButton, children: "\u2193" })] })), onRemove === undefined ? null : (_jsx(Button, { variant: "outline", size: "sm", title: t("remove"), "aria-label": t("remove"), disabled: disabledField, onClick: onRemove, style: { ...rowButton, ...destructiveAction }, children: "\u00D7" }))] }))
|
|
328
|
+
: undefined }));
|
|
329
|
+
}
|
|
330
|
+
// One secret environment variable, shared by the container block and the secret
|
|
331
|
+
// editor: the block shows the variable and the secret it points at as read-only
|
|
332
|
+
// copyable fields, the editor shows the variable name and the secret picker with
|
|
333
|
+
// the row's own Remove at the value line's end, exactly where the block puts
|
|
334
|
+
// that field's copy control, so both render the same two fields at the same
|
|
335
|
+
// widths. Removing one only stages the change, so it needs no confirmation.
|
|
336
|
+
export function SecretEnvRow(props) {
|
|
337
|
+
const { t, mode, name, secret, secrets, disabled, autoFocus, onChangeName, onChangeSecret, onRemove, keyInvalid, } = props;
|
|
338
|
+
const disabledField = disabled === true;
|
|
339
|
+
const candidates = secrets ?? [];
|
|
340
|
+
const removeControl = mode === "edit" && onRemove !== undefined
|
|
341
|
+
? (_jsx(Button, { variant: "outline", size: "sm", disabled: disabledField, style: destructiveAction, onClick: onRemove, children: t("remove") }))
|
|
342
|
+
: undefined;
|
|
343
|
+
return (_jsx(FieldRow, { fields: [
|
|
344
|
+
{
|
|
345
|
+
label: t("envKey"),
|
|
346
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: name, copyLabel: t("copyEnvKey", { key: name }), children: _jsx(Input, { id: id, className: keyInvalid === true
|
|
347
|
+
? `${SLOT_CLASS} ${SLOT_INVALID_CLASS}`
|
|
348
|
+
: SLOT_CLASS, value: name, disabled: disabledField, placeholder: t("secretEnvName"), autoFocus: autoFocus, onChange: (event) => onChangeName?.(event.target.value) }) })),
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
label: t("envValue"),
|
|
352
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: mode, id: id, value: secret, copyLabel: t("copyEnvValue", { key: name }), trailing: removeControl, children: _jsxs("select", { id: id, style: slotSelect, value: secret, disabled: disabledField, onChange: (event) => onChangeSecret?.(event.target.value), children: [candidates.some((candidate) => candidate.name === secret)
|
|
353
|
+
? null
|
|
354
|
+
: _jsx("option", { value: secret, children: secret }), candidates.length === 0
|
|
355
|
+
? _jsx("option", { value: "", children: t("none") })
|
|
356
|
+
: null, candidates.map((candidate) => (_jsx("option", { value: candidate.name, children: candidate.name }, candidate.name)))] }) })),
|
|
357
|
+
},
|
|
358
|
+
] }));
|
|
359
|
+
}
|
|
360
|
+
// One published port, shared by the container block and the port editor: the
|
|
361
|
+
// container port, then the host port the gateway bound — or, while the gateway
|
|
362
|
+
// has not bound one yet, the host port the user asked for with "(pending)"
|
|
363
|
+
// appended inside the field, so the entered port stays visible — then the
|
|
364
|
+
// protocol, each copyable on its own. The block shows the port as it is; the
|
|
365
|
+
// editor adds the row's own Remove or Unpublish action.
|
|
366
|
+
export function PortRow(props) {
|
|
367
|
+
const { t, mode, port, protocol, hostPort, suggestedHostPort = 0, pending, disabled, onRemove, removeLabel, } = props;
|
|
368
|
+
const containerPort = String(port);
|
|
369
|
+
const bound = hostPort > 0 ? String(hostPort) : "";
|
|
370
|
+
const requested = suggestedHostPort > 0 ? String(suggestedHostPort) : "";
|
|
371
|
+
const hostValue = bound !== "" ? bound : requested;
|
|
372
|
+
// A port the gateway has not bound yet keeps the value the user entered and
|
|
373
|
+
// says so inside the field, rather than replacing the value with that fact.
|
|
374
|
+
const pendingSuffix = pending === true ? t("portPendingSuffix") : "";
|
|
375
|
+
const hostField = hostValue === ""
|
|
376
|
+
? pendingSuffix
|
|
377
|
+
: pendingSuffix === ""
|
|
378
|
+
? hostValue
|
|
379
|
+
: `${hostValue} ${pendingSuffix}`;
|
|
380
|
+
return (_jsx(FieldRow, { fields: [
|
|
381
|
+
{
|
|
382
|
+
label: t("containerPort"),
|
|
383
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: "view", id: id, value: containerPort, copyLabel: t("copyContainerPort", { port: containerPort }) })),
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
label: t("hostPort"),
|
|
387
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: "view", id: id, value: hostField, copyValue: hostValue, copyLabel: t("copyHostPort", {
|
|
388
|
+
port: hostValue === "" ? t("valueMissing") : hostValue,
|
|
389
|
+
}) })),
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
label: t("protocol"),
|
|
393
|
+
render: (id) => (_jsx(ValueField, { t: t, mode: "view", id: id, value: protocol, copyLabel: t("copyProtocol", { protocol }) })),
|
|
394
|
+
},
|
|
395
|
+
], actions: mode === "edit" && onRemove !== undefined
|
|
396
|
+
? (_jsx(Button, { variant: "outline", size: "sm", disabled: disabled === true, style: destructiveAction, onClick: onRemove, children: removeLabel ?? t("remove") }))
|
|
397
|
+
: undefined }));
|
|
398
|
+
}
|
|
399
|
+
// The tone a container's status reads with; an unreadable status stays neutral
|
|
400
|
+
// rather than guessing at a failure.
|
|
401
|
+
export function containerStatusTone(status) {
|
|
402
|
+
if (status === "running")
|
|
403
|
+
return "ok";
|
|
404
|
+
if (status === "missing")
|
|
405
|
+
return "error";
|
|
406
|
+
return "muted";
|
|
407
|
+
}
|
|
408
|
+
// The tone an image's status reads with: an image that is present (built or
|
|
409
|
+
// pulled) is fine, a missing one is a failure.
|
|
410
|
+
export function imageStatusTone(status) {
|
|
411
|
+
if (status === "built" || status === "pulled")
|
|
412
|
+
return "ok";
|
|
413
|
+
if (status === "missing")
|
|
414
|
+
return "error";
|
|
415
|
+
return "muted";
|
|
416
|
+
}
|
|
417
|
+
// A titled region of the card: a `<section>` with a real heading instead of a
|
|
418
|
+
// styled div, so assistive technology can name and navigate it. `action` is a
|
|
419
|
+
// control that shares the heading's line (Build, Create, Copy…).
|
|
420
|
+
export function Subsection(props) {
|
|
421
|
+
const { title, action, children } = props;
|
|
422
|
+
const headingId = useId();
|
|
423
|
+
return (_jsxs("section", { "aria-labelledby": headingId, children: [_jsxs("div", { style: {
|
|
424
|
+
display: "flex",
|
|
425
|
+
flexWrap: "wrap",
|
|
426
|
+
alignItems: "center",
|
|
427
|
+
gap: "8px",
|
|
428
|
+
}, children: [_jsx("h3", { id: headingId, style: { ...sectionTitle, flex: 1 }, children: title }), action] }), children] }));
|
|
429
|
+
}
|
|
430
|
+
// One labelled group of a dialog: the heading, one line saying what the group
|
|
431
|
+
// is for, and its controls. The heading is a real heading under the dialog's
|
|
432
|
+
// own title (a dialog group is a `<section>`), and it never carries a rule.
|
|
433
|
+
export function DialogGroup(props) {
|
|
434
|
+
const { title, guidance, children } = props;
|
|
435
|
+
const headingId = useId();
|
|
436
|
+
return (_jsxs("section", { style: editorGroup, "aria-labelledby": headingId, children: [_jsx("h3", { id: headingId, style: sectionTitle, children: title }), guidance === undefined
|
|
437
|
+
? null
|
|
438
|
+
: _jsx("p", { style: { ...hint, margin: 0 }, children: guidance }), children] }));
|
|
439
|
+
}
|
|
440
|
+
// The short kind a mount row leads with, one chip per kind. The words reuse the
|
|
441
|
+
// kind picker's own labels wherever they are already short (tmpfs, Volume,
|
|
442
|
+
// Secret); a project gets a shorter one, since its picker entry also names the
|
|
443
|
+
// mount.
|
|
444
|
+
export const mountKindLabel = (t, kind) => {
|
|
445
|
+
const normalized = normalizeMountKind(kind);
|
|
446
|
+
if (normalized === "tmpfs")
|
|
447
|
+
return t("mountTmpfs");
|
|
448
|
+
if (normalized === "volume")
|
|
449
|
+
return t("mountVolume");
|
|
450
|
+
if (normalized === "secret")
|
|
451
|
+
return t("mountSecret");
|
|
452
|
+
return t("mountProjectShort");
|
|
453
|
+
};
|
|
454
|
+
// The tone a mount's kind chip reads with: the business blue for a project, the
|
|
455
|
+
// success green for a volume, the warn amber for a secret, and a violet literal
|
|
456
|
+
// for tmpfs, which has no design-system token of its own.
|
|
457
|
+
export const mountKindTone = (kind) => {
|
|
458
|
+
const normalized = normalizeMountKind(kind);
|
|
459
|
+
if (normalized === "volume")
|
|
460
|
+
return "ok";
|
|
461
|
+
if (normalized === "secret")
|
|
462
|
+
return "warn";
|
|
463
|
+
if (normalized === "tmpfs")
|
|
464
|
+
return "violet";
|
|
465
|
+
return "business";
|
|
466
|
+
};
|
|
467
|
+
// The label of the field carrying a mount's source: a project by its path, a
|
|
468
|
+
// volume and a secret by their own names. tmpfs has no source to label.
|
|
469
|
+
export const mountSourceLabel = (t, kind) => {
|
|
470
|
+
const normalized = normalizeMountKind(kind);
|
|
471
|
+
if (normalized === "volume")
|
|
472
|
+
return t("volumeName");
|
|
473
|
+
if (normalized === "secret")
|
|
474
|
+
return t("secretName");
|
|
475
|
+
return t("mountPath");
|
|
476
|
+
};
|
|
477
|
+
// The source one mount names: its project path, its volume or its secret. tmpfs
|
|
478
|
+
// is the one kind that mounts no source at all.
|
|
479
|
+
export const mountSourceName = (mount) => {
|
|
480
|
+
const normalized = normalizeMountKind(mount.kind);
|
|
481
|
+
if (normalized === "volume")
|
|
482
|
+
return mount.volume;
|
|
483
|
+
if (normalized === "secret")
|
|
484
|
+
return mount.secret;
|
|
485
|
+
if (normalized === "project")
|
|
486
|
+
return mount.project;
|
|
487
|
+
return "";
|
|
488
|
+
};
|
|
489
|
+
// Whether a mount kind names a source at all. tmpfs is the one kind that mounts
|
|
490
|
+
// no source, so its row carries no source field.
|
|
491
|
+
export const mountHasSource = (kind) => normalizeMountKind(kind) !== "tmpfs";
|
|
492
|
+
// Whether a mount kind carries a mode at all. A project and a volume mount are
|
|
493
|
+
// the ones a caller may switch; a secret is fixed read-only and a tmpfs is
|
|
494
|
+
// always read-write, so neither shows a mode control.
|
|
495
|
+
export const mountHasMode = (kind) => {
|
|
496
|
+
const normalized = normalizeMountKind(kind);
|
|
497
|
+
return normalized === "project" || normalized === "volume";
|
|
498
|
+
};
|
|
499
|
+
export const mountViewToInput = (mount) => {
|
|
500
|
+
const kind = normalizeMountKind(mount.kind);
|
|
501
|
+
return {
|
|
502
|
+
kind,
|
|
503
|
+
project: mount.projectName,
|
|
504
|
+
// A project mount never carries a destination on the wire: the host derives
|
|
505
|
+
// its mirror under the projects root. The snapshot keeps the derived path
|
|
506
|
+
// for the container block to render.
|
|
507
|
+
destination: kind === "project" ? "" : mount.destination,
|
|
508
|
+
mode: normalizeMountMode(mount.mode),
|
|
509
|
+
volume: mount.volume,
|
|
510
|
+
secret: mount.secret,
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
// The category a mount sorts under in an ordered mounts list: the workspace's
|
|
514
|
+
// main project mount first, then read-write projects, read-only projects,
|
|
515
|
+
// read-write volumes, read-only volumes, secrets and tmpfs.
|
|
516
|
+
function mountRank(mount, mainProject) {
|
|
517
|
+
if (mount.kind === "project" && mainProject !== "" &&
|
|
518
|
+
mount.project === mainProject) {
|
|
519
|
+
return 0;
|
|
520
|
+
}
|
|
521
|
+
if (mount.kind === "project")
|
|
522
|
+
return mount.mode === "read_write" ? 1 : 2;
|
|
523
|
+
if (mount.kind === "volume")
|
|
524
|
+
return mount.mode === "read_write" ? 3 : 4;
|
|
525
|
+
if (mount.kind === "secret")
|
|
526
|
+
return 5;
|
|
527
|
+
return 6;
|
|
528
|
+
}
|
|
529
|
+
// The mounts in the one order both the editors and a container block list them
|
|
530
|
+
// in: one category at a time, sorted by mounted path inside the category. Each
|
|
531
|
+
// entry keeps the index it has in the draft, so an edit or a removal still
|
|
532
|
+
// targets the entry behind the row.
|
|
533
|
+
export function orderedMounts(mounts, mainProject) {
|
|
534
|
+
return mounts
|
|
535
|
+
.map((mount, index) => ({ mount, index }))
|
|
536
|
+
.sort((left, right) => {
|
|
537
|
+
const rank = mountRank(left.mount, mainProject) -
|
|
538
|
+
mountRank(right.mount, mainProject);
|
|
539
|
+
if (rank !== 0)
|
|
540
|
+
return rank;
|
|
541
|
+
// A stable sort keeps the draft order inside a category when two mounts
|
|
542
|
+
// share a destination.
|
|
543
|
+
const a = left.mount.destination;
|
|
544
|
+
const b = right.mount.destination;
|
|
545
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
36
548
|
export const mountLabel = (t, mount, withMode = true) => {
|
|
549
|
+
const destination = mount.destination !== "" ? ` → ${mount.destination}` : "";
|
|
37
550
|
if (mount.kind === "tmpfs") {
|
|
38
551
|
return `${t("mountTmpfs")}${mount.destination !== "" ? ` ${t("mountAt")} ${mount.destination}` : ""}`;
|
|
39
552
|
}
|
|
40
553
|
if (mount.kind === "volume") {
|
|
41
|
-
return
|
|
554
|
+
return `${t("mountVolume")} ${mount.volume}${destination}`;
|
|
42
555
|
}
|
|
43
556
|
if (mount.kind === "secret") {
|
|
44
|
-
return
|
|
557
|
+
return `${t("mountSecret")} ${mount.secret}${destination}`;
|
|
45
558
|
}
|
|
46
559
|
const mode = withMode
|
|
47
560
|
? ` ${t(mount.mode === "read_only"
|
|
48
561
|
? "mountReadOnlySuffix"
|
|
49
562
|
: "mountReadWriteSuffix")}`
|
|
50
563
|
: "";
|
|
51
|
-
return `${
|
|
564
|
+
return `${t("mountProject")} ${mount.project}${destination}${mode}`;
|
|
52
565
|
};
|
|
566
|
+
// The protocol status strings the orchestrator reports are localized here; a
|
|
567
|
+
// value the card does not know yet is shown as it arrived rather than hidden.
|
|
568
|
+
export function containerStatusLabel(t, status) {
|
|
569
|
+
if (status === "running")
|
|
570
|
+
return t("statusRunning");
|
|
571
|
+
if (status === "stopped")
|
|
572
|
+
return t("statusStopped");
|
|
573
|
+
return status;
|
|
574
|
+
}
|
|
575
|
+
export function imageStatusLabel(t, status) {
|
|
576
|
+
if (status === "built")
|
|
577
|
+
return t("statusBuilt");
|
|
578
|
+
if (status === "pulled")
|
|
579
|
+
return t("statusPulled");
|
|
580
|
+
if (status === "missing")
|
|
581
|
+
return t("statusMissing");
|
|
582
|
+
return status;
|
|
583
|
+
}
|
|
53
584
|
// Adding a mount defaults to read-only, so granting write access is always a
|
|
54
585
|
// deliberate choice. tmpfs is scratch space and must be writable.
|
|
55
586
|
export const emptyMount = (kind = "project") => ({
|
|
@@ -60,14 +591,26 @@ export const emptyMount = (kind = "project") => ({
|
|
|
60
591
|
volume: "",
|
|
61
592
|
secret: "",
|
|
62
593
|
});
|
|
594
|
+
// The step that keeps a dialog from closing over an unsaved draft: the caller
|
|
595
|
+
// routes every close (Cancel, the header button, Escape, the mask) through it
|
|
596
|
+
// and only closes once the user confirms the discard.
|
|
597
|
+
export function DiscardChangesModal(props) {
|
|
598
|
+
const { t, open, onCancel, onDiscard } = props;
|
|
599
|
+
return (_jsx(Modal, { open: open, onClose: onCancel, title: t("discardChangesTitle"), closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: onCancel, children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", onClick: onDiscard, children: t("discardChanges") })] }), children: _jsx("p", { style: { ...hint, margin: 0 }, children: t("confirmDiscardChanges") }) }));
|
|
600
|
+
}
|
|
63
601
|
export function ConfirmButton(props) {
|
|
64
|
-
const { t, label, title, description, disabled, ariaLabel, onConfirm } = props;
|
|
602
|
+
const { t, label, title, description, id, disabled, pending, ariaLabel, variant, destructive, emphasis, onConfirm, } = props;
|
|
65
603
|
const [open, setOpen] = useState(false);
|
|
66
604
|
const confirm = () => {
|
|
67
605
|
setOpen(false);
|
|
68
606
|
onConfirm();
|
|
69
607
|
};
|
|
70
|
-
|
|
608
|
+
const triggerStyle = destructive === true
|
|
609
|
+
? destructiveAction
|
|
610
|
+
: emphasis === undefined
|
|
611
|
+
? undefined
|
|
612
|
+
: emphasisAction[emphasis];
|
|
613
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { id: id, variant: variant ?? "outline", size: "sm", disabled: disabled === true || pending === true, "aria-label": ariaLabel, style: triggerStyle, onClick: () => setOpen(true), children: pending === true ? t("busy") : label }), _jsx(Modal, { open: open, onClose: () => setOpen(false), title: title, closeLabel: t("cancel"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => setOpen(false), children: t("cancel") }), _jsx(Button, { variant: "primary", size: "sm", onClick: confirm, children: props.confirmLabel ?? label })] }), children: _jsx("p", { style: { ...hint, margin: 0 }, children: description }) })] }));
|
|
71
614
|
}
|
|
72
615
|
export function Chip(props) {
|
|
73
616
|
const { t, label, disabled, onRemove } = props;
|
|
@@ -93,7 +636,7 @@ export function Chip(props) {
|
|
|
93
636
|
}, children: "\u00D7" }))] }));
|
|
94
637
|
}
|
|
95
638
|
export function TagInput(props) {
|
|
96
|
-
const { t, value, onChange, placeholder, disabled, id } = props;
|
|
639
|
+
const { t, value, onChange, placeholder, disabled, id, chipsBelow } = props;
|
|
97
640
|
const [draft, setDraft] = useState("");
|
|
98
641
|
const commit = (raw) => {
|
|
99
642
|
const tag = raw.trim();
|
|
@@ -101,36 +644,52 @@ export function TagInput(props) {
|
|
|
101
644
|
return;
|
|
102
645
|
onChange([...value, tag]);
|
|
103
646
|
};
|
|
647
|
+
const chips = value.map((tag) => (_jsx(Chip, { t: t, label: tag, disabled: disabled, onRemove: () => onChange(value.filter((item) => item !== tag)) }, tag)));
|
|
648
|
+
const field = (_jsx(Input, { id: id, value: draft, disabled: disabled, placeholder: placeholder, onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
|
|
649
|
+
if (event.key === " " || event.key === "," || event.key === "Enter") {
|
|
650
|
+
if (event.key === " " || event.key === ",")
|
|
651
|
+
event.preventDefault();
|
|
652
|
+
commit(draft);
|
|
653
|
+
setDraft("");
|
|
654
|
+
}
|
|
655
|
+
else if (event.key === "Backspace" && draft === "") {
|
|
656
|
+
const last = value[value.length - 1];
|
|
657
|
+
if (last !== undefined)
|
|
658
|
+
onChange(value.slice(0, -1));
|
|
659
|
+
}
|
|
660
|
+
}, onPaste: (event) => {
|
|
661
|
+
const text = event.clipboardData.getData("text");
|
|
662
|
+
if (text === "")
|
|
663
|
+
return;
|
|
664
|
+
event.preventDefault();
|
|
665
|
+
const tokens = text.split(/[\s,]+/);
|
|
666
|
+
const next = [...value];
|
|
667
|
+
for (const token of tokens) {
|
|
668
|
+
const tag = token.trim();
|
|
669
|
+
if (tag !== "" && !next.includes(tag))
|
|
670
|
+
next.push(tag);
|
|
671
|
+
}
|
|
672
|
+
if (next.length !== value.length)
|
|
673
|
+
onChange(next);
|
|
674
|
+
}, style: chipsBelow ? { width: "100%" } : { flex: 1, minWidth: "160px" } }));
|
|
675
|
+
if (chipsBelow) {
|
|
676
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [field, _jsx("div", { style: tagSlot, children: chips })] }));
|
|
677
|
+
}
|
|
104
678
|
return (_jsxs("div", { style: {
|
|
105
679
|
display: "flex",
|
|
106
680
|
flexWrap: "wrap",
|
|
107
681
|
alignItems: "center",
|
|
108
682
|
gap: "6px",
|
|
109
|
-
}, children: [
|
|
110
|
-
if (event.key === " " || event.key === "," || event.key === "Enter") {
|
|
111
|
-
if (event.key === " " || event.key === ",")
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
commit(draft);
|
|
114
|
-
setDraft("");
|
|
115
|
-
}
|
|
116
|
-
else if (event.key === "Backspace" && draft === "") {
|
|
117
|
-
const last = value[value.length - 1];
|
|
118
|
-
if (last !== undefined)
|
|
119
|
-
onChange(value.slice(0, -1));
|
|
120
|
-
}
|
|
121
|
-
}, onPaste: (event) => {
|
|
122
|
-
const text = event.clipboardData.getData("text");
|
|
123
|
-
if (text === "")
|
|
124
|
-
return;
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
const tokens = text.split(/[\s,]+/);
|
|
127
|
-
const next = [...value];
|
|
128
|
-
for (const token of tokens) {
|
|
129
|
-
const tag = token.trim();
|
|
130
|
-
if (tag !== "" && !next.includes(tag))
|
|
131
|
-
next.push(tag);
|
|
132
|
-
}
|
|
133
|
-
if (next.length !== value.length)
|
|
134
|
-
onChange(next);
|
|
135
|
-
}, style: { flex: 1, minWidth: "160px" } })] }));
|
|
683
|
+
}, children: [chips, field] }));
|
|
136
684
|
}
|
|
685
|
+
// The packages slot under the build dialog's input: its height is reserved from
|
|
686
|
+
// the first chip's own size, so the field below never shifts when a chip is
|
|
687
|
+
// added or removed.
|
|
688
|
+
const tagSlot = {
|
|
689
|
+
display: "flex",
|
|
690
|
+
flexWrap: "wrap",
|
|
691
|
+
alignItems: "center",
|
|
692
|
+
gap: "6px",
|
|
693
|
+
minHeight: "24px",
|
|
694
|
+
marginTop: "6px",
|
|
695
|
+
};
|