@attraccess/plugin-rabbitmq 0.1.0-nightly.1166.1 → 0.1.0-nightly.1188.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,14 @@
1
+ # Lizenz von @attraccess/plugin-rabbitmq
2
+
3
+ Copyright (c) 2025 Jan Jaap (Github: JappyJan, E-Mail: mail@janjaap.de)
4
+ Project: Attraccess
5
+
6
+ Dieses Plugin hat keine eigene Lizenz. Es steht unter der Lizenz des Attraccess-Kerns, der **Prosperity Public License 3.0 – Modified Version**. Der vollständige Text steht in der Datei [LICENSE.md im Repository-Stamm](https://github.com/Attraccess/Attraccess/blob/main/LICENSE.md).
7
+
8
+ Kurz zusammengefasst (maßgeblich ist allein der Text der Kernlizenz):
9
+
10
+ - Kostenlos für Privatpersonen und gemeinnützige Organisationen, für nicht-kommerzielle Zwecke.
11
+ - Kommerzielle Nutzer dürfen 30 Tage kostenlos evaluieren, danach ist eine kommerzielle Lizenz erforderlich.
12
+ - Forks und abgeleitete Werke nur unter exakt denselben Lizenzbedingungen.
13
+
14
+ Für kommerzielle Lizenzen: [contact@attraccess.org](mailto:contact@attraccess.org)
package/dist/index.js CHANGED
@@ -33,17 +33,50 @@ __export(plugin_exports, {
33
33
  default: () => plugin_default
34
34
  });
35
35
  module.exports = __toCommonJS(plugin_exports);
36
- var import_plugins_backend_sdk6 = require("@attraccess/plugins-backend-sdk");
36
+ var import_plugins_backend_sdk7 = require("@attraccess/plugins-backend-sdk");
37
37
  var import_common9 = require("@nestjs/common");
38
38
 
39
39
  // backend/detection/service.ts
40
- var import_plugins_backend_sdk = require("@attraccess/plugins-backend-sdk");
40
+ var import_plugins_backend_sdk2 = require("@attraccess/plugins-backend-sdk");
41
41
  var import_common = require("@nestjs/common");
42
42
  var import_node_crypto2 = require("node:crypto");
43
43
 
44
44
  // backend/permissions.ts
45
- var RABBITMQ_VIEW_PERMISSION = "resources.update";
46
- var RABBITMQ_MANAGE_PERMISSION = "system.settings.manage";
45
+ var import_plugins_backend_sdk = require("@attraccess/plugins-backend-sdk");
46
+
47
+ // backend/permission-keys.ts
48
+ var RABBITMQ_BROKER_READ = "rabbitmq.broker.read";
49
+ var RABBITMQ_BROKER_MANAGE = "rabbitmq.broker.manage";
50
+
51
+ // backend/permissions.ts
52
+ var RABBITMQ_PERMISSIONS = (0, import_plugins_backend_sdk.definePluginPermissions)({
53
+ category: { en: "RabbitMQ", de: "RabbitMQ" },
54
+ permissions: [
55
+ {
56
+ // View tier — detection/status, user list, connections list and broker stats.
57
+ key: RABBITMQ_BROKER_READ,
58
+ label: { en: "View RabbitMQ broker", de: "RabbitMQ-Broker anzeigen" },
59
+ description: {
60
+ en: "View the RabbitMQ detection, broker users, connections and statistics",
61
+ de: "RabbitMQ-Erkennung, Broker-Benutzer, Verbindungen und Statistiken anzeigen"
62
+ },
63
+ defaultRoles: ["administrator", "resource-manager", "system-admin"]
64
+ },
65
+ {
66
+ // Manage tier — everything that changes the broker: user create/update/delete, permissions and closing
67
+ // connections. The live MQTT message explorer is not part of the plugin: it is a core feature for every broker.
68
+ key: RABBITMQ_BROKER_MANAGE,
69
+ label: { en: "Manage RabbitMQ broker", de: "RabbitMQ-Broker verwalten" },
70
+ description: {
71
+ en: "Create, change and delete broker users and their permissions, and close connections",
72
+ de: "Broker-Benutzer und deren Berechtigungen anlegen, \xE4ndern und l\xF6schen sowie Verbindungen schlie\xDFen"
73
+ },
74
+ defaultRoles: ["administrator", "system-admin"]
75
+ }
76
+ ]
77
+ });
78
+ var RABBITMQ_VIEW_PERMISSION = RABBITMQ_PERMISSIONS.keys[RABBITMQ_BROKER_READ];
79
+ var RABBITMQ_MANAGE_PERMISSION = RABBITMQ_PERMISSIONS.keys[RABBITMQ_BROKER_MANAGE];
47
80
 
48
81
  // backend/management/transport.ts
49
82
  var import_node_crypto = require("node:crypto");
@@ -319,7 +352,7 @@ __decorateClass([
319
352
  __decorateParam(1, (0, import_common.Query)("refresh"))
320
353
  ], RabbitmqDetectionController.prototype, "detect", 1);
321
354
  RabbitmqDetectionController = __decorateClass([
322
- (0, import_plugins_backend_sdk.Auth)(RABBITMQ_VIEW_PERMISSION),
355
+ (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_VIEW_PERMISSION),
323
356
  (0, import_common.Controller)("rabbitmq"),
324
357
  __decorateParam(0, (0, import_common.Inject)(RabbitmqDetectionService))
325
358
  ], RabbitmqDetectionController);
@@ -410,7 +443,7 @@ RabbitmqManagementClient = __decorateClass([
410
443
  ], RabbitmqManagementClient);
411
444
 
412
445
  // backend/users/service.ts
413
- var import_plugins_backend_sdk2 = require("@attraccess/plugins-backend-sdk");
446
+ var import_plugins_backend_sdk3 = require("@attraccess/plugins-backend-sdk");
414
447
  var import_common4 = require("@nestjs/common");
415
448
 
416
449
  // backend/management/config.ts
@@ -600,32 +633,32 @@ var RabbitmqUsersController = class {
600
633
  }
601
634
  };
602
635
  __decorateClass([
603
- (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_VIEW_PERMISSION),
636
+ (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_VIEW_PERMISSION),
604
637
  (0, import_common4.Get)("users/:mqttServerId"),
605
638
  __decorateParam(0, (0, import_common4.Param)("mqttServerId", import_common4.ParseIntPipe))
606
639
  ], RabbitmqUsersController.prototype, "list", 1);
607
640
  __decorateClass([
608
- (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_MANAGE_PERMISSION),
641
+ (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_MANAGE_PERMISSION),
609
642
  (0, import_common4.Put)("users/:mqttServerId/:username"),
610
643
  __decorateParam(0, (0, import_common4.Param)("mqttServerId", import_common4.ParseIntPipe)),
611
644
  __decorateParam(1, (0, import_common4.Param)("username")),
612
645
  __decorateParam(2, (0, import_common4.Body)())
613
646
  ], RabbitmqUsersController.prototype, "upsert", 1);
614
647
  __decorateClass([
615
- (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_MANAGE_PERMISSION),
648
+ (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_MANAGE_PERMISSION),
616
649
  (0, import_common4.Delete)("users/:mqttServerId/:username"),
617
650
  __decorateParam(0, (0, import_common4.Param)("mqttServerId", import_common4.ParseIntPipe)),
618
651
  __decorateParam(1, (0, import_common4.Param)("username"))
619
652
  ], RabbitmqUsersController.prototype, "remove", 1);
620
653
  __decorateClass([
621
- (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_MANAGE_PERMISSION),
654
+ (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_MANAGE_PERMISSION),
622
655
  (0, import_common4.Put)("users/:mqttServerId/:username/permissions"),
623
656
  __decorateParam(0, (0, import_common4.Param)("mqttServerId", import_common4.ParseIntPipe)),
624
657
  __decorateParam(1, (0, import_common4.Param)("username")),
625
658
  __decorateParam(2, (0, import_common4.Body)())
626
659
  ], RabbitmqUsersController.prototype, "setPermissions", 1);
