@sfxcode/nuxt-ui-mongocamp 1.3.0 → 1.3.1
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/dist/module.json
CHANGED
|
@@ -126,6 +126,21 @@ async function handleEditGrant() {
|
|
|
126
126
|
async function removeGrant(index) {
|
|
127
127
|
await saveGrants(grants.value.filter((_, i) => i !== index));
|
|
128
128
|
}
|
|
129
|
+
const missingReadCollections = computed(() => {
|
|
130
|
+
const grantedNames = new Set(grants.value.map((g) => g.name));
|
|
131
|
+
return allCollections.value.filter((c) => !c.startsWith("mc_") && !grantedNames.has(c));
|
|
132
|
+
});
|
|
133
|
+
async function addAllReadGrants() {
|
|
134
|
+
const added = missingReadCollections.value.map((name) => ({
|
|
135
|
+
name,
|
|
136
|
+
read: true,
|
|
137
|
+
write: false,
|
|
138
|
+
administrate: false,
|
|
139
|
+
grantType: "COLLECTION"
|
|
140
|
+
}));
|
|
141
|
+
if (!added.length) return;
|
|
142
|
+
await saveGrants([...grants.value, ...added]);
|
|
143
|
+
}
|
|
129
144
|
function openAdd() {
|
|
130
145
|
const grantedNames = new Set(grants.value.map((g) => g.name));
|
|
131
146
|
addGrantSchema[0].options = allCollections.value.filter((c) => !grantedNames.has(c));
|
|
@@ -226,6 +241,16 @@ fetchCollections();
|
|
|
226
241
|
@click="fetchRole"
|
|
227
242
|
/>
|
|
228
243
|
</UTooltip>
|
|
244
|
+
<UTooltip :text="t('nuxtUiMongocamp.roleGrants.addAllReadTooltip')">
|
|
245
|
+
<UButton
|
|
246
|
+
icon="i-lucide-eye"
|
|
247
|
+
color="neutral"
|
|
248
|
+
variant="outline"
|
|
249
|
+
:label="t('nuxtUiMongocamp.roleGrants.addAllRead')"
|
|
250
|
+
:disabled="saving || loading || !missingReadCollections.length"
|
|
251
|
+
@click="addAllReadGrants"
|
|
252
|
+
/>
|
|
253
|
+
</UTooltip>
|
|
229
254
|
<UButton
|
|
230
255
|
icon="i-lucide-plus"
|
|
231
256
|
:label="t('nuxtUiMongocamp.roleGrants.addGrant')"
|
|
@@ -17,11 +17,17 @@ let filterTimer;
|
|
|
17
17
|
const isAddModalOpen = ref(false);
|
|
18
18
|
const isEditModalOpen = ref(false);
|
|
19
19
|
const isDeleteModalOpen = ref(false);
|
|
20
|
+
const isCloneModalOpen = ref(false);
|
|
20
21
|
const roleToDelete = ref("");
|
|
21
22
|
const errorMessage = ref("");
|
|
22
23
|
const newRole = ref({ name: "", isAdmin: false });
|
|
23
24
|
const editRole = ref({ roleName: "", isAdmin: false });
|
|
24
25
|
const editGrants = ref([]);
|
|
26
|
+
const cloneSource = ref("");
|
|
27
|
+
const cloneRole = ref({ name: "", isAdmin: false });
|
|
28
|
+
const cloneGrants = ref([]);
|
|
29
|
+
const cloneError = ref("");
|
|
30
|
+
const cloning = ref(false);
|
|
25
31
|
const addRoleSchema = reactive([
|
|
26
32
|
{
|
|
27
33
|
$formkit: "nuxtUIInput",
|
|
@@ -42,6 +48,19 @@ const editRoleSchema = reactive([
|
|
|
42
48
|
label: t("nuxtUiMongocamp.roles.adminRole")
|
|
43
49
|
}
|
|
44
50
|
]);
|
|
51
|
+
const cloneRoleSchema = reactive([
|
|
52
|
+
{
|
|
53
|
+
$formkit: "nuxtUIInput",
|
|
54
|
+
name: "name",
|
|
55
|
+
label: t("nuxtUiMongocamp.roles.roleName"),
|
|
56
|
+
validation: "required|length:2"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
$formkit: "nuxtUISwitch",
|
|
60
|
+
name: "isAdmin",
|
|
61
|
+
label: t("nuxtUiMongocamp.roles.adminRole")
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
45
64
|
const loadError = ref(null);
|
|
46
65
|
const { describeError } = useMongocampError();
|
|
47
66
|
const rowSelection = ref({});
|
|
@@ -106,6 +125,26 @@ async function handleEditRole() {
|
|
|
106
125
|
errorMessage.value = e instanceof Error ? e.message : t("nuxtUiMongocamp.roles.errorEditRole");
|
|
107
126
|
}
|
|
108
127
|
}
|
|
128
|
+
function openClone(role) {
|
|
129
|
+
cloneSource.value = role.name;
|
|
130
|
+
cloneRole.value = { name: "", isAdmin: role.isAdmin };
|
|
131
|
+
cloneGrants.value = (role.collectionGrants ?? []).map((g) => ({ ...g }));
|
|
132
|
+
cloneError.value = "";
|
|
133
|
+
isCloneModalOpen.value = true;
|
|
134
|
+
}
|
|
135
|
+
async function handleCloneRole() {
|
|
136
|
+
cloning.value = true;
|
|
137
|
+
cloneError.value = "";
|
|
138
|
+
try {
|
|
139
|
+
await addRole(cloneRole.value.name, cloneRole.value.isAdmin, cloneGrants.value);
|
|
140
|
+
isCloneModalOpen.value = false;
|
|
141
|
+
await fetchRoles();
|
|
142
|
+
} catch (e) {
|
|
143
|
+
cloneError.value = describeError(e, "nuxtUiMongocamp.roles.errorClone").message;
|
|
144
|
+
} finally {
|
|
145
|
+
cloning.value = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
109
148
|
const deleteError = ref("");
|
|
110
149
|
const deleting = ref(false);
|
|
111
150
|
function confirmDelete(roleName) {
|
|
@@ -187,6 +226,14 @@ const columns = computed(() => [
|
|
|
187
226
|
"aria-label": t("nuxtUiMongocamp.roles.editRoleTooltip"),
|
|
188
227
|
"onClick": () => openEdit(row.original)
|
|
189
228
|
})),
|
|
229
|
+
withTooltip(t("nuxtUiMongocamp.roles.cloneRoleTooltip"), h(UButton, {
|
|
230
|
+
"icon": "i-lucide-copy",
|
|
231
|
+
"color": "neutral",
|
|
232
|
+
"variant": "ghost",
|
|
233
|
+
"size": "sm",
|
|
234
|
+
"aria-label": t("nuxtUiMongocamp.roles.cloneRoleTooltip"),
|
|
235
|
+
"onClick": () => openClone(row.original)
|
|
236
|
+
})),
|
|
190
237
|
withTooltip(t("nuxtUiMongocamp.roles.deleteRoleTooltip"), h(UButton, {
|
|
191
238
|
"icon": "i-lucide-trash-2",
|
|
192
239
|
"color": "error",
|
|
@@ -305,6 +352,33 @@ fetchRoles();
|
|
|
305
352
|
</template>
|
|
306
353
|
</UModal>
|
|
307
354
|
|
|
355
|
+
<!-- Clone Role Modal -->
|
|
356
|
+
<UModal
|
|
357
|
+
v-model:open="isCloneModalOpen"
|
|
358
|
+
:title="t('nuxtUiMongocamp.roles.cloneRoleTitle', { roleName: cloneSource })"
|
|
359
|
+
>
|
|
360
|
+
<template #body>
|
|
361
|
+
<p class="mb-3 text-sm text-dimmed">
|
|
362
|
+
{{ t("nuxtUiMongocamp.roles.cloneRoleHint", { count: cloneGrants.length }) }}
|
|
363
|
+
</p>
|
|
364
|
+
<FUDataEdit
|
|
365
|
+
:data="cloneRole"
|
|
366
|
+
:schema="cloneRoleSchema"
|
|
367
|
+
:submit-label="t('nuxtUiMongocamp.roles.cloneRole')"
|
|
368
|
+
submit-icon="i-lucide-copy"
|
|
369
|
+
@data-saved="handleCloneRole"
|
|
370
|
+
/>
|
|
371
|
+
<UAlert
|
|
372
|
+
v-if="cloneError"
|
|
373
|
+
class="mt-3"
|
|
374
|
+
color="error"
|
|
375
|
+
variant="subtle"
|
|
376
|
+
icon="i-lucide-circle-alert"
|
|
377
|
+
:description="cloneError"
|
|
378
|
+
/>
|
|
379
|
+
</template>
|
|
380
|
+
</UModal>
|
|
381
|
+
|
|
308
382
|
<!-- Delete Confirmation Modal -->
|
|
309
383
|
<UModal
|
|
310
384
|
v-model:open="isDeleteModalOpen"
|
|
@@ -61,6 +61,11 @@
|
|
|
61
61
|
"manageGrantsTooltip": "Berechtigungen verwalten",
|
|
62
62
|
"editRoleTooltip": "Rolle bearbeiten",
|
|
63
63
|
"deleteRoleTooltip": "Rolle löschen",
|
|
64
|
+
"cloneRoleTooltip": "Rolle klonen",
|
|
65
|
+
"cloneRoleTitle": "Rolle klonen: {roleName}",
|
|
66
|
+
"cloneRole": "Rolle klonen",
|
|
67
|
+
"cloneRoleHint": "Die neue Rolle erhält eine Kopie des Admin-Flags und aller {count} Berechtigungen.",
|
|
68
|
+
"errorClone": "Rolle konnte nicht geklont werden",
|
|
64
69
|
"errorAddRole": "Rolle konnte nicht hinzugefügt werden",
|
|
65
70
|
"errorEditRole": "Rolle konnte nicht aktualisiert werden",
|
|
66
71
|
"errorDelete": "Rolle konnte nicht gelöscht werden"
|
|
@@ -68,6 +73,8 @@
|
|
|
68
73
|
"roleGrants": {
|
|
69
74
|
"heading": "Berechtigungen: {roleName}",
|
|
70
75
|
"addGrant": "Berechtigung hinzufügen",
|
|
76
|
+
"addAllRead": "Alle nur lesend hinzufügen",
|
|
77
|
+
"addAllReadTooltip": "Lesezugriff auf alle Collections ohne Berechtigung geben, außer auf die mc_-Collections von MongoCamp",
|
|
71
78
|
"editGrantTitle": "Berechtigung bearbeiten: {name}",
|
|
72
79
|
"collection": "Collection",
|
|
73
80
|
"read": "Lesen",
|
|
@@ -61,6 +61,11 @@
|
|
|
61
61
|
"manageGrantsTooltip": "Manage grants",
|
|
62
62
|
"editRoleTooltip": "Edit role",
|
|
63
63
|
"deleteRoleTooltip": "Delete role",
|
|
64
|
+
"cloneRoleTooltip": "Clone role",
|
|
65
|
+
"cloneRoleTitle": "Clone Role: {roleName}",
|
|
66
|
+
"cloneRole": "Clone Role",
|
|
67
|
+
"cloneRoleHint": "The new role gets a copy of the admin flag and all {count} grants.",
|
|
68
|
+
"errorClone": "Failed to clone role",
|
|
64
69
|
"errorAddRole": "Failed to add role",
|
|
65
70
|
"errorEditRole": "Failed to update role",
|
|
66
71
|
"errorDelete": "Failed to delete role"
|
|
@@ -68,6 +73,8 @@
|
|
|
68
73
|
"roleGrants": {
|
|
69
74
|
"heading": "Grants: {roleName}",
|
|
70
75
|
"addGrant": "Add Grant",
|
|
76
|
+
"addAllRead": "Add all read-only",
|
|
77
|
+
"addAllReadTooltip": "Grant read access to every collection without a grant, except MongoCamp's own mc_ collections",
|
|
71
78
|
"editGrantTitle": "Edit Grant: {name}",
|
|
72
79
|
"collection": "Collection",
|
|
73
80
|
"read": "Read",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-mongocamp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A Nuxt module that wraps @sfxcode/nuxt-mongocamp-server with ready-made UI components, composables, and a runtime plugin",
|
|
5
5
|
"repository": "sfxcode/nuxt-ui-mongocamp",
|
|
6
6
|
"homepage": "https://sfxcode.github.io/nuxt-ui-mongocamp/",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
45
45
|
"dev:build": "nuxt build playground",
|
|
46
46
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
47
|
-
"release": "npm run lint && npm run test && npm run prepack && changelogen --
|
|
47
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --patch --release && npm publish && git push --follow-tags",
|
|
48
48
|
"lint": "eslint .",
|
|
49
49
|
"test": "vitest run --project unit --project components",
|
|
50
50
|
"test:watch": "vitest watch",
|