@nivaro/react 0.3.35 → 0.3.37
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/components/slots/CommentsSlot.js +44 -36
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/shared/components/AgentBadge.js +26 -0
- package/dist/shared/components/AgentQuestionsCard.js +198 -0
- package/dist/shared/components/ItemEditForm.js +3329 -3263
- package/dist/shared/components/McpConnectionScope.js +480 -0
- package/dist/shared/components/MyWorkView.js +223 -208
- package/dist/shared/components/RecordReadView.js +620 -572
- package/dist/shared/components/chat/ChatPanel.js +683 -671
- package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
- package/dist/shared/components/imports/ImportConsole.js +106 -104
- package/dist/shared/components/imports/RunDetailSheet.js +11 -10
- package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
- package/dist/shared/components/item-edit/FormTour.js +279 -0
- package/dist/shared/components/item-edit/GroupSection.js +377 -360
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +80 -63
- package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
- package/dist/shared/components/item-edit/form-density.js +36 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
- package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
- package/dist/shared/components/layout-editor/AddPanel.js +349 -192
- package/dist/shared/components/layout-editor/DesignNode.js +146 -131
- package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
- package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
- package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
- package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
- package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
- package/dist/shared/components/layout-editor/add-target.js +54 -43
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +379 -185
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
- package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
- package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
- package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
- package/dist/shared/components/layout-editor/dnd/node.js +115 -105
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
- package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
- package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
- package/dist/shared/components/layout-editor/even-row.js +86 -0
- package/dist/shared/components/layout-editor/field-list.js +99 -0
- package/dist/shared/components/layout-editor/format-painter.js +102 -0
- package/dist/shared/components/layout-editor/grid-guides.js +15 -13
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
- package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
- package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
- package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
- package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
- package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
- package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
- package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
- package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
- package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
- package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
- package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
- package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
- package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
- package/dist/shared/components/layout-editor/panel-frame.js +1 -1
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
- package/dist/shared/components/layout-editor/pin.js +37 -19
- package/dist/shared/components/layout-editor/place-clip.js +257 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +149 -118
- package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
- package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
- package/dist/shared/components/layout-editor/removed-log.js +151 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
- package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
- package/dist/shared/components/layout-editor/revert-element.js +140 -0
- package/dist/shared/components/layout-editor/section-structure.js +193 -170
- package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
- package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
- package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
- package/dist/shared/components/layout-editor/shortcuts.js +21 -16
- package/dist/shared/components/layout-editor/structure-ops.js +221 -195
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
- package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
- package/dist/shared/components/panels/CommentPanel.js +47 -45
- package/dist/shared/components/panels/RevisionsPanel.js +66 -64
- package/dist/shared/components/panels/TaskPanel.js +395 -332
- package/dist/shared/components/profile/AgentsPanel.js +196 -147
- package/dist/shared/components/profile/ConnectionRollback.js +329 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
- package/dist/shared/lib/entry-config.js +22 -22
- package/dist/shared/lib/form-usage-beacon.js +91 -55
- package/dist/shared/lib/layout-lint.js +530 -284
- package/dist/shared/lib/layout-resolve.js +58 -44
- package/package.json +1 -1
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { jsxs as a, jsx as o, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Z, useQuery as G, useMutation as K } from "@tanstack/react-query";
|
|
3
|
+
import { Lock as ee, SlidersHorizontal as te, Check as Q, Loader2 as oe, Search as le, X as ae, Plus as ne, ChevronsUpDown as re } from "lucide-react";
|
|
4
|
+
import { useState as E, useRef as se, useEffect as ie, useMemo as ce } from "react";
|
|
5
|
+
import { useNivaroClient as U } from "../context.js";
|
|
6
|
+
import { get as X, put as de, del as me } from "../lib/commands.js";
|
|
7
|
+
import { cn as C, formatNumber as W } from "../lib/utils.js";
|
|
8
|
+
import { ConfirmButton as he } from "./profile/primitives.js";
|
|
9
|
+
import { Command as pe, CommandInput as ue, CommandList as xe, CommandEmpty as be, CommandGroup as fe, CommandItem as ke } from "./ui/command.js";
|
|
10
|
+
import { Popover as ge, PopoverTrigger as ye, PopoverContent as Ne } from "./ui/popover.js";
|
|
11
|
+
import { SimpleSelect as ve } from "./ui/SimpleSelect.js";
|
|
12
|
+
import { Sheet as we, SheetContent as Ce, SheetHeader as $e, SheetTitle as Se, SheetDescription as Te } from "./ui/sheet.js";
|
|
13
|
+
import { Skeleton as P } from "./ui/skeleton.js";
|
|
14
|
+
import { Switch as Le } from "./ui/switch.js";
|
|
15
|
+
const Ae = ["nvr-mcp-catalog"];
|
|
16
|
+
function Oe(e = !0) {
|
|
17
|
+
const r = U();
|
|
18
|
+
return G({
|
|
19
|
+
queryKey: Ae,
|
|
20
|
+
queryFn: () => r.request(X("/mcp-connections/catalog")).then((i) => i.data),
|
|
21
|
+
staleTime: 6e4,
|
|
22
|
+
enabled: e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const _ = {
|
|
26
|
+
read: "Read",
|
|
27
|
+
create: "Create",
|
|
28
|
+
update: "Change",
|
|
29
|
+
delete: "Delete"
|
|
30
|
+
}, qe = {
|
|
31
|
+
everyday: "Everyday",
|
|
32
|
+
chat: "Chat",
|
|
33
|
+
admin: "Administration",
|
|
34
|
+
instance: "This instance’s own tools"
|
|
35
|
+
};
|
|
36
|
+
function Pe(e) {
|
|
37
|
+
if (!e) return "Everything the person can do";
|
|
38
|
+
if (e.kit_missing) return "Its kit was removed — it can use nothing";
|
|
39
|
+
const r = [];
|
|
40
|
+
return e.kit && r.push(`${e.kit_label ?? e.kit} kit`), e.tools && r.push(`${W(e.tools.length)} tool${e.tools.length === 1 ? "" : "s"}`), e.collections && r.push(
|
|
41
|
+
e.collections.length === 1 ? e.collections[0] : `${W(e.collections.length)} collections`
|
|
42
|
+
), e.actions && (e.actions.length === 1 && e.actions[0] === "read" ? r.push("read only") : e.actions.length === 0 ? r.push("no actions") : e.actions.length < 4 && r.push(
|
|
43
|
+
e.actions.map((i) => _[i]).join(", ").toLowerCase()
|
|
44
|
+
)), r.join(" · ") || "No limits";
|
|
45
|
+
}
|
|
46
|
+
function Xe({ scope: e }) {
|
|
47
|
+
return /* @__PURE__ */ a("span", { className: "inline-flex min-w-0 items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
|
|
48
|
+
(e == null ? void 0 : e.locked) && /* @__PURE__ */ o(
|
|
49
|
+
ee,
|
|
50
|
+
{
|
|
51
|
+
className: "h-3 w-3 shrink-0 text-slate-400 dark:text-slate-500",
|
|
52
|
+
"aria-label": "Set by an administrator"
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ o(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: C(
|
|
59
|
+
"truncate",
|
|
60
|
+
!e && "text-slate-500 dark:text-slate-400",
|
|
61
|
+
(e == null ? void 0 : e.kit_missing) && "text-red-600 dark:text-red-400"
|
|
62
|
+
),
|
|
63
|
+
"data-tip": (e == null ? void 0 : e.note) ?? void 0,
|
|
64
|
+
children: Pe(e)
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
const L = "text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", w = "text-[12px] text-slate-500 dark:text-slate-400";
|
|
70
|
+
function R({
|
|
71
|
+
label: e,
|
|
72
|
+
help: r,
|
|
73
|
+
checked: i,
|
|
74
|
+
onChange: p,
|
|
75
|
+
disabled: u
|
|
76
|
+
}) {
|
|
77
|
+
return /* @__PURE__ */ a("div", { className: "flex items-start justify-between gap-4", children: [
|
|
78
|
+
/* @__PURE__ */ a("div", { className: "min-w-0", children: [
|
|
79
|
+
/* @__PURE__ */ o("p", { className: L, children: e }),
|
|
80
|
+
/* @__PURE__ */ o("p", { className: w, children: r })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ o(Le, { checked: i, onCheckedChange: p, disabled: u, "aria-label": e })
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
function Re({
|
|
86
|
+
tools: e,
|
|
87
|
+
picked: r,
|
|
88
|
+
kitTools: i,
|
|
89
|
+
onChange: p
|
|
90
|
+
}) {
|
|
91
|
+
const [u, x] = E(""), n = u.trim().toLowerCase(), f = ce(() => {
|
|
92
|
+
const h = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const s of e)
|
|
94
|
+
n && !`${s.name} ${s.title}`.toLowerCase().includes(n) || h.set(s.group, [...h.get(s.group) ?? [], s]);
|
|
95
|
+
return [...h];
|
|
96
|
+
}, [e, n]), k = (h, s) => {
|
|
97
|
+
const b = new Set(r);
|
|
98
|
+
for (const t of h)
|
|
99
|
+
s && i && !i.has(t) || (s ? b.add(t) : b.delete(t));
|
|
100
|
+
p(b);
|
|
101
|
+
};
|
|
102
|
+
return /* @__PURE__ */ a("div", { className: "rounded-md border border-slate-200 dark:border-border", children: [
|
|
103
|
+
/* @__PURE__ */ a("label", { className: "flex items-center gap-2 border-b border-slate-200 px-2.5 dark:border-border", children: [
|
|
104
|
+
/* @__PURE__ */ o(le, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
105
|
+
/* @__PURE__ */ o(
|
|
106
|
+
"input",
|
|
107
|
+
{
|
|
108
|
+
value: u,
|
|
109
|
+
onChange: (h) => x(h.target.value),
|
|
110
|
+
placeholder: "Find a tool",
|
|
111
|
+
"aria-label": "Find a tool",
|
|
112
|
+
className: "h-8 w-full bg-transparent text-[12.5px] text-slate-800 outline-none placeholder:text-slate-500 dark:text-slate-100 dark:placeholder:text-slate-400"
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ a("div", { className: "max-h-[320px] overflow-y-auto overscroll-contain px-2.5 py-2", children: [
|
|
117
|
+
f.length === 0 && /* @__PURE__ */ o("p", { className: C(w, "py-2"), children: "No tool matches." }),
|
|
118
|
+
f.map(([h, s]) => {
|
|
119
|
+
const b = s.map((t) => t.name);
|
|
120
|
+
return /* @__PURE__ */ a("section", { className: "pb-2 last:pb-0", children: [
|
|
121
|
+
/* @__PURE__ */ a("div", { className: "flex items-center justify-between py-1", children: [
|
|
122
|
+
/* @__PURE__ */ o("span", { className: "text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: qe[h] }),
|
|
123
|
+
/* @__PURE__ */ a("span", { className: "flex gap-2 text-[11.5px]", children: [
|
|
124
|
+
/* @__PURE__ */ o(
|
|
125
|
+
"button",
|
|
126
|
+
{
|
|
127
|
+
type: "button",
|
|
128
|
+
onClick: () => k(b, !0),
|
|
129
|
+
className: "text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white",
|
|
130
|
+
children: "All"
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ o(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
type: "button",
|
|
137
|
+
onClick: () => k(b, !1),
|
|
138
|
+
className: "text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white",
|
|
139
|
+
children: "None"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] })
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ o("ul", { className: "grid gap-0.5 sm:grid-cols-2", children: s.map((t) => {
|
|
145
|
+
const d = i ? !i.has(t.name) : !1, $ = r.has(t.name) && !d;
|
|
146
|
+
return /* @__PURE__ */ o("li", { children: /* @__PURE__ */ a(
|
|
147
|
+
"label",
|
|
148
|
+
{
|
|
149
|
+
className: C(
|
|
150
|
+
"flex items-center gap-2 rounded px-1.5 py-1 text-[12px]",
|
|
151
|
+
d ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-muted"
|
|
152
|
+
),
|
|
153
|
+
"data-tip": d ? "Not in the chosen kit" : t.description || void 0,
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ o(
|
|
156
|
+
"input",
|
|
157
|
+
{
|
|
158
|
+
type: "checkbox",
|
|
159
|
+
checked: $,
|
|
160
|
+
disabled: d,
|
|
161
|
+
onChange: (S) => k([t.name], S.target.checked),
|
|
162
|
+
className: "h-3.5 w-3.5 shrink-0 accent-nvr-cyan"
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ o("span", { className: "truncate font-mono text-[11.5px] text-slate-700 dark:text-slate-200", children: t.name }),
|
|
166
|
+
!t.read_only && /* @__PURE__ */ o("span", { className: "ml-auto shrink-0 text-[10.5px] text-amber-700 dark:text-amber-400", children: "writes" })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
) }, t.name);
|
|
170
|
+
}) })
|
|
171
|
+
] }, h);
|
|
172
|
+
})
|
|
173
|
+
] })
|
|
174
|
+
] });
|
|
175
|
+
}
|
|
176
|
+
function _e({
|
|
177
|
+
value: e,
|
|
178
|
+
onChange: r,
|
|
179
|
+
options: i
|
|
180
|
+
}) {
|
|
181
|
+
const [p, u] = E(!1), x = new Map(i.map((n) => [n.collection, n.label]));
|
|
182
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
183
|
+
e.map((n) => /* @__PURE__ */ a(
|
|
184
|
+
"span",
|
|
185
|
+
{
|
|
186
|
+
className: "inline-flex items-center gap-1 rounded bg-slate-100 py-0.5 pl-2 pr-1 text-[12px] text-slate-700 dark:bg-muted dark:text-slate-200",
|
|
187
|
+
children: [
|
|
188
|
+
x.get(n) ?? n,
|
|
189
|
+
/* @__PURE__ */ o(
|
|
190
|
+
"button",
|
|
191
|
+
{
|
|
192
|
+
type: "button",
|
|
193
|
+
onClick: () => r(e.filter((f) => f !== n)),
|
|
194
|
+
"aria-label": `Remove ${x.get(n) ?? n}`,
|
|
195
|
+
className: "rounded p-0.5 text-slate-500 hover:bg-slate-200 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-border dark:hover:text-white",
|
|
196
|
+
children: /* @__PURE__ */ o(ae, { className: "h-3 w-3" })
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
n
|
|
202
|
+
)),
|
|
203
|
+
/* @__PURE__ */ a(ge, { open: p, onOpenChange: u, children: [
|
|
204
|
+
/* @__PURE__ */ o(ye, { asChild: !0, children: /* @__PURE__ */ a(
|
|
205
|
+
"button",
|
|
206
|
+
{
|
|
207
|
+
type: "button",
|
|
208
|
+
className: "inline-flex h-7 items-center gap-1 rounded-md border border-dashed border-slate-300 px-2 text-[12px] text-slate-600 hover:border-slate-400 hover:text-slate-900 dark:border-border dark:text-slate-300 dark:hover:text-white",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ o(ne, { className: "h-3.5 w-3.5" }),
|
|
211
|
+
" Add a collection",
|
|
212
|
+
/* @__PURE__ */ o(re, { className: "h-3 w-3 opacity-60" })
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
) }),
|
|
216
|
+
/* @__PURE__ */ o(Ne, { align: "start", className: "w-64 p-0", children: /* @__PURE__ */ a(pe, { children: [
|
|
217
|
+
/* @__PURE__ */ o(ue, { placeholder: "Find a collection" }),
|
|
218
|
+
/* @__PURE__ */ a(xe, { children: [
|
|
219
|
+
/* @__PURE__ */ o(be, { children: "No collection matches." }),
|
|
220
|
+
/* @__PURE__ */ o(fe, { children: i.filter((n) => !e.includes(n.collection)).map((n) => /* @__PURE__ */ a(
|
|
221
|
+
ke,
|
|
222
|
+
{
|
|
223
|
+
value: `${n.label} ${n.collection}`,
|
|
224
|
+
onSelect: () => {
|
|
225
|
+
r([...e, n.collection]), u(!1);
|
|
226
|
+
},
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ o("span", { className: "truncate", children: n.label }),
|
|
229
|
+
/* @__PURE__ */ o("span", { className: "ml-auto truncate font-mono text-[10.5px] text-slate-500 dark:text-slate-400", children: n.collection })
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
n.collection
|
|
233
|
+
)) })
|
|
234
|
+
] })
|
|
235
|
+
] }) })
|
|
236
|
+
] })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
const y = ["read", "create", "update", "delete"];
|
|
240
|
+
function H(e) {
|
|
241
|
+
return {
|
|
242
|
+
kit: (e == null ? void 0 : e.kit) ?? "",
|
|
243
|
+
limitTools: (e == null ? void 0 : e.own.tools) != null,
|
|
244
|
+
tools: new Set((e == null ? void 0 : e.own.tools) ?? []),
|
|
245
|
+
limitCollections: (e == null ? void 0 : e.own.collections) != null,
|
|
246
|
+
collections: (e == null ? void 0 : e.own.collections) ?? [],
|
|
247
|
+
actions: new Set((e == null ? void 0 : e.own.actions) ?? y),
|
|
248
|
+
locked: (e == null ? void 0 : e.locked) ?? !1,
|
|
249
|
+
note: (e == null ? void 0 : e.note) ?? ""
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function Je({
|
|
253
|
+
open: e,
|
|
254
|
+
onClose: r,
|
|
255
|
+
conn: i,
|
|
256
|
+
name: p,
|
|
257
|
+
who: u,
|
|
258
|
+
scope: x,
|
|
259
|
+
mode: n,
|
|
260
|
+
onSaved: f
|
|
261
|
+
}) {
|
|
262
|
+
var M, B, D;
|
|
263
|
+
const k = U(), h = Z(), s = Oe(e), b = G({
|
|
264
|
+
queryKey: ["nvr-mcp-scope-collections"],
|
|
265
|
+
queryFn: () => k.request(
|
|
266
|
+
X("/collections")
|
|
267
|
+
).then(
|
|
268
|
+
(l) => (l.data ?? []).filter((m) => !/^(nivaro_|directus_)/.test(m.collection)).map((m) => ({ collection: m.collection, label: m.display_name || m.collection })).sort((m, g) => m.label.localeCompare(g.label))
|
|
269
|
+
),
|
|
270
|
+
enabled: e,
|
|
271
|
+
staleTime: 6e4
|
|
272
|
+
}), [t, d] = E(() => H(x)), $ = se(!1);
|
|
273
|
+
ie(() => {
|
|
274
|
+
e && !$.current && d(H(x)), $.current = e;
|
|
275
|
+
}, [e, x]);
|
|
276
|
+
const S = n === "mine" ? `/mcp-connections/mine/${i}/scope` : `/mcp-connections/${i}/scope`, j = () => {
|
|
277
|
+
h.invalidateQueries({ queryKey: ["nvr-mcp-connections"] }), f == null || f(), r();
|
|
278
|
+
}, N = K({
|
|
279
|
+
mutationFn: () => k.request(
|
|
280
|
+
de(S, {
|
|
281
|
+
kit: t.kit || null,
|
|
282
|
+
tools: t.limitTools ? [...t.tools] : null,
|
|
283
|
+
collections: t.limitCollections ? t.collections : null,
|
|
284
|
+
actions: t.actions.size === y.length ? null : y.filter((l) => t.actions.has(l)),
|
|
285
|
+
...n === "admin" ? { locked: t.locked, note: t.note.trim() || null } : {}
|
|
286
|
+
})
|
|
287
|
+
),
|
|
288
|
+
onSuccess: j
|
|
289
|
+
}), T = K({ mutationFn: () => k.request(me(S)), onSuccess: j }), F = ((M = s.data) == null ? void 0 : M.kits) ?? [], c = F.find((l) => l.key === t.kit) ?? null, A = c != null && c.tools ? new Set(c.tools) : null, J = ((B = s.data) == null ? void 0 : B.tools) ?? [], v = t.limitTools ? [...t.tools].filter((l) => !A || A.has(l)) : (c == null ? void 0 : c.tools) ?? null, z = t.actions.size === 0, I = v != null && v.length === 0, O = s.data && !s.data.ready, V = (() => {
|
|
290
|
+
const l = v == null ? "every tool it is offered" : `${v.length} tool${v.length === 1 ? "" : "s"}`, m = t.limitCollections ? t.collections.length ? `on ${t.collections.length === 1 ? t.collections[0] : `${t.collections.length} collections`}` : "on no collection" : "on every collection the person can reach", g = t.actions.size === y.length ? "" : t.actions.size === 1 && t.actions.has("read") ? ", read only" : `, only ${y.filter((q) => t.actions.has(q)).map((q) => _[q].toLowerCase()).join(", ")}`;
|
|
291
|
+
return `${p} will use ${l} ${m}${g}.`;
|
|
292
|
+
})();
|
|
293
|
+
return /* @__PURE__ */ o(we, { open: e, onOpenChange: (l) => !l && r(), children: /* @__PURE__ */ a(Ce, { className: "flex w-[560px] max-w-[96vw] flex-col gap-0 p-0 sm:max-w-[560px]", children: [
|
|
294
|
+
/* @__PURE__ */ a($e, { className: "shrink-0 border-b border-slate-200 px-5 py-4 text-left dark:border-border", children: [
|
|
295
|
+
/* @__PURE__ */ a(Se, { className: "flex items-center gap-2 pr-6 text-[15px]", children: [
|
|
296
|
+
/* @__PURE__ */ o(te, { className: "h-4 w-4 text-nvr-navy dark:text-nvr-cyan" }),
|
|
297
|
+
"Limits for ",
|
|
298
|
+
p
|
|
299
|
+
] }),
|
|
300
|
+
/* @__PURE__ */ a(Te, { className: "text-[12.5px]", children: [
|
|
301
|
+
u ? `${u} · ` : "",
|
|
302
|
+
"Limits only take away: it never gets more than",
|
|
303
|
+
" ",
|
|
304
|
+
n === "mine" ? "you" : "its person",
|
|
305
|
+
" can do."
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ o("div", { className: "flex-1 space-y-6 overflow-y-auto px-5 py-5", children: s.isLoading ? /* @__PURE__ */ a("div", { className: "space-y-3", children: [
|
|
309
|
+
/* @__PURE__ */ o(P, { className: "h-9" }),
|
|
310
|
+
/* @__PURE__ */ o(P, { className: "h-40" })
|
|
311
|
+
] }) : s.isError ? /* @__PURE__ */ o("p", { className: w, children: "The tool list could not be loaded. Try again in a moment." }) : O ? /* @__PURE__ */ o("p", { className: "text-[12.5px] text-amber-700 dark:text-amber-400", children: "Connection limits need database migration 509. They can be set once it has run." }) : /* @__PURE__ */ a(Y, { children: [
|
|
312
|
+
/* @__PURE__ */ a("section", { className: "space-y-2", children: [
|
|
313
|
+
/* @__PURE__ */ o("p", { className: L, children: "Tool kit" }),
|
|
314
|
+
/* @__PURE__ */ o(
|
|
315
|
+
ve,
|
|
316
|
+
{
|
|
317
|
+
value: t.kit,
|
|
318
|
+
onChange: (l) => d({ ...t, kit: l }),
|
|
319
|
+
ariaLabel: "Tool kit",
|
|
320
|
+
className: "h-9 w-full text-[12.5px]",
|
|
321
|
+
options: [
|
|
322
|
+
{ value: "", label: "No kit" },
|
|
323
|
+
...F.map((l) => ({ value: l.key, label: l.label }))
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
),
|
|
327
|
+
/* @__PURE__ */ o("p", { className: w, children: c ? `${c.description} ${c.tools ? `${c.tools.length} tools.` : ""}` : "A kit is a ready set of tools for one kind of job. Without one, pick tools below or leave them open." })
|
|
328
|
+
] }),
|
|
329
|
+
/* @__PURE__ */ a("section", { className: "space-y-3", children: [
|
|
330
|
+
/* @__PURE__ */ o(
|
|
331
|
+
R,
|
|
332
|
+
{
|
|
333
|
+
label: "Only these tools",
|
|
334
|
+
help: c ? "Narrow the kit further." : "Off = every tool it would otherwise get.",
|
|
335
|
+
checked: t.limitTools,
|
|
336
|
+
onChange: (l) => d({
|
|
337
|
+
...t,
|
|
338
|
+
limitTools: l,
|
|
339
|
+
tools: l && t.tools.size === 0 ? new Set((c == null ? void 0 : c.tools) ?? []) : t.tools
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
t.limitTools && /* @__PURE__ */ o(
|
|
344
|
+
Re,
|
|
345
|
+
{
|
|
346
|
+
tools: J,
|
|
347
|
+
picked: t.tools,
|
|
348
|
+
kitTools: A,
|
|
349
|
+
onChange: (l) => d({ ...t, tools: l })
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ a("section", { className: "space-y-3", children: [
|
|
354
|
+
/* @__PURE__ */ o(
|
|
355
|
+
R,
|
|
356
|
+
{
|
|
357
|
+
label: "Only these collections",
|
|
358
|
+
help: "Records elsewhere are out of reach, as for an API key limited to collections. Administrator tools are off while this is on.",
|
|
359
|
+
checked: t.limitCollections,
|
|
360
|
+
onChange: (l) => d({ ...t, limitCollections: l })
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
t.limitCollections && (b.isLoading ? /* @__PURE__ */ o(P, { className: "h-7 w-48" }) : /* @__PURE__ */ o(
|
|
364
|
+
_e,
|
|
365
|
+
{
|
|
366
|
+
value: t.collections,
|
|
367
|
+
onChange: (l) => d({ ...t, collections: l }),
|
|
368
|
+
options: b.data ?? []
|
|
369
|
+
}
|
|
370
|
+
))
|
|
371
|
+
] }),
|
|
372
|
+
/* @__PURE__ */ a("section", { className: "space-y-2", children: [
|
|
373
|
+
/* @__PURE__ */ o("p", { className: L, children: "What it may do" }),
|
|
374
|
+
/* @__PURE__ */ o("fieldset", { className: "flex flex-wrap gap-1.5", "aria-label": "What it may do", children: y.map((l) => {
|
|
375
|
+
const m = t.actions.has(l);
|
|
376
|
+
return /* @__PURE__ */ a(
|
|
377
|
+
"button",
|
|
378
|
+
{
|
|
379
|
+
type: "button",
|
|
380
|
+
"aria-pressed": m,
|
|
381
|
+
onClick: () => {
|
|
382
|
+
const g = new Set(t.actions);
|
|
383
|
+
m ? g.delete(l) : g.add(l), d({ ...t, actions: g });
|
|
384
|
+
},
|
|
385
|
+
className: C(
|
|
386
|
+
"inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-[12px] font-medium transition-colors",
|
|
387
|
+
m ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:text-slate-800 dark:border-border dark:text-slate-400 dark:hover:text-white"
|
|
388
|
+
),
|
|
389
|
+
children: [
|
|
390
|
+
m && /* @__PURE__ */ o(Q, { className: "h-3 w-3" }),
|
|
391
|
+
_[l]
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
l
|
|
395
|
+
);
|
|
396
|
+
}) }),
|
|
397
|
+
/* @__PURE__ */ o("p", { className: w, children: "Held to these on every record it reads or writes, on top of the person’s own access." })
|
|
398
|
+
] }),
|
|
399
|
+
n === "admin" && /* @__PURE__ */ a("section", { className: "space-y-3 border-t border-slate-100 pt-5 dark:border-border/60", children: [
|
|
400
|
+
/* @__PURE__ */ o(
|
|
401
|
+
R,
|
|
402
|
+
{
|
|
403
|
+
label: "Lock",
|
|
404
|
+
help: "Only administrators can change or remove these limits. The person still sees them.",
|
|
405
|
+
checked: t.locked,
|
|
406
|
+
onChange: (l) => d({ ...t, locked: l })
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
/* @__PURE__ */ a("label", { className: "block space-y-1", children: [
|
|
410
|
+
/* @__PURE__ */ o("span", { className: L, children: "Note" }),
|
|
411
|
+
/* @__PURE__ */ o(
|
|
412
|
+
"input",
|
|
413
|
+
{
|
|
414
|
+
value: t.note,
|
|
415
|
+
onChange: (l) => d({ ...t, note: l.target.value.slice(0, 300) }),
|
|
416
|
+
placeholder: "Why it is limited (the person sees this)",
|
|
417
|
+
className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12.5px] text-slate-800 outline-none placeholder:text-slate-500 focus:border-nvr-cyan focus-visible:ring-2 focus-visible:ring-nvr-cyan/25 dark:border-border dark:bg-background dark:text-slate-100 dark:placeholder:text-slate-400"
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
] })
|
|
421
|
+
] })
|
|
422
|
+
] }) }),
|
|
423
|
+
/* @__PURE__ */ a("footer", { className: "shrink-0 space-y-3 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
|
|
424
|
+
!O && s.data && /* @__PURE__ */ o(
|
|
425
|
+
"p",
|
|
426
|
+
{
|
|
427
|
+
className: C(
|
|
428
|
+
"text-[12px]",
|
|
429
|
+
I || z ? "text-amber-700 dark:text-amber-400" : "text-slate-600 dark:text-slate-300"
|
|
430
|
+
),
|
|
431
|
+
children: I ? `${p} will have no tools at all.` : z ? `${p} will not be able to read or change any record.` : V
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
(N.isError || T.isError) && /* @__PURE__ */ o("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: ((D = N.error ?? T.error) == null ? void 0 : D.message) || "Could not save" }),
|
|
435
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
|
|
436
|
+
x && /* @__PURE__ */ o(
|
|
437
|
+
he,
|
|
438
|
+
{
|
|
439
|
+
onConfirm: () => T.mutate(),
|
|
440
|
+
disabled: T.isPending,
|
|
441
|
+
confirmLabel: "Remove limits?",
|
|
442
|
+
title: "Remove every limit",
|
|
443
|
+
className: "h-8 rounded-md px-2.5 text-[12.5px] font-medium text-slate-600 transition-colors hover:bg-muted hover:text-slate-900 dark:text-slate-300 dark:hover:text-white",
|
|
444
|
+
armedClassName: "bg-red-50 text-red-700 dark:bg-red-500/10 dark:text-red-400",
|
|
445
|
+
children: "Remove limits"
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
/* @__PURE__ */ o(
|
|
449
|
+
"button",
|
|
450
|
+
{
|
|
451
|
+
type: "button",
|
|
452
|
+
onClick: r,
|
|
453
|
+
className: "ml-auto h-8 rounded-md border border-slate-200 px-3 text-[12.5px] font-medium text-slate-700 transition-colors hover:bg-muted dark:border-border dark:text-slate-200",
|
|
454
|
+
children: "Cancel"
|
|
455
|
+
}
|
|
456
|
+
),
|
|
457
|
+
/* @__PURE__ */ a(
|
|
458
|
+
"button",
|
|
459
|
+
{
|
|
460
|
+
type: "button",
|
|
461
|
+
disabled: N.isPending || !s.data || !!O,
|
|
462
|
+
onClick: () => N.mutate(),
|
|
463
|
+
className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-nvr-cyan px-3.5 text-[12.5px] font-medium text-white transition-colors hover:bg-nvr-cyan/90 disabled:opacity-40",
|
|
464
|
+
children: [
|
|
465
|
+
N.isPending ? /* @__PURE__ */ o(oe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ o(Q, { className: "h-3.5 w-3.5" }),
|
|
466
|
+
"Save limits"
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
] })
|
|
471
|
+
] })
|
|
472
|
+
] }) });
|
|
473
|
+
}
|
|
474
|
+
export {
|
|
475
|
+
Je as McpScopeSheet,
|
|
476
|
+
Xe as ScopeBadge,
|
|
477
|
+
Ae as mcpCatalogKey,
|
|
478
|
+
Pe as scopeSummaryText,
|
|
479
|
+
Oe as useMcpCatalog
|
|
480
|
+
};
|