@sfxcode/nuxt-ui-mongocamp 1.5.7 → 1.5.8
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.d.mts +17 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -0
- package/dist/runtime/components/MongocampAccount.vue +12 -14
- package/dist/runtime/components/MongocampAggregationBuilder.vue +27 -43
- package/dist/runtime/components/MongocampAggregationChart.vue +7 -5
- package/dist/runtime/components/MongocampAggregationStagePreview.vue +1 -1
- package/dist/runtime/components/MongocampBucketFiles.vue +25 -34
- package/dist/runtime/components/MongocampBulkDelete.vue +8 -9
- package/dist/runtime/components/MongocampBulkEdit.vue +5 -4
- package/dist/runtime/components/MongocampChart.vue +1 -1
- package/dist/runtime/components/MongocampCollectionCharts.vue +6 -5
- package/dist/runtime/components/MongocampCollectionCopy.vue +6 -6
- package/dist/runtime/components/MongocampCollectionData.vue +37 -62
- package/dist/runtime/components/MongocampCollectionInfos.vue +18 -23
- package/dist/runtime/components/MongocampCollectionRename.vue +5 -4
- package/dist/runtime/components/MongocampCollections.vue +24 -33
- package/dist/runtime/components/MongocampCommandPalette.vue +3 -1
- package/dist/runtime/components/MongocampConfirmByName.vue +5 -4
- package/dist/runtime/components/MongocampDashboard.vue +5 -3
- package/dist/runtime/components/MongocampDatabases.vue +14 -8
- package/dist/runtime/components/MongocampDocumentCompare.vue +6 -4
- package/dist/runtime/components/MongocampDocumentView.vue +6 -8
- package/dist/runtime/components/MongocampEmptyState.vue +4 -1
- package/dist/runtime/components/MongocampErrorAlert.vue +8 -7
- package/dist/runtime/components/MongocampExportAll.vue +7 -7
- package/dist/runtime/components/MongocampFilePreview.vue +7 -6
- package/dist/runtime/components/MongocampFilterBuilder.vue +12 -16
- package/dist/runtime/components/MongocampGrantList.vue +6 -2
- package/dist/runtime/components/MongocampImport.vue +29 -28
- package/dist/runtime/components/MongocampIndexes.vue +15 -17
- package/dist/runtime/components/MongocampJobs.vue +20 -20
- package/dist/runtime/components/MongocampLogin.vue +2 -1
- package/dist/runtime/components/MongocampPermissionMatrix.vue +14 -11
- package/dist/runtime/components/MongocampQueryBar.vue +18 -32
- package/dist/runtime/components/MongocampRoleGrants.vue +21 -17
- package/dist/runtime/components/MongocampRoles.vue +28 -32
- package/dist/runtime/components/MongocampServerInfo.vue +17 -12
- package/dist/runtime/components/MongocampServerOverview.vue +16 -12
- package/dist/runtime/components/MongocampServerStatus.vue +2 -1
- package/dist/runtime/components/MongocampSettings.vue +15 -11
- package/dist/runtime/components/MongocampUserAccess.vue +11 -6
- package/dist/runtime/components/MongocampUsers.vue +32 -35
- package/dist/runtime/components/MongocampVersion.vue +6 -4
- package/dist/runtime/composables/useMongocampUi.d.ts +8 -0
- package/dist/runtime/composables/useMongocampUi.js +7 -0
- package/dist/runtime/plugin.js +8 -0
- package/dist/runtime/utils/compactSession.d.ts +13 -0
- package/dist/runtime/utils/compactSession.js +12 -0
- package/dist/runtime/utils/uiTheme.d.ts +65 -0
- package/dist/runtime/utils/uiTheme.js +47 -0
- package/package.json +13 -13
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, h, ref, resolveComponent, watch } from "vue";
|
|
3
3
|
import { useI18n, useMongocampRoles, useMongocampSystem } from "#imports";
|
|
4
4
|
import { grantStatusHint, MASKED_VALUE } from "../utils/configRows";
|
|
5
|
+
import { useMongocampUi } from "../composables/useMongocampUi";
|
|
5
6
|
const PAGE_SIZE = 10;
|
|
6
7
|
const props = defineProps({
|
|
7
8
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
@@ -14,6 +15,7 @@ const props = defineProps({
|
|
|
14
15
|
hideGrantHint: { type: Boolean, required: false, default: false }
|
|
15
16
|
});
|
|
16
17
|
const { t } = useI18n();
|
|
18
|
+
const ui = useMongocampUi();
|
|
17
19
|
const { getSettings, listConfigurations, getCluster } = useMongocampSystem();
|
|
18
20
|
const { isAdmin } = useMongocampRoles();
|
|
19
21
|
const configurations = ref([]);
|
|
@@ -71,13 +73,13 @@ const columns = computed(() => [
|
|
|
71
73
|
{
|
|
72
74
|
accessorKey: "value",
|
|
73
75
|
header: t("nuxtUiMongocamp.settings.columnValue"),
|
|
74
|
-
cell: ({ row }) => row.original.masked ? h(UBadge, { label: MASKED_VALUE, color: "neutral", variant:
|
|
76
|
+
cell: ({ row }) => row.original.masked ? h(UBadge, { label: MASKED_VALUE, color: "neutral", variant: ui.value.badge.variant, title: t("nuxtUiMongocamp.settings.maskedHint") }) : h("span", { class: "font-mono text-xs break-all" }, row.original.value)
|
|
75
77
|
},
|
|
76
78
|
{ accessorKey: "configType", header: t("nuxtUiMongocamp.settings.columnType") },
|
|
77
79
|
{
|
|
78
80
|
accessorKey: "needsRestart",
|
|
79
81
|
header: t("nuxtUiMongocamp.settings.columnRestart"),
|
|
80
|
-
cell: ({ row }) => row.original.needsRestart ? h(UBadge, { label: t("nuxtUiMongocamp.settings.restartNeeded"), color: "warning", variant:
|
|
82
|
+
cell: ({ row }) => row.original.needsRestart ? h(UBadge, { label: t("nuxtUiMongocamp.settings.restartNeeded"), color: "warning", variant: ui.value.badge.variant }) : h("span", { class: "text-dimmed" }, "\u2014")
|
|
81
83
|
}
|
|
82
84
|
]);
|
|
83
85
|
const pluginGroups = computed(() => [
|
|
@@ -90,13 +92,15 @@ defineExpose({ refresh: fetchSettings });
|
|
|
90
92
|
</script>
|
|
91
93
|
|
|
92
94
|
<template>
|
|
93
|
-
<div class="flex flex-col gap-4">
|
|
95
|
+
<div class="mongocamp-settings flex flex-col gap-4">
|
|
94
96
|
<div
|
|
95
97
|
v-if="!hideHeading || isAdmin && !hideRefresh || $slots.toolbar"
|
|
98
|
+
data-mongocamp-part="toolbar"
|
|
96
99
|
class="flex items-center justify-between gap-4"
|
|
97
100
|
>
|
|
98
101
|
<h2
|
|
99
102
|
v-if="!hideHeading"
|
|
103
|
+
data-mongocamp-part="heading"
|
|
100
104
|
class="text-xl font-semibold"
|
|
101
105
|
>
|
|
102
106
|
{{ t("nuxtUiMongocamp.settings.heading") }}
|
|
@@ -108,8 +112,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
108
112
|
>
|
|
109
113
|
<UButton
|
|
110
114
|
icon="i-lucide-refresh-cw"
|
|
111
|
-
|
|
112
|
-
variant="ghost"
|
|
115
|
+
v-bind="ui.toolbarButton"
|
|
113
116
|
:loading="loading"
|
|
114
117
|
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
115
118
|
@click="fetchSettings"
|
|
@@ -121,7 +124,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
121
124
|
<UAlert
|
|
122
125
|
v-if="!isAdmin"
|
|
123
126
|
color="neutral"
|
|
124
|
-
variant="
|
|
127
|
+
:variant="ui.alert.variant"
|
|
125
128
|
icon="i-lucide-lock"
|
|
126
129
|
:description="t('nuxtUiMongocamp.settings.adminOnly')"
|
|
127
130
|
/>
|
|
@@ -155,7 +158,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
155
158
|
:key="item"
|
|
156
159
|
:label="item"
|
|
157
160
|
color="neutral"
|
|
158
|
-
variant="
|
|
161
|
+
:variant="ui.badge.variant"
|
|
159
162
|
size="sm"
|
|
160
163
|
/>
|
|
161
164
|
</div>
|
|
@@ -184,14 +187,14 @@ defineExpose({ refresh: fetchSettings });
|
|
|
184
187
|
v-if="member.coordinator"
|
|
185
188
|
:label="t('nuxtUiMongocamp.settings.clusterCoordinator')"
|
|
186
189
|
color="primary"
|
|
187
|
-
variant="
|
|
190
|
+
:variant="ui.badge.variant"
|
|
188
191
|
size="sm"
|
|
189
192
|
/>
|
|
190
193
|
<UBadge
|
|
191
194
|
v-if="member.siteMaster"
|
|
192
195
|
:label="t('nuxtUiMongocamp.settings.clusterSiteMaster')"
|
|
193
196
|
color="neutral"
|
|
194
|
-
variant="
|
|
197
|
+
:variant="ui.badge.variant"
|
|
195
198
|
size="sm"
|
|
196
199
|
/>
|
|
197
200
|
</li>
|
|
@@ -207,7 +210,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
207
210
|
v-model="search"
|
|
208
211
|
icon="i-lucide-search"
|
|
209
212
|
:placeholder="t('nuxtUiMongocamp.settings.searchPlaceholder')"
|
|
210
|
-
size="
|
|
213
|
+
:size="ui.controlSize"
|
|
211
214
|
class="w-full max-w-xs"
|
|
212
215
|
/>
|
|
213
216
|
<p
|
|
@@ -221,7 +224,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
221
224
|
<UAlert
|
|
222
225
|
v-if="!hideConfigurations && !hideGrantHint && showGrantHint"
|
|
223
226
|
color="info"
|
|
224
|
-
variant="
|
|
227
|
+
:variant="ui.alert.variant"
|
|
225
228
|
icon="i-lucide-info"
|
|
226
229
|
:title="t('nuxtUiMongocamp.settings.grantHintTitle')"
|
|
227
230
|
:description="t('nuxtUiMongocamp.settings.grantHint')"
|
|
@@ -231,6 +234,7 @@ defineExpose({ refresh: fetchSettings });
|
|
|
231
234
|
<!-- Long values make it scroll sideways: focusable and named so a keyboard can scroll it too -->
|
|
232
235
|
<UTable
|
|
233
236
|
v-if="!hideConfigurations"
|
|
237
|
+
data-mongocamp-part="table"
|
|
234
238
|
:data="pageRows"
|
|
235
239
|
:columns="columns"
|
|
236
240
|
:loading="loading"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref } from "vue";
|
|
3
3
|
import { useI18n, useMongocampClientApi, useMongocampStorage } from "#imports";
|
|
4
|
+
import { useMongocampUi } from "../composables/useMongocampUi";
|
|
4
5
|
defineProps({
|
|
5
6
|
hideHeading: { type: Boolean, required: false, default: false },
|
|
6
7
|
hideRefresh: { type: Boolean, required: false, default: false },
|
|
@@ -8,6 +9,7 @@ defineProps({
|
|
|
8
9
|
});
|
|
9
10
|
const FLAGS = ["read", "write", "administrate"];
|
|
10
11
|
const { t } = useI18n();
|
|
12
|
+
const ui = useMongocampUi();
|
|
11
13
|
const { authApi } = useMongocampClientApi();
|
|
12
14
|
const state = useMongocampStorage();
|
|
13
15
|
const isAdmin = computed(() => state.value?.profile?.isAdmin === true);
|
|
@@ -39,26 +41,29 @@ refresh();
|
|
|
39
41
|
</script>
|
|
40
42
|
|
|
41
43
|
<template>
|
|
42
|
-
<div class="flex flex-col gap-6">
|
|
44
|
+
<div class="mongocamp-user-access flex flex-col gap-6">
|
|
43
45
|
<div
|
|
44
46
|
v-if="!hideHeading || !hideRefresh || $slots.toolbar"
|
|
45
47
|
class="flex items-center justify-between gap-2"
|
|
46
48
|
>
|
|
47
49
|
<h2
|
|
48
50
|
v-if="!hideHeading"
|
|
51
|
+
data-mongocamp-part="heading"
|
|
49
52
|
class="text-lg font-semibold"
|
|
50
53
|
>
|
|
51
54
|
{{ t("nuxtUiMongocamp.userAccess.heading") }}
|
|
52
55
|
</h2>
|
|
53
|
-
<div
|
|
56
|
+
<div
|
|
57
|
+
data-mongocamp-part="toolbar"
|
|
58
|
+
class="ml-auto flex items-center gap-2"
|
|
59
|
+
>
|
|
54
60
|
<UTooltip
|
|
55
61
|
v-if="!isAdmin && !hideRefresh"
|
|
56
62
|
:text="t('nuxtUiMongocamp.common.refresh')"
|
|
57
63
|
>
|
|
58
64
|
<UButton
|
|
59
65
|
icon="i-lucide-refresh-cw"
|
|
60
|
-
|
|
61
|
-
variant="ghost"
|
|
66
|
+
v-bind="ui.toolbarButton"
|
|
62
67
|
:loading="loading"
|
|
63
68
|
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
64
69
|
@click="refresh"
|
|
@@ -71,7 +76,7 @@ refresh();
|
|
|
71
76
|
<UAlert
|
|
72
77
|
v-if="isAdmin"
|
|
73
78
|
color="info"
|
|
74
|
-
variant="
|
|
79
|
+
:variant="ui.alert.variant"
|
|
75
80
|
icon="i-lucide-shield-check"
|
|
76
81
|
:title="t('nuxtUiMongocamp.userAccess.adminTitle')"
|
|
77
82
|
:description="t('nuxtUiMongocamp.userAccess.adminDescription')"
|
|
@@ -157,7 +162,7 @@ refresh();
|
|
|
157
162
|
<UBadge
|
|
158
163
|
:label="row[flag] ? t('nuxtUiMongocamp.common.yes') : t('nuxtUiMongocamp.common.no')"
|
|
159
164
|
:color="row[flag] ? 'success' : 'neutral'"
|
|
160
|
-
variant="
|
|
165
|
+
:variant="ui.badge.variant"
|
|
161
166
|
/>
|
|
162
167
|
</td>
|
|
163
168
|
</tr>
|
|
@@ -6,12 +6,14 @@ import { runBulkDelete } from "../utils/bulkDelete";
|
|
|
6
6
|
import { createSelectColumn } from "../utils/createSelectColumn";
|
|
7
7
|
import { createListPagination } from "../utils/listPagination";
|
|
8
8
|
import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
|
|
9
|
+
import { useMongocampUi } from "../composables/useMongocampUi";
|
|
9
10
|
defineProps({
|
|
10
11
|
hideHeading: { type: Boolean, required: false },
|
|
11
12
|
hideRefresh: { type: Boolean, required: false }
|
|
12
13
|
});
|
|
13
14
|
const emit = defineEmits(["changed"]);
|
|
14
15
|
const { t } = useI18n();
|
|
16
|
+
const ui = useMongocampUi();
|
|
15
17
|
const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, regenerateUserApiKey } = useMongocampAdmin();
|
|
16
18
|
const toast = useToast();
|
|
17
19
|
const users = ref([]);
|
|
@@ -256,8 +258,7 @@ function withTooltip(text, node) {
|
|
|
256
258
|
function sortHeader(column, label) {
|
|
257
259
|
const isSorted = column.getIsSorted();
|
|
258
260
|
return h(UButton, {
|
|
259
|
-
|
|
260
|
-
variant: "ghost",
|
|
261
|
+
...ui.value.sortHeader,
|
|
261
262
|
label,
|
|
262
263
|
icon: isSorted === "asc" ? "i-lucide-arrow-up-narrow-wide" : isSorted === "desc" ? "i-lucide-arrow-down-wide-narrow" : "i-lucide-arrow-up-down",
|
|
263
264
|
class: "-mx-2.5",
|
|
@@ -267,9 +268,8 @@ function sortHeader(column, label) {
|
|
|
267
268
|
function deleteButton(userId) {
|
|
268
269
|
const button = (disabled) => h(UButton, {
|
|
269
270
|
"icon": "i-lucide-trash-2",
|
|
271
|
+
...ui.value.iconButton,
|
|
270
272
|
"color": "error",
|
|
271
|
-
"variant": "ghost",
|
|
272
|
-
"size": "sm",
|
|
273
273
|
"aria-label": t("nuxtUiMongocamp.users.deleteUserTooltip"),
|
|
274
274
|
disabled,
|
|
275
275
|
"onClick": () => confirmDelete(userId)
|
|
@@ -295,7 +295,7 @@ const columns = computed(() => [
|
|
|
295
295
|
cell: ({ row }) => h(UBadge, {
|
|
296
296
|
label: row.original.isAdmin ? t("nuxtUiMongocamp.users.roleAdmin") : t("nuxtUiMongocamp.users.roleUser"),
|
|
297
297
|
color: row.original.isAdmin ? "primary" : "neutral",
|
|
298
|
-
variant:
|
|
298
|
+
variant: ui.value.badge.variant
|
|
299
299
|
})
|
|
300
300
|
},
|
|
301
301
|
{
|
|
@@ -308,35 +308,30 @@ const columns = computed(() => [
|
|
|
308
308
|
return h(
|
|
309
309
|
"div",
|
|
310
310
|
{ class: "flex flex-wrap gap-1" },
|
|
311
|
-
roles.map((role) => h(UBadge, { label: role, color: "primary", variant:
|
|
311
|
+
roles.map((role) => h(UBadge, { label: role, color: "primary", variant: ui.value.badge.variant }))
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
id: "actions",
|
|
317
317
|
header: "",
|
|
318
|
-
cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
|
|
318
|
+
cell: ({ row }) => h("div", { "class": "flex gap-1 justify-end", "data-mongocamp-part": "row-actions" }, [
|
|
319
319
|
withTooltip(t("nuxtUiMongocamp.users.detailsTooltip"), h(UButton, {
|
|
320
320
|
"icon": "i-lucide-info",
|
|
321
|
-
|
|
322
|
-
"variant": "ghost",
|
|
323
|
-
"size": "sm",
|
|
321
|
+
...ui.value.iconButton,
|
|
324
322
|
"aria-label": t("nuxtUiMongocamp.users.detailsTooltip"),
|
|
325
323
|
"onClick": () => openDetail(row.original)
|
|
326
324
|
})),
|
|
327
325
|
withTooltip(t("nuxtUiMongocamp.users.editUserTooltip"), h(UButton, {
|
|
328
326
|
"icon": "i-lucide-pencil",
|
|
329
|
-
|
|
330
|
-
"variant": "ghost",
|
|
331
|
-
"size": "sm",
|
|
327
|
+
...ui.value.iconButton,
|
|
332
328
|
"aria-label": t("nuxtUiMongocamp.users.editUserTooltip"),
|
|
333
329
|
"onClick": () => openEdit(row.original)
|
|
334
330
|
})),
|
|
335
331
|
isSelf(row.original.user) ? null : withTooltip(t("nuxtUiMongocamp.users.regenerateKeyTooltip"), h(UButton, {
|
|
336
332
|
"icon": "i-lucide-key-round",
|
|
333
|
+
...ui.value.iconButton,
|
|
337
334
|
"color": "warning",
|
|
338
|
-
"variant": "ghost",
|
|
339
|
-
"size": "sm",
|
|
340
335
|
"aria-label": t("nuxtUiMongocamp.users.regenerateKeyTooltip"),
|
|
341
336
|
"onClick": () => confirmRegenerateKey(row.original.user)
|
|
342
337
|
})),
|
|
@@ -354,27 +349,32 @@ defineExpose({ refresh: fetchUsers });
|
|
|
354
349
|
<template>
|
|
355
350
|
<MongocampEmptyState
|
|
356
351
|
v-if="blocked"
|
|
352
|
+
class="mongocamp-users"
|
|
357
353
|
icon="i-lucide-shield-alert"
|
|
358
354
|
:title="message"
|
|
359
355
|
data-test="admin-only"
|
|
360
356
|
/>
|
|
361
357
|
<div
|
|
362
358
|
v-else
|
|
363
|
-
class="flex flex-col gap-4"
|
|
359
|
+
class="mongocamp-users flex flex-col gap-4"
|
|
364
360
|
>
|
|
365
361
|
<div class="flex items-center justify-between gap-4">
|
|
366
362
|
<h2
|
|
367
363
|
v-if="!hideHeading"
|
|
364
|
+
data-mongocamp-part="heading"
|
|
368
365
|
class="text-xl font-semibold"
|
|
369
366
|
>
|
|
370
367
|
{{ t("nuxtUiMongocamp.users.heading") }}
|
|
371
368
|
</h2>
|
|
372
|
-
<div
|
|
369
|
+
<div
|
|
370
|
+
data-mongocamp-part="toolbar"
|
|
371
|
+
class="flex flex-1 items-center gap-2"
|
|
372
|
+
>
|
|
373
373
|
<UInput
|
|
374
374
|
v-model="filterText"
|
|
375
375
|
icon="i-lucide-search"
|
|
376
376
|
:placeholder="t('nuxtUiMongocamp.users.searchPlaceholder')"
|
|
377
|
-
size="
|
|
377
|
+
:size="ui.controlSize"
|
|
378
378
|
class="flex-1 max-w-xs"
|
|
379
379
|
@input="onFilterInput"
|
|
380
380
|
/>
|
|
@@ -384,8 +384,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
384
384
|
>
|
|
385
385
|
<UButton
|
|
386
386
|
icon="i-lucide-refresh-cw"
|
|
387
|
-
|
|
388
|
-
variant="ghost"
|
|
387
|
+
v-bind="ui.toolbarButton"
|
|
389
388
|
:loading="loading"
|
|
390
389
|
:aria-label="t('nuxtUiMongocamp.common.refresh')"
|
|
391
390
|
@click="fetchUsers"
|
|
@@ -418,6 +417,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
418
417
|
v-model:sorting="sorting"
|
|
419
418
|
v-model:row-selection="rowSelection"
|
|
420
419
|
v-model:pagination="pagination"
|
|
420
|
+
data-mongocamp-part="table"
|
|
421
421
|
:pagination-options="paginationOptions"
|
|
422
422
|
:get-row-id="(row) => row.user"
|
|
423
423
|
:row-selection-options="{ enableRowSelection: canSelectUser }"
|
|
@@ -488,7 +488,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
488
488
|
<UModal
|
|
489
489
|
v-model:open="isDeleteModalOpen"
|
|
490
490
|
:title="t('nuxtUiMongocamp.users.deleteUserTitle')"
|
|
491
|
-
:ui="{ footer:
|
|
491
|
+
:ui="{ footer: ui.modal.footer }"
|
|
492
492
|
>
|
|
493
493
|
<template #body>
|
|
494
494
|
<p>{{ t("nuxtUiMongocamp.users.confirmDelete", { userId: userToDelete }) }}</p>
|
|
@@ -496,7 +496,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
496
496
|
v-if="deleteError"
|
|
497
497
|
class="mt-3"
|
|
498
498
|
color="error"
|
|
499
|
-
variant="
|
|
499
|
+
:variant="ui.alert.variant"
|
|
500
500
|
icon="i-lucide-circle-alert"
|
|
501
501
|
:description="deleteError"
|
|
502
502
|
/>
|
|
@@ -504,14 +504,13 @@ defineExpose({ refresh: fetchUsers });
|
|
|
504
504
|
<template #footer>
|
|
505
505
|
<UButton
|
|
506
506
|
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
507
|
-
|
|
508
|
-
variant="ghost"
|
|
507
|
+
v-bind="ui.dialogCancel"
|
|
509
508
|
:disabled="deleting"
|
|
510
509
|
@click="isDeleteModalOpen = false"
|
|
511
510
|
/>
|
|
512
511
|
<UButton
|
|
513
512
|
:label="t('nuxtUiMongocamp.common.delete')"
|
|
514
|
-
|
|
513
|
+
v-bind="ui.dangerAction"
|
|
515
514
|
:loading="deleting"
|
|
516
515
|
@click="handleDeleteUser"
|
|
517
516
|
/>
|
|
@@ -522,7 +521,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
522
521
|
v-model:open="isKeyModalOpen"
|
|
523
522
|
:title="t('nuxtUiMongocamp.users.regenerateKeyTitle', { userId: keyUser })"
|
|
524
523
|
:dismissible="!keyBusy"
|
|
525
|
-
:ui="{ footer:
|
|
524
|
+
:ui="{ footer: ui.modal.footer }"
|
|
526
525
|
>
|
|
527
526
|
<template #body>
|
|
528
527
|
<div
|
|
@@ -542,8 +541,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
542
541
|
<UButton
|
|
543
542
|
icon="i-lucide-copy"
|
|
544
543
|
:label="t('nuxtUiMongocamp.common.copy')"
|
|
545
|
-
|
|
546
|
-
variant="subtle"
|
|
544
|
+
v-bind="ui.secondaryAction"
|
|
547
545
|
@click="copyNewApiKey"
|
|
548
546
|
/>
|
|
549
547
|
</div>
|
|
@@ -554,7 +552,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
554
552
|
v-if="keyError"
|
|
555
553
|
class="mt-3"
|
|
556
554
|
color="error"
|
|
557
|
-
variant="
|
|
555
|
+
:variant="ui.alert.variant"
|
|
558
556
|
icon="i-lucide-circle-alert"
|
|
559
557
|
:description="keyError"
|
|
560
558
|
/>
|
|
@@ -570,14 +568,13 @@ defineExpose({ refresh: fetchUsers });
|
|
|
570
568
|
<template v-else>
|
|
571
569
|
<UButton
|
|
572
570
|
:label="t('nuxtUiMongocamp.common.cancel')"
|
|
573
|
-
|
|
574
|
-
variant="ghost"
|
|
571
|
+
v-bind="ui.dialogCancel"
|
|
575
572
|
:disabled="keyBusy"
|
|
576
573
|
@click="isKeyModalOpen = false"
|
|
577
574
|
/>
|
|
578
575
|
<UButton
|
|
579
576
|
:label="t('nuxtUiMongocamp.account.regenerate')"
|
|
580
|
-
|
|
577
|
+
v-bind="ui.dangerAction"
|
|
581
578
|
icon="i-lucide-key-round"
|
|
582
579
|
:loading="keyBusy"
|
|
583
580
|
@click="handleRegenerateKey"
|
|
@@ -589,7 +586,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
589
586
|
<USlideover
|
|
590
587
|
v-model:open="isDetailOpen"
|
|
591
588
|
:title="t('nuxtUiMongocamp.users.detailsTitle', { userId: detail?.user ?? '' })"
|
|
592
|
-
:ui="{ content:
|
|
589
|
+
:ui="{ content: ui.modal.md }"
|
|
593
590
|
>
|
|
594
591
|
<template #body>
|
|
595
592
|
<div
|
|
@@ -600,7 +597,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
600
597
|
<UBadge
|
|
601
598
|
:label="detail.isAdmin ? t('nuxtUiMongocamp.users.roleAdmin') : t('nuxtUiMongocamp.users.roleUser')"
|
|
602
599
|
:color="detail.isAdmin ? 'primary' : 'neutral'"
|
|
603
|
-
variant="
|
|
600
|
+
:variant="ui.badge.variant"
|
|
604
601
|
/>
|
|
605
602
|
</div>
|
|
606
603
|
<section class="flex flex-col gap-2">
|
|
@@ -616,7 +613,7 @@ defineExpose({ refresh: fetchUsers });
|
|
|
616
613
|
:key="role"
|
|
617
614
|
:label="role"
|
|
618
615
|
color="primary"
|
|
619
|
-
variant="
|
|
616
|
+
:variant="ui.badge.variant"
|
|
620
617
|
/>
|
|
621
618
|
</div>
|
|
622
619
|
<p
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
3
|
import { useI18n, useMongocampProxyMode, useMongocampStorage, useMongocampSystem } from "#imports";
|
|
4
4
|
import { useNuxtApp } from "#app";
|
|
5
|
+
import { useMongocampUi } from "../composables/useMongocampUi";
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
hideDatabase: { type: Boolean, required: false, default: false }
|
|
7
8
|
});
|
|
8
9
|
const { t } = useI18n();
|
|
10
|
+
const ui = useMongocampUi();
|
|
9
11
|
const { $mongocampVersion } = useNuxtApp();
|
|
10
12
|
const { getServerInfo } = useMongocampSystem();
|
|
11
13
|
const state = useMongocampStorage();
|
|
@@ -27,11 +29,11 @@ watch(canAsk, async (ask) => {
|
|
|
27
29
|
</script>
|
|
28
30
|
|
|
29
31
|
<template>
|
|
30
|
-
<span class="inline-flex items-center gap-1.5">
|
|
32
|
+
<span class="mongocamp-version inline-flex items-center gap-1.5">
|
|
31
33
|
<UBadge
|
|
32
34
|
v-if="version"
|
|
33
35
|
color="primary"
|
|
34
|
-
variant="
|
|
36
|
+
:variant="ui.badge.variant"
|
|
35
37
|
icon="i-lucide-database"
|
|
36
38
|
>
|
|
37
39
|
{{ version.name }} v{{ version.version }}
|
|
@@ -39,7 +41,7 @@ watch(canAsk, async (ask) => {
|
|
|
39
41
|
<UBadge
|
|
40
42
|
v-else
|
|
41
43
|
color="neutral"
|
|
42
|
-
variant="
|
|
44
|
+
:variant="ui.badge.variant"
|
|
43
45
|
icon="i-lucide-database-zap"
|
|
44
46
|
>
|
|
45
47
|
{{ t("nuxtUiMongocamp.version.unavailable") }}
|
|
@@ -47,7 +49,7 @@ watch(canAsk, async (ask) => {
|
|
|
47
49
|
<UBadge
|
|
48
50
|
v-if="mongoDbVersion"
|
|
49
51
|
color="neutral"
|
|
50
|
-
variant="
|
|
52
|
+
:variant="ui.badge.variant"
|
|
51
53
|
icon="i-simple-icons-mongodb"
|
|
52
54
|
data-testid="mongodb-version"
|
|
53
55
|
>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { MongocampUiTheme } from '../utils/uiTheme.js';
|
|
3
|
+
/**
|
|
4
|
+
* The module's look from `app.config.ts` (key `ui` under `nuxtUiMongocamp`), merged over the defaults and checked. Reactive:
|
|
5
|
+
* `updateAppConfig()` restyles the components without a reload. Components spread a role onto Nuxt UI
|
|
6
|
+
* components (`v-bind="ui.iconButton"`, `h(UButton, { ...ui.value.iconButton, color: 'error' })`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMongocampUi(): ComputedRef<MongocampUiTheme>;
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -7,6 +7,7 @@ import { useMongocampConnection } from "./composables/useMongocampConnection.js"
|
|
|
7
7
|
import { CONNECTION_CHECK_TIMEOUT_MS, CONNECTION_RETRY_MAX_MS, CONNECTION_RETRY_MS } from "./utils/connection.js";
|
|
8
8
|
import { nextDelay } from "./utils/autoRefresh.js";
|
|
9
9
|
import { createVerifyCache, runSessionGuard } from "./utils/sessionGuard.js";
|
|
10
|
+
import { compactProfile } from "./utils/compactSession.js";
|
|
10
11
|
export default defineNuxtPlugin(async (_nuxtApp) => {
|
|
11
12
|
const { systemApi } = useMongocampClientApi();
|
|
12
13
|
const config = useRuntimeConfig();
|
|
@@ -28,6 +29,13 @@ export default defineNuxtPlugin(async (_nuxtApp) => {
|
|
|
28
29
|
}
|
|
29
30
|
}, { lazy: true, server: false }) : await useAsyncData("version", () => systemApi.version());
|
|
30
31
|
if (offline && import.meta.client) watchConnection();
|
|
32
|
+
if (config.public.nuxtUiMongocampOptions.compactSession && import.meta.client) {
|
|
33
|
+
const storage = useMongocampStorage();
|
|
34
|
+
watch(() => storage.value?.profile, (profile) => {
|
|
35
|
+
const compact = compactProfile(profile);
|
|
36
|
+
if (compact) storage.value.profile = compact;
|
|
37
|
+
}, { immediate: true, flush: "sync" });
|
|
38
|
+
}
|
|
31
39
|
if (sessionGuard && !useServerProxy) {
|
|
32
40
|
addRouteMiddleware("session-guard", async (to) => {
|
|
33
41
|
const { checkExpiry, invalidateSession, verify } = useMongocampSession();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module option `compactSession`: what of the user profile goes into the session cookie. `@sfxcode/nuxt-mongocamp-server`
|
|
3
|
+
* stores the whole `userProfile` of a login or token refresh — grants and the API key included — so a user with many
|
|
4
|
+
* grants pushes the cookie past the browser's ~4 KB limit and the login silently fails. The module itself never reads
|
|
5
|
+
* grants from the session (`useMongocampPermissions` asks the server), so the cookie only needs who the user is.
|
|
6
|
+
*/
|
|
7
|
+
export interface CompactProfile {
|
|
8
|
+
user: string;
|
|
9
|
+
isAdmin: boolean;
|
|
10
|
+
roles?: string[];
|
|
11
|
+
}
|
|
12
|
+
/** The compact profile, or `undefined` when the stored one is already compact (or missing) and nothing needs writing. */
|
|
13
|
+
export declare function compactProfile(profile: unknown): CompactProfile | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const KEPT = /* @__PURE__ */ new Set(["user", "isAdmin", "roles"]);
|
|
2
|
+
export function compactProfile(profile) {
|
|
3
|
+
if (!profile || typeof profile !== "object") return void 0;
|
|
4
|
+
const p = profile;
|
|
5
|
+
if (Object.keys(p).every((key) => KEPT.has(key))) return void 0;
|
|
6
|
+
const roles = Array.isArray(p.roles) ? p.roles.filter((r) => typeof r === "string") : void 0;
|
|
7
|
+
return {
|
|
8
|
+
user: typeof p.user === "string" ? p.user : "",
|
|
9
|
+
isAdmin: p.isAdmin === true,
|
|
10
|
+
...roles ? { roles } : {}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AlertProps, BadgeProps, ButtonProps } from '@nuxt/ui';
|
|
2
|
+
/**
|
|
3
|
+
* The module's own look, set by an app in `app.config.ts` (key `ui` under `nuxtUiMongocamp`) and read through
|
|
4
|
+
* `useMongocampUi()`. Roles, not components: one entry styles every button/alert/badge of that kind in
|
|
5
|
+
* every Mongocamp component. Colours that carry a meaning (`error`, `warning`, `success`, `info` on a
|
|
6
|
+
* delete button, an error alert, a status badge) are not themeable — only the variant and size around them.
|
|
7
|
+
*/
|
|
8
|
+
export type ControlSize = NonNullable<ButtonProps['size']>;
|
|
9
|
+
export interface ButtonStyle {
|
|
10
|
+
color?: ButtonProps['color'];
|
|
11
|
+
variant?: ButtonProps['variant'];
|
|
12
|
+
size?: ButtonProps['size'];
|
|
13
|
+
}
|
|
14
|
+
export interface MongocampUiTheme {
|
|
15
|
+
/** Inputs, selects and field groups inside the components' toolbars and editors. */
|
|
16
|
+
controlSize: ControlSize;
|
|
17
|
+
/** Reload and other buttons in a component's own toolbar. */
|
|
18
|
+
toolbarButton: ButtonStyle;
|
|
19
|
+
/** Small icon buttons: table row actions (a delete keeps its `error` colour) and toolbar icons. */
|
|
20
|
+
iconButton: ButtonStyle;
|
|
21
|
+
/** The sortable column headers of tables. */
|
|
22
|
+
sortHeader: ButtonStyle;
|
|
23
|
+
/** Cancel, close and back in dialog footers. */
|
|
24
|
+
dialogCancel: ButtonStyle;
|
|
25
|
+
/** The confirming button of an irreversible action (delete, regenerate). */
|
|
26
|
+
dangerAction: ButtonStyle;
|
|
27
|
+
/** Secondary actions beside content: copy, download, stop. */
|
|
28
|
+
secondaryAction: ButtonStyle;
|
|
29
|
+
/** Small buttons inside dense editors (document tree, aggregation stages, chips). */
|
|
30
|
+
compactButton: ButtonStyle;
|
|
31
|
+
/** Every alert; its colour stays the one that fits the message. */
|
|
32
|
+
alert: {
|
|
33
|
+
variant?: AlertProps['variant'];
|
|
34
|
+
};
|
|
35
|
+
/** A button inside an alert (retry, log in again); its colour follows the alert. */
|
|
36
|
+
alertAction: {
|
|
37
|
+
variant?: ButtonProps['variant'];
|
|
38
|
+
size?: ButtonProps['size'];
|
|
39
|
+
};
|
|
40
|
+
/** Every badge; its colour stays the one that fits the value. */
|
|
41
|
+
badge: {
|
|
42
|
+
variant?: BadgeProps['variant'];
|
|
43
|
+
};
|
|
44
|
+
/** Widths of dialogs and drawers (`content` classes) and the footer layout. */
|
|
45
|
+
modal: {
|
|
46
|
+
md: string;
|
|
47
|
+
lg: string;
|
|
48
|
+
xl: string;
|
|
49
|
+
footer: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export type MongocampUiThemeInput = {
|
|
53
|
+
[K in keyof MongocampUiTheme]?: MongocampUiTheme[K] extends string ? MongocampUiTheme[K] : Partial<MongocampUiTheme[K]>;
|
|
54
|
+
};
|
|
55
|
+
/** Today's look. Changing a value here changes every consumer app that has not set it. */
|
|
56
|
+
export declare const DEFAULT_UI: MongocampUiTheme;
|
|
57
|
+
/** Values of `data-mongocamp-part`. Public API: a stylesheet can target them. */
|
|
58
|
+
export declare const MONGOCAMP_PARTS: readonly ["heading", "toolbar", "table", "row-actions", "empty", "error"];
|
|
59
|
+
export type MongocampPart = typeof MONGOCAMP_PARTS[number];
|
|
60
|
+
/**
|
|
61
|
+
* Merges an app's (partial, unchecked) theme over the defaults. Unknown keys are ignored, a value that is
|
|
62
|
+
* not a non-empty string falls back to the default, a role's field the default leaves open (`size` of
|
|
63
|
+
* `toolbarButton`) can be set. Always returns fresh objects.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveUi(input: unknown): MongocampUiTheme;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const DEFAULT_UI = {
|
|
2
|
+
controlSize: "sm",
|
|
3
|
+
toolbarButton: { color: "neutral", variant: "ghost" },
|
|
4
|
+
iconButton: { color: "neutral", variant: "ghost", size: "sm" },
|
|
5
|
+
sortHeader: { color: "neutral", variant: "ghost" },
|
|
6
|
+
dialogCancel: { color: "neutral", variant: "ghost" },
|
|
7
|
+
dangerAction: { color: "error" },
|
|
8
|
+
secondaryAction: { color: "neutral", variant: "subtle" },
|
|
9
|
+
compactButton: { color: "neutral", variant: "ghost", size: "xs" },
|
|
10
|
+
alert: { variant: "subtle" },
|
|
11
|
+
alertAction: { variant: "subtle" },
|
|
12
|
+
badge: { variant: "subtle" },
|
|
13
|
+
modal: { md: "sm:max-w-xl", lg: "sm:max-w-3xl", xl: "sm:max-w-5xl", footer: "justify-end" }
|
|
14
|
+
};
|
|
15
|
+
export const MONGOCAMP_PARTS = ["heading", "toolbar", "table", "row-actions", "empty", "error"];
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function isText(value) {
|
|
20
|
+
return typeof value === "string" && value.trim() !== "";
|
|
21
|
+
}
|
|
22
|
+
export function resolveUi(input) {
|
|
23
|
+
const source = isRecord(input) ? input : {};
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const [key, fallback] of Object.entries(DEFAULT_UI)) {
|
|
26
|
+
const given = source[key];
|
|
27
|
+
if (typeof fallback === "string") {
|
|
28
|
+
result[key] = isText(given) ? given.trim() : fallback;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const base = fallback;
|
|
32
|
+
const fields = key === "modal" ? Object.keys(base) : roleFields(key);
|
|
33
|
+
const merged = {};
|
|
34
|
+
for (const field of fields) {
|
|
35
|
+
const value = isRecord(given) ? given[field] : void 0;
|
|
36
|
+
if (isText(value)) merged[field] = value.trim();
|
|
37
|
+
else if (base[field] !== void 0) merged[field] = base[field];
|
|
38
|
+
}
|
|
39
|
+
result[key] = merged;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function roleFields(key) {
|
|
44
|
+
if (key === "alert" || key === "badge") return ["variant"];
|
|
45
|
+
if (key === "alertAction") return ["variant", "size"];
|
|
46
|
+
return ["color", "variant", "size"];
|
|
47
|
+
}
|