627
660
  __decorateClass([
628
- (0, import_plugins_backend_sdk2.Auth)(RABBITMQ_MANAGE_PERMISSION),
661
+ (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_MANAGE_PERMISSION),
629
662
  (0, import_common4.Delete)("users/:mqttServerId/:username/permissions"),
630
663
  __decorateParam(0, (0, import_common4.Param)("mqttServerId", import_common4.ParseIntPipe)),
631
664
  __decorateParam(1, (0, import_common4.Param)("username")),
@@ -1068,7 +1101,7 @@ __publicField(_RabbitmqCredentialProvisioningProvider, "vhostLocks", /* @__PURE_
1068
1101
  var RabbitmqCredentialProvisioningProvider = _RabbitmqCredentialProvisioningProvider;
1069
1102
 
1070
1103
  // backend/capabilities.ts
1071
- var import_plugins_backend_sdk3 = require("@attraccess/plugins-backend-sdk");
1104
+ var import_plugins_backend_sdk4 = require("@attraccess/plugins-backend-sdk");
1072
1105
  var import_common6 = require("@nestjs/common");
1073
1106
  var RabbitmqCapabilitiesController = class {
1074
1107
  capabilities(request2) {
@@ -1076,7 +1109,7 @@ var RabbitmqCapabilitiesController = class {
1076
1109
  }
1077
1110
  };
1078
1111
  __decorateClass([
1079
- (0, import_plugins_backend_sdk3.Auth)(RABBITMQ_VIEW_PERMISSION),
1112
+ (0, import_plugins_backend_sdk4.Auth)(RABBITMQ_VIEW_PERMISSION),
1080
1113
  (0, import_common6.Get)("capabilities"),
1081
1114
  __decorateParam(0, (0, import_common6.Req)())
1082
1115
  ], RabbitmqCapabilitiesController.prototype, "capabilities", 1);
@@ -1085,7 +1118,7 @@ RabbitmqCapabilitiesController = __decorateClass([
1085
1118
  ], RabbitmqCapabilitiesController);
1086
1119
 
1087
1120
  // backend/connections/service.ts
1088
- var import_plugins_backend_sdk4 = require("@attraccess/plugins-backend-sdk");
1121
+ var import_plugins_backend_sdk5 = require("@attraccess/plugins-backend-sdk");
1089
1122
  var import_common7 = require("@nestjs/common");
1090
1123
  var PLUGIN_CONTEXT3 = /* @__PURE__ */ Symbol.for("attraccess.plugin.context");
1091
1124
  var MAX_CONNECTIONS = 1e3;
@@ -1180,12 +1213,12 @@ var RabbitmqConnectionsController = class {
1180
1213
  }
1181
1214
  };
1182
1215
  __decorateClass([
1183
- (0, import_plugins_backend_sdk4.Auth)(RABBITMQ_VIEW_PERMISSION),
1216
+ (0, import_plugins_backend_sdk5.Auth)(RABBITMQ_VIEW_PERMISSION),
1184
1217
  (0, import_common7.Get)("connections/:mqttServerId"),
1185
1218
  __decorateParam(0, (0, import_common7.Param)("mqttServerId", import_common7.ParseIntPipe))
1186
1219
  ], RabbitmqConnectionsController.prototype, "list", 1);
1187
1220
  __decorateClass([
1188
- (0, import_plugins_backend_sdk4.Auth)(RABBITMQ_MANAGE_PERMISSION),
1221
+ (0, import_plugins_backend_sdk5.Auth)(RABBITMQ_MANAGE_PERMISSION),
1189
1222
  (0, import_common7.Delete)("connections/:mqttServerId"),
1190
1223
  __decorateParam(0, (0, import_common7.Param)("mqttServerId", import_common7.ParseIntPipe)),
1191
1224
  __decorateParam(1, (0, import_common7.Query)("name")),
@@ -1197,7 +1230,7 @@ RabbitmqConnectionsController = __decorateClass([
1197
1230
  ], RabbitmqConnectionsController);
1198
1231
 
1199
1232
  // backend/stats/service.ts
1200
- var import_plugins_backend_sdk5 = require("@attraccess/plugins-backend-sdk");
1233
+ var import_plugins_backend_sdk6 = require("@attraccess/plugins-backend-sdk");
1201
1234
  var import_common8 = require("@nestjs/common");
1202
1235
  var PLUGIN_CONTEXT4 = /* @__PURE__ */ Symbol.for("attraccess.plugin.context");
1203
1236
  var MAX_QUEUES = 1e3;
@@ -1299,7 +1332,7 @@ __decorateClass([
1299
1332
  __decorateParam(0, (0, import_common8.Param)("mqttServerId", import_common8.ParseIntPipe))
1300
1333
  ], RabbitmqStatsController.prototype, "get", 1);
1301
1334
  RabbitmqStatsController = __decorateClass([
1302
- (0, import_plugins_backend_sdk5.Auth)(RABBITMQ_VIEW_PERMISSION),
1335
+ (0, import_plugins_backend_sdk6.Auth)(RABBITMQ_VIEW_PERMISSION),
1303
1336
  (0, import_common8.Controller)("rabbitmq"),
1304
1337
  __decorateParam(0, (0, import_common8.Inject)(RabbitmqStatsService))
1305
1338
  ], RabbitmqStatsController);
@@ -1335,13 +1368,15 @@ __decorateClass([
1335
1368
  (0, import_common9.Get)("status")
1336
1369
  ], RabbitmqController.prototype, "status", 1);
1337
1370
  RabbitmqController = __decorateClass([
1338
- (0, import_plugins_backend_sdk6.Auth)(RABBITMQ_VIEW_PERMISSION),
1371
+ (0, import_plugins_backend_sdk7.Auth)(RABBITMQ_VIEW_PERMISSION),
1339
1372
  (0, import_common9.Controller)("rabbitmq"),
1340
1373
  __decorateParam(0, (0, import_common9.Inject)(RabbitmqService))
1341
1374
  ], RabbitmqController);
1342
1375
  var RabbitmqPluginModule = class {
1343
1376
  };
1344
1377
  var plugin = {
1378
+ // ATT-1003: the plugin's own view and manage keys (see ./permissions).
1379
+ permissions: RABBITMQ_PERMISSIONS,
1345
1380
  credentialProvisioningProvider(context) {
1346
1381
  return new RabbitmqCredentialProvisioningProvider(context);
1347
1382
  },
@@ -1,8 +1,7 @@
1
- import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
2
- //#region \0rolldown/runtime.js
3
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
- //#endregion
5
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
1
+ import { r as importShared } from "./_virtual___federation_fn_import-D2E5es2p.js";
2
+ // \0rolldown/runtime.js
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
4
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
6
5
  var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
7
6
  /** The API origin the host is talking to. Falls back to the current origin. */
8
7
  function getApiBaseUrl() {
@@ -61,8 +60,9 @@ function createPluginApiClient(basePath = "") {
61
60
  }
62
61
  };
63
62
  }
64
- //#endregion
65
- //#region ../../../node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react-jsx-runtime.production.js
63
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.license.ts
64
+ var { useCallback: useCallback$5, useEffect: useEffect$7, useState: useState$8 } = await importShared("react");
65
+ // ../../../node_modules/.pnpm/react@19.3.1/node_modules/react/cjs/react-jsx-runtime.production.js
66
66
  /**
67
67
  * @license React
68
68
  * react-jsx-runtime.production.js
@@ -96,8 +96,7 @@ var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((expor
96
96
  exports.jsx = jsxProd;
97
97
  exports.jsxs = jsxProd;
98
98
  }));
99
- //#endregion
100
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
99
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
101
100
  var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
102
101
  module.exports = require_react_jsx_runtime_production();
103
102
  })))();
@@ -108,15 +107,17 @@ contexts[contextKey] ??= createContext(null);
108
107
  var identityKey = Symbol.for("attraccess.plugin.live-updates.identity");
109
108
  var identities = globalThis;
110
109
  identities[identityKey] ??= createContext(null);
111
- //#endregion
112
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
110
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.pluggable.ts
111
+ /** Whether the signed-in user holds `permission`. False when signed out or when the host sends no permissions. */
112
+ function hasPluginAuthPermission(authData, permission) {
113
+ return (authData?.effectivePermissions ?? (authData?.user)?.effectivePermissions)?.includes(permission) ?? false;
114
+ }
115
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
113
116
  var { StandardDrawer: SharedStandardDrawer } = await importShared("@attraccess/plugins-frontend-ui");
114
- //#endregion
115
- //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
117
+ // ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
116
118
  var { StandardModal: SharedStandardModal } = await importShared("@attraccess/plugins-frontend-ui");
117
- //#endregion
118
- //#region frontend/src/detection/detection.ts
119
- var { useCallback: useCallback$3, useEffect: useEffect$5, useState: useState$6 } = await importShared("react");
119
+ // frontend/src/detection/detection.ts
120
+ var { useCallback: useCallback$3, useEffect: useEffect$5, useState: useState$7 } = await importShared("react");
120
121
  var api$4 = createPluginApiClient("/api/rabbitmq/detection");
121
122
  function fetchDetection(mqttServerId, refresh) {
122
123
  return api$4.request(`/${mqttServerId}`, { query: { refresh: refresh ? "true" : void 0 } });
@@ -163,7 +164,7 @@ function ensureLoaded(mqttServerId, refresh) {
163
164
  notify(mqttServerId);
164
165
  }
165
166
  function useDetection(mqttServerId) {
166
- const [, forceRender] = useState$6(0);
167
+ const [, forceRender] = useState$7(0);
167
168
  useEffect$5(() => {
168
169
  const rerender = () => forceRender((n) => n + 1);
169
170
  let set = subscribers.get(mqttServerId);
@@ -187,11 +188,30 @@ function useDetection(mqttServerId) {
187
188
  refresh
188
189
  };
189
190
  }
190
- //#endregion
191
- //#region frontend/src/users/RabbitmqListBadge.tsx
191
+ // backend/permission-keys.ts
192
+ var RABBITMQ_BROKER_READ = "rabbitmq.broker.read";
193
+ // frontend/src/access.ts
194
+ var { useSyncExternalStore } = await importShared("react");
195
+ var authData = null;
196
+ var listeners = /* @__PURE__ */ new Set();
197
+ function setRabbitmqAuthData(next) {
198
+ authData = next;
199
+ for (const listener of listeners) listener();
200
+ }
201
+ var subscribe = (listener) => {
202
+ listeners.add(listener);
203
+ return () => listeners.delete(listener);
204
+ };
205
+ function useCanViewBroker() {
206
+ return hasPluginAuthPermission(useSyncExternalStore(subscribe, () => authData), RABBITMQ_BROKER_READ);
207
+ }
208
+ // frontend/src/users/RabbitmqListBadge.tsx
192
209
  var { Chip: Chip$4 } = await importShared("@heroui/react");
193
210
  var { RabbitIcon: RabbitIcon$1 } = await importShared("lucide-react");
194
211
  function RabbitmqListBadge({ mqttServerId }) {
212
+ return useCanViewBroker() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DetectedBadge, { mqttServerId }) : null;
213
+ }
214
+ function DetectedBadge({ mqttServerId }) {
195
215
  const { result } = useDetection(mqttServerId);
196
216
  if (!result?.isRabbitMQ) return null;
197
217
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Chip$4, {
@@ -454,16 +474,14 @@ var de_default = {
454
474
  "queuesTruncated": "Die ersten {{shown}} von {{total}} Queues werden angezeigt."
455
475
  }
456
476
  };
457
- //#endregion
458
- //#region frontend/src/i18n.ts
477
+ // frontend/src/i18n.ts
459
478
  var { useTranslations } = await importShared("@attraccess/plugins-frontend-ui");
460
479
  var useRabbitmqTranslations = () => useTranslations({
461
480
  en: en_default,
462
481
  de: de_default
463
482
  }, { escapeValues: false });
464
- //#endregion
465
- //#region frontend/src/format.tsx
466
- var { useDateTimeFormatter, useFormatedDuration, useNumberFormatter } = await importShared("@attraccess/plugins-frontend-ui");
483
+ // frontend/src/useRabbitmqFormatters.ts
484
+ var { useDateTimeFormatter, useNumberFormatter } = await importShared("@attraccess/plugins-frontend-ui");
467
485
  var { useCallback: useCallback$2, useMemo } = await importShared("react");
468
486
  var BYTE_UNITS = [
469
487
  "B",
@@ -520,12 +538,7 @@ function useRabbitmqFormatters() {
520
538
  time
521
539
  ]);
522
540
  }
523
- function Duration({ ms }) {
524
- const formatted = useFormatedDuration(ms == null ? 0 : Math.floor(ms / 6e4));
525
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ms == null ? "—" : formatted });
526
- }
527
- //#endregion
528
- //#region frontend/src/detection/RabbitmqStatusPanel.tsx
541
+ // frontend/src/detection/RabbitmqStatusPanel.tsx
529
542
  var { Button: Button$6 } = await importShared("@attraccess/plugins-frontend-ui");
530
543
  var { Alert: Alert$2, AlertContent: AlertContent$2, AlertDescription: AlertDescription$2, Card: Card$4, Chip: Chip$3 } = await importShared("@heroui/react");
531
544
  var { CheckCircle2Icon, RabbitIcon, RefreshCwIcon: RefreshCwIcon$3, XCircleIcon } = await importShared("lucide-react");
@@ -630,8 +643,7 @@ function RabbitmqStatusPanel({ mqttServerId }) {
630
643
  })]
631
644
  });
