@fungi.computer/oyster 0.19.25 → 0.19.26

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.
@@ -9,6 +9,7 @@ import { Form, FormFooter } from "@fungi.computer/caps/components/field";
9
9
  import { Switch } from "@fungi.computer/caps/components/switch";
10
10
  import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
11
11
  import { PermissionGrid, } from "@fungi.computer/caps/blocks/permission-grid";
12
+ import { Toaster, toast } from "@fungi.computer/caps/components/toaster";
12
13
  import { Status } from "@fungi.computer/caps/components/status";
13
14
  import { Sigil } from "@fungi.computer/sigils";
14
15
  import { permissionCatalog } from "../apps/catalog.js";
@@ -225,7 +226,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
225
226
  setSaving(false);
226
227
  }
227
228
  }
228
- async function save() {
229
+ async function save(nextDraft = draft, confirmation) {
229
230
  const isMounted = () => mounted.current;
230
231
  if (view === null || saving || retired || !view.canEdit)
231
232
  return;
@@ -239,7 +240,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
239
240
  storeGeneration: view.storeGeneration,
240
241
  authorityVersion: view.permissions.authority.authorityVersion,
241
242
  artifactDigest: view.artifactDigest,
242
- }, changes);
243
+ }, planGrantChange(view.permissions.authority, nextDraft));
243
244
  if (!isMounted())
244
245
  return;
245
246
  if (result === "unavailable") {
@@ -268,6 +269,8 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
268
269
  setView(next);
269
270
  setDraft(draftOf(next.permissions.authority));
270
271
  setUncertain(false);
272
+ if (confirmation !== undefined)
273
+ toast.success(confirmation, { toasterId: describeId });
271
274
  await refreshAfterAcceptance();
272
275
  return;
273
276
  }
@@ -280,7 +283,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
280
283
  return;
281
284
  }
282
285
  setView(next);
283
- setDraft(rebaseDraft(draft, view.permissions.authority, next.permissions.authority));
286
+ setDraft(rebaseDraft(nextDraft, view.permissions.authority, next.permissions.authority));
284
287
  setUncertain(false);
285
288
  setMessage("Current permissions loaded. Review your edits before saving again.");
286
289
  }
@@ -345,9 +348,30 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
345
348
  return (_jsxs(Form, { style: { maxWidth: "var(--container-2xl)", marginInline: "auto" }, onSubmit: (event) => {
346
349
  event.preventDefault();
347
350
  void save();
348
- }, children: [!screen.canEdit && _jsx("p", { children: "Only an owner can change these permissions." }), pending.length > 0 && (_jsx(Alert, { tone: "warning", title: `${String(pending.length)} ${pending.length === 1 ? "permission needs" : "permissions need"} your OK`, action: _jsx(Button, { type: "button", size: "xs", variant: "outline", onClick: () => {
349
- document.querySelector('[id^="grant-"]')?.focus();
350
- }, children: "Review" }), children: "Turn on what you want this App to do, then save." })), shell !== undefined && (_jsx(ShellPermissionRow, { column: shell, changed: shellChanged, otherChanges: changes.length > 1, disabled: disabled, onToggle: () => {
351
+ }, children: [_jsx(Toaster, { id: describeId }), !screen.canEdit && _jsx("p", { children: "Only an owner can change these permissions." }), pending.length > 0 && (_jsx(Alert, { tone: "warning", title: `${String(pending.length)} ${pending.length === 1 ? "permission needs" : "permissions need"} your OK`, action: screen.canEdit ? (_jsxs(Button, { type: "button", size: "xs", variant: "primary", disabled: disabled || shellChanged, onClick: () => {
352
+ const allowed = new Map(draft);
353
+ for (const capability of pending) {
354
+ const declared = view.permissions.declaredOperations.capabilities.find((row) => row.capability === capability);
355
+ if (declared === undefined)
356
+ continue;
357
+ const resources = allowed.get(capability)?.resources;
358
+ allowed.set(capability, {
359
+ operations: declared.operations,
360
+ resources: resources !== undefined && resources.length > 0
361
+ ? resources
362
+ : "tenant-scope",
363
+ });
364
+ }
365
+ setDraft(allowed);
366
+ const abilities = new Intl.ListFormat("en", {
367
+ style: "long",
368
+ type: "conjunction",
369
+ }).format(pending.map((capability) => {
370
+ const label = permissionCatalog[capability].label;
371
+ return label.charAt(0).toLowerCase() + label.slice(1);
372
+ }));
373
+ void save(allowed, `${view.appName} can now ${abilities}.`);
374
+ }, children: ["Allow all ", pending.length] })) : undefined, children: "Allow all requested permissions, or choose individually below and save." })), shell !== undefined && (_jsx(ShellPermissionRow, { column: shell, changed: shellChanged, otherChanges: changes.length > 1, disabled: disabled, onToggle: () => {
351
375
  edit({
352
376
  kind: "switch",
353
377
  capability: "team.workbenchHost",