@eum-agent/authorization-policy 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/ui/ui.js +25 -4
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "en-US": "Authorization Policy",
5
5
  "zh-CN": "授权策略"
6
6
  },
7
- "version": "1.0.0",
7
+ "version": "1.0.1",
8
8
  "type": "module",
9
9
  "description": "Default authorization policy and resource permission settings",
10
10
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "i18next": "^26.4.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@eum-agent/plugin": "1.0.0",
25
+ "@eum-agent/plugin": "1.0.1",
26
26
  "@types/react": "^19.2.18",
27
27
  "@types/react-dom": "^19.2.5",
28
28
  "react": "^19.2.0",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {},
45
45
  "foundationDependencies": {
46
- "@eum-agent/storage-sqlite": "1.0.0"
46
+ "@eum-agent/storage-sqlite": "1.0.1"
47
47
  }
48
48
  },
49
49
  "scripts": {
package/ui/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ActionButton, Badge, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FacetedFilter, Failure, Field, FormFailure, Input, Panel, Popover, ReadFailure, RuleEditor, SecurityRuleList, Segmented, SettingsLink, Warning, failureText, useBrowserService, useGateway, useGatewayAction, useGatewayRead, useTranslation } from "@eum-agent/host/framework";
1
+ import { ActionButton, Badge, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FacetedFilter, Failure, Field, FormFailure, Input, Panel, Popover, ReadFailure, RuleEditor, SecurityRuleList, Segmented, SettingsLink, Warning, failureText, useBrowserService, useGateway, useGatewayAction, useGatewayRead, useTranslation, uuid } from "@eum-agent/host/framework";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region ui-src/api.ts
@@ -204,7 +204,10 @@ function FileHolders({ record }) {
204
204
  loading: stopping.pending,
205
205
  disabled: stopping.pending,
206
206
  onClick: () => {
207
- stopping.run(() => Promise.all(holders.map((process) => client.call("process.stop", { processId: process.processId }))));
207
+ stopping.run(() => client.call("process.stop", { processIds: holders.map((process) => process.processId) }).then((answer) => {
208
+ const refused = answer.results.find((member) => !member.ok);
209
+ if (refused && !refused.ok) throw new Error(refused.error.message);
210
+ }));
208
211
  },
209
212
  children: t("access.stopHolders")
210
213
  }),
@@ -222,6 +225,7 @@ function AddResource({ open, onOpenChange, kind, reload }) {
222
225
  const [argv, setArgv] = useState("");
223
226
  const [cwd, setCwd] = useState("");
224
227
  const [invalid, setInvalid] = useState(null);
228
+ const intent = useRef(null);
225
229
  async function submit() {
226
230
  if (action.pending) return;
227
231
  let authorization;
@@ -250,7 +254,21 @@ function AddResource({ open, onOpenChange, kind, reload }) {
250
254
  return;
251
255
  }
252
256
  setInvalid(null);
253
- if ((await action.run((client) => client.call("config.access.add", { authorization }))).ok) {
257
+ const key = JSON.stringify(authorization);
258
+ const operationId = intent.current?.key === key ? intent.current.id : uuid();
259
+ intent.current = {
260
+ key,
261
+ id: operationId
262
+ };
263
+ if ((await action.run(async (client) => {
264
+ const answer = await client.call("config.access.add", {
265
+ operationId,
266
+ authorizations: [authorization]
267
+ });
268
+ if (answer.operationState === "admitted") throw new Error(t("common.working"));
269
+ return answer;
270
+ })).ok) {
271
+ intent.current = null;
254
272
  reload();
255
273
  onOpenChange(false);
256
274
  setHost("");
@@ -442,7 +460,10 @@ function ResourceGrantsPanel({ kind }) {
442
460
  empty: t("access.empty"),
443
461
  removalHint: t("authorization.removalHint"),
444
462
  revoke: true,
445
- onRemove: (client, record) => client.call("config.access.revoke", { id: record.id }),
463
+ onRemove: (client, records) => client.call("config.access.revoke", {
464
+ operationId: uuid(),
465
+ ids: records.map((record) => record.id)
466
+ }),
446
467
  tools: kind === "records" ? void 0 : /* @__PURE__ */ jsx(ActionButton, {
447
468
  label: t("common.add"),
448
469
  onClick: () => setAdding(true)