@verikit/vue 0.24.3 → 0.24.4

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.
@@ -8,9 +8,17 @@ export interface ResourceDetailProps {
8
8
  /** Id of the record to show. */
9
9
  id: string;
10
10
  /**
11
- * Renders the built-in Edit (opens a `ResourceForm` dialog pre-filled from the record) and Delete (opens a confirmation dialog) actions. One the server denies (403) is hidden for the rest of this component's lifetime.
11
+ * Renders the built-in Edit and Delete actions, and the default for `editAction`, `deleteAction`, and `resourceActions`.
12
12
  */
13
13
  actions?: boolean;
14
+ /**
15
+ * Renders the built-in Edit action, which opens a `ResourceForm` dialog pre-filled from the record. Hidden when the server reports the actor can't update the record, or when an update is denied (403 or 404) for the rest of this component's lifetime. Defaults to `actions`.
16
+ */
17
+ editAction?: boolean;
18
+ /**
19
+ * Renders the built-in Delete action, which opens a confirmation dialog. Hidden when the server reports the actor can't delete the record, or when a delete is denied (403 or 404) for the rest of this component's lifetime. Defaults to `actions`.
20
+ */
21
+ deleteAction?: boolean;
14
22
  /**
15
23
  * Renders the record-scoped actions declared on the resource via `defineResource({ actions })`. The page asks the server which of them the actor can't run on this record: those it may not run are hidden, and those that can't run right now are disabled, with the reason as a tooltip. An action denied when run (403 or 404) is hidden for the rest of this component's lifetime. Defaults to `actions`.
16
24
  */
@@ -25,7 +33,7 @@ export interface ResourceDetailProps {
25
33
  className?: string;
26
34
  }
27
35
  /**
28
- * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
36
+ * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
29
37
  */
30
38
  export declare const ResourceDetail: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
31
39
  resource: {
@@ -40,6 +48,14 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
40
48
  type: BooleanConstructor;
41
49
  default: boolean;
42
50
  };
51
+ editAction: {
52
+ type: PropType<boolean | undefined>;
53
+ default: undefined;
54
+ };
55
+ deleteAction: {
56
+ type: PropType<boolean | undefined>;
57
+ default: undefined;
58
+ };
43
59
  resourceActions: {
44
60
  type: PropType<boolean | undefined>;
45
61
  default: undefined;
@@ -71,6 +87,14 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
71
87
  type: BooleanConstructor;
72
88
  default: boolean;
73
89
  };
90
+ editAction: {
91
+ type: PropType<boolean | undefined>;
92
+ default: undefined;
93
+ };
94
+ deleteAction: {
95
+ type: PropType<boolean | undefined>;
96
+ default: undefined;
97
+ };
74
98
  resourceActions: {
75
99
  type: PropType<boolean | undefined>;
76
100
  default: undefined;
@@ -92,6 +116,8 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
92
116
  actions: boolean;
93
117
  renderActions: ((record: DetailRecord) => VNodeChild) | undefined;
94
118
  onDeleted: ((record: DetailRecord) => void) | undefined;
119
+ editAction: boolean | undefined;
120
+ deleteAction: boolean | undefined;
95
121
  resourceActions: boolean | undefined;
96
122
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
97
123
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"resource-detail.d.ts","sourceRoot":"","sources":["../../src/resource/resource-detail.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAa9E,OAAO,KAAK,EAAoB,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmBhF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C,wCAAwC;AACxC,MAAM,WAAW,mBAAmB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B,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;;;;cAI7B,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;;;;cAI5B,QAAQ,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;;;;cAI9C,QAAQ,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;;;;cAI5C,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;;;6BA1CvB,YAAY,KAAK,UAAU;yBAI/B,YAAY,KAAK,IAAI;;;;4EAgZ1C,CAAC"}
@@ -9,10 +9,10 @@ import { formatFieldValue } from "@verikit/ui-core/layout/format-value";
9
9
  import { useDeleteResource } from "../query/use-resource-mutations.js";
10
10
  import { useResourceFindWithActions } from "../query/use-resource-queries.js";
11
11
  import { declaredActionButton } from "./declared-action-button.js";
12
- import { hasStatus, isActionDenied, isPermissionDenied, ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
12
+ import { hasStatus, isActionDenied, ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
13
13
  import { ResourceForm } from "./resource-form.js";
14
14
  /**
15
- * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
15
+ * Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
16
16
  */
17
17
  export const ResourceDetail = defineComponent({
18
18
  name: "ResourceDetail",
@@ -23,6 +23,14 @@ export const ResourceDetail = defineComponent({
23
23
  },
24
24
  id: { type: String, required: true },
25
25
  actions: { type: Boolean, default: false },
26
+ editAction: {
27
+ type: Boolean,
28
+ default: undefined,
29
+ },
30
+ deleteAction: {
31
+ type: Boolean,
32
+ default: undefined,
33
+ },
26
34
  resourceActions: {
27
35
  type: Boolean,
28
36
  default: undefined,
@@ -81,7 +89,9 @@ export const ResourceDetail = defineComponent({
81
89
  }
82
90
  const deleteMutation = useDeleteResource(props.resource.name, {
83
91
  onError: (mutationError) => {
84
- if (isPermissionDenied(mutationError)) {
92
+ // The server answers a denied delete with 404 so as not to reveal
93
+ // whether the record exists, the same as a denied record action.
94
+ if (isActionDenied(mutationError, props.id)) {
85
95
  deniedDelete.value = true;
86
96
  deleteOpen.value = false;
87
97
  }
@@ -98,7 +108,7 @@ export const ResourceDetail = defineComponent({
98
108
  class: cn("text-sm text-muted-foreground", props.className),
99
109
  }, message);
100
110
  }
101
- function actionBar(record) {
111
+ function actionBar(record, showEdit, showDelete) {
102
112
  const unavailable = query.data.value.actions;
103
113
  return h("div", { class: "flex flex-wrap items-center justify-end gap-2 pb-3" }, [
104
114
  ...recordActions.map((action) => deniedActions.value[action.name]
@@ -110,7 +120,7 @@ export const ResourceDetail = defineComponent({
110
120
  disabled: directAction.isPending.value,
111
121
  onClick: () => startAction(action),
112
122
  })),
113
- props.actions && !deniedUpdate.value
123
+ showEdit
114
124
  ? h(Button, {
115
125
  type: "button",
116
126
  variant: "outline",
@@ -120,7 +130,7 @@ export const ResourceDetail = defineComponent({
120
130
  },
121
131
  }, { default: () => [h(PencilIcon), "Edit"] })
122
132
  : null,
123
- props.actions && !deniedDelete.value
133
+ showDelete
124
134
  ? h(Button, {
125
135
  type: "button",
126
136
  variant: "outline",
@@ -154,7 +164,7 @@ export const ResourceDetail = defineComponent({
154
164
  editOpen.value = false;
155
165
  },
156
166
  onError: (mutationError) => {
157
- if (isPermissionDenied(mutationError)) {
167
+ if (isActionDenied(mutationError, props.id)) {
158
168
  deniedUpdate.value = true;
159
169
  editOpen.value = false;
160
170
  }
@@ -183,7 +193,7 @@ export const ResourceDetail = defineComponent({
183
193
  ],
184
194
  }),
185
195
  deleteMutation.error.value &&
186
- !isPermissionDenied(deleteMutation.error.value)
196
+ !isActionDenied(deleteMutation.error.value, props.id)
187
197
  ? h("p", { role: "alert", class: "text-sm text-destructive" }, deleteMutation.error.value.message)
188
198
  : null,
189
199
  h(DialogFooter, {}, {
@@ -223,13 +233,18 @@ export const ResourceDetail = defineComponent({
223
233
  class: cn("text-sm text-destructive", props.className),
224
234
  }, error.message);
225
235
  }
226
- const record = query.data.value.record;
236
+ const { record, operations } = query.data.value;
237
+ const editEnabled = props.editAction ?? props.actions;
238
+ const deleteEnabled = props.deleteAction ?? props.actions;
239
+ const showEdit = editEnabled && !deniedUpdate.value && !operations.update;
240
+ const showDelete = deleteEnabled && !deniedDelete.value && !operations.delete;
227
241
  const visibleFields = Object.values(fields).filter((field) => !field.hidden && Object.hasOwn(record, field.name));
228
- const hasActions = props.actions ||
242
+ const hasActions = showEdit ||
243
+ showDelete ||
229
244
  recordActions.length > 0 ||
230
245
  Boolean(props.renderActions);
231
246
  return h("div", { class: cn("w-full", props.className) }, [
232
- hasActions ? actionBar(record) : null,
247
+ hasActions ? actionBar(record, showEdit, showDelete) : null,
233
248
  actionError.value
234
249
  ? h("p", { role: "alert", class: "pb-3 text-sm text-destructive" }, actionError.value)
235
250
  : null,
@@ -250,8 +265,8 @@ export const ResourceDetail = defineComponent({
250
265
  onDenied: denyAction,
251
266
  })
252
267
  : null,
253
- props.actions ? editDialog(record) : null,
254
- props.actions ? deleteDialog() : null,
268
+ editEnabled ? editDialog(record) : null,
269
+ deleteEnabled ? deleteDialog() : null,
255
270
  ]);
256
271
  };
257
272
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verikit/vue",
3
- "version": "0.24.3",
3
+ "version": "0.24.4",
4
4
  "description": "Vue UI bindings for Verikit resource workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -61,11 +61,11 @@
61
61
  "lucide-vue-next": "^1.0.0",
62
62
  "reka-ui": "^2.10.3",
63
63
  "tailwind-merge": "^3.6.0",
64
- "@verikit/core": "0.24.3",
65
- "@verikit/runtime": "0.24.3",
66
- "@verikit/theme": "0.24.3",
67
- "@verikit/ui-core": "0.24.3",
68
- "@verikit/client": "0.24.3"
64
+ "@verikit/client": "0.24.4",
65
+ "@verikit/runtime": "0.24.4",
66
+ "@verikit/theme": "0.24.4",
67
+ "@verikit/ui-core": "0.24.4",
68
+ "@verikit/core": "0.24.4"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/jsdom": "^28.0.3",