@7365admin1/layer-common 4.97.1-staging.723 → 4.97.1-staging.724
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/components/MemberMain.vue +37 -11
- package/package.json +1 -1
- package/utils/member-row-actions.ts +78 -0
|
@@ -224,14 +224,10 @@
|
|
|
224
224
|
`members:assign-member-role` and nothing else got no menu at all,
|
|
225
225
|
and the permission was unreachable.
|
|
226
226
|
-->
|
|
227
|
+
<!-- #1859: the organisation owner's row offers none of them, and
|
|
228
|
+
your own row no Suspend / Delete (`utils/member-row-actions`). -->
|
|
227
229
|
<v-menu
|
|
228
|
-
v-if="!isLimited(item) && (
|
|
229
|
-
props.assignRole ||
|
|
230
|
-
(currentStatus === 'active' &&
|
|
231
|
-
(canSuspendMembers || canDeleteMembers)) ||
|
|
232
|
-
(currentStatus === 'suspended' &&
|
|
233
|
-
(canActivateMembers || canDeleteMembers)))
|
|
234
|
-
"
|
|
230
|
+
v-if="!isLimited(item) && rowActions(item).menu"
|
|
235
231
|
v-model="item.menuOpen"
|
|
236
232
|
:close-on-content-click="false"
|
|
237
233
|
offset-y
|
|
@@ -249,7 +245,7 @@
|
|
|
249
245
|
<!-- Highlighted when the row's role chip is a warning (no /
|
|
250
246
|
deleted / other org / other site role): this is the fix. -->
|
|
251
247
|
<v-list-item
|
|
252
|
-
v-if="
|
|
248
|
+
v-if="rowActions(item).assignRole"
|
|
253
249
|
:class="{
|
|
254
250
|
'text-warning font-weight-bold':
|
|
255
251
|
memberRoleChip(item)?.tone === 'warn',
|
|
@@ -280,19 +276,19 @@
|
|
|
280
276
|
</v-list-item>
|
|
281
277
|
|
|
282
278
|
<v-list-item
|
|
283
|
-
v-if="
|
|
279
|
+
v-if="rowActions(item).suspend"
|
|
284
280
|
@click="openUpdateDialog(item._id, 'suspended')"
|
|
285
281
|
>
|
|
286
282
|
Suspend
|
|
287
283
|
</v-list-item>
|
|
288
284
|
<v-list-item
|
|
289
|
-
v-if="
|
|
285
|
+
v-if="rowActions(item).activate"
|
|
290
286
|
@click="openUpdateDialog(item._id, 'active')"
|
|
291
287
|
>
|
|
292
288
|
Activate
|
|
293
289
|
</v-list-item>
|
|
294
290
|
<v-list-item
|
|
295
|
-
v-if="
|
|
291
|
+
v-if="rowActions(item).delete"
|
|
296
292
|
@click="openUpdateDialog(item._id, 'deleted')"
|
|
297
293
|
>
|
|
298
294
|
Delete
|
|
@@ -440,6 +436,7 @@ import {
|
|
|
440
436
|
} from "../utils/role";
|
|
441
437
|
import { formatLastActive } from "../utils/last-active";
|
|
442
438
|
import { formatMemberDate, memberAccess, memberPerson } from "../utils/member-row";
|
|
439
|
+
import { memberRowActions } from "../utils/member-row-actions";
|
|
443
440
|
|
|
444
441
|
const props = defineProps({
|
|
445
442
|
/** The design's page title. Every app that mounts this screen calls it
|
|
@@ -707,6 +704,35 @@ const siteAccessAllowed = computed(() => props.assignRole && !props.siteId);
|
|
|
707
704
|
one-membership actions (Assign Role, Suspend, Delete) are not offered on it;
|
|
708
705
|
Site access manages them. */
|
|
709
706
|
const isLimited = (item: Record<string, any>) => orgLevel.value && limitedSites(item).length > 0;
|
|
707
|
+
/*
|
|
708
|
+
* #1859: the organisation owner's row offered Assign Role, Suspend and Delete
|
|
709
|
+
* (all seven apps). The organisation's record names its owner - `createdBy`
|
|
710
|
+
* and its e-mail, the server's own test (core `hasOrgOwnership`) - and the
|
|
711
|
+
* signed-in user is the viewer. A failed or name-only read names no owner;
|
|
712
|
+
* the server still refuses, as it always did.
|
|
713
|
+
*/
|
|
714
|
+
const { currentUser } = useLocalAuth();
|
|
715
|
+
const { data: ownerOrg } = useAsyncData(
|
|
716
|
+
`member-owner-org-${props.orgId}`,
|
|
717
|
+
() =>
|
|
718
|
+
props.orgId
|
|
719
|
+
? useNuxtApp()
|
|
720
|
+
.$api<Record<string, any>>(`/api/organizations/id/${props.orgId}`)
|
|
721
|
+
.catch(() => null)
|
|
722
|
+
: Promise.resolve(null),
|
|
723
|
+
{ watch: [() => props.orgId] }
|
|
724
|
+
);
|
|
725
|
+
const rowActions = (item: Record<string, any>) =>
|
|
726
|
+
memberRowActions({
|
|
727
|
+
item,
|
|
728
|
+
org: ownerOrg.value,
|
|
729
|
+
viewerId: String(currentUser.value?._id ?? ""),
|
|
730
|
+
status: currentStatus.value,
|
|
731
|
+
assignRole: props.assignRole,
|
|
732
|
+
canSuspend: props.canSuspendMembers,
|
|
733
|
+
canActivate: props.canActivateMembers,
|
|
734
|
+
canDelete: props.canDeleteMembers,
|
|
735
|
+
});
|
|
710
736
|
/* Keep the actions column on screen however wide the table gets. */
|
|
711
737
|
const actionLast = computed(() => props.headers[props.headers.length - 1]?.value === "action-table");
|
|
712
738
|
const siteAccessDialog = ref(false);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.724",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which actions one row of the Members table offers (#1859).
|
|
3
|
+
*
|
|
4
|
+
* The organisation owner's row offered Assign Role, Suspend and Delete - in all
|
|
5
|
+
* seven apps, to the owner looking at their own row too. Suspending or deleting
|
|
6
|
+
* the owner can lock the organisation out. The server already refuses each of
|
|
7
|
+
* them (core `requireNotOwnerUnlessOwner`, and "You cannot suspend or remove
|
|
8
|
+
* your own access." in `requireMemberStatusChanger`); the screen offered them
|
|
9
|
+
* anyway, so pressing one ended in a red error.
|
|
10
|
+
*
|
|
11
|
+
* - The owner's row: no Assign Role, Suspend, Activate or Delete, for anybody.
|
|
12
|
+
* - Your own row: no Suspend or Delete.
|
|
13
|
+
* - Every other row: exactly what the permissions gave it before.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type TRow = Record<string, any> | null | undefined;
|
|
17
|
+
|
|
18
|
+
function idOf(value: unknown): string {
|
|
19
|
+
if (typeof value === "string") return value.trim();
|
|
20
|
+
const hex = (value as any)?.toHexString;
|
|
21
|
+
return typeof hex === "function" ? String(hex.call(value)).trim() : "";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function emailOf(value: unknown): string {
|
|
25
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Is this the organisation owner's row? The same test the server applies
|
|
30
|
+
* (core `hasOrgOwnership`): the account that created the organisation
|
|
31
|
+
* (`createdBy`), or the organisation's own e-mail. A name-only organisation
|
|
32
|
+
* record (no `createdBy`, no `email`) names nobody.
|
|
33
|
+
*/
|
|
34
|
+
export function isOrgOwnerRow(item: TRow, org: TRow): boolean {
|
|
35
|
+
const user = idOf(item?.user);
|
|
36
|
+
const owner = idOf(org?.createdBy);
|
|
37
|
+
if (user && owner && user === owner) return true;
|
|
38
|
+
const email = emailOf(item?.email);
|
|
39
|
+
const orgEmail = emailOf(org?.email);
|
|
40
|
+
return !!email && !!orgEmail && email === orgEmail;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type TMemberRowActions = {
|
|
44
|
+
/** Whether the row's three-dot menu is drawn at all. */
|
|
45
|
+
menu: boolean;
|
|
46
|
+
assignRole: boolean;
|
|
47
|
+
suspend: boolean;
|
|
48
|
+
activate: boolean;
|
|
49
|
+
delete: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function memberRowActions(input: {
|
|
53
|
+
item: TRow;
|
|
54
|
+
org: TRow;
|
|
55
|
+
/** The signed-in user's id. */
|
|
56
|
+
viewerId?: string;
|
|
57
|
+
/** The tab: "active", "suspended", or an app's extra tab. */
|
|
58
|
+
status: string;
|
|
59
|
+
assignRole: boolean;
|
|
60
|
+
canSuspend: boolean;
|
|
61
|
+
canActivate: boolean;
|
|
62
|
+
canDelete: boolean;
|
|
63
|
+
}): TMemberRowActions {
|
|
64
|
+
const owner = isOrgOwnerRow(input.item, input.org);
|
|
65
|
+
const viewer = idOf(input.viewerId);
|
|
66
|
+
const self = !!viewer && idOf(input.item?.user) === viewer;
|
|
67
|
+
const locked = owner || self;
|
|
68
|
+
|
|
69
|
+
const assignRole = input.assignRole && !owner;
|
|
70
|
+
const suspend = input.status === "active" && input.canSuspend && !locked;
|
|
71
|
+
const activate = input.status === "suspended" && input.canActivate && !owner;
|
|
72
|
+
const del = input.canDelete && !locked;
|
|
73
|
+
// As before: Delete alone opens the menu only on Active / Inactive.
|
|
74
|
+
const onStatusTab = input.status === "active" || input.status === "suspended";
|
|
75
|
+
const menu = assignRole || (onStatusTab && (suspend || activate || del));
|
|
76
|
+
|
|
77
|
+
return { menu, assignRole, suspend, activate, delete: del };
|
|
78
|
+
}
|