632
645
  }
633
- //#endregion
634
- //#region frontend/src/users/users-api.ts
646
+ // frontend/src/users/users-api.ts
635
647
  var DEFAULT_MQTT_PERMISSIONS = {
636
648
  configure: "^mqtt-subscription-.*$",
637
649
  write: "^(amq\\.topic|mqtt-subscription-.*)$",
@@ -662,12 +674,11 @@ function clearPermissions(mqttServerId, username, vhost) {
662
674
  query: { vhost }
663
675
  });
664
676
  }
665
- //#endregion
666
- //#region frontend/src/users/permissions/RabbitmqPermissionsModal.tsx
677
+ // frontend/src/users/permissions/RabbitmqPermissionsModal.tsx
667
678
  var { Button: Button$5, EmptyState: EmptyState$2, StandardModal: StandardModal$1 } = await importShared("@attraccess/plugins-frontend-ui");
668
679
  var { Alert: Alert$1, AlertContent: AlertContent$1, AlertDescription: AlertDescription$1, Input: Input$2, Label: Label$2, ModalBody: ModalBody$1, ModalFooter: ModalFooter$1, ModalHeader: ModalHeader$1, ModalHeading: ModalHeading$1, TextField: TextField$2 } = await importShared("@heroui/react");
669
680
  var { PlusIcon: PlusIcon$1, Trash2Icon: Trash2Icon$1 } = await importShared("lucide-react");
