@7365admin1/layer-common 4.97.1-staging.725 → 4.97.1-staging.727
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.
|
@@ -155,26 +155,33 @@
|
|
|
155
155
|
<p class="mb-4">
|
|
156
156
|
There are currently
|
|
157
157
|
<span class="text-error font-weight-bold">
|
|
158
|
-
{{
|
|
159
|
-
{{
|
|
158
|
+
{{ deletionPeople.length }}
|
|
159
|
+
{{ deletionPeople.length === 1 ? "user" : "users" }}
|
|
160
160
|
</span>
|
|
161
161
|
assigned to this role. Reassign each user before deleting it so
|
|
162
162
|
they do not lose access.
|
|
163
163
|
</p>
|
|
164
164
|
|
|
165
|
+
<!-- DV-1858: one row per person; their memberships move together. -->
|
|
165
166
|
<v-row
|
|
166
|
-
v-for="
|
|
167
|
-
:key="
|
|
167
|
+
v-for="person in deletionPeople"
|
|
168
|
+
:key="person.key"
|
|
168
169
|
no-gutters
|
|
169
170
|
class="mb-3 pa-3 border rounded-lg"
|
|
170
171
|
align="center"
|
|
171
172
|
>
|
|
172
173
|
<v-col cols="12" sm="5" class="mb-2 mb-sm-0">
|
|
173
|
-
{{
|
|
174
|
+
{{ person.name || person.email || person.key }}
|
|
175
|
+
<div
|
|
176
|
+
v-if="person.name && person.email && person.name !== person.email"
|
|
177
|
+
class="text-caption text-medium-emphasis"
|
|
178
|
+
>
|
|
179
|
+
{{ person.email }}
|
|
180
|
+
</div>
|
|
174
181
|
</v-col>
|
|
175
182
|
<v-col cols="12" sm="7">
|
|
176
183
|
<v-select
|
|
177
|
-
v-model="memberReassignments[
|
|
184
|
+
v-model="memberReassignments[person.key]"
|
|
178
185
|
:items="deletionPreview.replacementRoles"
|
|
179
186
|
:item-title="props.siteId ? sitePickerRoleLabel : roleLabel"
|
|
180
187
|
item-value="_id"
|
|
@@ -219,6 +226,7 @@
|
|
|
219
226
|
import { roleAppLabel, roleLabel, safeReturnTo, showSiteField, sitePickerRoleLabel } from "../utils/role";
|
|
220
227
|
import { holdsPermission } from "../utils/permission-spellings";
|
|
221
228
|
import { countRealPermissions } from "../utils/security-catalogue";
|
|
229
|
+
import { groupDeletionMembers, reassignmentsFor } from "../utils/role-deletion-people";
|
|
222
230
|
import {
|
|
223
231
|
catalogueForOrg,
|
|
224
232
|
catalogueForOwnerGrant,
|
|
@@ -728,9 +736,14 @@ const hasAssignedMembers = computed(
|
|
|
728
736
|
() => deletionPreview.value.members.length > 0
|
|
729
737
|
);
|
|
730
738
|
|
|
739
|
+
// DV-1858: a person has a membership per scope (Organisation and the app).
|
|
740
|
+
const deletionPeople = computed(() =>
|
|
741
|
+
groupDeletionMembers(deletionPreview.value.members)
|
|
742
|
+
);
|
|
743
|
+
|
|
731
744
|
const canConfirmDeletion = computed(() =>
|
|
732
|
-
|
|
733
|
-
|
|
745
|
+
deletionPeople.value.every((person) =>
|
|
746
|
+
Boolean(memberReassignments.value[person.key])
|
|
734
747
|
)
|
|
735
748
|
);
|
|
736
749
|
|
|
@@ -773,10 +786,10 @@ async function handleDeleteRole() {
|
|
|
773
786
|
if (!selectedRoleId.value) return;
|
|
774
787
|
deleteLoading.value = true;
|
|
775
788
|
try {
|
|
776
|
-
const reassignments =
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
789
|
+
const reassignments = reassignmentsFor(
|
|
790
|
+
deletionPeople.value,
|
|
791
|
+
memberReassignments.value
|
|
792
|
+
);
|
|
780
793
|
const res = hasAssignedMembers.value
|
|
781
794
|
? await deleteWithReassignments(selectedRoleId.value, reassignments)
|
|
782
795
|
: await deleteRole(selectedRoleId.value);
|
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.727",
|
|
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,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DV-1858: who holds a role, one entry per PERSON.
|
|
3
|
+
*
|
|
4
|
+
* The deletion preview returns one row per membership, and a person usually
|
|
5
|
+
* has two on the same role (Organisation and the app), so Delete Role listed
|
|
6
|
+
* them twice with two Reassign fields. Group by `user`; keep every membership
|
|
7
|
+
* id so one choice reassigns all of them (the API refuses a reassignment that
|
|
8
|
+
* leaves any membership on the deleted role).
|
|
9
|
+
*/
|
|
10
|
+
export type TDeletionPerson = {
|
|
11
|
+
key: string;
|
|
12
|
+
name: string;
|
|
13
|
+
email: string;
|
|
14
|
+
memberIds: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const idOf = (v: unknown) => String((v as any)?.toString?.() ?? v ?? "").trim();
|
|
18
|
+
|
|
19
|
+
export function groupDeletionMembers(
|
|
20
|
+
members: ReadonlyArray<Record<string, any>> | null | undefined,
|
|
21
|
+
): TDeletionPerson[] {
|
|
22
|
+
const people = new Map<string, TDeletionPerson>();
|
|
23
|
+
for (const m of members ?? []) {
|
|
24
|
+
const memberId = idOf(m?._id);
|
|
25
|
+
const key = idOf(m?.user) || `member:${memberId}`;
|
|
26
|
+
const found = people.get(key);
|
|
27
|
+
if (found) {
|
|
28
|
+
found.memberIds.push(memberId);
|
|
29
|
+
if (!found.name && m?.name) found.name = String(m.name);
|
|
30
|
+
if (!found.email && m?.email) found.email = String(m.email);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
people.set(key, {
|
|
34
|
+
key,
|
|
35
|
+
name: String(m?.name ?? ""),
|
|
36
|
+
email: String(m?.email ?? ""),
|
|
37
|
+
memberIds: [memberId],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return [...people.values()];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function reassignmentsFor(
|
|
44
|
+
people: ReadonlyArray<TDeletionPerson>,
|
|
45
|
+
choice: Record<string, string>,
|
|
46
|
+
): Array<{ memberId: string; roleId: string }> {
|
|
47
|
+
return people.flatMap((p) => p.memberIds.map((memberId) => ({ memberId, roleId: choice[p.key] })));
|
|
48
|
+
}
|