@sfxcode/nuxt-ui-mongocamp 1.3.5 → 1.5.0

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.
Files changed (224) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +6 -0
  5. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationBuilder.vue +331 -5
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  8. package/dist/runtime/components/MongocampAggregationChart.d.vue.ts +6 -0
  9. package/dist/runtime/components/MongocampAggregationChart.vue +93 -0
  10. package/dist/runtime/components/MongocampAggregationChart.vue.d.ts +6 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +10 -0
  12. package/dist/runtime/components/MongocampAggregationStagePreview.vue +149 -0
  13. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +10 -0
  14. package/dist/runtime/components/MongocampBucketFiles.vue +230 -48
  15. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +9 -0
  16. package/dist/runtime/components/MongocampBulkDelete.vue +94 -25
  17. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +9 -0
  18. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +5 -0
  19. package/dist/runtime/components/MongocampBulkEdit.vue +41 -3
  20. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +5 -0
  21. package/dist/runtime/components/MongocampChart.d.vue.ts +29 -0
  22. package/dist/runtime/components/MongocampChart.vue +129 -0
  23. package/dist/runtime/components/MongocampChart.vue.d.ts +29 -0
  24. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +17 -0
  25. package/dist/runtime/components/MongocampCollectionCharts.vue +200 -0
  26. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +17 -0
  27. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +23 -0
  28. package/dist/runtime/components/MongocampCollectionCopy.vue +206 -0
  29. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +23 -0
  30. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +6 -0
  31. package/dist/runtime/components/MongocampCollectionData.vue +423 -138
  32. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +6 -0
  33. package/dist/runtime/components/MongocampCollectionInfos.vue +106 -238
  34. package/dist/runtime/components/MongocampCollectionRename.d.vue.ts +22 -0
  35. package/dist/runtime/components/MongocampCollectionRename.vue +116 -0
  36. package/dist/runtime/components/MongocampCollectionRename.vue.d.ts +22 -0
  37. package/dist/runtime/components/MongocampCollections.vue +93 -12
  38. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +40 -0
  39. package/dist/runtime/components/MongocampCommandPalette.vue +135 -0
  40. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +40 -0
  41. package/dist/runtime/components/MongocampConfirmByName.vue +2 -2
  42. package/dist/runtime/components/MongocampDashboard.d.vue.ts +3 -1
  43. package/dist/runtime/components/MongocampDashboard.vue +39 -5
  44. package/dist/runtime/components/MongocampDashboard.vue.d.ts +3 -1
  45. package/dist/runtime/components/MongocampDatabases.vue +35 -2
  46. package/dist/runtime/components/MongocampDocumentCompare.d.vue.ts +20 -0
  47. package/dist/runtime/components/MongocampDocumentCompare.vue +146 -0
  48. package/dist/runtime/components/MongocampDocumentCompare.vue.d.ts +20 -0
  49. package/dist/runtime/components/MongocampDocumentView.d.vue.ts +22 -0
  50. package/dist/runtime/components/MongocampDocumentView.vue +202 -0
  51. package/dist/runtime/components/MongocampDocumentView.vue.d.ts +22 -0
  52. package/dist/runtime/components/MongocampErrorAlert.vue +12 -4
  53. package/dist/runtime/components/MongocampExportAll.d.vue.ts +18 -0
  54. package/dist/runtime/components/MongocampExportAll.vue +191 -0
  55. package/dist/runtime/components/MongocampExportAll.vue.d.ts +18 -0
  56. package/dist/runtime/components/MongocampFilePreview.d.vue.ts +16 -0
  57. package/dist/runtime/components/MongocampFilePreview.vue +162 -0
  58. package/dist/runtime/components/MongocampFilePreview.vue.d.ts +16 -0
  59. package/dist/runtime/components/MongocampFilterBuilder.vue +11 -0
  60. package/dist/runtime/components/MongocampImport.vue +171 -13
  61. package/dist/runtime/components/MongocampIndexes.d.vue.ts +18 -0
  62. package/dist/runtime/components/MongocampIndexes.vue +496 -0
  63. package/dist/runtime/components/MongocampIndexes.vue.d.ts +18 -0
  64. package/dist/runtime/components/MongocampJobs.d.vue.ts +6 -1
  65. package/dist/runtime/components/MongocampJobs.vue +36 -5
  66. package/dist/runtime/components/MongocampJobs.vue.d.ts +6 -1
  67. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +12 -0
  68. package/dist/runtime/components/MongocampPermissionMatrix.vue +301 -0
  69. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +12 -0
  70. package/dist/runtime/components/MongocampQueryBar.d.vue.ts +26 -0
  71. package/dist/runtime/components/MongocampQueryBar.vue +398 -0
  72. package/dist/runtime/components/MongocampQueryBar.vue.d.ts +26 -0
  73. package/dist/runtime/components/MongocampRoleGrants.vue +18 -5
  74. package/dist/runtime/components/MongocampRoles.vue +16 -5
  75. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +20 -0
  76. package/dist/runtime/components/MongocampServerOverview.vue +420 -0
  77. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +20 -0
  78. package/dist/runtime/components/MongocampSettings.d.vue.ts +28 -1
  79. package/dist/runtime/components/MongocampSettings.vue +83 -10
  80. package/dist/runtime/components/MongocampSettings.vue.d.ts +28 -1
  81. package/dist/runtime/components/MongocampUsers.vue +19 -6
  82. package/dist/runtime/composables/useMongocampAdmin.d.ts +2 -1
  83. package/dist/runtime/composables/useMongocampAdmin.js +6 -1
  84. package/dist/runtime/composables/useMongocampAdminGate.d.ts +12 -0
  85. package/dist/runtime/composables/useMongocampAdminGate.js +12 -0
  86. package/dist/runtime/composables/useMongocampAggregation.d.ts +23 -1
  87. package/dist/runtime/composables/useMongocampAggregation.js +41 -26
  88. package/dist/runtime/composables/useMongocampAutoRefresh.d.ts +26 -0
  89. package/dist/runtime/composables/useMongocampAutoRefresh.js +78 -0
  90. package/dist/runtime/composables/useMongocampBucket.d.ts +13 -1
  91. package/dist/runtime/composables/useMongocampBucket.js +34 -0
  92. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +15 -0
  93. package/dist/runtime/composables/useMongocampBulkByFilter.js +32 -0
  94. package/dist/runtime/composables/useMongocampClientApi.js +2 -1
  95. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +45 -0
  96. package/dist/runtime/composables/useMongocampCollectionCopy.js +48 -0
  97. package/dist/runtime/composables/useMongocampCollectionStats.d.ts +10 -0
  98. package/dist/runtime/composables/useMongocampCollectionStats.js +17 -0
  99. package/dist/runtime/composables/useMongocampError.d.ts +2 -1
  100. package/dist/runtime/composables/useMongocampError.js +16 -1
  101. package/dist/runtime/composables/useMongocampExportAll.d.ts +53 -0
  102. package/dist/runtime/composables/useMongocampExportAll.js +57 -0
  103. package/dist/runtime/composables/useMongocampExtendedJson.d.ts +7 -2
  104. package/dist/runtime/composables/useMongocampExtendedJson.js +44 -11
  105. package/dist/runtime/composables/useMongocampFetchAll.d.ts +25 -0
  106. package/dist/runtime/composables/useMongocampFetchAll.js +27 -0
  107. package/dist/runtime/composables/useMongocampFieldTypes.d.ts +24 -0
  108. package/dist/runtime/composables/useMongocampFieldTypes.js +44 -0
  109. package/dist/runtime/composables/useMongocampImport.d.ts +4 -0
  110. package/dist/runtime/composables/useMongocampImport.js +5 -2
  111. package/dist/runtime/composables/useMongocampIndex.d.ts +6 -1
  112. package/dist/runtime/composables/useMongocampIndex.js +7 -1
  113. package/dist/runtime/composables/useMongocampPermissions.d.ts +17 -0
  114. package/dist/runtime/composables/useMongocampPermissions.js +43 -0
  115. package/dist/runtime/composables/useMongocampPersistedState.d.ts +15 -0
  116. package/dist/runtime/composables/useMongocampPersistedState.js +21 -0
  117. package/dist/runtime/composables/useMongocampProxyApi.js +2 -1
  118. package/dist/runtime/composables/useMongocampQuery.d.ts +50 -2
  119. package/dist/runtime/composables/useMongocampQuery.js +72 -1
  120. package/dist/runtime/composables/useMongocampSavedPipelines.d.ts +25 -0
  121. package/dist/runtime/composables/useMongocampSavedPipelines.js +23 -0
  122. package/dist/runtime/composables/useMongocampSavedQueries.d.ts +37 -0
  123. package/dist/runtime/composables/useMongocampSavedQueries.js +50 -0
  124. package/dist/runtime/composables/useMongocampServerOverview.d.ts +35 -0
  125. package/dist/runtime/composables/useMongocampServerOverview.js +51 -0
  126. package/dist/runtime/composables/useMongocampSession.d.ts +2 -0
  127. package/dist/runtime/composables/useMongocampSession.js +16 -2
  128. package/dist/runtime/composables/useMongocampSystem.d.ts +7 -2
  129. package/dist/runtime/composables/useMongocampSystem.js +6 -2
  130. package/dist/runtime/locales/de.json +509 -25
  131. package/dist/runtime/locales/en.json +509 -25
  132. package/dist/runtime/plugin.js +6 -3
  133. package/dist/runtime/utils/aggregationErrors.d.ts +4 -0
  134. package/dist/runtime/utils/aggregationErrors.js +7 -0
  135. package/dist/runtime/utils/aggregationPipeline.d.ts +5 -4
  136. package/dist/runtime/utils/aggregationPipeline.js +23 -9
  137. package/dist/runtime/utils/aggregationPreview.d.ts +13 -0
  138. package/dist/runtime/utils/aggregationPreview.js +10 -0
  139. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  140. package/dist/runtime/utils/aggregationResult.js +4 -0
  141. package/dist/runtime/utils/aggregationTemplates.d.ts +34 -0
  142. package/dist/runtime/utils/aggregationTemplates.js +47 -0
  143. package/dist/runtime/utils/analyzeSamples.d.ts +1 -0
  144. package/dist/runtime/utils/analyzeSamples.js +1 -1
  145. package/dist/runtime/utils/autoRefresh.d.ts +14 -0
  146. package/dist/runtime/utils/autoRefresh.js +15 -0
  147. package/dist/runtime/utils/batchInsert.d.ts +6 -0
  148. package/dist/runtime/utils/batchInsert.js +31 -3
  149. package/dist/runtime/utils/bigIntJson.d.ts +15 -0
  150. package/dist/runtime/utils/bigIntJson.js +55 -0
  151. package/dist/runtime/utils/bsonTypes.d.ts +10 -0
  152. package/dist/runtime/utils/bsonTypes.js +42 -0
  153. package/dist/runtime/utils/bulkDelete.d.ts +9 -1
  154. package/dist/runtime/utils/bulkDelete.js +15 -3
  155. package/dist/runtime/utils/bulkEdit.d.ts +6 -0
  156. package/dist/runtime/utils/bulkEdit.js +7 -0
  157. package/dist/runtime/utils/chartData.d.ts +11 -0
  158. package/dist/runtime/utils/chartData.js +9 -0
  159. package/dist/runtime/utils/collectionChart.d.ts +36 -0
  160. package/dist/runtime/utils/collectionChart.js +73 -0
  161. package/dist/runtime/utils/collectionCopy.d.ts +24 -0
  162. package/dist/runtime/utils/collectionCopy.js +37 -0
  163. package/dist/runtime/utils/collectionStats.d.ts +31 -0
  164. package/dist/runtime/utils/collectionStats.js +42 -0
  165. package/dist/runtime/utils/commandPalette.d.ts +48 -0
  166. package/dist/runtime/utils/commandPalette.js +39 -0
  167. package/dist/runtime/utils/configRows.d.ts +7 -0
  168. package/dist/runtime/utils/configRows.js +4 -0
  169. package/dist/runtime/utils/documentCompare.d.ts +31 -0
  170. package/dist/runtime/utils/documentCompare.js +71 -0
  171. package/dist/runtime/utils/documentDiff.d.ts +19 -0
  172. package/dist/runtime/utils/documentDiff.js +71 -0
  173. package/dist/runtime/utils/documentPaths.d.ts +41 -0
  174. package/dist/runtime/utils/documentPaths.js +139 -0
  175. package/dist/runtime/utils/documentTree.d.ts +40 -0
  176. package/dist/runtime/utils/documentTree.js +102 -0
  177. package/dist/runtime/utils/exportDocuments.d.ts +33 -0
  178. package/dist/runtime/utils/exportDocuments.js +53 -0
  179. package/dist/runtime/utils/exportRows.d.ts +2 -0
  180. package/dist/runtime/utils/exportRows.js +6 -3
  181. package/dist/runtime/utils/fieldDetails.d.ts +51 -0
  182. package/dist/runtime/utils/fieldDetails.js +113 -0
  183. package/dist/runtime/utils/filePreview.d.ts +27 -0
  184. package/dist/runtime/utils/filePreview.js +50 -0
  185. package/dist/runtime/utils/filterBuilder.d.ts +6 -1
  186. package/dist/runtime/utils/filterBuilder.js +6 -5
  187. package/dist/runtime/utils/formatBytes.d.ts +2 -0
  188. package/dist/runtime/utils/formatBytes.js +11 -0
  189. package/dist/runtime/utils/grantMatching.d.ts +8 -0
  190. package/dist/runtime/utils/grantMatching.js +15 -0
  191. package/dist/runtime/utils/importRows.js +12 -2
  192. package/dist/runtime/utils/indexForm.d.ts +83 -0
  193. package/dist/runtime/utils/indexForm.js +74 -0
  194. package/dist/runtime/utils/luceneExpression.d.ts +15 -0
  195. package/dist/runtime/utils/luceneExpression.js +74 -0
  196. package/dist/runtime/utils/pagedFetch.d.ts +46 -0
  197. package/dist/runtime/utils/pagedFetch.js +58 -0
  198. package/dist/runtime/utils/paginationHeaders.d.ts +4 -0
  199. package/dist/runtime/utils/paginationHeaders.js +4 -0
  200. package/dist/runtime/utils/permissionDenied.d.ts +10 -0
  201. package/dist/runtime/utils/permissionDenied.js +23 -0
  202. package/dist/runtime/utils/permissionMatrix.d.ts +55 -0
  203. package/dist/runtime/utils/permissionMatrix.js +85 -0
  204. package/dist/runtime/utils/persistedState.d.ts +25 -0
  205. package/dist/runtime/utils/persistedState.js +47 -0
  206. package/dist/runtime/utils/queryState.d.ts +45 -0
  207. package/dist/runtime/utils/queryState.js +75 -0
  208. package/dist/runtime/utils/requestLimits.d.ts +2 -0
  209. package/dist/runtime/utils/requestLimits.js +4 -0
  210. package/dist/runtime/utils/resultChart.d.ts +32 -0
  211. package/dist/runtime/utils/resultChart.js +59 -0
  212. package/dist/runtime/utils/savedPipelines.d.ts +22 -0
  213. package/dist/runtime/utils/savedPipelines.js +46 -0
  214. package/dist/runtime/utils/savedQueries.d.ts +60 -0
  215. package/dist/runtime/utils/savedQueries.js +143 -0
  216. package/dist/runtime/utils/schemaAnalysis.d.ts +16 -0
  217. package/dist/runtime/utils/schemaAnalysis.js +57 -0
  218. package/dist/runtime/utils/serverError.d.ts +19 -0
  219. package/dist/runtime/utils/serverError.js +19 -0
  220. package/dist/runtime/utils/serverOverview.d.ts +47 -0
  221. package/dist/runtime/utils/serverOverview.js +40 -0
  222. package/dist/runtime/utils/sessionGuard.d.ts +3 -0
  223. package/dist/runtime/utils/sessionGuard.js +18 -1
  224. package/package.json +15 -14