670
- var { useEffect: useEffect$4, useState: useState$5 } = await importShared("react");
681
+ var { useEffect: useEffect$4, useState: useState$6 } = await importShared("react");
671
682
  function PermissionEditor({ row, busy, onChange, onSave, onRemove }) {
672
683
  const { t } = useRabbitmqTranslations();
673
684
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
@@ -758,10 +769,10 @@ function PermissionEditor({ row, busy, onChange, onSave, onRemove }) {
758
769
  }
759
770
  function RabbitmqPermissionsModal({ mqttServerId, isOpen, user, vhosts, onClose, onSaved }) {
760
771
  const { t, tMessage } = useRabbitmqTranslations();
761
- const [rows, setRows] = useState$5([]);
762
- const [newVhost, setNewVhost] = useState$5("");
763
- const [busyVhost, setBusyVhost] = useState$5(null);
764
- const [error, setError] = useState$5(null);
772
+ const [rows, setRows] = useState$6([]);
773
+ const [newVhost, setNewVhost] = useState$6("");
774
+ const [busyVhost, setBusyVhost] = useState$6(null);
775
+ const [error, setError] = useState$6(null);
765
776
  useEffect$4(() => {
766
777
  if (!isOpen) return;
767
778
  setRows((user?.permissions ?? []).map((permission) => ({
@@ -893,10 +904,70 @@ function RabbitmqPermissionsModal({ mqttServerId, isOpen, user, vhosts, onClose,
893
904
  ] })
894
905
  });
895
906
  }
896
- //#endregion
897
- //#region frontend/src/users/useRabbitmqUserFormModalState.tsx
907
+ // frontend/src/users/errorTitle.ts
908
+ function errorTitle(error, title) {
909
+ return typeof error === "string" ? title : void 0;
910
+ }
911
+ // frontend/src/users/RabbitmqUserDeleteDialog.tsx
912
+ var { StatusAlert: StatusAlert$3, StatusDialog: StatusDialog$1 } = await importShared("@attraccess/plugins-frontend-ui");
913
+ var { useState: useState$5 } = await importShared("react");
914
+ function RabbitmqUserDeleteDialog({ mqttServerId, user, onClose, onDeleted }) {
915
+ const { t, tMessage } = useRabbitmqTranslations();
916
+ const [deleting, setDeleting] = useState$5(false);
917
+ const [deleteError, setDeleteError] = useState$5(null);
918
+ const [confirmingName, setConfirmingName] = useState$5(null);
919
+ const userName = user?.name ?? null;
920
+ if (userName !== confirmingName) {
921
+ setConfirmingName(userName);
922
+ if (userName !== null) setDeleteError(null);
923
+ }
924
+ const confirmDelete = async () => {
925
+ if (!user) return;
926
+ setDeleting(true);
927
+ setDeleteError(null);
928
+ try {
929
+ await deleteUser(mqttServerId, user.name);
930
+ onClose();
931
+ onDeleted();
932
+ } catch (err) {
933
+ setDeleteError(err instanceof Error ? err.message : { key: "users.deleteError" });
934
+ } finally {
935
+ setDeleting(false);
936
+ }
937
+ };
938
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
939
+ isOpen: user !== null,
940
+ onClose,
941
+ status: "error",
942
+ title: t("users.deleteTitle"),
943
+ action: {
944
+ label: t("common.delete"),
945
+ onPress: confirmDelete,
946
+ isPending: deleting,
947
+ "data-cy": "rabbitmq-user-delete-confirm-button"
948
+ },
949
+ closeLabel: t("common.cancel"),
950
+ closeDataCy: "rabbitmq-user-delete-cancel-button",
951
+ "data-cy": `rabbitmq-user-delete-modal-${mqttServerId}`,
952
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
953
+ className: "rmq:flex rmq:flex-col rmq:gap-3",
954
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("users.deleteDescription", { name: user?.name }) }), deleteError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
955
+ status: "danger",
956
+ title: errorTitle(deleteError, t("users.deleteError")),
957
+ "data-cy": "rabbitmq-user-delete-error-alert",
958
+ children: tMessage(deleteError)
959
+ })]
960
+ })
961
+ });
962
+ }
963
+ // frontend/src/users/RabbitmqUserFormModal.tsx
964
+ var { Button: Button$4, StandardModal } = await importShared("@attraccess/plugins-frontend-ui");
965
+ var { Alert, AlertContent, AlertDescription, Checkbox, Form, Input: Input$1, Label: Label$1, ModalBody, ModalFooter, ModalHeader, ModalHeading, TextField: TextField$1 } = await importShared("@heroui/react");
898
966
  var { useEffect: useEffect$3, useState: useState$4 } = await importShared("react");
899
- function useRabbitmqUserFormModalState({ mqttServerId, isOpen, user, vhosts, existingUsernames = [], onClose, onSaved }) {
967
+ function parseTags(value) {
968
+ return value.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0);
969
+ }
970
+ function RabbitmqUserFormModal({ mqttServerId, isOpen, user, vhosts, existingUsernames = [], onClose, onSaved }) {
900
971
  const { t, tMessage } = useRabbitmqTranslations();
901
972
  const isEdit = user !== null;
902
973
  const [username, setUsername] = useState$4("");
@@ -952,47 +1023,6 @@ function useRabbitmqUserFormModalState({ mqttServerId, isOpen, user, vhosts, exi
952
1023
  setSaving(false);
953
1024
  }
954
1025
  };
955
- return {
956
- t,
957
- tMessage,
958
- isEdit,
959
- username,
960
- setUsername,
961
- password,
962
- setPassword,
963
- tags,
964
- setTags,
965
- grantMqttDefaults,
966
- setGrantMqttDefaults,
967
- vhost,
968
- setVhost,
969
- saving,
970
- error,
971
- handleSubmit,
972
- mqttServerId,
973
- isOpen,
974
- user,
975
- vhosts,
976
- onClose
977
- };
978
- }
979
- function parseTags(value) {
980
- return value.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0);
981
- }
982
- //#endregion
983
- //#region frontend/src/users/RabbitmqUserFormModal.tsx
984
- var { Button: Button$4, StandardModal } = await importShared("@attraccess/plugins-frontend-ui");
985
- var { Alert, AlertContent, AlertDescription, Checkbox, Form, Input: Input$1, Label: Label$1, ModalBody, ModalFooter, ModalHeader, ModalHeading, TextField: TextField$1 } = await importShared("@heroui/react");
986
- function RabbitmqUserFormModal({ mqttServerId, isOpen, user, vhosts, existingUsernames, onClose, onSaved }) {
987
- const { t, tMessage, isEdit, username, setUsername, password, setPassword, tags, setTags, grantMqttDefaults, setGrantMqttDefaults, vhost, setVhost, saving, error, handleSubmit } = useRabbitmqUserFormModalState({
988
- mqttServerId,
989
- isOpen,
990
- user,
991
- vhosts,
992
- existingUsernames,
993
- onClose,
994
- onSaved
995
- });
996
1026
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandardModal, {
997
1027
  size: "md",
998
1028
  isOpen,
@@ -1092,92 +1122,12 @@ function RabbitmqUserFormModal({ mqttServerId, isOpen, user, vhosts, existingUse
1092
1122
  })] })
1093
1123
  });
1094
1124
  }
