@wssto2/vue-core 0.5.1 → 0.5.3

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 (56) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/{ActionRow.vue_vue_type_script_setup_true_lang-BCgKzUvG.js → ActionRow.vue_vue_type_script_setup_true_lang-Bv-APkGf.js} +1 -1
  3. package/dist/{Activity-dpY2kIs2.js → Activity-DUjDaPfP.js} +4 -4
  4. package/dist/{Changes-CL8F1w8q.js → Changes-B0tZO6BZ.js} +3 -3
  5. package/dist/{CollectionPage.vue_vue_type_script_setup_true_lang-l-e-6WeS.js → CollectionPage.vue_vue_type_script_setup_true_lang-o_Pj-JcD.js} +2 -2
  6. package/dist/{DateField.vue_vue_type_script_setup_true_lang-DRuWzSaX.js → DateField.vue_vue_type_script_setup_true_lang-CDg31ZU7.js} +1 -1
  7. package/dist/{DeadLetters-BZLyL5lR.js → DeadLetters-IgVHao84.js} +2 -2
  8. package/dist/{FormGroup.vue_vue_type_script_setup_true_lang-BPchlRCl.js → FormGroup.vue_vue_type_script_setup_true_lang-CSgT4ITL.js} +1 -1
  9. package/dist/{FormView.vue_vue_type_script_setup_true_lang-CPSYV7iQ.js → FormView.vue_vue_type_script_setup_true_lang-D31Hk3pJ.js} +1 -1
  10. package/dist/{General-mrVzi-5R.js → General-C40HxupS.js} +6 -6
  11. package/dist/{NewRolePage-B2DItwvf.js → NewRolePage-Bhy8KJO1.js} +2 -2
  12. package/dist/{NumberField.vue_vue_type_script_setup_true_lang-ButMV_sf.js → NumberField.vue_vue_type_script_setup_true_lang-BdS7BxuS.js} +1 -1
  13. package/dist/{ProfilePage-EiTIYzZ5.js → ProfilePage-Bf7dFzGd.js} +9 -9
  14. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-BqqilJGF.js → RoleEditor.vue_vue_type_script_setup_true_lang-C6oloGIh.js} +12 -11
  15. package/dist/{RolePage-jMHAt9y8.js → RolePage-BjbvciTg.js} +6 -6
  16. package/dist/{RolesPage-B9GaVQBx.js → RolesPage-DzVOgF4z.js} +4 -4
  17. package/dist/{SegmentedField.vue_vue_type_script_setup_true_lang-BwyMvkis.js → SegmentedField.vue_vue_type_script_setup_true_lang-DXe_iOS8.js} +1 -1
  18. package/dist/{SelectField.vue_vue_type_script_setup_true_lang-BzQC1qDQ.js → SelectField.vue_vue_type_script_setup_true_lang-BN4vzvV9.js} +2 -2
  19. package/dist/{SessionList.vue_vue_type_script_setup_true_lang-DhoTd5D7.js → SessionList.vue_vue_type_script_setup_true_lang-PuWIK-Wa.js} +2 -2
  20. package/dist/{Sessions-CHLokZ9e.js → Sessions-CRUObe5G.js} +2 -2
  21. package/dist/{SettingsPage-CudoKdXm.js → SettingsPage-C0qEC0uI.js} +8 -8
  22. package/dist/{SignIn-ypRvdmjg.js → SignIn-Uy0Jujzz.js} +4 -4
  23. package/dist/{SignInPage-CbPeKlAo.js → SignInPage-CpVZfrLZ.js} +3 -3
  24. package/dist/{SignIns-BApzbGq-.js → SignIns-Cp5Gx2dk.js} +1 -1
  25. package/dist/{SwitchField.vue_vue_type_script_setup_true_lang-D_-HACqT.js → SwitchField.vue_vue_type_script_setup_true_lang-Dj5Aq8QT.js} +1 -1
  26. package/dist/{TextField.vue_vue_type_script_setup_true_lang-DTAQPbW0.js → TextField.vue_vue_type_script_setup_true_lang-BwfNNQEz.js} +2 -2
  27. package/dist/{TextareaField.vue_vue_type_script_setup_true_lang-DsjK2C9T.js → TextareaField.vue_vue_type_script_setup_true_lang-aT1P8Xqr.js} +1 -1
  28. package/dist/{TimeField.vue_vue_type_script_setup_true_lang-Cz7KhUqt.js → TimeField.vue_vue_type_script_setup_true_lang-jPKPE1hc.js} +1 -1
  29. package/dist/{UserRecord-BCTaBajE.js → UserRecord-DbSMnTbj.js} +6 -6
  30. package/dist/{UsersList-CqSK3cQL.js → UsersList-9MicE2pG.js} +7 -7
  31. package/dist/access/api.d.ts +8 -7
  32. package/dist/access/context.d.ts +7 -0
  33. package/dist/access/feature.d.ts +8 -0
  34. package/dist/access/index.js +1 -1
  35. package/dist/access/labels.d.ts +5 -0
  36. package/dist/collection/index.js +1 -1
  37. package/dist/form/FormRow.vue.d.ts +3 -0
  38. package/dist/form/index.js +22 -22
  39. package/dist/identity/index.js +2 -2
  40. package/dist/index-BdGnA1Jh.js +765 -0
  41. package/dist/{index-BTRv8mcf.js → index-C-oM_Mnf.js} +261 -239
  42. package/dist/{index-auJqVMWC.js → index-Ok29ucE3.js} +13 -13
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/notifications/index.d.ts +2 -0
  46. package/dist/notifications/index.js +5 -4
  47. package/dist/notifications/push/pushState.d.ts +27 -0
  48. package/dist/{options-g8RwEhBk.js → options-Bu0XbEpN.js} +104 -102
  49. package/dist/phone/index.js +1 -1
  50. package/dist/{status-BUFELJz2.js → status-C78NpXyB.js} +1 -1
  51. package/dist/styles.css +1 -1
  52. package/dist/{suggestions-CfFTHi8y.js → suggestions-ClyLexMO.js} +1 -1
  53. package/dist/{useCommand-CtqheKUv.js → useCommand-DyuPTosF.js} +1 -1
  54. package/dist/{useGroupSheet-ATvc0IiM.js → useGroupSheet-C2NyqWRp.js} +2 -2
  55. package/package.json +1 -1
  56. package/dist/index-VPzJJN6Z.js +0 -745
