@sfxcode/nuxt-ui-mongocamp 1.5.3 → 1.5.5

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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "1.5.3",
7
+ "version": "1.5.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.4",
10
10
  "unbuild": "3.6.1"
@@ -148,13 +148,15 @@ function makeMetadataCell() {
148
148
  const metadata = row.original.metadata ?? {};
149
149
  const keys = Object.keys(metadata);
150
150
  if (keys.length === 0) return h("span", { class: "text-dimmed" }, "\u2014");
151
+ const label = keys.length === 1 ? t("nuxtUiMongocamp.bucketFiles.keyCount") : t("nuxtUiMongocamp.bucketFiles.keysCount", { count: keys.length });
151
152
  return withTooltip(t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip"), h(UButton, {
152
153
  "icon": "i-lucide-braces",
153
154
  "color": "neutral",
154
155
  "variant": "ghost",
155
156
  "size": "xs",
156
- "label": keys.length === 1 ? t("nuxtUiMongocamp.bucketFiles.keyCount") : t("nuxtUiMongocamp.bucketFiles.keysCount", { count: keys.length }),
157
- "aria-label": t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip"),
157
+ label,
158
+ // Starts with the visible text, so voice control ("click 1 key") still finds it
159
+ "aria-label": `${label}: ${t("nuxtUiMongocamp.bucketFiles.viewMetadataTooltip")}`,
158
160
  "onClick": () => openMetadataDetail(metadata)
159
161
  }));
160
162
  };
@@ -5,6 +5,10 @@ type __VLS_Props = {
5
5
  persistState?: boolean;
6
6
  stateKey?: string;
7
7
  hideRefresh?: boolean;
8
+ stickyActions?: boolean;
9
+ stickyId?: boolean;
10
+ pageSizes?: number[];
11
+ defaultPageSize?: number;
8
12
  };
9
13
  declare function init(): Promise<void>;
10
14
  declare const __VLS_template: () => {
@@ -24,6 +28,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
24
28
  aggregatePath: string;
25
29
  persistState: boolean;
26
30
  stateKey: string;
31
+ stickyActions: boolean;
32
+ stickyId: boolean;
33
+ pageSizes: number[];
34
+ defaultPageSize: number;
27
35
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
37
  declare const _default: typeof __VLS_export;
@@ -34,7 +34,11 @@ const props = defineProps({
34
34
  aggregatePath: { type: String, required: false, default: "" },
35
35
  persistState: { type: Boolean, required: false, default: true },
36
36
  stateKey: { type: String, required: false, default: "" },
37
- hideRefresh: { type: Boolean, required: false, default: false }
37
+ hideRefresh: { type: Boolean, required: false, default: false },
38
+ stickyActions: { type: Boolean, required: false, default: true },
39
+ stickyId: { type: Boolean, required: false, default: false },
40
+ pageSizes: { type: Array, required: false, default: () => [10, 20, 50, 100] },
41
+ defaultPageSize: { type: Number, required: false, default: 20 }
38
42
  });
39
43
  const emit = defineEmits(["changed"]);
40
44
  const { t } = useI18n();
@@ -43,7 +47,8 @@ const { documentApi } = useMongocampClientApi();
43
47
  const { pagination, total } = useMongocampCollection();
44
48
  const { state: persisted } = useMongocampPersistedState(
45
49
  () => `collectionData:${props.collectionName}${props.stateKey ? `:${props.stateKey}` : ""}`,
46
- { pageSize: pagination.value.pageSize, sort: [], hidden: [] },
50
+ // pageSize 0 = nothing remembered yet, so the collection opens with `defaultPageSize`
51
+ { pageSize: 0, sort: [], hidden: [] },
47
52
  { storage: props.persistState ? void 0 : null }
48
53
  );
49
54
  const { isBucketCollection, fileIdForRow, downloadingFileIds, uploading, downloadFile, uploadFile } = useMongocampBucket();
@@ -326,6 +331,17 @@ function columnHeader(column, key) {
326
331
  ]);
327
332
  }
328
333
  const columns = ref([]);
334
+ const STICKY_ACTIONS = "sticky right-0 z-10 bg-default";
335
+ const STICKY_ID = "sticky left-0 z-10 bg-default";
336
+ const tableColumns = computed(() => {
337
+ if (!props.stickyActions && !props.stickyId) return columns.value;
338
+ const firstData = columns.value.find((column) => "accessorKey" in column);
339
+ return columns.value.map((column) => {
340
+ if (props.stickyActions && column.id === "actions") return { ...column, meta: { class: { th: STICKY_ACTIONS, td: STICKY_ACTIONS } } };
341
+ if (props.stickyId && column === firstData) return { ...column, meta: { class: { th: STICKY_ID, td: STICKY_ID } } };
342
+ return column;
343
+ });
344
+ });
329
345
  const documents = ref([]);