1095
- //#endregion
1096
- //#region frontend/src/users/useRabbitmqUserPanelState.tsx
1097
- var { useCallback: useCallback$1, useEffect: useEffect$2, useRef: useRef$1, useState: useState$3 } = await importShared("react");
1098
- function useRabbitmqUserPanelState({ mqttServerId }) {
1099
- const { t, tMessage, language } = useRabbitmqTranslations();
1100
- const { result } = useDetection(mqttServerId);
1101
- const [data, setData] = useState$3(null);
1102
- const [loading, setLoading] = useState$3(false);
1103
- const [loadError, setLoadError] = useState$3(null);
1104
- const [formOpen, setFormOpen] = useState$3(false);
1105
- const [formUser, setFormUser] = useState$3(null);
1106
- const [permissionsUser, setPermissionsUser] = useState$3(null);
1107
- const [userToDelete, setUserToDelete] = useState$3(null);
1108
- const [deleting, setDeleting] = useState$3(false);
1109
- const [deleteError, setDeleteError] = useState$3(null);
1110
- const mounted = useRef$1(true);
1111
- useEffect$2(() => {
1112
- mounted.current = true;
1113
- return () => {
1114
- mounted.current = false;
1115
- };
1116
- }, []);
1117
- const confirmDelete = async () => {
1118
- if (!userToDelete) return;
1119
- setDeleting(true);
1120
- setDeleteError(null);
1121
- try {
1122
- await deleteUser(mqttServerId, userToDelete.name);
1123
- setUserToDelete(null);
1124
- reload();
1125
- } catch (err) {
1126
- setDeleteError(err instanceof Error ? err.message : { key: "users.deleteError" });
1127
- } finally {
1128
- setDeleting(false);
1129
- }
1130
- };
1131
- const reload = useCallback$1(async () => {
1132
- setLoading(true);
1133
- setLoadError(null);
1134
- try {
1135
- const list = await fetchUsers(mqttServerId);
1136
- if (mounted.current) {
1137
- setData(list);
1138
- setPermissionsUser((current) => current ? list.users.find((user) => user.name === current.name) ?? current : null);
1139
- }
1140
- } catch (err) {
1141
- if (mounted.current) setLoadError(err instanceof Error ? err.message : { key: "users.loadError" });
1142
- } finally {
1143
- if (mounted.current) setLoading(false);
1144
- }
1145
- }, [mqttServerId]);
1146
- const manageable = result?.isRabbitMQ === true && result.authOk;
1147
- useEffect$2(() => {
1148
- if (manageable) reload();
1149
- }, [manageable, reload]);
1150
- return {
1151
- t,
1152
- tMessage,
1153
- language,
1154
- data,
1155
- loading,
1156
- loadError,
1157
- formOpen,
1158
- setFormOpen,
1159
- formUser,
1160
- setFormUser,
1161
- permissionsUser,
1162
- setPermissionsUser,
1163
- userToDelete,
1164
- setUserToDelete,
1165
- deleting,
1166
- setDeleting,
1167
- deleteError,
1168
- setDeleteError,
1169
- reload,
1170
- manageable,
1171
- mqttServerId,
1172
- confirmDelete
1173
- };
1174
- }
1175
- //#endregion
1176
- //#region frontend/src/users/RabbitmqUserPanelCardHeader.tsx
1125
+ // frontend/src/users/RabbitmqUserPanelCardHeader.tsx
1177
1126
  var { Button: Button$3 } = await importShared("@attraccess/plugins-frontend-ui");
1178
1127
  var { Card: Card$3 } = await importShared("@heroui/react");
1179
1128
  var { PlusIcon, RefreshCwIcon: RefreshCwIcon$2, UsersIcon } = await importShared("lucide-react");
1180
- function RabbitmqUserPanelCardHeader({ t, reload, loading, mqttServerId, setFormUser, setFormOpen, canManage }) {
1129
+ function RabbitmqUserPanelCardHeader({ reload, loading, mqttServerId, onCreate, canManage }) {
1130
+ const { t } = useRabbitmqTranslations();
1181
1131
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$3.Header, {
1182
1132
  className: "rmq:flex rmq:flex-row rmq:items-center rmq:justify-between rmq:gap-2",
1183
1133
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
@@ -1200,20 +1150,15 @@ function RabbitmqUserPanelCardHeader({ t, reload, loading, mqttServerId, setForm
1200
1150
  }), canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$3, {
1201
1151
  size: "sm",
1202
1152
  variant: "primary",
1203
- onPress: () => {
1204
- setFormUser(null);
1205
- setFormOpen(true);
1206
- },
1153
+ onPress: onCreate,
1207
1154
  "data-cy": `rabbitmq-user-panel-create-button-${mqttServerId}`,
1208
1155
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { className: "rmq:w-4 rmq:h-4" }), t("users.add")]
1209
1156
  })]
1210
1157
  })]
1211
1158
  });
1212
1159
  }
1213
- //#endregion
1214
- //#region frontend/src/users/RabbitmqUserPanel.tsx
1215
- var { StatusAlert: StatusAlert$2, StatusDialog: StatusDialog$1, TableDataLoadingIndicator: TableDataLoadingIndicator$2 } = await importShared("@attraccess/plugins-frontend-ui");
1216
- var { Button: Button$2, Card: Card$2, Chip: Chip$2, Table: Table$2, TableBody: TableBody$2, TableCell: TableCell$2, TableColumn: TableColumn$2, TableContent: TableContent$2, TableHeader: TableHeader$2, TableRow: TableRow$2, TableScrollContainer: TableScrollContainer$2 } = await importShared("@heroui/react");
1160
+ // frontend/src/users/RabbitmqUserTable.tsx
1161
+ var { Button: Button$2, Chip: Chip$2, Table: Table$2, TableBody: TableBody$2, TableCell: TableCell$2, TableColumn: TableColumn$2, TableContent: TableContent$2, TableHeader: TableHeader$2, TableRow: TableRow$2, TableScrollContainer: TableScrollContainer$2 } = await importShared("@heroui/react");
1217
1162
  var { KeyRoundIcon, PencilIcon, Trash2Icon } = await importShared("lucide-react");
1218
1163
  function PermissionChips({ user }) {
1219
1164
  const { t } = useRabbitmqTranslations();
@@ -1231,164 +1176,188 @@ function PermissionChips({ user }) {
1231
1176
  }, permission.vhost))
1232
1177
  });
1233
1178
  }
1234
- function errorTitle(error, title) {
1235
- return typeof error === "string" ? title : void 0;
1179
+ function RabbitmqUserTable({ users, canManage, onEdit, onPermissions, onDelete }) {
1180
+ const { t, language } = useRabbitmqTranslations();
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table$2, {
1182
+ "data-cy": "rabbitmq-user-panel-table",
1183
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent$2, {
1184
+ "aria-label": t("users.title"),
1185
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader$2, { children: [
1186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, {
1187
+ isRowHeader: true,
1188
+ children: t("users.username")
1189
+ }),
1190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: t("users.tags") }),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: t("users.access") }),
1192
+ canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: t("common.actions") })
1193
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody$2, {
1194
+ items: users,
1195
+ dependencies: [language],
1196
+ children: (user) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow$2, {
1197
+ id: user.name,
1198
+ children: [
1199
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, {
1200
+ className: "rmq:whitespace-nowrap rmq:font-medium",
1201
+ children: user.name
1202
+ }),
1203
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: user.tags.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1204
+ className: "rmq:text-xs rmq:text-default-400",
1205
+ children: t("users.none")
1206
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1207
+ className: "rmq:flex rmq:flex-wrap rmq:gap-1",
1208
+ children: user.tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$2, {
1209
+ size: "sm",
1210
+ color: "accent",
1211
+ variant: "soft",
1212
+ children: tag
1213
+ }, tag))
1214
+ }) }),
1215
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PermissionChips, { user }) }),
1216
+ canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1217
+ className: "rmq:flex rmq:flex-row rmq:gap-1",
1218
+ children: [
1219
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1220
+ isIconOnly: true,
1221
+ size: "sm",
1222
+ variant: "ghost",
1223
+ "aria-label": t("users.edit", { name: user.name }),
1224
+ onPress: () => onEdit(user),
1225
+ "data-cy": `rabbitmq-user-edit-button-${user.name}`,
1226
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PencilIcon, { className: "rmq:w-4 rmq:h-4" })
1227
+ }),
1228
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1229
+ isIconOnly: true,
1230
+ size: "sm",
1231
+ variant: "ghost",
1232
+ "aria-label": t("users.permissions", { name: user.name }),
1233
+ onPress: () => onPermissions(user),
1234
+ "data-cy": `rabbitmq-user-permissions-button-${user.name}`,
1235
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon, { className: "rmq:w-4 rmq:h-4" })
1236
+ }),
1237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1238
+ isIconOnly: true,
1239
+ size: "sm",
1240
+ variant: "ghost",
1241
+ "aria-label": t("users.delete", { name: user.name }),
1242
+ onPress: () => onDelete(user),
1243
+ "data-cy": `rabbitmq-user-delete-button-${user.name}`,
1244
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { className: "rmq:w-4 rmq:h-4 rmq:text-danger" })
1245
+ })
1246
+ ]
1247
+ }) })
1248
+ ]
1249
+ }, user.name)
1250
+ })]
1251
+ }) })
1252
+ });
1236
1253
  }