@@ -0,0 +1,301 @@
1
+ <script setup>
2
+ import { computed, ref } from "vue";
3
+ import { useI18n } from "#imports";
4
+ import useMongocampAdmin from "../composables/useMongocampAdmin";
5
+ import {
6
+ buildPermissionMatrix,
7
+ cellLetters,
8
+ collectionsNobodyCan,
9
+ filterMatrix,
10
+ matrixToCsvRows,
11
+ QUICK_VIEWS,
12
+ usersWithoutRoles
13
+ } from "../utils/permissionMatrix";
14
+ import { downloadTextFile, rowsToCsv } from "../utils/exportRows";
15
+ import { isBucketMemberCollection } from "../utils/collectionProtection";
16
+ const props = defineProps({
17
+ grantsPath: { type: String, required: false, default: "/secured/admin/roles" },
18
+ maxCollections: { type: Number, required: false, default: 60 },
19
+ maxUsers: { type: Number, required: false, default: 200 }
20
+ });
21
+ const { t } = useI18n();
22
+ const { listUsers, listRoles, listCollections } = useMongocampAdmin();
23
+ const matrix = ref(null);
24
+ const roleNames = ref([]);
25
+ const loading = ref(false);
26
+ const loadError = ref(null);
27
+ async function load() {
28
+ loading.value = true;
29
+ loadError.value = null;
30
+ try {
31
+ const [users2, roles, collections2] = await Promise.all([listUsers(), listRoles(), listCollections()]);
32
+ matrix.value = buildPermissionMatrix(users2, roles, collections2.filter((name) => !name.startsWith("mc_")));
33
+ roleNames.value = roles.map((role2) => role2.name).sort((a, b) => a.localeCompare(b));
34
+ } catch (e) {
35
+ loadError.value = e;
36
+ matrix.value = null;
37
+ } finally {
38
+ loading.value = false;
39
+ }
40
+ }
41
+ void load();
42
+ const ALL_ROLES = "__all__";
43
+ const text = ref("");
44
+ const role = ref(ALL_ROLES);
45
+ const view = ref("all");
46
+ const swapped = ref(false);
47
+ const filter = computed(() => ({ text: text.value, role: role.value === ALL_ROLES ? void 0 : role.value, view: view.value }));
48
+ const shown = computed(() => matrix.value ? filterMatrix(matrix.value, filter.value) : null);
49
+ const users = computed(() => shown.value?.users.slice(0, props.maxUsers) ?? []);
50
+ const collections = computed(() => shown.value?.collections.slice(0, props.maxCollections) ?? []);
51
+ const roleItems = computed(() => [{ value: ALL_ROLES, label: t("nuxtUiMongocamp.permissionMatrix.roleAll") }, ...roleNames.value.map((name) => ({ value: name, label: name }))]);
52
+ const viewCounts = computed(() => {
53
+ const m = matrix.value;
54
+ if (!m) return { "all": void 0, "users-without-roles": void 0, "collections-nobody-writes": void 0, "collections-nobody-reads": void 0 };
55
+ return {
56
+ "all": void 0,
57
+ "users-without-roles": usersWithoutRoles(m).length,
58
+ "collections-nobody-writes": collectionsNobodyCan(m, "write").length,
59
+ "collections-nobody-reads": collectionsNobodyCan(m, "read").length
60
+ };
61
+ });
62
+ const VIEW_KEYS = { "all": "viewAll", "users-without-roles": "viewNoRoles", "collections-nobody-writes": "viewNobodyWrites", "collections-nobody-reads": "viewNobodyReads" };
63
+ const viewLabel = (v) => t(`nuxtUiMongocamp.permissionMatrix.${VIEW_KEYS[v]}`);
64
+ function cellOf(userName, collection) {
65
+ return matrix.value?.cells[userName]?.[collection];
66
+ }
67
+ function cellTitle(cell) {
68
+ if (cell.admin) return t("nuxtUiMongocamp.permissionMatrix.cellAdmin");
69
+ const allowed = ["read", "write", "administrate"].filter((p) => cell[p] === true).map((p) => t(`nuxtUiMongocamp.permissionMatrix.cell${p.charAt(0).toUpperCase()}${p.slice(1)}`));
70
+ if (cell.read === void 0 && cell.write === void 0 && cell.administrate === void 0) return t("nuxtUiMongocamp.permissionMatrix.cellUnknown");
71
+ if (allowed.length === 0) return t("nuxtUiMongocamp.permissionMatrix.cellNone");
72
+ const via = cell.via.length > 0 ? t("nuxtUiMongocamp.permissionMatrix.via", { roles: cell.via.join(", ") }) : t("nuxtUiMongocamp.permissionMatrix.viaDirect");
73
+ return `${allowed.join(", ")} \u2014 ${via}`;
74
+ }
75
+ function cellClass(cell) {
76
+ if (cell.admin) return "font-semibold text-highlighted";
77
+ const any = cell.read === true || cell.write === true || cell.administrate === true;
78
+ return any ? "text-default" : "text-dimmed";
79
+ }
80
+ const rowLabels = computed(() => swapped.value ? collections.value : users.value.map((u) => u.name));
81
+ const columnLabels = computed(() => swapped.value ? users.value.map((u) => u.name) : collections.value);
82
+ function cellAtRowColumn(row, column) {
83
+ return swapped.value ? cellOf(column, row) : cellOf(row, column);
84
+ }
85
+ const userByName = computed(() => new Map((matrix.value?.users ?? []).map((u) => [u.name, u])));
86
+ const hasBucketParts = computed(() => collections.value.some(isBucketMemberCollection));
87
+ function exportCsv() {
88
+ if (!shown.value) return;
89
+ const { keys, rows } = matrixToCsvRows({ ...shown.value, users: users.value, collections: collections.value });
90
+ downloadTextFile(`permissions-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`, rowsToCsv(rows, keys), "text/csv");
91
+ }
92
+ </script>
93
+
94
+ <template>
95
+ <div
96
+ class="flex flex-col gap-4"
97
+ data-test="permission-matrix"
98
+ >
99
+ <div class="flex flex-wrap items-start justify-between gap-2">
100
+ <div class="flex flex-col gap-1">
101
+ <h2 class="text-xl font-semibold">
102
+ {{ t("nuxtUiMongocamp.permissionMatrix.heading") }}
103
+ </h2>
104
+ <p class="text-sm text-dimmed">
105
+ {{ t("nuxtUiMongocamp.permissionMatrix.subtitle") }}
106
+ </p>
107
+ </div>
108
+ <div class="flex items-center gap-1">
109
+ <UButton
110
+ icon="i-lucide-arrow-left-right"
111
+ color="neutral"
112
+ variant="ghost"
113
+ :aria-pressed="swapped"
114
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.swap')"
115
+ :disabled="!matrix"
116
+ @click="swapped = !swapped"
117
+ />
118
+ <UButton
119
+ icon="i-lucide-download"
120
+ color="neutral"
121
+ variant="ghost"
122
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.exportCsv')"
123
+ :disabled="!shown || users.length === 0 || collections.length === 0"
124
+ @click="exportCsv"
125
+ />
126
+ <UButton
127
+ icon="i-lucide-refresh-cw"
128
+ color="neutral"
129
+ variant="ghost"
130
+ :loading="loading"
131
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.refresh')"
132
+ @click="load"
133
+ />
134
+ </div>
135
+ </div>
136
+
137
+ <MongocampErrorAlert
138
+ :error="loadError"
139
+ @retry="load"
140
+ />
141
+
142
+ <template v-if="matrix">
143
+ <div class="flex flex-wrap items-center gap-2">
144
+ <UInput
145
+ v-model="text"
146
+ icon="i-lucide-search"
147
+ size="sm"
148
+ class="w-64"
149
+ :placeholder="t('nuxtUiMongocamp.permissionMatrix.filterPlaceholder')"
150
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.filterPlaceholder')"
151
+ />
152
+ <USelect
153
+ v-model="role"
154
+ :items="roleItems"
155
+ size="sm"
156
+ class="w-44"
157
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.roleLabel')"
158
+ />
159
+ <div
160
+ class="flex flex-wrap items-center gap-1"
161
+ role="group"
162
+ :aria-label="t('nuxtUiMongocamp.permissionMatrix.viewLabel')"
163
+ >
164
+ <UButton
165
+ v-for="v in QUICK_VIEWS"
166
+ :key="v"
167
+ size="xs"
168
+ color="neutral"
169
+ :variant="view === v ? 'subtle' : 'ghost'"
170
+ :aria-pressed="view === v"
171
+ :label="viewCounts[v] === void 0 ? viewLabel(v) : `${viewLabel(v)} (${viewCounts[v]})`"
172
+ :data-test="`view-${v}`"
173
+ @click="view = v"
174
+ />
175
+ </div>
176
+ </div>
177
+
178
+ <p class="text-xs text-dimmed">
179
+ <span data-test="matrix-summary">{{ t("nuxtUiMongocamp.permissionMatrix.summary", { users: users.length, collections: collections.length }) }}</span>
180
+ · {{ t("nuxtUiMongocamp.permissionMatrix.legend") }}
181
+ </p>
182
+ <p
183
+ v-if="view === 'collections-nobody-writes' || view === 'collections-nobody-reads'"
184
+ class="text-xs text-dimmed"
185
+ >
186
+ {{ t("nuxtUiMongocamp.permissionMatrix.nobodyNote") }}
187
+ </p>
188
+ <p
189
+ v-if="shown && shown.collections.length > collections.length"
190
+ class="text-sm text-warning"
191
+ data-test="capped-collections"
192
+ >
193
+ {{ t("nuxtUiMongocamp.permissionMatrix.cappedCollections", { shown: collections.length, total: shown.collections.length }) }}
194
+ </p>
195
+ <p
196
+ v-if="shown && shown.users.length > users.length"
197
+ class="text-sm text-warning"
198
+ data-test="capped-users"
199
+ >
200
+ {{ t("nuxtUiMongocamp.permissionMatrix.cappedUsers", { shown: users.length, total: shown.users.length }) }}
201
+ </p>
202
+
203
+ <p
204
+ v-if="matrix.users.length === 0 && matrix.collections.length === 0"
205
+ class="text-sm text-dimmed"
206
+ >
207
+ {{ t("nuxtUiMongocamp.permissionMatrix.nothingLoaded") }}
208
+ </p>
209
+ <p
210
+ v-else-if="rowLabels.length === 0 || columnLabels.length === 0"
211
+ class="text-sm text-dimmed"
212
+ data-test="matrix-empty"
213
+ >
214
+ {{ users.length === 0 ? t("nuxtUiMongocamp.permissionMatrix.noUsers") : t("nuxtUiMongocamp.permissionMatrix.noCollections") }}
215
+ </p>
216
+ <div
217
+ v-else
218
+ class="overflow-auto rounded-md border border-default"
219
+ >
220
+ <table
221
+ class="w-max min-w-full border-collapse text-sm"
222
+ data-test="matrix-table"
223
+ >
224
+ <thead>
225
+ <tr class="bg-elevated/50">
226
+ <th class="sticky left-0 z-10 bg-default px-3 py-2 text-left font-medium">
227
+ {{ swapped ? t("nuxtUiMongocamp.permissionMatrix.columnCollection") : t("nuxtUiMongocamp.permissionMatrix.columnUser") }}
228
+ </th>
229
+ <th
230
+ v-for="column in columnLabels"
231
+ :key="column"
232
+ class="max-w-40 truncate px-2 py-2 text-center font-medium"
233
+ :title="column"
234
+ scope="col"
235
+ >
236
+ {{ column }}
237
+ </th>
238
+ </tr>
239
+ </thead>
240
+ <tbody>
241
+ <tr
242
+ v-for="row in rowLabels"
243
+ :key="row"
244
+ class="border-t border-default"
245
+ :data-row="row"
246
+ >
247
+ <th
248
+ class="sticky left-0 z-10 bg-default px-3 py-1.5 text-left font-medium"
249
+ scope="row"
250
+ >
251
+ <div class="flex flex-wrap items-center gap-1">
252
+ <span>{{ row }}</span>
253
+ <template v-if="!swapped && userByName.get(row)">
254
+ <UBadge
255
+ v-if="userByName.get(row).admin"
256
+ :label="t('nuxtUiMongocamp.permissionMatrix.adminBadge')"
257
+ color="primary"
258
+ variant="subtle"
259
+ size="sm"
260
+ />
261
+ <NuxtLink
262
+ v-for="roleName in userByName.get(row).roles"
263
+ :key="roleName"
264
+ :to="`${grantsPath}/${roleName}`"
265
+ class="rounded bg-elevated px-1.5 py-0.5 text-xs hover:underline"
266
+ :class="userByName.get(row).unknownRoles.includes(roleName) ? 'text-warning' : 'text-dimmed'"
267
+ :title="userByName.get(row).unknownRoles.includes(roleName) ? t('nuxtUiMongocamp.permissionMatrix.unknownRoleNote') : t('nuxtUiMongocamp.permissionMatrix.openRole', { role: roleName })"
268
+ >
269
+ {{ roleName }}
270
+ </NuxtLink>
271
+ </template>
272
+ </div>
273
+ </th>
274
+ <td
275
+ v-for="column in columnLabels"
276
+ :key="column"
277
+ class="px-2 py-1.5 text-center"
278
+ >
279
+ <template v-if="cellAtRowColumn(row, column)">
280
+ <span
281
+ class="font-mono text-xs"
282
+ :class="cellClass(cellAtRowColumn(row, column))"
283
+ :title="cellTitle(cellAtRowColumn(row, column))"
284
+ :data-cell="`${swapped ? column : row}|${swapped ? row : column}`"
285
+ >{{ cellLetters(cellAtRowColumn(row, column)) }}</span>
286
+ <span class="sr-only">{{ cellTitle(cellAtRowColumn(row, column)) }}</span>
287
+ </template>
288
+ </td>
289
+ </tr>
290
+ </tbody>
291
+ </table>
292
+ </div>
293
+ <p
294
+ v-if="hasBucketParts"
295
+ class="text-xs text-dimmed"
296
+ >
297
+ {{ t("nuxtUiMongocamp.permissionMatrix.bucketNote") }}
298
+ </p>
299
+ </template>
300
+ </div>
301
+ </template>
@@ -0,0 +1,12 @@
1
+ type __VLS_Props = {
2
+ grantsPath?: string;
3
+ maxCollections?: number;
4
+ maxUsers?: number;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
7
+ grantsPath: string;
8
+ maxCollections: number;
9
+ maxUsers: number;
10
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import type { FilterFieldType } from '../utils/filterBuilder.js';
2
+ import type { QueryState } from '../utils/queryState.js';
3
+ type __VLS_Props = {
4
+ fields: {
5
+ key: string;
6
+ type: FilterFieldType;
7
+ }[];
8
+ columns: string[];
9
+ collection: string;
10
+ loadDistinct?: (field: string) => Promise<string[]>;
11
+ };
12
+ type __VLS_ModelProps = {
13
+ modelValue: QueryState;
14
+ };
15
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
16
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
17
+ closePanel: () => boolean;
18
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (value: QueryState) => any;
20
+ apply: (state: QueryState) => any;
21
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
+ "onUpdate:modelValue"?: ((value: QueryState) => any) | undefined;
23
+ onApply?: ((state: QueryState) => any) | undefined;
24
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
+ declare const _default: typeof __VLS_export;
26
+ export default _default;