@@ -1,745 +0,0 @@
1
- import { route as E } from "./client/index.js";
2
- import { d as Re, p as Ee } from "./feature-DdUAfyi4.js";
3
- import { d as Ne } from "./context-Ch1r4fdN.js";
4
- import { d as Se } from "./defineRoutes-BGAdiIrt.js";
5
- import { useI18n as z } from "vue-i18n";
6
- import { hasInjectionContext as Te, inject as Oe, defineComponent as J, ref as A, computed as N, watch as ce, openBlock as m, createBlock as T, unref as l, withCtx as h, createElementVNode as O, createElementBlock as _, toDisplayString as $, createCommentVNode as D, createVNode as j, Fragment as K, renderList as B, createSlots as _e, renderSlot as Ae, createTextVNode as G, useTemplateRef as re } from "vue";
7
- import { i as oe } from "./error-Bb_dr_Ay.js";
8
- import { u as De } from "./describeError-BqGAUZgX.js";
9
- import { _ as Y } from "./Button.vue_vue_type_script_setup_true_lang-CL9Qh5yq.js";
10
- import { _ as V } from "./FormGroup.vue_vue_type_script_setup_true_lang-BPchlRCl.js";
11
- import { g as U } from "./options-g8RwEhBk.js";
12
- import { _ as Ke } from "./AlertDialog.vue_vue_type_script_setup_true_lang-whA4WLdl.js";
13
- import { t as ee } from "./toast-CqSDTWRX.js";
14
- import { _ as ie } from "./AccessGate.vue_vue_type_script_setup_true_lang-DZ9GcLC1.js";
15
- import { _ as Pe } from "./AsyncSection.vue_vue_type_script_setup_true_lang-B0NfvG3B.js";
16
- import { _ as Be } from "./EmptyState.vue_vue_type_script_setup_true_lang-50p-Mp8I.js";
17
- import { u as Ue } from "./useLoad-W4tfxmm5.js";
18
- import { _ as Fe, a as Me } from "./SelectField.vue_vue_type_script_setup_true_lang-BzQC1qDQ.js";
19
- import { _ as Ge } from "./SegmentedField.vue_vue_type_script_setup_true_lang-BwyMvkis.js";
20
- import { u as Ve, _ as ze } from "./useCommand-CtqheKUv.js";
21
- import { u as He } from "./platform-Dx6STiwY.js";
22
- import { _ as We } from "./IconTile.vue_vue_type_script_setup_true_lang-_FXvaj93.js";
23
- import { u as Ie } from "./mediaQuery-CygcXmFW.js";
24
- import { _ as Qe } from "./Badge.vue_vue_type_script_setup_true_lang-DJyZc0C7.js";
25
- const S = {
26
- rolesList: E("GET", "/v1/iam/roles", { permission: "iam.role:view" }),
27
- rolesShow: E("GET", "/v1/iam/roles/:ref", { permission: "iam.role:view" }),
28
- rolesHolders: E("GET", "/v1/iam/roles/:ref/holders", { permission: "iam.role:view" }),
29
- rolesCompare: E("GET", "/v1/iam/roles/:ref/compare", { permission: "iam.role:view" }),
30
- rolesCreate: E("POST", "/v1/iam/roles", { permission: "iam.role:manage" }),
31
- rolesUpdate: E("PUT", "/v1/iam/roles/:ref", { permission: "iam.role:manage" }),
32
- rolesDelete: E("DELETE", "/v1/iam/roles/:ref", { permission: "iam.role:delete" }),
33
- rolesReplace: E("POST", "/v1/iam/roles/:ref/replace", { permission: "iam.role:manage" }),
34
- bindable: E("GET", "/v1/iam/bindable-roles"),
35
- subjectsAccess: E("GET", "/v1/iam/users/:id/access", { permission: "iam.user:view" }),
36
- subjectsScopes: E("GET", "/v1/iam/users/:id/scopes", { permission: "iam.user:manage" }),
37
- subjectsBind: E("POST", "/v1/iam/users/:id/bindings", { permission: "iam.user:manage" }),
38
- subjectsUnbind: E("DELETE", "/v1/iam/users/:id/bindings/:binding_id", { permission: "iam.user:manage" }),
39
- me: E.raw("GET", "/v1/me/access")
40
- }, [ge, ae] = Ne("vue-core.access"), F = {
41
- viewRoles: "iam.role:view",
42
- manageRoles: "iam.role:manage",
43
- deleteRoles: "iam.role:delete",
44
- viewAccess: "iam.user:view",
45
- manageBindings: "iam.user:manage"
46
- }, ue = Se({
47
- roles: { name: "access.roles", path: "/iam/roles", component: () => import("./RolesPage-B9GaVQBx.js"), meta: { access: F.viewRoles, titleKey: "core.access.title" } },
48
- newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-B2DItwvf.js"), meta: { access: F.manageRoles, titleKey: "core.access.new_title" } },
49
- role: {
50
- name: "access.role",
51
- path: "/iam/roles/:ref",
52
- component: () => import("./RolePage-jMHAt9y8.js"),
53
- // A role's ref (its key, or the id of a custom one) swaps in place when a link leads to another role.
54
- meta: { access: F.viewRoles, titleKey: "core.access.title", remountOnParam: "ref" }
55
- }
56
- }), to = {
57
- access: F.viewAccess,
58
- section: { labelKey: "core.access.person_roles", icon: "shieldStarFill" }
59
- };
60
- function lo(s) {
61
- return Re({
62
- id: "access",
63
- routes: ue.records,
64
- context: Ee(ge, {
65
- catalogue: s.catalogue,
66
- subjectRoute: s.subjectRoute ?? (() => null),
67
- constraints: s.roleConstraints ?? [],
68
- problems: s.problems ?? {},
69
- scopes: s.scopes ?? null
70
- }),
71
- navigation: s.destination ? [{ destination: s.destination, to: ue.roles, within: ["access.role", "access.roles.new"] }] : []
72
- });
73
- }
74
- const M = "system", de = ["view", "create", "update", "manage", "delete"], me = (s) => {
75
- const o = de.indexOf(s);
76
- return o === -1 ? de.length : o;
77
- }, se = (s) => s.system ? M : s.module, ye = (s) => s.resource === "" ? s.module : `${s.module}_${s.resource.replace(/\./g, "_")}`;
78
- function no(s) {
79
- const o = /* @__PURE__ */ new Map();
80
- for (const [n, t] of Object.entries(s)) {
81
- const e = o.get(se(t)) ?? /* @__PURE__ */ new Map(), c = ye(t);
82
- e.set(c, [...e.get(c) ?? [], { ...t, id: n }]), o.set(se(t), e);
83
- }
84
- return [...o.keys()].sort((n, t) => +(n === M) - +(t === M) || n.localeCompare(t)).map((n) => ({
85
- key: n,
86
- screens: [...o.get(n) ?? []].map(([t, e]) => ({ key: t, permissions: e.sort((c, u) => me(c.verb) - me(u.verb) || c.verb.localeCompare(u.verb)) })).sort((t, e) => t.key.localeCompare(e.key))
87
- }));
88
- }
89
- function Ye(s, o) {
90
- const a = /* @__PURE__ */ new Set(), n = (t) => {
91
- for (const e of s[t]?.requires ?? [])
92
- a.has(e) || (a.add(e), n(e));
93
- };
94
- return n(o), [...a];
95
- }
96
- function Je(s, o) {
97
- const a = /* @__PURE__ */ new Set(), n = (t) => {
98
- for (const [e, c] of Object.entries(s))
99
- a.has(e) || !c.requires.includes(t) || (a.add(e), n(e));
100
- };
101
- return n(o), [...a];
102
- }
103
- function Xe(s, o, a) {
104
- const n = Object.entries(s).filter(([e, c]) => c.ownable === a && e in o), t = n.find(([, e]) => e.verb === "view") ?? n[0];
105
- return t ? o[t[0]] ?? null : null;
106
- }
107
- function Ze(s, o, a) {
108
- for (const n of [a, ...Ye(s, a)]) {
109
- if (n in o || !(n in s)) continue;
110
- const t = s[n]?.ownable;
111
- o[n] = t ? Xe(s, o, t) ?? "own" : "all";
112
- }
113
- }
114
- function co(s, o, a) {
115
- for (const n of [a, ...Je(s, a)]) delete o[n];
116
- }
117
- function ro(s, o, a, n) {
118
- for (const [t, e] of Object.entries(s)) e.ownable === a && t in o && (o[t] = n);
119
- }
120
- function io(s, o) {
121
- const a = new Set(Object.keys(o));
122
- for (const n of a) Ze(s, o, n);
123
- return Object.keys(o).filter((n) => !a.has(n));
124
- }
125
- function H() {
126
- const { t: s, te: o } = z(), { catalogue: a } = ae(), n = (e, c) => {
127
- const u = e.find((q) => o(q));
128
- return u ? s(u) : c;
129
- }, t = (e) => n([`access.levels.${e}`, `core.access.levels.${e}`], e);
130
- return {
131
- roleName: (e) => e.key ? n([`access.roles.${e.key}`], e.name) : e.name,
132
- permissionLabel: (e) => n(a[e]?.labelKey ? [a[e].labelKey] : [], e),
133
- permissionDescription: (e) => n(a[e]?.descriptionKey ? [a[e].descriptionKey] : [], ""),
134
- groupLabel: (e) => n([`access.modules.${e}`, ...e === M ? ["core.access.system_group"] : []], e),
135
- screenLabel: (e) => n([`access.resources.${e}`], e),
136
- ownableLabel: (e) => n([`access.ownable.${e.replace(/\./g, "_")}`], e),
137
- qualifierLabel: (e) => s(`core.access.qualifier.${e}`),
138
- qualifierHint: (e) => s(`core.access.qualifier_hint.${e}`),
139
- qualifierNoun: (e) => s(`core.access.qualifier_noun.${e}`),
140
- levelLabel: t,
141
- /** A place: the level and its name (`Dealer · Auto Zagreb`); the root, which has no name, by its level. */
142
- scopeLabel: (e) => e.name ? `${t(e.level)} · ${e.name}` : t(e.level),
143
- roleKind: (e) => s(`core.access.role_kind.${e.computed ? "computed" : e.predefined ? "predefined" : "custom"}`)
144
- };
145
- }
146
- function es(s) {
147
- if (!oe(s) || s.code !== "authz.invalid") return [];
148
- const o = s.params?.problems;
149
- return Array.isArray(o) ? o.flatMap((a) => {
150
- if (typeof a != "object" || a === null || typeof a.code != "string") return [];
151
- const { code: n, permission: t, detail: e } = a;
152
- return [{ code: n, ...typeof t == "string" ? { permission: t } : {}, ...typeof e == "string" ? { detail: e } : {} }];
153
- }) : [];
154
- }
155
- function he() {
156
- const { t: s, te: o } = z(), a = De(), n = Te() ? Oe(ge, null) : null, t = n ? H() : null;
157
- return (e, c) => {
158
- const u = es(e);
159
- if (u.length === 0) return a(e, c);
160
- const q = u.map((g) => {
161
- const L = [n?.problems[g.code], `core.access.problems.${g.code}`].find((r) => r && o(r)), R = { code: g.code, permission: g.permission ? t?.permissionLabel(g.permission) ?? g.permission : "", detail: g.detail ?? "" };
162
- return s(L ?? "core.access.problems.unknown", R);
163
- });
164
- return [...new Set(q)].join(" ");
165
- };
166
- }
167
- function ss() {
168
- const s = he();
169
- return (o, a) => oe(a) && a.code?.startsWith("authz.") ? s(a) : void 0;
170
- }
171
- function os(s) {
172
- return {
173
- roles: async (o) => (await s.request(S.rolesList, void 0, o)).data.roles,
174
- role: async (o, a) => (await s.request(S.rolesShow, { ref: o }, a)).data,
175
- holders: async (o, a) => (await s.request(S.rolesHolders, { ref: o }, a)).data.holders,
176
- compare: async (o, a, n) => (await s.request(S.rolesCompare, { ref: o, with: a }, n)).data,
177
- create: async (o) => (await s.request(S.rolesCreate, o)).data,
178
- update: async (o) => (await s.request(S.rolesUpdate, o)).data,
179
- remove: async (o) => void await s.request(S.rolesDelete, { ref: o }),
180
- replace: async (o, a) => (await s.request(S.rolesReplace, { ref: o, with: a })).data.rebound,
181
- access: async (o, a) => (await s.request(S.subjectsAccess, { id: o.id }, a)).data,
182
- scopes: async (o, a) => (await s.request(S.subjectsScopes, { id: o.id }, a)).data,
183
- bindable: async (o, a, n) => (await s.request(S.bindable, { level: o, scope_id: a ?? 0 }, n)).data.roles,
184
- bind: async (o, a) => (await s.request(S.subjectsBind, { id: o.id, ...a })).data,
185
- unbind: async (o, a) => void await s.request(S.subjectsUnbind, { id: o.id, binding_id: a })
186
- };
187
- }
188
- const we = () => os(He().http);
189
- function as(s) {
190
- const o = /* @__PURE__ */ new Map();
191
- for (const t of s.places) o.set(t.level, t.parent_level);
192
- const a = (t) => {
193
- const e = [t], c = new Set(e);
194
- for (let u = o.get(t); u !== void 0 && u !== s.root_level && o.has(u) && !c.has(u); u = o.get(u))
195
- e.unshift(u), c.add(u);
196
- return e;
197
- }, n = [...o.keys()].map((t) => ({ level: t, chain: a(t) })).sort((t, e) => e.chain.length - t.chain.length || t.level.localeCompare(e.level));
198
- return s.root ? [...n, { level: s.root_level, chain: [] }] : n;
199
- }
200
- const ts = (s) => s.filter((o) => o.chain.length > 0).sort((o, a) => o.chain.length - a.chain.length)[0] ?? s[0] ?? null;
201
- function fe(s, o, a, n) {
202
- const t = o.chain[a], e = o.chain[a + 1];
203
- return s.places.filter(
204
- (c) => c.level === t && (a === 0 || c.parent_level === o.chain[a - 1] && c.parent_id === n[a - 1]) && (e === void 0 || s.places.some((u) => u.level === e && u.parent_id === c.id))
205
- );
206
- }
207
- const ls = {
208
- class: "flex min-w-0 flex-col gap-group-gap",
209
- "data-test": "add-role-sheet"
210
- }, ns = {
211
- key: 0,
212
- class: "px-row-inset text-body text-content-destructive",
213
- role: "alert",
214
- "data-test": "scopes-failed"
215
- }, cs = {
216
- key: 1,
217
- class: "px-row-inset text-body text-content-muted",
218
- "data-test": "no-places"
219
- }, rs = {
220
- key: 0,
221
- class: "px-row-inset text-body text-content-muted",
222
- "data-test": "roles-loading"
223
- }, is = {
224
- key: 1,
225
- class: "px-row-inset text-body text-content-destructive",
226
- role: "alert",
227
- "data-test": "roles-failed"
228
- }, us = {
229
- key: 2,
230
- class: "px-row-inset text-body text-content-muted",
231
- "data-test": "roles-none"
232
- }, ds = {
233
- key: 3,
234
- "data-test": "bindable-roles"
235
- }, ms = { class: "px-row-inset pb-1.5 text-footnote uppercase tracking-wide text-content-muted" }, fs = {
236
- key: 4,
237
- "data-test": "chosen-role"
238
- }, ps = /* @__PURE__ */ J({
239
- __name: "AddRoleDialog",
240
- props: {
241
- subject: {},
242
- subjectLabel: {}
243
- },
244
- emits: ["added"],
245
- setup(s, { expose: o, emit: a }) {
246
- const n = s, t = a, { t: e } = z(), c = H(), u = we(), { catalogue: q, scopes: g } = ae(), R = Ve({
247
- defaults: () => ({ level: null, place: null, role: null }),
248
- validator: {
249
- safeParse(i) {
250
- const f = i, d = [
251
- ...f.level === null || f.level !== p.value?.root_level && f.place === null ? [{ path: ["level"], message: e("core.access.add.choose_place") }] : [],
252
- ...f.role === null ? [{ path: ["role"], message: e("core.access.add.choose_role") }] : []
253
- ];
254
- return d.length === 0 ? { success: !0, data: { level: f.level, place: f.place, role: f.role } } : { success: !1, error: { issues: d } };
255
- }
256
- },
257
- failureMessage: ss(),
258
- run: (i) => u.bind(n.subject, { role_ref: i.role, level: i.level, scope_id: i.place }),
259
- done: (i) => {
260
- ee.success(e("core.access.added")), t("added", i);
261
- }
262
- }), r = R.form.values, p = A(null), y = A(!1), v = A([]), b = A([]), x = A(!1), w = A(!1), k = N(() => p.value ? as(p.value) : []), C = N(() => k.value.find((i) => i.level === r.level) ?? null), te = N(() => k.value.length > 1), ke = N(() => {
263
- const i = p.value, f = C.value;
264
- return i && f ? f.chain.map((d, P) => ({ name: d, places: fe(i, f, P, v.value) })) : [];
265
- }), $e = N(() => {
266
- const i = C.value?.chain.length ?? 0, f = i ? v.value[i - 1] : null;
267
- return p.value?.places.find((d) => d.level === C.value?.level && d.id === f)?.name ?? null;
268
- }), X = N(() => C.value !== null && C.value.chain.every((i, f) => v.value[f] != null));
269
- function le(i) {
270
- r.level = i, v.value = [], r.place = null;
271
- }
272
- function ne(i, f) {
273
- const d = v.value.slice(0, i);
274
- d[i] = f, v.value = d;
275
- }
276
- ce([() => r.level, v, p], () => {
277
- const i = p.value, f = C.value;
278
- if (!(!i || !f)) {
279
- for (let d = 0; d < f.chain.length; d++) {
280
- if (v.value[d] != null) continue;
281
- const P = fe(i, f, d, v.value);
282
- P.length === 1 && P[0] && ne(d, P[0].id);
283
- break;
284
- }
285
- r.place = f.chain.length === 0 ? null : v.value[f.chain.length - 1] ?? null;
286
- }
287
- }, { deep: !0 });
288
- async function xe() {
289
- if (r.role = null, b.value = [], w.value = !1, !C.value || !X.value) return;
290
- x.value = !0;
291
- const i = `${r.level}:${r.place}`;
292
- try {
293
- const f = await u.bindable(C.value.level, r.place);
294
- i === `${r.level}:${r.place}` && (b.value = f);
295
- } catch {
296
- i === `${r.level}:${r.place}` && (w.value = !0);
297
- } finally {
298
- x.value = !1;
299
- }
300
- }
301
- ce([() => r.level, () => r.place, X], () => void xe());
302
- const je = N(() => b.value.map((i) => ({ value: i.ref, label: c.roleName(i), description: c.roleKind(i) }))), W = N(() => b.value.find((i) => i.ref === r.role) ?? null), qe = N(() => {
303
- const i = /* @__PURE__ */ new Map();
304
- for (const f of W.value?.grants ?? []) {
305
- const d = q[f.permission]?.ownable;
306
- d && (!i.has(d) || f.permission.endsWith(":view")) && i.set(d, f.qualifier);
307
- }
308
- return [...i].map(([f, d]) => ({ ownable: f, qualifier: d }));
309
- }), Le = N(() => c.scopeLabel({ level: r.level ?? p.value?.root_level ?? "", name: $e.value }));
310
- async function Ce() {
311
- p.value = null, y.value = !1, v.value = [], b.value = [], R.present();
312
- try {
313
- p.value = g ? await g(n.subject, new AbortController().signal) : await u.scopes(n.subject);
314
- } catch {
315
- y.value = !0;
316
- return;
317
- }
318
- const i = ts(k.value);
319
- i && le(i.level);
320
- }
321
- return o({ present: Ce }), (i, f) => (m(), T(l(ze), {
322
- command: l(R),
323
- title: l(e)("core.access.add_role"),
324
- subtitle: n.subjectLabel,
325
- size: "lg",
326
- "confirm-label": l(e)("core.access.add.confirm")
327
- }, {
328
- default: h(() => [
329
- O("div", ls, [
330
- y.value ? (m(), _("p", ns, $(l(e)("core.access.add.scopes_failed")), 1)) : p.value && k.value.length === 0 ? (m(), _("p", cs, $(l(e)("core.access.add.no_places")), 1)) : D("", !0),
331
- te.value ? (m(), T(l(V), {
332
- key: 2,
333
- header: l(e)("core.access.add.scope_header")
334
- }, {
335
- default: h(() => [
336
- j(l(Ge), {
337
- "model-value": l(r).level,
338
- label: l(e)("core.access.add.scope_level"),
339
- options: k.value.map((d) => ({ value: d.level, label: l(c).levelLabel(d.level) })),
340
- "onUpdate:modelValue": f[0] || (f[0] = (d) => le(d))
341
- }, null, 8, ["model-value", "label", "options"]),
342
- (m(!0), _(K, null, B(ke.value, (d, P) => (m(), T(l(Fe), {
343
- key: d.name,
344
- "model-value": v.value[P] ?? null,
345
- label: l(c).levelLabel(d.name),
346
- options: d.places.map((I) => ({ value: I.id, label: I.name })),
347
- "onUpdate:modelValue": (I) => ne(P, I)
348
- }, null, 8, ["model-value", "label", "options", "onUpdate:modelValue"]))), 128))
349
- ]),
350
- _: 1
351
- }, 8, ["header"])) : D("", !0),
352
- X.value ? (m(), _(K, { key: 3 }, [
353
- x.value ? (m(), _("p", rs, $(l(e)("core.access.add.roles_loading")), 1)) : w.value ? (m(), _("p", is, $(l(e)("core.access.add.roles_failed")), 1)) : b.value.length === 0 ? (m(), _("p", us, $(l(e)("core.access.add.no_roles")), 1)) : (m(), _("div", ds, [
354
- O("p", ms, $(l(e)("core.access.add.role")), 1),
355
- j(l(Me), {
356
- options: je.value,
357
- "model-value": l(r).role,
358
- onSelect: f[1] || (f[1] = (d) => l(r).role = d)
359
- }, null, 8, ["options", "model-value"])
360
- ]))
361
- ], 64)) : D("", !0),
362
- W.value ? (m(), _("div", fs, [
363
- j(l(V), {
364
- header: l(e)("core.access.add.role_gives"),
365
- footer: l(e)("core.access.add.role_gives_footer")
366
- }, {
367
- default: h(() => [
368
- j(l(U), {
369
- layout: "setting",
370
- label: l(c).roleName(W.value),
371
- sub: W.value.description
372
- }, null, 8, ["label", "sub"]),
373
- (m(!0), _(K, null, B(qe.value, (d) => (m(), T(l(U), {
374
- key: d.ownable,
375
- layout: "setting",
376
- label: l(c).ownableLabel(d.ownable),
377
- value: `${l(c).qualifierNoun(d.qualifier)} · ${Le.value}`
378
- }, null, 8, ["label", "value"]))), 128))
379
- ]),
380
- _: 1
381
- }, 8, ["header", "footer"])
382
- ])) : D("", !0)
383
- ])
384
- ]),
385
- _: 1
386
- }, 8, ["command", "title", "subtitle", "confirm-label"]));
387
- }
388
- }), vs = {
389
- class: "text-right text-footnote text-content-muted",
390
- "data-test": "binding-scope"
391
- }, bs = /* @__PURE__ */ J({
392
- __name: "BindingRow",
393
- props: {
394
- binding: {}
395
- },
396
- setup(s) {
397
- const o = s, a = H(), n = N(() => [a.roleKind(o.binding.role), ...o.binding.role.attrs.map((t) => `${t.attribute}: ${t.values.join(", ")}`)].join(" · "));
398
- return (t, e) => (m(), T(l(U), {
399
- layout: "setting",
400
- label: l(a).roleName(o.binding.role),
401
- sub: n.value
402
- }, _e({
403
- leading: h(() => [
404
- j(l(We), {
405
- tone: o.binding.role.predefined ? "anchor" : "brand",
406
- icon: "shieldStarFill"
407
- }, null, 8, ["tone"])
408
- ]),
409
- default: h(() => [
410
- O("span", vs, $(l(a).scopeLabel(o.binding.scope)), 1)
411
- ]),
412
- _: 2
413
- }, [
414
- t.$slots.trailing ? {
415
- name: "trailing",
416
- fn: h(() => [
417
- Ae(t.$slots, "trailing")
418
- ]),
419
- key: "0"
420
- } : void 0
421
- ]), 1032, ["label", "sub"]));
422
- }
423
- }), pe = { own: 0, own_location: 1, all: 2 }, ve = (s, o) => pe[o] > pe[s] ? o : s, Q = (s) => `${s.level}:${s.id ?? ""}`, Z = ["view", "create", "update", "manage", "delete"], be = (s) => Z.includes(s) ? Z.indexOf(s) : Z.length;
424
- function _s(s, o) {
425
- const a = /* @__PURE__ */ new Map();
426
- for (const t of o) {
427
- if (t.grants.length === 0) continue;
428
- const e = s[t.permission], [c = t.permission, u = ""] = t.permission.split(":"), q = e ? se(e) : c.split(".")[0] ?? c, g = e ? ye(e) : c.replace(/\./g, "_"), L = e?.ownable != null, R = a.get(q) ?? /* @__PURE__ */ new Map(), r = R.get(g) ?? { key: g, actions: [], sources: [], qualifier: null, scopes: [], ownable: !1, allUnavailable: !0 };
429
- r.actions.push({ permission: t.permission, verb: e?.verb ?? u, unavailable: t.unavailable, grants: t.grants }), r.ownable || (r.ownable = L), r.allUnavailable && (r.allUnavailable = t.unavailable);
430
- for (const p of t.grants) {
431
- const y = L ? p.qualifier : "all";
432
- r.scopes.some((b) => Q(b) === Q(p.scope)) || r.scopes.push(p.scope), L && (r.qualifier = r.qualifier ? ve(r.qualifier, y) : y);
433
- const v = r.sources.find((b) => b.roleName === p.role_name && Q(b.scope) === Q(p.scope));
434
- v ? L && (r.sources[r.sources.indexOf(v)] = { ...v, qualifier: ve(v.qualifier, y) }) : r.sources.push({ roleKey: p.role_key, roleName: p.role_name, qualifier: y, scope: p.scope });
435
- }
436
- R.set(g, r), a.set(q, R);
437
- }
438
- return [...a.keys()].sort((t, e) => +(t === M) - +(e === M) || t.localeCompare(e)).map((t) => ({
439
- key: t,
440
- screens: [...a.get(t)?.values() ?? []].map((e) => ({
441
- ...e,
442
- actions: [...e.actions].sort((c, u) => be(c.verb) - be(u.verb) || c.verb.localeCompare(u.verb)),
443
- // the root (the place without an id) first: what applies everywhere is what a reader looks for
444
- scopes: [...e.scopes].sort((c, u) => +(u.id === null) - +(c.id === null))
445
- })).sort((e, c) => e.key.localeCompare(c.key))
446
- }));
447
- }
448
- const gs = {
449
- class: "flex min-w-0 flex-col gap-group-gap",
450
- "data-test": "effective-access"
451
- }, ys = { class: "px-row-inset text-title3 font-semibold text-content-strong" }, hs = {
452
- class: "block",
453
- "data-test": "effective-actions"
454
- }, ws = {
455
- class: "block",
456
- "data-test": "effective-sources"
457
- }, ks = {
458
- key: 0,
459
- class: "mt-2 flex flex-col gap-1.5 border-l border-border-separator pl-3",
460
- "data-test": "effective-why"
461
- }, $s = ["data-permission"], xs = { class: "text-content" }, js = {
462
- key: 0,
463
- class: "ml-2 text-content-muted"
464
- }, qs = {
465
- key: 0,
466
- class: "contents",
467
- "data-test": "effective-unavailable"
468
- }, Ls = {
469
- class: "text-right text-footnote text-content-muted",
470
- "data-test": "effective-reach"
471
- }, Cs = ["data-test"], Rs = {
472
- key: 0,
473
- class: "contents",
474
- "data-test": "effective-show-all"
475
- }, Es = /* @__PURE__ */ J({
476
- __name: "EffectiveAccess",
477
- props: {
478
- effective: {},
479
- name: {}
480
- },
481
- setup(s) {
482
- const o = s, { t: a } = z(), { catalogue: n } = ae(), t = H(), e = Ie(), c = N(() => _s(n, o.effective)), u = A(!1), q = N(() => e.value && !u.value ? c.value.slice(0, 3) : c.value), g = A({}), L = (p) => p.actions.map((y) => t.permissionLabel(y.permission)).join(" · "), R = (p) => p.sources.map((y) => {
483
- const v = t.roleName({ key: y.roleKey, name: y.roleName });
484
- return p.ownable ? `${v} (${t.qualifierNoun(y.qualifier).toLowerCase()})` : v;
485
- }).join(", "), r = (p) => [p.qualifier ? t.qualifierNoun(p.qualifier) : "", p.scopes.map((y) => t.scopeLabel(y)).join(", ")].filter(Boolean).join(" · ");
486
- return (p, y) => (m(), _("section", gs, [
487
- O("h2", ys, $(l(a)("core.access.effective.title", { name: o.name })), 1),
488
- c.value.length === 0 ? (m(), T(l(V), {
489
- key: 0,
490
- footer: l(a)("core.access.effective.footer")
491
- }, {
492
- default: h(() => [
493
- j(l(U), {
494
- layout: "setting",
495
- label: l(a)("core.access.effective.empty")
496
- }, null, 8, ["label"])
497
- ]),
498
- _: 1
499
- }, 8, ["footer"])) : (m(), _(K, { key: 1 }, [
500
- (m(!0), _(K, null, B(q.value, (v) => (m(), T(l(V), {
501
- key: v.key,
502
- header: l(t).groupLabel(v.key),
503
- footer: v === q.value[q.value.length - 1] ? l(a)("core.access.effective.footer") : void 0
504
- }, {
505
- default: h(() => [
506
- (m(!0), _(K, null, B(v.screens, (b) => (m(), T(l(U), {
507
- key: b.key,
508
- layout: "setting",
509
- label: l(t).screenLabel(b.key)
510
- }, {
511
- sub: h(() => [
512
- O("span", hs, $(L(b)), 1),
513
- O("span", ws, $(l(a)("core.access.effective.from_roles", { roles: R(b) })), 1),
514
- g.value[b.key] ? (m(), _("ul", ks, [
515
- (m(!0), _(K, null, B(b.actions, (x) => (m(), _("li", {
516
- key: x.permission,
517
- "data-permission": x.permission
518
- }, [
519
- O("span", xs, $(l(t).permissionLabel(x.permission)), 1),
520
- x.unavailable ? (m(), _("span", js, $(l(a)("core.access.effective.unavailable")), 1)) : D("", !0),
521
- (m(!0), _(K, null, B(x.grants, (w) => (m(), _("span", {
522
- key: `${w.binding_id}-${w.scope.level}-${w.scope.id ?? 0}`,
523
- class: "block text-content-muted"
524
- }, $(l(a)("core.access.effective.why_row", {
525
- role: l(t).roleName({ key: w.role_key, name: w.role_name }),
526
- whose: l(t).qualifierNoun(b.ownable ? w.qualifier : "all"),
527
- scope: l(t).scopeLabel(w.scope)
528
- })), 1))), 128))
529
- ], 8, $s))), 128))
530
- ])) : D("", !0)
531
- ]),
532
- default: h(() => [
533
- b.allUnavailable ? (m(), _("span", qs, [
534
- j(l(Qe), { tone: "warning" }, {
535
- default: h(() => [
536
- G($(l(a)("core.access.effective.unavailable")), 1)
537
- ]),
538
- _: 1
539
- })
540
- ])) : D("", !0),
541
- O("span", Ls, $(r(b)), 1),
542
- O("span", {
543
- class: "contents",
544
- "data-test": `why-${b.key}`
545
- }, [
546
- j(l(Y), {
547
- prominence: "secondary",
548
- size: "sm",
549
- onClick: (x) => g.value[b.key] = !g.value[b.key]
550
- }, {
551
- default: h(() => [
552
- G($(g.value[b.key] ? l(a)("core.access.effective.hide_why") : l(a)("core.access.effective.show_why")), 1)
553
- ]),
554
- _: 2
555
- }, 1032, ["onClick"])
556
- ], 8, Cs)
557
- ]),
558
- _: 2
559
- }, 1032, ["label"]))), 128))
560
- ]),
561
- _: 2
562
- }, 1032, ["header", "footer"]))), 128)),
563
- l(e) && c.value.length > 3 ? (m(), _("span", Rs, [
564
- j(l(Y), {
565
- prominence: "secondary",
566
- class: "self-center",
567
- onClick: y[0] || (y[0] = (v) => u.value = !u.value)
568
- }, {
569
- default: h(() => [
570
- G($(u.value ? l(a)("core.access.effective.fewer_modules") : l(a)("core.access.effective.all_modules", { count: c.value.length })), 1)
571
- ]),
572
- _: 1
573
- })
574
- ])) : D("", !0)
575
- ], 64))
576
- ]));
577
- }
578
- }), Ns = {
579
- class: "flex min-w-0 flex-col gap-group-gap",
580
- "data-test": "access-panel"
581
- }, Ss = ["data-test"], Ts = {
582
- class: "contents",
583
- "data-test": "add-role"
584
- }, uo = /* @__PURE__ */ J({
585
- __name: "PersonAccess",
586
- props: {
587
- subject: {},
588
- name: {},
589
- subjectLabel: {}
590
- },
591
- emits: ["loaded"],
592
- setup(s, { expose: o, emit: a }) {
593
- const n = s, t = a, { t: e } = z(), c = H(), u = he(), q = we(), g = A(!1), L = Ue(async ({ signal: x, abandon: w }) => {
594
- g.value = !1;
595
- try {
596
- const k = await q.access(n.subject, { signal: x });
597
- return t("loaded", k.bindings.length), k;
598
- } catch (k) {
599
- if (!oe(k) || k.kind !== "notFound") throw k;
600
- return g.value = !0, w();
601
- }
602
- }, { watch: () => n.subject.id }), R = re("addDialog"), r = re("removeDialog");
603
- async function p(x) {
604
- await q.unbind(n.subject, x.id), ee.success(e("core.access.removed")), await L.reload();
605
- }
606
- const y = (x) => ee.error(u(x, { fallback: e("core.access.remove_failed") })), v = A(null), b = N(() => v.value ? e("core.access.remove_body", { name: n.name, role: c.roleName(v.value.role), scope: c.scopeLabel(v.value.scope) }) : "");
607
- return o({ reload: L.reload }), (x, w) => (m(), _("div", Ns, [
608
- g.value ? (m(), T(l(Be), {
609
- key: 0,
610
- title: l(e)("core.resource.not_found.title"),
611
- description: l(e)("core.resource.not_found.body"),
612
- icon: "errorWarningLine",
613
- "data-test": "access-not-found"
614
- }, null, 8, ["title", "description"])) : (m(), T(l(Pe), {
615
- key: 1,
616
- state: l(L).state.value,
617
- "skeleton-rows": 6,
618
- "is-empty": () => !1,
619
- onRetry: w[1] || (w[1] = (k) => l(L).reload())
620
- }, {
621
- default: h(({ value: k }) => [
622
- j(l(V), {
623
- header: l(e)("core.access.person_roles"),
624
- footer: l(e)("core.access.roles_footer")
625
- }, {
626
- default: h(() => [
627
- k.bindings.length === 0 ? (m(), T(l(U), {
628
- key: 0,
629
- layout: "setting",
630
- label: l(e)("core.access.no_roles_title"),
631
- sub: l(e)("core.access.no_roles_description")
632
- }, null, 8, ["label", "sub"])) : D("", !0),
633
- (m(!0), _(K, null, B(k.bindings, (C) => (m(), T(bs, {
634
- key: C.id,
635
- binding: C
636
- }, _e({ _: 2 }, [
637
- k.can_manage ? {
638
- name: "trailing",
639
- fn: h(() => [
640
- j(l(ie), {
641
- permission: l(F).manageBindings
642
- }, {
643
- default: h(() => [
644
- O("span", {
645
- class: "contents",
646
- "data-test": `remove-binding-${C.id}`
647
- }, [
648
- j(l(Y), {
649
- tone: "critical",
650
- prominence: "secondary",
651
- size: "sm",
652
- onClick: (te) => (v.value = C, r.value?.present(C))
653
- }, {
654
- default: h(() => [
655
- G($(l(e)("core.access.remove")), 1)
656
- ]),
657
- _: 1
658
- }, 8, ["onClick"])
659
- ], 8, Ss)
660
- ]),
661
- _: 2
662
- }, 1032, ["permission"])
663
- ]),
664
- key: "0"
665
- } : void 0
666
- ]), 1032, ["binding"]))), 128)),
667
- k.can_manage ? (m(), T(l(ie), {
668
- key: 1,
669
- permission: l(F).manageBindings
670
- }, {
671
- default: h(() => [
672
- j(l(U), { layout: "stacked" }, {
673
- default: h(() => [
674
- O("span", Ts, [
675
- j(l(Y), {
676
- prominence: "secondary",
677
- icon: "addLine",
678
- onClick: w[0] || (w[0] = (C) => R.value?.present())
679
- }, {
680
- default: h(() => [
681
- G($(l(e)("core.access.add_role")), 1)
682
- ]),
683
- _: 1
684
- })
685
- ])
686
- ]),
687
- _: 1
688
- })
689
- ]),
690
- _: 1
691
- }, 8, ["permission"])) : D("", !0)
692
- ]),
693
- _: 2
694
- }, 1032, ["header", "footer"]),
695
- j(Es, {
696
- effective: k.effective,
697
- name: n.name
698
- }, null, 8, ["effective", "name"])
699
- ]),
700
- _: 1
701
- }, 8, ["state"])),
702
- j(ps, {
703
- ref_key: "addDialog",
704
- ref: R,
705
- subject: n.subject,
706
- "subject-label": n.subjectLabel ?? n.name,
707
- onAdded: w[2] || (w[2] = (k) => l(L).reload())
708
- }, null, 8, ["subject", "subject-label"]),
709
- j(l(Ke), {
710
- ref_key: "removeDialog",
711
- ref: r,
712
- tone: "critical",
713
- title: l(e)("core.access.remove_title"),
714
- message: b.value,
715
- "confirm-label": l(e)("core.access.remove"),
716
- action: p,
717
- onFailed: y
718
- }, null, 8, ["title", "message", "confirm-label"])
719
- ]));
720
- }
721
- });
722
- export {
723
- bs as _,
724
- we as a,
725
- F as b,
726
- ue as c,
727
- ae as d,
728
- se as e,
729
- ss as f,
730
- Ze as g,
731
- io as h,
732
- he as i,
733
- uo as j,
734
- lo as k,
735
- S as l,
736
- Je as m,
737
- to as n,
738
- Xe as o,
739
- no as p,
740
- Ye as q,
741
- co as r,
742
- ro as s,
743
- es as t,
744
- H as u
745
- };