1254
+ // frontend/src/users/RabbitmqUserPanel.tsx
1255
+ var { StatusAlert: StatusAlert$2, TableDataLoadingIndicator: TableDataLoadingIndicator$2 } = await importShared("@attraccess/plugins-frontend-ui");
1256
+ var { Card: Card$2 } = await importShared("@heroui/react");
1257
+ var { useCallback: useCallback$1, useEffect: useEffect$2, useRef: useRef$1, useState: useState$3 } = await importShared("react");
1237
1258
  function RabbitmqUserPanel({ mqttServerId, canManage = false }) {
1238
- const model = useRabbitmqUserPanelState({ mqttServerId });
1239
- if (!model.manageable) return null;
1259
+ const { t, tMessage } = useRabbitmqTranslations();
1260
+ const { result } = useDetection(mqttServerId);
1261
+ const [data, setData] = useState$3(null);
1262
+ const [loading, setLoading] = useState$3(false);
1263
+ const [loadError, setLoadError] = useState$3(null);
1264
+ const [formOpen, setFormOpen] = useState$3(false);
1265
+ const [formUser, setFormUser] = useState$3(null);
1266
+ const [permissionsUser, setPermissionsUser] = useState$3(null);
1267
+ const [userToDelete, setUserToDelete] = useState$3(null);
1268
+ const mounted = useRef$1(true);
1269
+ useEffect$2(() => {
1270
+ mounted.current = true;
1271
+ return () => {
1272
+ mounted.current = false;
1273
+ };
1274
+ }, []);
1275
+ const reload = useCallback$1(async () => {
1276
+ setLoading(true);
1277
+ setLoadError(null);
1278
+ try {
1279
+ const list = await fetchUsers(mqttServerId);
1280
+ if (mounted.current) {
1281
+ setData(list);
1282
+ setPermissionsUser((current) => current ? list.users.find((user) => user.name === current.name) ?? current : null);
1283
+ }
1284
+ } catch (err) {
1285
+ if (mounted.current) setLoadError(err instanceof Error ? err.message : { key: "users.loadError" });
1286
+ } finally {
1287
+ if (mounted.current) setLoading(false);
1288
+ }
1289
+ }, [mqttServerId]);
1290
+ const manageable = result?.isRabbitMQ === true && result.authOk;
1291
+ useEffect$2(() => {
1292
+ if (manageable) reload();
1293
+ }, [manageable, reload]);
1294
+ if (!manageable) return null;
1240
1295
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2, {
1241
1296
  "data-cy": `rabbitmq-user-panel-${mqttServerId}`,
1242
1297
  className: "rmq:w-full rmq:border rmq:border-default-200 rmq:dark:border-default-100",
1243
1298
  children: [
1244
1299
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqUserPanelCardHeader, {
1245
- t: model.t,
1246
- reload: model.reload,
1247
- loading: model.loading,
1300
+ reload,
1301
+ loading,
1248
1302
  mqttServerId,
1249
- setFormUser: model.setFormUser,
1250
- setFormOpen: model.setFormOpen,
1303
+ onCreate: () => {
1304
+ setFormUser(null);
1305
+ setFormOpen(true);
1306
+ },
1251
1307
  canManage
1252
1308
  }),
1253
1309
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2.Content, {
1254
1310
  className: "rmq:flex rmq:flex-col rmq:gap-3",
1255
1311
  children: [
1256
- model.loadError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
1312
+ loadError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
1257
1313
  status: "danger",
1258
- title: errorTitle(model.loadError, model.t("users.loadError")),
1314
+ title: errorTitle(loadError, t("users.loadError")),
1259
1315
  "data-cy": "rabbitmq-user-panel-error-alert",
1260
- children: model.tMessage(model.loadError)
1316
+ children: tMessage(loadError)
1261
1317
  }),
1262
- !model.data && !model.loadError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1318
+ !data && !loadError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1263
1319
  "data-cy": "rabbitmq-user-panel-loading-spinner",
1264
1320
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator$2, {})
1265
1321
  }),
1266
- model.data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table$2, {
1267
- "data-cy": "rabbitmq-user-panel-table",
1268
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent$2, {
1269
- "aria-label": model.t("users.title"),
1270
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader$2, { children: [
1271
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, {
1272
- isRowHeader: true,
1273
- children: model.t("users.username")
1274
- }),
1275
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: model.t("users.tags") }),
1276
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: model.t("users.access") }),
1277
- canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn$2, { children: model.t("common.actions") })
1278
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody$2, {
1279
- items: model.data.users,
1280
- dependencies: [model.language],
1281
- children: (user) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow$2, {
1282
- id: user.name,
1283
- children: [
1284
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, {
1285
- className: "rmq:whitespace-nowrap rmq:font-medium",
1286
- children: user.name
1287
- }),
1288
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: user.tags.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1289
- className: "rmq:text-xs rmq:text-default-400",
1290
- children: model.t("users.none")
1291
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1292
- className: "rmq:flex rmq:flex-wrap rmq:gap-1",
1293
- children: user.tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$2, {
1294
- size: "sm",
1295
- color: "accent",
1296
- variant: "soft",
1297
- children: tag
1298
- }, tag))
1299
- }) }),
1300
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PermissionChips, { user }) }),
1301
- canManage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell$2, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1302
- className: "rmq:flex rmq:flex-row rmq:gap-1",
1303
- children: [
1304
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1305
- isIconOnly: true,
1306
- size: "sm",
1307
- variant: "ghost",
1308
- "aria-label": model.t("users.edit", { name: user.name }),
1309
- onPress: () => {
1310
- model.setFormUser(user);
1311
- model.setFormOpen(true);
1312
- },
1313
- "data-cy": `rabbitmq-user-edit-button-${user.name}`,
1314
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PencilIcon, { className: "rmq:w-4 rmq:h-4" })
1315
- }),
1316
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1317
- isIconOnly: true,
1318
- size: "sm",
1319
- variant: "ghost",
1320
- "aria-label": model.t("users.permissions", { name: user.name }),
1321
- onPress: () => model.setPermissionsUser(user),
1322
- "data-cy": `rabbitmq-user-permissions-button-${user.name}`,
1323
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeyRoundIcon, { className: "rmq:w-4 rmq:h-4" })
1324
- }),
1325
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1326
- isIconOnly: true,
1327
- size: "sm",
1328
- variant: "ghost",
1329
- "aria-label": model.t("users.delete", { name: user.name }),
1330
- onPress: () => {
1331
- model.setDeleteError(null);
1332
- model.setUserToDelete(user);
1333
- },
1334
- "data-cy": `rabbitmq-user-delete-button-${user.name}`,
1335
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { className: "rmq:w-4 rmq:h-4 rmq:text-danger" })
1336
- })
1337
- ]
1338
- }) })
1339
- ]
1340
- }, user.name)
1341
- })]
1342
- }) })
1322
+ data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqUserTable, {
1323
+ users: data.users,
1324
+ canManage,
1325
+ onEdit: (user) => {
1326
+ setFormUser(user);
1327
+ setFormOpen(true);
1328
+ },
1329
+ onPermissions: setPermissionsUser,
1330
+ onDelete: setUserToDelete
1343
1331
  })
1344
1332
  ]
1345
1333
  }),
1346
1334
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqUserFormModal, {
1347
1335
  mqttServerId,
1348
- isOpen: model.formOpen,
1349
- user: model.formUser,
1350
- vhosts: model.data?.vhosts ?? [],
1351
- existingUsernames: model.data?.users.map((user) => user.name),
1352
- onClose: () => model.setFormOpen(false),
1353
- onSaved: () => void model.reload()
1336
+ isOpen: formOpen,
1337
+ user: formUser,
1338
+ vhosts: data?.vhosts ?? [],
1339
+ existingUsernames: data?.users.map((user) => user.name),
1340
+ onClose: () => setFormOpen(false),
1341
+ onSaved: () => void reload()
1354
1342
  }),