330
346
  const loading = ref(false);
331
347
  const filterText = ref("");
@@ -340,7 +356,11 @@ const filterFields = computed(() => {
340
356
  });
341
357
  const sorting = ref([]);
342
358
  const columnVisibility = ref({});
343
- const PAGE_SIZES = [10, 20, 50, 100];
359
+ const pageSizeOptions = computed(() => {
360
+ const sizes = [...new Set(props.pageSizes.filter((size) => Number.isInteger(size) && size > 0))].sort((a, b) => a - b);
361
+ return sizes.length > 0 ? sizes : [10, 20, 50, 100];
362
+ });
363
+ const startPageSize = computed(() => pageSizeOptions.value.includes(props.defaultPageSize) ? props.defaultPageSize : pageSizeOptions.value[Math.min(1, pageSizeOptions.value.length - 1)]);
344
364
  const isInitializing = ref(false);
345
365
  const detailOpen = ref(false);
346
366
  const compareOpen = ref(false);
@@ -673,12 +693,10 @@ async function fetchDocuments() {
673
693
  ...keys.filter((k) => k !== "_id" && k !== "metaData").sort(),
674
694
  ...keys.filter((k) => k === "metaData")
675
695
  ];
676
- columns.value = orderedKeys.map((key, index) => ({
696
+ columns.value = orderedKeys.map((key) => ({
677
697
  accessorKey: key,
678
698
  header: ({ column }) => columnHeader(column, key),
679
- cell: makeCell(key, "string"),
680
- // keep the first column (usually _id) pinned so rows stay identifiable when the table scrolls sideways
681
- ...index === 0 ? { meta: { class: { th: "sticky left-0 z-10 bg-default", td: "sticky left-0 z-10 bg-default" } } } : {}
699
+ cell: makeCell(key, "string")
682
700
  }));
683
701
  filterableColumns.value = orderedKeys.filter((k) => k !== "_id" && k !== "metaData" && typeof firstRow[k] === "string");
684
702
  pageFilterFields.value = schemaFromSamples(rows.map((row) => unwrapExtendedJson(row, { exactLongs: false }))).map((c) => ({ key: c.columnKey, type: c.columnKey === "_id" ? "objectId" : toFilterFieldType(c.columnType) })).filter((f) => operatorsFor(f.type).length > 0);
@@ -785,7 +803,7 @@ async function onImported() {
785
803
  async function init() {
786
804
  distinctCache = /* @__PURE__ */ new Map();
787
805
  isInitializing.value = true;
788
- const rememberedSize = PAGE_SIZES.includes(persisted.value.pageSize) ? persisted.value.pageSize : PAGE_SIZES[1];
806
+ const rememberedSize = pageSizeOptions.value.includes(persisted.value.pageSize) ? persisted.value.pageSize : startPageSize.value;
789
807
  pagination.value.pageSize = rememberedSize;
790
808
  sorting.value = (Array.isArray(persisted.value.sort) ? persisted.value.sort : []).filter((e) => typeof e?.id === "string" && e.id !== "" && typeof e.desc === "boolean");
791
809
  pagination.value.pageIndex = 1;
@@ -944,7 +962,7 @@ defineExpose({ refresh: init });
944
962
  </UDropdownMenu>
945
963
  <USelect
946
964
  v-model="pagination.pageSize"
947
- :items="PAGE_SIZES"
965
+ :items="pageSizeOptions"
948
966
  size="sm"
949
967
  class="w-20"
950
968
  :aria-label="t('nuxtUiMongocamp.collectionData.pageSizeLabel')"
@@ -1036,7 +1054,7 @@ defineExpose({ refresh: init });
1036
1054
  :get-row-id="rowId"
1037
1055
  :sorting-options="{ manualSorting: true }"
1038
1056
  :data="documents"
1039
- :columns="columns"
1057
+ :columns="tableColumns"
1040
1058
  :loading="loading"
1041
1059
  >
1042
1060
  <template #empty>
@@ -5,6 +5,10 @@ type __VLS_Props = {
5
5
  persistState?: boolean;
6
6
  stateKey?: string;
7
7
  hideRefresh?: boolean;
8
+ stickyActions?: boolean;
9
+ stickyId?: boolean;
10
+ pageSizes?: number[];
11
+ defaultPageSize?: number;
8
12
  };
9
13
  declare function init(): Promise<void>;
10
14
  declare const __VLS_template: () => {
@@ -24,6 +28,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
24
28
  aggregatePath: string;
25
29
  persistState: boolean;
26
30
  stateKey: string;
31
+ stickyActions: boolean;
32
+ stickyId: boolean;
33
+ pageSizes: number[];
34
+ defaultPageSize: number;
27
35
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
37
  declare const _default: typeof __VLS_export;
@@ -2,7 +2,10 @@ type __VLS_Props = {
2
2
  collectionName: string;
3
3
  sampleSize?: number;
4
4
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ declare function fetchInfo(): Promise<void>;
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
7
+ refresh: typeof fetchInfo;
8
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
9
  sampleSize: number;
7
10
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
11
  declare const _default: typeof __VLS_export;
@@ -223,6 +223,7 @@ const chartFieldItems = computed(() => columnDefinitions.value.filter((c) => c.c
223
223
  async function refreshInfo() {
224
224
  info.value = await collectionApi.getCollectionInformation({ collectionName: props.collectionName });
225
225
  }
226
+ defineExpose({ refresh: fetchInfo });
226
227
  </script>
227
228
 
228
229
  <template>
@@ -2,7 +2,10 @@ type __VLS_Props = {
2
2
  collectionName: string;
3
3
  sampleSize?: number;
4
4
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ declare function fetchInfo(): Promise<void>;
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
7
+ refresh: typeof fetchInfo;
8
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
9
  sampleSize: number;
7
10
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
11
  declare const _default: typeof __VLS_export;
@@ -3,6 +3,7 @@ import { computed, h, onMounted, reactive, ref, resolveComponent, watch } from "
3
3
  import { useI18n, useMongocampError, useMongocampJobs, useToast } from "#imports";
4
4
  import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
5
5
  import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
6
+ import { createListPagination } from "../utils/listPagination";
6
7
  const props = defineProps({
7
8
  autoRefresh: { type: Number, required: false, default: 0 },
8
9
  hideHeading: { type: Boolean, required: false, default: false },
@@ -16,6 +17,7 @@ const toast = useToast();
16
17
  const jobs = ref([]);
17
18
  const loading = ref(false);
18
19
  const sorting = ref([]);
20
+ const { pagination, options: paginationOptions, page, paged, pageSize } = createListPagination(() => jobs.value.length);
19
21
  const isAddModalOpen = ref(false);
20
22
  const isEditModalOpen = ref(false);
21
23
  const isDeleteModalOpen = ref(false);
@@ -342,6 +344,8 @@ defineExpose({ refresh: fetchJobs });
342
344
 
343
345
  <UTable
344
346
  v-model:sorting="sorting"
347
+ v-model:pagination="pagination"
348
+ :pagination-options="paginationOptions"
345
349
  :data="jobs"
346
350
  :columns="columns"
347
351
  :loading="loading"
@@ -350,6 +354,16 @@ defineExpose({ refresh: fetchJobs });
350
354
  <MongocampEmptyState :title="t('nuxtUiMongocamp.empty.jobs')" />
351
355
  </template>
352
356
  </UTable>
357
+ <div
358
+ v-if="paged"
359
+ class="flex justify-end"
360
+ >
361
+ <UPagination
362
+ v-model:page="page"
363
+ :total="jobs.length"
364
+ :items-per-page="pageSize"
365
+ />
366
+ </div>
353
367
 
354
368
  <!-- Add Job Modal -->
355
369
  <UModal
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { computed, h, reactive, ref, resolveComponent } from "vue";
3
- import { useI18n, useMongocampError } from "#imports";
3
+ import { useI18n, useMongocampError, useToast } from "#imports";
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
5
  import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
6
6
  const props = defineProps({
@@ -67,6 +67,8 @@ const editGrantSchema = reactive([
67
67
  }
68
68
  ]);
69
69
  const loadError = ref(null);
70
+ const notFound = ref(false);
71
+ const toast = useToast();
70
72
  const { blocked, message } = useMongocampAdminGate();
71
73
  async function fetchRole() {
72
74
  loading.value = true;
@@ -75,9 +77,12 @@ async function fetchRole() {
75
77
  try {
76
78
  const roles = await listRoles();
77
79
  const role = roles.find((r) => r.name === props.roleName);
80
+ notFound.value = !role;
78
81
  if (role) {
79
82
  isAdmin.value = role.isAdmin;
80
83
  grants.value = (role.collectionGrants ?? []).map((g) => ({ ...g }));
84
+ } else {
85
+ grants.value = [];
81
86
  }
82
87
  } catch (e) {
83
88
  loadError.value = e;
@@ -130,7 +135,10 @@ async function handleEditGrant() {
130
135
  if (await saveGrants(next)) isEditModalOpen.value = false;
131
136
  }
132
137
  async function removeGrant(index) {
133
- await saveGrants(grants.value.filter((_, i) => i !== index));
138
+ const name = grants.value[index]?.name;
139
+ if (await saveGrants(grants.value.filter((_, i) => i !== index))) {
140
+ toast.add({ title: t("nuxtUiMongocamp.roleGrants.removedTitle"), description: t("nuxtUiMongocamp.roleGrants.removedDescription", { name, roleName: props.roleName }), color: "success" });
141
+ }
134
142
  }
135
143
  const missingReadCollections = computed(() => {
136
144
  const grantedNames = new Set(grants.value.map((g) => g.name));
@@ -145,7 +153,9 @@ async function addAllReadGrants() {
145
153
  grantType: "COLLECTION"
146
154
  }));
147
155
  if (!added.length) return;
148
- await saveGrants([...grants.value, ...added]);
156
+ if (await saveGrants([...grants.value, ...added])) {
157
+ toast.add({ title: t("nuxtUiMongocamp.roleGrants.addedAllReadTitle"), description: t("nuxtUiMongocamp.roleGrants.addedAllReadDescription", { count: added.length, roleName: props.roleName }, added.length), color: "success" });
158
+ }
149
159
  }
150
160
  function openAdd() {
151
161
  const grantedNames = new Set(grants.value.map((g) => g.name));
@@ -197,7 +207,7 @@ const columns = computed(() => [
197
207
  header: t("nuxtUiMongocamp.roleGrants.columnAdmin"),
198
208
  cell: ({ row }) => h(UBadge, {
199
209
  label: row.original.administrate ? t("nuxtUiMongocamp.common.yes") : t("nuxtUiMongocamp.common.no"),
200
- color: row.original.administrate ? "error" : "neutral",
210
+ color: row.original.administrate ? "primary" : "neutral",
201
211
  variant: "subtle"
202
212
  })
203
213
  },
@@ -266,7 +276,10 @@ defineExpose({ refresh: fetchRole });
266
276
  />
267
277
  </UTooltip>
268
278
  <slot name="toolbar" />
269
- <UTooltip :text="t('nuxtUiMongocamp.roleGrants.addAllReadTooltip')">
279
+ <UTooltip
280
+ v-if="!notFound"
281
+ :text="t('nuxtUiMongocamp.roleGrants.addAllReadTooltip')"
282
+ >
270
283
  <UButton
271
284
  icon="i-lucide-eye"
272
285
  color="neutral"
@@ -277,6 +290,7 @@ defineExpose({ refresh: fetchRole });
277
290
  />
278
291
  </UTooltip>
279
292
  <UButton
293
+ v-if="!notFound"
280
294
  icon="i-lucide-plus"
281
295
  :label="t('nuxtUiMongocamp.roleGrants.addGrant')"
282
296
  @click="openAdd"
@@ -299,7 +313,16 @@ defineExpose({ refresh: fetchRole });
299
313
  :description="saveError"
300
314
  />
301
315
 
316
+ <MongocampEmptyState
317
+ v-if="notFound && !loadError"
318
+ icon="i-lucide-shield-question"
319
+ :title="t('nuxtUiMongocamp.roleGrants.notFoundTitle', { roleName })"
320
+ :description="t('nuxtUiMongocamp.roleGrants.notFoundText')"
321
+ data-test="role-not-found"
322
+ />
323
+
302
324
  <UTable
325
+ v-else
303
326
  :data="grants"
304
327
  :columns="columns"
305
328
  :loading="loading"
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError, useMongocampPaths } from "#imports";
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
5
  import { runBulkDelete } from "../utils/bulkDelete";
6
6
  import { createSelectColumn } from "../utils/createSelectColumn";
7
+ import { createListPagination } from "../utils/listPagination";
7
8
  import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
8
9
  const props = defineProps({
9
10
  grantsPath: { type: String, required: false },
@@ -18,6 +19,7 @@ const roles = ref([]);
18
19
  const loading = ref(false);
19
20
  const filterText = ref("");
20
21
  const sorting = ref([]);
22
+ const { pagination, options: paginationOptions, page, paged, reset: resetPage, pageSize } = createListPagination(() => roles.value.length);
21
23
  let filterTimer;
22
24
  const isAddModalOpen = ref(false);
23
25
  const isEditModalOpen = ref(false);
@@ -104,7 +106,10 @@ async function fetchRoles() {
104
106
  }
105
107
  function onFilterInput() {
106
108
  clearTimeout(filterTimer);
107
- filterTimer = setTimeout(() => fetchRoles(), 300);
109
+ filterTimer = setTimeout(() => {
110
+ resetPage();
111
+ fetchRoles();
112
+ }, 300);
108
113
  }
109
114
  async function handleAddRole() {
110
115
  errorMessage.value = "";
@@ -215,7 +220,7 @@ const columns = computed(() => [
215
220
  header: t("nuxtUiMongocamp.roles.columnAdmin"),
216
221
  cell: ({ row }) => h(UBadge, {
217
222
  label: row.original.isAdmin ? t("nuxtUiMongocamp.common.admin") : t("nuxtUiMongocamp.common.standard"),
218
- color: row.original.isAdmin ? "error" : "neutral",
223
+ color: row.original.isAdmin ? "primary" : "neutral",
219
224
  variant: "subtle"
220
225
  })
221
226
  },
@@ -344,6 +349,8 @@ defineExpose({ refresh: fetchRoles });
344
349
  <UTable
345
350
  v-model:sorting="sorting"
346
351
  v-model:row-selection="rowSelection"
352
+ v-model:pagination="pagination"
353
+ :pagination-options="paginationOptions"
347
354
  :get-row-id="(row) => row.name"
348
355
  :data="roles"
349
356
  :columns="columns"
@@ -353,6 +360,16 @@ defineExpose({ refresh: fetchRoles });
353
360
  <MongocampEmptyState :title="t('nuxtUiMongocamp.empty.roles')" />
354
361
  </template>
355
362
  </UTable>
363
+ <div
364
+ v-if="paged"
365
+ class="flex justify-end"
366
+ >
367
+ <UPagination
368
+ v-model:page="page"
369
+ :total="roles.length"
370
+ :items-per-page="pageSize"
371
+ />
372
+ </div>
356
373
 
357
374
  <!-- Add Role Modal -->
358
375
  <UModal
@@ -472,7 +489,7 @@ defineExpose({ refresh: fetchRoles });
472
489
  <div class="flex items-center gap-2">
473
490
  <UBadge
474
491
  :label="detail.isAdmin ? t('nuxtUiMongocamp.common.admin') : t('nuxtUiMongocamp.common.standard')"
475
- :color="detail.isAdmin ? 'error' : 'neutral'"
492
+ :color="detail.isAdmin ? 'primary' : 'neutral'"
476
493
  variant="subtle"
477
494
  />
478
495
  </div>
@@ -92,7 +92,6 @@ defineExpose({ refresh: quietRefresh });
92
92
  :to="linkTarget || void 0"
93
93
  class="flex flex-col gap-1.5 rounded-md text-xs"
94
94
  :class="linkTarget ? 'hover:bg-elevated' : ''"
95
- :aria-label="linkTarget ? t('nuxtUiMongocamp.serverStatus.details') : void 0"
96
95
  data-test="server-status"
97
96
  :data-health="health"
98
97
  >
@@ -143,5 +142,10 @@ defineExpose({ refresh: quietRefresh });
143
142
  >
144
143
  {{ t("nuxtUiMongocamp.serverStatus.uptime", { time: formatUptime(uptimeSeconds) }) }}
145
144
  </div>
145
+ <!-- The visible text names the link (an aria-label would hide it from voice control); this says where it goes -->
146
+ <span
147
+ v-if="linkTarget"
148
+ class="sr-only"
149
+ >{{ t("nuxtUiMongocamp.serverStatus.details") }}</span>
146
150
  </component>
147
151
  </template>
@@ -16,7 +16,16 @@ type __VLS_Props = {
16
16
  /** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
17
17
  hideGrantHint?: boolean;
18
18
  };
19
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ declare function fetchSettings(): Promise<void>;
20
+ declare const __VLS_template: () => {
21
+ __VLS_Slots: {
22
+ toolbar?: (props: {}) => any;
23
+ };
24
+ };
25
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
26
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
27
+ refresh: typeof fetchSettings;
28
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
29
  hideRefresh: boolean;
21
30
  hideHeading: boolean;
22
31
  hidePlugins: boolean;
@@ -26,5 +35,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
26
35
  hideMaskedNote: boolean;
27
36
  hideGrantHint: boolean;
28
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
39
  declare const _default: typeof __VLS_export;
30
40
  export default _default;
41
+ type __VLS_WithSlots<T, S> = T & {
42
+ new (): {
43
+ $slots: S;
44
+ };
45
+ };
@@ -86,12 +86,13 @@ const pluginGroups = computed(() => [
86
86
  { key: "ignored", label: t("nuxtUiMongocamp.settings.ignoredPlugins"), items: plugins.value?.ignoredPlugins ?? [] }
87
87
  ]);
88
88
  fetchSettings();
89
+ defineExpose({ refresh: fetchSettings });
89
90
  </script>
90
91
 
91
92
  <template>
92
93
  <div class="flex flex-col gap-4">
93
94
  <div
94
- v-if="!hideHeading || isAdmin && !hideRefresh"
95
+ v-if="!hideHeading || isAdmin && !hideRefresh || $slots.toolbar"
95
96
  class="flex items-center justify-between gap-4"
96
97
  >
97
98
  <h2
@@ -114,6 +115,7 @@ fetchSettings();
114
115
  @click="fetchSettings"
115
116
  />
116
117
  </UTooltip>
118
+ <slot name="toolbar" />
117
119
  </div>
118
120
 
119
121
  <UAlert
@@ -226,11 +228,15 @@ fetchSettings();
226
228
  data-test="grant-hint"
227
229
  />
228
230
 
231
+ <!-- Long values make it scroll sideways: focusable and named so a keyboard can scroll it too -->
229
232
  <UTable
230
233
  v-if="!hideConfigurations"
231
234
  :data="pageRows"
232
235
  :columns="columns"
233
236
  :loading="loading"
237
+ tabindex="0"
238
+ role="region"
239
+ :aria-label="t('nuxtUiMongocamp.settings.configurationsLabel')"
234
240
  >
235
241
  <template #empty>
236
242
  <MongocampEmptyState :title="t('nuxtUiMongocamp.settings.empty')" />
@@ -16,7 +16,16 @@ type __VLS_Props = {
16
16
  /** Hide the hint that the server answers a missing grant with 401 (`AUTH_GRANT_DENIED_STATUS`). */
17
17
  hideGrantHint?: boolean;
18
18
  };
19
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ declare function fetchSettings(): Promise<void>;
20
+ declare const __VLS_template: () => {
21
+ __VLS_Slots: {
22
+ toolbar?: (props: {}) => any;
23
+ };
24
+ };
25
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
26
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
27
+ refresh: typeof fetchSettings;
28
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
20
29
  hideRefresh: boolean;
21
30
  hideHeading: boolean;
22
31
  hidePlugins: boolean;
@@ -26,5 +35,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
26
35
  hideMaskedNote: boolean;
27
36
  hideGrantHint: boolean;
28
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
39
  declare const _default: typeof __VLS_export;
30
40
  export default _default;
41
+ type __VLS_WithSlots<T, S> = T & {
42
+ new (): {
43
+ $slots: S;
44
+ };
45
+ };
@@ -4,6 +4,7 @@ import { useI18n, useMongocampError, useMongocampStorage, useToast } from "#impo
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
5
  import { runBulkDelete } from "../utils/bulkDelete";
6
6
  import { createSelectColumn } from "../utils/createSelectColumn";
7
+ import { createListPagination } from "../utils/listPagination";
7
8
  import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
8
9
  defineProps({
9
10
  hideHeading: { type: Boolean, required: false },
@@ -17,6 +18,7 @@ const users = ref([]);
17
18
  const loading = ref(false);
18
19
  const filterText = ref("");
19
20
  const sorting = ref([]);
21
+ const { pagination, options: paginationOptions, page, paged, reset: resetPage, pageSize } = createListPagination(() => users.value.length);
20
22
  let filterTimer;
21
23
  const isAddModalOpen = ref(false);
22
24
  const isEditModalOpen = ref(false);
@@ -130,7 +132,10 @@ async function fetchUsers() {
130
132
  }
131
133
  function onFilterInput() {
132
134
  clearTimeout(filterTimer);
133
- filterTimer = setTimeout(() => fetchUsers(), 300);
135
+ filterTimer = setTimeout(() => {
136
+ resetPage();
137
+ fetchUsers();
138
+ }, 300);
134
139
  }
135
140
  async function fetchRoles() {
136
141
  const roles = await listRoles();
@@ -289,7 +294,7 @@ const columns = computed(() => [
289
294
  header: ({ column }) => sortHeader(column, t("nuxtUiMongocamp.users.columnAdmin")),
290
295
  cell: ({ row }) => h(UBadge, {
291
296
  label: row.original.isAdmin ? t("nuxtUiMongocamp.users.roleAdmin") : t("nuxtUiMongocamp.users.roleUser"),
292
- color: row.original.isAdmin ? "error" : "neutral",
297
+ color: row.original.isAdmin ? "primary" : "neutral",
293
298
  variant: "subtle"
294
299
  })
295
300
  },
@@ -412,6 +417,8 @@ defineExpose({ refresh: fetchUsers });
412
417
  <UTable
413
418
  v-model:sorting="sorting"
414
419
  v-model:row-selection="rowSelection"
420
+ v-model:pagination="pagination"
421
+ :pagination-options="paginationOptions"
415
422
  :get-row-id="(row) => row.user"
416
423
  :row-selection-options="{ enableRowSelection: canSelectUser }"
417
424
  :data="users"
@@ -422,6 +429,16 @@ defineExpose({ refresh: fetchUsers });
422
429
  <MongocampEmptyState :title="t('nuxtUiMongocamp.empty.users')" />
423
430
  </template>
424
431
  </UTable>
432
+ <div
433
+ v-if="paged"
434
+ class="flex justify-end"
435
+ >
436
+ <UPagination
437
+ v-model:page="page"
438
+ :total="users.length"
439
+ :items-per-page="pageSize"
440
+ />
441
+ </div>
425
442
 
426
443
  <!-- Add User Modal -->
427
444
  <UModal
@@ -582,7 +599,7 @@ defineExpose({ refresh: fetchUsers });
582
599
  <div class="flex items-center gap-2">
583
600
  <UBadge
584
601
  :label="detail.isAdmin ? t('nuxtUiMongocamp.users.roleAdmin') : t('nuxtUiMongocamp.users.roleUser')"
585
- :color="detail.isAdmin ? 'error' : 'neutral'"
602
+ :color="detail.isAdmin ? 'primary' : 'neutral'"
586
603
  variant="subtle"
587
604
  />
588
605
  </div>
@@ -19,7 +19,7 @@
19
19
  "adminOnly": "Dieser Bereich ist nur für Administratoren."
20
20
  },
21
21
  "login": {
22
- "heading": "Mongocamp-Anmeldung",
22
+ "heading": "MongoCamp-Anmeldung",
23
23
  "email": "E-Mail",
24
24
  "password": "Passwort",
25
25
  "submit": "Anmelden",
@@ -103,7 +103,13 @@
103
103
  "columnAdmin": "Admin",
104
104
  "editGrantTooltip": "Berechtigung bearbeiten",
105
105
  "removeGrantTooltip": "Berechtigung entfernen",
106
- "errorSave": "Berechtigungen konnten nicht gespeichert werden"
106
+ "errorSave": "Berechtigungen konnten nicht gespeichert werden",
107
+ "notFoundTitle": "Es gibt keine Rolle {roleName}",
108
+ "notFoundText": "Sie wurde vielleicht umbenannt oder gelöscht. Wählen Sie sie in der Rollenliste erneut aus.",
109
+ "removedTitle": "Recht entfernt",
110
+ "removedDescription": "{roleName} hat kein Recht mehr für {name}.",
111
+ "addedAllReadTitle": "Leserechte hinzugefügt",
112
+ "addedAllReadDescription": "{roleName} wurde keine Collection hinzugefügt. | {roleName} kann jetzt eine weitere Collection lesen. | {roleName} kann jetzt {count} weitere Collections lesen."
107
113
  },
108
114
  "collections": {
109
115
  "heading": "Collections",
@@ -355,7 +361,8 @@
355
361
  "restartNeeded": "Neustart nötig",
356
362
  "empty": "Keine Einstellungen gefunden",
357
363
  "grantHintTitle": "Ein fehlendes Recht wird mit 401 beantwortet",
358
- "grantHint": "AUTH_GRANT_DENIED_STATUS ist 401 (der Standard). Der generierte Client hält ein 401 für eine abgelaufene Sitzung, deshalb macht dieses Modul daraus selbst ein 403 und niemand wird abgemeldet. Mit AUTH_GRANT_DENIED_STATUS=403 am Server wird 403 die eigene Antwort des Servers."
364
+ "grantHint": "AUTH_GRANT_DENIED_STATUS ist 401 (der Standard). Der generierte Client hält ein 401 für eine abgelaufene Sitzung, deshalb macht dieses Modul daraus selbst ein 403 und niemand wird abgemeldet. Mit AUTH_GRANT_DENIED_STATUS=403 am Server wird 403 die eigene Antwort des Servers.",
365
+ "configurationsLabel": "Serverkonfiguration"
359
366
  },
360
367
  "databases": {
361
368
  "heading": "Datenbanken",
@@ -19,7 +19,7 @@
19
19
  "adminOnly": "This area is for administrators only."
20
20
  },
21
21
  "login": {
22
- "heading": "Mongocamp Login",
22
+ "heading": "MongoCamp Login",
23
23
  "email": "Email",
24
24
  "password": "Password",
25
25
  "submit": "Login",
@@ -103,7 +103,13 @@
103
103
  "columnAdmin": "Admin",
104
104
  "editGrantTooltip": "Edit grant",
105
105
  "removeGrantTooltip": "Remove grant",
106
- "errorSave": "Failed to save grants"
106
+ "errorSave": "Failed to save grants",
107
+ "notFoundTitle": "There is no role {roleName}",
108
+ "notFoundText": "It may have been renamed or deleted. Pick it again from the roles list.",
109
+ "removedTitle": "Grant removed",
110
+ "removedDescription": "{roleName} no longer has a grant for {name}.",
111
+ "addedAllReadTitle": "Read grants added",
112
+ "addedAllReadDescription": "No collection was added to {roleName}. | {roleName} can now read one more collection. | {roleName} can now read {count} more collections."
107
113
  },
108
114
  "collections": {
109
115
  "heading": "Collections",
@@ -355,7 +361,8 @@
355
361
  "restartNeeded": "needs restart",
356
362
  "empty": "No settings found",
357
363
  "grantHintTitle": "A missing grant is answered with 401",
358
- "grantHint": "AUTH_GRANT_DENIED_STATUS is 401 (the default). The generated client treats a 401 as a dead session, so this module turns that answer into a 403 itself and nobody is logged out. Set AUTH_GRANT_DENIED_STATUS to 403 on the server to make 403 the server's own answer."
364
+ "grantHint": "AUTH_GRANT_DENIED_STATUS is 401 (the default). The generated client treats a 401 as a dead session, so this module turns that answer into a 403 itself and nobody is logged out. Set AUTH_GRANT_DENIED_STATUS to 403 on the server to make 403 the server's own answer.",
365
+ "configurationsLabel": "Server configuration"
359
366
  },
360
367
  "databases": {
361
368
  "heading": "Databases",
@@ -0,0 +1,29 @@
1
+ /** Rows per page of the users, roles and jobs tables. */
2
+ export declare const LIST_PAGE_SIZE = 25;
3
+ /**
4
+ * Client-side paging for a `UTable` whose rows are all loaded (users, roles, jobs). The table pages its *sorted*
5
+ * rows, so a header sort still orders the whole list; row selection is kept by row id across pages, and the
6
+ * select-all box selects the page on screen. `total` is the row count after any search: a new search starts at the
7
+ * first page, and a shorter list (after a delete) never leaves the page past the end.
8
+ */
9
+ export declare function createListPagination(total: () => number, pageSize?: number): {
10
+ pagination: import("vue").Ref<{
11
+ pageIndex: number;
12
+ pageSize: number;
13
+ }, {
14
+ pageIndex: number;
15
+ pageSize: number;
16
+ } | {
17
+ pageIndex: number;
18
+ pageSize: number;
19
+ }>;
20
+ options: {
21
+ getPaginationRowModel: (table: import("@tanstack/table-core").Table<unknown>) => () => import("@tanstack/table-core").RowModel<unknown>;
22
+ };
23
+ /** 1-based, for `UPagination` */
24
+ page: import("vue").WritableComputedRef<number, number>;
25
+ /** Whether a pager is worth showing */
26
+ paged: import("vue").ComputedRef<boolean>;
27
+ reset: () => void;
28
+ pageSize: number;
29
+ };
@@ -0,0 +1,26 @@
1
+ import { computed, ref, watch } from "vue";
2
+ import { getPaginationRowModel } from "@tanstack/vue-table";
3
+ export const LIST_PAGE_SIZE = 25;
4
+ export function createListPagination(total, pageSize = LIST_PAGE_SIZE) {
5
+ const pagination = ref({ pageIndex: 0, pageSize });
6
+ const pageCount = computed(() => Math.max(1, Math.ceil(total() / pageSize)));
7
+ const goTo = (pageIndex) => {
8
+ pagination.value = { pageIndex, pageSize };
9
+ };
10
+ watch(total, (count, before) => {
11
+ if (count !== before && pagination.value.pageIndex >= pageCount.value) goTo(pageCount.value - 1);
12
+ });
13
+ return {
14
+ pagination,
15
+ options: { getPaginationRowModel: getPaginationRowModel() },
16
+ /** 1-based, for `UPagination` */
17
+ page: computed({
18
+ get: () => pagination.value.pageIndex + 1,
19
+ set: (value) => goTo(Math.min(Math.max(value, 1), pageCount.value) - 1)
20
+ }),
21
+ /** Whether a pager is worth showing */
22
+ paged: computed(() => total() > pageSize),
23
+ reset: () => goTo(0),
24
+ pageSize
25
+ };
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
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/",
@@ -69,6 +69,7 @@
69
69
  "@sfxcode/nuxt-mongocamp-server": "^1.9.1",
70
70
  "@sfxcode/nuxt-ui-formkit": "^1.4.2",
71
71
  "@tanstack/charts": "^1.5.0",
72
+ "@tanstack/vue-table": "^8.21.3",
72
73
  "consola": "^3.4.2",
73
74
  "defu": "^6.1.7",
74
75
  "minimatch": "^11.0.8",
@@ -82,12 +83,12 @@
82
83
  "@nuxt/module-builder": "^1.0.4",
83
84
  "@nuxt/schema": "^4.6.4",
84
85
  "@nuxt/test-utils": "^4.4.0",
85
- "@playwright/test": "^1.65.0",
86
+ "@playwright/test": "^1.65.1",
86
87
  "@types/node": "latest",
87
88
  "@unhead/vue": "^3.4.3",
88
89
  "@vue/test-utils": "^2.5.1",
89
90
  "changelogen": "^0.6.2",
90
- "eslint": "^10.14.0",
91
+ "eslint": "^10.15.0",
91
92
  "happy-dom": "^21.0.4",
92
93
  "nuxt": "^4.6.4",
93
94
  "typescript": "~6.0.3",