@7365admin1/layer-common 4.97.1-staging.542 → 4.97.1-staging.543
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.
|
@@ -34,6 +34,33 @@
|
|
|
34
34
|
<p v-if="!choices.length" class="text-body-2">This organisation has no sites yet.</p>
|
|
35
35
|
|
|
36
36
|
<div v-else>
|
|
37
|
+
<!--
|
|
38
|
+
WHO GOES OUT TO THE SITES. One switch for the whole person, not one
|
|
39
|
+
per row: an officer is an officer everywhere they are sent, and the
|
|
40
|
+
server writes the same value onto every site ticked below.
|
|
41
|
+
|
|
42
|
+
It grants NOTHING. What a member may do is still their role, which
|
|
43
|
+
is why this sits apart from the Role column rather than inside it.
|
|
44
|
+
-->
|
|
45
|
+
<v-switch
|
|
46
|
+
v-model="securityOps"
|
|
47
|
+
color="primary"
|
|
48
|
+
density="compact"
|
|
49
|
+
hide-details
|
|
50
|
+
inset
|
|
51
|
+
class="mb-2"
|
|
52
|
+
data-test="site-access-security-ops"
|
|
53
|
+
>
|
|
54
|
+
<template #label>
|
|
55
|
+
<div>
|
|
56
|
+
<div class="text-body-2">This person is part of Security Ops</div>
|
|
57
|
+
<div class="text-caption text-medium-emphasis">
|
|
58
|
+
They visit the sites ticked below and fill in the checklists.
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
</v-switch>
|
|
63
|
+
|
|
37
64
|
<div class="d-flex align-center ga-2 mb-2">
|
|
38
65
|
<v-select
|
|
39
66
|
v-model="sameRole"
|
|
@@ -53,6 +80,7 @@
|
|
|
53
80
|
|
|
54
81
|
<div v-for="(c, i) in choices" :key="c.site" class="d-flex align-center ga-2 py-1" data-test="site-access-row">
|
|
55
82
|
<v-checkbox v-model="choices[i].on" density="compact" hide-details :label="c.name" style="min-width: 220px" />
|
|
83
|
+
<v-chip v-if="securityOps && choices[i].on" size="x-small" color="primary" variant="tonal">Security Ops</v-chip>
|
|
56
84
|
<v-select
|
|
57
85
|
v-if="c.roles.length"
|
|
58
86
|
v-model="choices[i].role"
|
|
@@ -72,6 +100,10 @@
|
|
|
72
100
|
</p>
|
|
73
101
|
</div>
|
|
74
102
|
|
|
103
|
+
<p v-if="choices.length" class="text-caption mt-2" data-test="site-access-security-ops-note">
|
|
104
|
+
{{ securityOpsNote }}
|
|
105
|
+
</p>
|
|
106
|
+
|
|
75
107
|
<p v-if="missing.length" class="text-error text-caption mt-2">Choose a role for: {{ missing.join(", ") }}</p>
|
|
76
108
|
<p v-if="saveError" class="text-error mt-2">{{ saveError }}</p>
|
|
77
109
|
</template>
|
|
@@ -87,7 +119,7 @@
|
|
|
87
119
|
|
|
88
120
|
<script setup lang="ts">
|
|
89
121
|
// Relative import: this layer's `utils/` is not auto-imported into consumers.
|
|
90
|
-
import { applySameRole, initialChoices, roleItems, sharedRoleItems, toPayload, type SiteChoice } from "../utils/site-access";
|
|
122
|
+
import { applySameRole, initialChoices, initialSecurityOps, roleItems, sharedRoleItems, toPayload, type SiteChoice } from "../utils/site-access";
|
|
91
123
|
|
|
92
124
|
const props = defineProps({
|
|
93
125
|
org: { type: String, required: true },
|
|
@@ -106,6 +138,7 @@ const choices = ref<SiteChoice[]>([]);
|
|
|
106
138
|
const orgWide = ref<Array<{ roleName?: string }>>([]);
|
|
107
139
|
const removeOrgAccess = ref(false);
|
|
108
140
|
const sameRole = ref<string | null>(null);
|
|
141
|
+
const securityOps = ref(false);
|
|
109
142
|
|
|
110
143
|
const sharedItems = computed(() => sharedRoleItems(choices.value));
|
|
111
144
|
const anyOn = computed(() => choices.value.some((c) => c.on));
|
|
@@ -119,6 +152,15 @@ function createOrgRole() {
|
|
|
119
152
|
}
|
|
120
153
|
const missing = computed(() => toPayload(choices.value).missing);
|
|
121
154
|
|
|
155
|
+
/** Say back what the switch and the ticks add up to, in the order they read. */
|
|
156
|
+
const securityOpsNote = computed(() => {
|
|
157
|
+
if (!securityOps.value) return "Not part of Security Ops.";
|
|
158
|
+
const names = choices.value.filter((c) => c.on).map((c) => c.name);
|
|
159
|
+
if (!names.length) return "Part of Security Ops, but no site is ticked yet.";
|
|
160
|
+
if (names.length === 1) return `Part of Security Ops at ${names[0]}.`;
|
|
161
|
+
return `Part of Security Ops at ${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}.`;
|
|
162
|
+
});
|
|
163
|
+
|
|
122
164
|
function applySame() {
|
|
123
165
|
if (sameRole.value) choices.value = applySameRole(choices.value, sameRole.value);
|
|
124
166
|
}
|
|
@@ -130,6 +172,7 @@ async function load() {
|
|
|
130
172
|
const res = await getSiteAccess(props.org, props.user);
|
|
131
173
|
choices.value = initialChoices(res?.sites ?? []);
|
|
132
174
|
orgWide.value = res?.orgWide ?? [];
|
|
175
|
+
securityOps.value = initialSecurityOps(res?.sites ?? []);
|
|
133
176
|
} catch (e: any) {
|
|
134
177
|
loadError.value = e?.data?.message || "Site access could not be loaded. Only the organisation's owner or an admin can change it.";
|
|
135
178
|
}
|
|
@@ -141,7 +184,13 @@ async function save() {
|
|
|
141
184
|
saveError.value = "";
|
|
142
185
|
try {
|
|
143
186
|
const { sites } = toPayload(choices.value);
|
|
144
|
-
await saveSiteAccess({
|
|
187
|
+
await saveSiteAccess({
|
|
188
|
+
org: props.org,
|
|
189
|
+
user: props.user,
|
|
190
|
+
sites,
|
|
191
|
+
securityOps: securityOps.value,
|
|
192
|
+
removeOrgAccess: removeOrgAccess.value,
|
|
193
|
+
});
|
|
145
194
|
emit("saved", sites.length ? `Site access saved: ${sites.length} site(s).` : "Site access saved: no sites.");
|
|
146
195
|
} catch (e: any) {
|
|
147
196
|
saveError.value = e?.data?.message || "Site access could not be saved.";
|
package/composables/useMember.ts
CHANGED
|
@@ -201,6 +201,12 @@ export default function useMember() {
|
|
|
201
201
|
org: string;
|
|
202
202
|
user: string;
|
|
203
203
|
sites: Array<{ site: string; role: string }>;
|
|
204
|
+
/**
|
|
205
|
+
* Is this person one of the Security Ops officers who visits sites? One
|
|
206
|
+
* value for the whole person, written onto every site they end up with.
|
|
207
|
+
* Omit it and the server leaves the mark exactly as it is.
|
|
208
|
+
*/
|
|
209
|
+
securityOps?: boolean;
|
|
204
210
|
removeOrgAccess?: boolean;
|
|
205
211
|
}) {
|
|
206
212
|
return useNuxtApp().$api<Record<string, any>>("/api/members/site-access", {
|
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.543",
|
|
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.",
|
package/utils/site-access.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type SiteAccessRole = { _id: string; name: string; type?: string; scope?:
|
|
|
8
8
|
export type SiteAccessRow = {
|
|
9
9
|
site: string;
|
|
10
10
|
name: string;
|
|
11
|
-
membership: { role: string; roleName?: string } | null;
|
|
11
|
+
membership: { role: string; roleName?: string; securityOps?: boolean } | null;
|
|
12
12
|
roles: SiteAccessRole[];
|
|
13
13
|
};
|
|
14
14
|
export type SiteChoice = { site: string; name: string; on: boolean; role: string; roles: SiteAccessRole[]; replacedRole?: string };
|
|
@@ -31,6 +31,18 @@ export function initialChoices(rows: SiteAccessRow[]): SiteChoice[] {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Is this person already marked as Security Ops?
|
|
36
|
+
*
|
|
37
|
+
* ONE ANSWER FOR THE WHOLE PERSON, because that is the question the switch
|
|
38
|
+
* asks: an officer is an officer everywhere they are sent. Any marked site
|
|
39
|
+
* means yes, so a person whose rows disagree (only reachable by an older client
|
|
40
|
+
* or a hand edit) reads as marked, and saving settles every row to one value.
|
|
41
|
+
*/
|
|
42
|
+
export function initialSecurityOps(rows: SiteAccessRow[]): boolean {
|
|
43
|
+
return (rows ?? []).some((r) => Boolean(r.membership?.securityOps));
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
/** One site's Role list: "Organisation roles" first, then "<Site> roles". */
|
|
35
47
|
export function roleItems(choice: Pick<SiteChoice, "name" | "roles">): RoleItem[] {
|
|
36
48
|
const org = choice.roles.filter(isOrgRole);
|