1355
1343
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqPermissionsModal, {
1356
1344
  mqttServerId,
1357
- isOpen: model.permissionsUser !== null,
1358
- user: model.permissionsUser,
1359
- vhosts: model.data?.vhosts ?? [],
1360
- onClose: () => model.setPermissionsUser(null),
1361
- onSaved: () => void model.reload()
1345
+ isOpen: permissionsUser !== null,
1346
+ user: permissionsUser,
1347
+ vhosts: data?.vhosts ?? [],
1348
+ onClose: () => setPermissionsUser(null),
1349
+ onSaved: () => void reload()
1362
1350
  }),
1363
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
1364
- isOpen: model.userToDelete !== null,
1365
- onClose: () => model.setUserToDelete(null),
1366
- status: "error",
1367
- title: model.t("users.deleteTitle"),
1368
- action: {
1369
- label: model.t("common.delete"),
1370
- onPress: model.confirmDelete,
1371
- isPending: model.deleting,
1372
- "data-cy": "rabbitmq-user-delete-confirm-button"
1373
- },
1374
- closeLabel: model.t("common.cancel"),
1375
- closeDataCy: "rabbitmq-user-delete-cancel-button",
1376
- "data-cy": `rabbitmq-user-delete-modal-${mqttServerId}`,
1377
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1378
- className: "rmq:flex rmq:flex-col rmq:gap-3",
1379
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: model.t("users.deleteDescription", { name: model.userToDelete?.name }) }), model.deleteError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
1380
- status: "danger",
1381
- title: errorTitle(model.deleteError, model.t("users.deleteError")),
1382
- "data-cy": "rabbitmq-user-delete-error-alert",
1383
- children: model.tMessage(model.deleteError)
1384
- })]
1385
- })
1351
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqUserDeleteDialog, {
1352
+ mqttServerId,
1353
+ user: userToDelete,
1354
+ onClose: () => setUserToDelete(null),
1355
+ onDeleted: () => void reload()
1386
1356
  })
1387
1357
  ]
1388
1358
  });
1389
1359
  }
1390
- //#endregion
1391
- //#region frontend/src/usePolledResource.ts
1360
+ // frontend/src/usePolledResource.ts
1392
1361
  var { useCallback, useEffect: useEffect$1, useRef, useState: useState$2 } = await importShared("react");
1393
1362
  function usePolledResource(fetcher, intervalMs, fallbackError) {
1394
1363
  const [data, setData] = useState$2(null);
@@ -1455,8 +1424,7 @@ function usePolledResource(fetcher, intervalMs, fallbackError) {
1455
1424
  reload
1456
1425
  };
1457
1426
  }
1458
- //#endregion
1459
- //#region frontend/src/connections/connections-api.ts
1427
+ // frontend/src/connections/connections-api.ts
1460
1428
  var api$2 = createPluginApiClient("/api/rabbitmq/connections");
1461
1429
  function fetchConnections(mqttServerId) {
1462
1430
  return api$2.request(`/${mqttServerId}`);
@@ -1470,8 +1438,7 @@ function closeConnection(mqttServerId, name, reason) {
1470
1438
  }
1471
1439
  });
1472
1440
  }
1473
- //#endregion
1474
- //#region frontend/src/connections/RabbitmqConnectionsPanel.tsx
1441
+ // frontend/src/connections/RabbitmqConnectionsPanel.tsx
1475
1442
  var { Button: Button$1, EmptyState: EmptyState$1, StatusAlert: StatusAlert$1, StatusDialog, TableDataLoadingIndicator: TableDataLoadingIndicator$1 } = await importShared("@attraccess/plugins-frontend-ui");
1476
1443
  var { Card: Card$1, Chip: Chip$1, Input, Label, Table: Table$1, TableBody: TableBody$1, TableCell: TableCell$1, TableColumn: TableColumn$1, TableContent: TableContent$1, TableHeader: TableHeader$1, TableRow: TableRow$1, TableScrollContainer: TableScrollContainer$1, TextField } = await importShared("@heroui/react");
1477
1444
  var { PlugZapIcon, RefreshCwIcon: RefreshCwIcon$1, UnplugIcon } = await importShared("lucide-react");
@@ -1682,14 +1649,18 @@ function RabbitmqConnectionsPanel({ mqttServerId, canManage }) {
1682
1649
  ]
1683
1650
  });
1684
1651
  }
1685
- //#endregion
1686
- //#region frontend/src/stats/stats-api.ts
1652
+ // frontend/src/Duration.tsx
1653
+ var { useFormatedDuration } = await importShared("@attraccess/plugins-frontend-ui");
1654
+ function Duration({ ms }) {
1655
+ const formatted = useFormatedDuration(ms == null ? 0 : Math.floor(ms / 6e4));
1656
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ms == null ? "—" : formatted });
1657
+ }
1658
+ // frontend/src/stats/stats-api.ts
1687
1659
  var api$1 = createPluginApiClient("/api/rabbitmq/stats");
1688
1660
  function fetchStats(mqttServerId) {
1689
1661
  return api$1.request(`/${mqttServerId}`);
1690
1662
  }
1691
- //#endregion
1692
- //#region frontend/src/stats/RabbitmqStatsPanel.tsx
1663
+ // frontend/src/stats/RabbitmqStatsPanel.tsx
1693
1664
  var { Button, EmptyState, StatusAlert, TableDataLoadingIndicator } = await importShared("@attraccess/plugins-frontend-ui");
1694
1665
  var { Card, Chip, Table, TableBody, TableCell, TableColumn, TableContent, TableHeader, TableRow, TableScrollContainer } = await importShared("@heroui/react");
1695
1666
  var { BarChart3Icon, RefreshCwIcon, TriangleAlertIcon } = await importShared("lucide-react");
@@ -1916,8 +1887,7 @@ function RabbitmqStatsPanel({ mqttServerId }) {
1916
1887
  })]
1917
1888
  });
1918
1889
  }
1919
- //#endregion
1920
- //#region frontend/src/capabilities.ts
1890
+ // frontend/src/capabilities.ts
1921
1891
  var { useEffect, useState } = await importShared("react");
1922
1892
  var api = createPluginApiClient("/api/rabbitmq/capabilities");
1923
1893
  function useCapabilities(enabled = true) {
@@ -1934,8 +1904,7 @@ function useCapabilities(enabled = true) {
1934
1904
  }, [enabled]);
1935
1905
  return capabilities;
1936
1906
  }
1937
- //#endregion
1938
- //#region frontend/src/plugin.tsx
1907
+ // frontend/src/plugin.tsx
1939
1908
  var MQTT_SERVER_DETAIL_SLOT = "mqtt.server.detail";
1940
1909
  var MQTT_SERVER_LIST_ROW_SLOT = "mqtt.server.list.row";
1941
1910
  function RabbitmqDataPanels({ mqttServerId, canManage }) {
@@ -1945,6 +1914,9 @@ function RabbitmqDataPanels({ mqttServerId, canManage }) {
1945
1914
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqStatsPanel, { mqttServerId })] });
1946
1915
  }
1947
1916
  function RabbitmqDetailSlot({ mqttServerId }) {
1917
+ return useCanViewBroker() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RabbitmqDetailPanels, { mqttServerId }) : null;
1918
+ }
1919
+ function RabbitmqDetailPanels({ mqttServerId }) {
1948
1920
  const { result } = useDetection(mqttServerId);
1949
1921
  const { canManage } = useCapabilities(result?.isRabbitMQ === true);
1950
1922
  if (!result?.isRabbitMQ) return null;
@@ -1973,7 +1945,9 @@ var RabbitmqPlugin = class {
1973
1945
  init(_store) {}
1974
1946
  activate() {}
1975
1947
  deactivate() {}
1976
- onApiAuthStateChange(_authData) {}
1948
+ onApiAuthStateChange(authData) {
1949
+ setRabbitmqAuthData(authData);
1950
+ }
1977
1951
  onApiEndpointChange(_endpoint) {}
1978
1952
  getSlotContributions() {
1979
1953
  return [{
@@ -1987,5 +1961,4 @@ var RabbitmqPlugin = class {
1987
1961
  }];
1988
1962
  }
1989
1963
  };
1990
- //#endregion
1991
1964
  export { RabbitmqDetailSlot, RabbitmqPlugin as default };
@@ -0,0 +1 @@
1
+ export { r as importShared, t as importSharedLocal, n as importSharedRuntime } from "./_virtual___federation_fn_import-D2E5es2p.js";
@@ -1,4 +1,4 @@
1
- //#region ../../../node_modules/.pnpm/@originjs+vite-plugin-federation@1.4.1/node_modules/@originjs/vite-plugin-federation/dist/satisfy.mjs
1
+ // ../../../node_modules/.pnpm/@originjs+vite-plugin-federation@1.4.1/node_modules/@originjs/vite-plugin-federation/dist/satisfy.mjs
2
2
  var buildIdentifier = "[0-9A-Za-z-]+";
3
3
  var build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
4
4
  var numericIdentifier = "0|[1-9]\\d*";
@@ -221,8 +221,7 @@ function satisfy(version, range) {
221
221
  }
222
222
  return true;
223
223
  }
224
- //#endregion
225
- //#region \0virtual:__federation_fn_import
224
+ // \0virtual:__federation_fn_import
226
225
  var moduleMap = {};
227
226
  var moduleCache = Object.create(null);
228
227
  async function importShared(name, shareScope = "default") {
@@ -257,5 +256,4 @@ function flattenModule(module, name) {
257
256
  moduleCache[name] = module;
258
257
  return module;
259
258
  }
260
- //#endregion
261
259
  export { getSharedFromRuntime as n, importShared as r, getSharedFromLocal as t };
@@ -1,71 +1,4 @@
1
- //#region \0vite/preload-helper.js
2
- var scriptRel = "modulepreload";
3
- var assetsURL = function(dep) {
4
- return "/" + dep;
5
- };
6
- var seen$1 = {};
7
- var __vitePreload = function preload(baseModule, deps, importerUrl) {
8
- let promise = Promise.resolve();
9
- if (deps && deps.length > 0) {
10
- const links = document.getElementsByTagName("link");
11
- const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
12
- const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
13
- function allSettled(promises) {
14
- return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
15
- status: "fulfilled",
16
- value
17
- }), (reason) => ({
18
- status: "rejected",
19
- reason
20
- }))));
21
- }
22
- function importMetaResolve(specifier) {
23
- if (import.meta.resolve) return import.meta.resolve(specifier);
24
- return new URL(
25
- specifier,
26
- /** #__KEEP__ */
27
- import.meta.url
28
- ).href;
29
- }
30
- promise = allSettled(deps.map((dep) => {
31
- dep = assetsURL(dep, importerUrl);
32
- dep = importMetaResolve(dep);
33
- if (dep in seen$1) return;
34
- seen$1[dep] = true;
35
- const isCss = dep.endsWith(".css");
36
- for (let i = links.length - 1; i >= 0; i--) {
37
- const link = links[i];
38
- if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
39
- }
40
- const link = document.createElement("link");
41
- link.rel = isCss ? "stylesheet" : scriptRel;
42
- if (!isCss) link.as = "script";
43
- link.crossOrigin = "";
44
- link.href = dep;
45
- if (cspNonce) link.setAttribute("nonce", cspNonce);
46
- document.head.appendChild(link);
47
- if (isCss) return new Promise((res, rej) => {
48
- link.addEventListener("load", res);
49
- link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
50
- });
51
- }));
52
- }
53
- function handlePreloadError(err) {
54
- const e = new Event("vite:preloadError", { cancelable: true });
55
- e.payload = err;
56
- window.dispatchEvent(e);
57
- if (!e.defaultPrevented) throw err;
58
- }
59
- return promise.then((res) => {
60
- for (const item of res || []) {
61
- if (item.status !== "rejected") continue;
62
- handlePreloadError(item.reason);
63
- }
64
- return baseModule().catch(handlePreloadError);
65
- });
66
- };
67
- //#endregion
68
- //#region \0virtual:__remoteEntryHelper__remoteEntry.js
1
+ // \0virtual:__remoteEntryHelper__remoteEntry.js
69
2
  var currentImports = {};
70
3
  var exportSet = /* @__PURE__ */ new Set([
71
4
  "Module",
@@ -75,7 +8,7 @@ var exportSet = /* @__PURE__ */ new Set([
75
8
  ]);
76
9
  var moduleMap = { "./plugin": () => {
77
10
  dynamicLoadingCss(["style.css"], false, "./plugin");
78
- return __federation_import("./__federation_expose_Plugin-DElteI_k.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
11
+ return __federation_import("./__federation_expose_Plugin-XMYQG5xa.js").then((module) => Object.keys(module).every((item) => exportSet.has(item)) ? () => module.default : () => module);
79
12
  } };
80
13
  var seen = {};
81
14
  var dynamicLoadingCss = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => {
@@ -118,7 +51,7 @@ var dynamicLoadingCss = (cssFilePaths, dontAppendStylesToHead, exposeItemName) =
118
51
  });
119
52
  };
120
53
  async function __federation_import(name) {
121
- currentImports[name] ??= __vitePreload(() => import(name), []);
54
+ currentImports[name] ??= import(name);
122
55
  return currentImports[name];
123
56
  }
124
57
  var get = (module) => {
@@ -136,5 +69,4 @@ var init = (shareScope) => {
136
69
  }
137
70
  });
138
71
  };
139
- //#endregion
140
72
  export { dynamicLoadingCss, get, init };
@@ -1,6 +1,6 @@
1
- /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
1
+ /*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
2
2
  @layer properties {
3
- @supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
3
+ @supports (((-webkit-hyphens: none)) and (not (margin-trim: block))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
4
4
  *, :before, :after, ::backdrop {
5
5
  --tw-border-style: solid;
6
6
  --tw-font-weight: initial;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@attraccess/plugin-rabbitmq",
3
- "version": "0.1.0-nightly.1166.1",
3
+ "version": "0.1.0-nightly.1188.1",
4
4
  "description": "Official Attraccess integration for RabbitMQ.",
5
- "license": "AGPL-3.0-only",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/Attraccess/Attraccess.git",
@@ -22,8 +22,8 @@
22
22
  "access": "public"
23
23
  },
24
24
  "peerDependencies": {
25
- "@attraccess/plugins-backend-sdk": "^1.9.0",
26
- "@attraccess/plugins-frontend-sdk": "^1.9.0",
25
+ "@attraccess/plugins-backend-sdk": "^1.11.0-0",
26
+ "@attraccess/plugins-frontend-sdk": "^1.11.0-0",
27
27
  "@attraccess/plugins-frontend-ui": "^1.11.0-0"
28
28
  },
29
29
  "attraccess": {
@@ -37,10 +37,10 @@
37
37
  "ACCESS_MQTT_SERVERS"
38
38
  ],
39
39
  "sdk": {
40
- "backend": "^1.9.0",
41
- "frontend": "^1.9.0"
40
+ "backend": "^1.11.0-0",
41
+ "frontend": "^1.11.0-0"
42
42
  },
43
- "publishedCommit": "ad0616ec36e5b48848bc7ba7f7ec794550424dd8"
43
+ "publishedCommit": "cd28283778a934e08258c3305ff4c07114226385"
44
44
  },
45
- "gitHead": "ad0616ec36e5b48848bc7ba7f7ec794550424dd8"
45
+ "gitHead": "cd28283778a934e08258c3305ff4c07114226385"
46
46
  }
@@ -1,2 +0,0 @@
1
- import { n as getSharedFromRuntime, r as importShared, t as getSharedFromLocal } from "./_virtual___federation_fn_import-BXODRNto.js";
2
- export { importShared, getSharedFromLocal as importSharedLocal, getSharedFromRuntime as importSharedRuntime };