@moh-sso/announcements 0.0.0-stage → 1.3.2
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/README.md +24 -2
- package/dist/_types/apps/announcements/src/api/announcement.api.d.ts +3490 -0
- package/dist/_types/apps/announcements/src/api/index.d.ts +1 -0
- package/dist/_types/apps/announcements/src/components/announcement-actions-menu.component.d.ts +12 -0
- package/dist/_types/apps/announcements/src/components/announcement-attachments.component.d.ts +5 -0
- package/dist/_types/apps/announcements/src/components/announcement-bulk-actions.component.d.ts +14 -0
- package/dist/_types/apps/announcements/src/components/announcement-filters.component.d.ts +23 -0
- package/dist/_types/apps/announcements/src/components/announcements-form.component.d.ts +37 -0
- package/dist/_types/apps/announcements/src/components/manage-announcement-panel.d.ts +9 -0
- package/dist/_types/apps/announcements/src/index.d.ts +6 -0
- package/dist/_types/apps/announcements/src/pages/announcements.components.d.ts +1 -0
- package/dist/_types/apps/announcements/src/root.component.d.ts +2 -0
- package/dist/_types/apps/announcements/src/routes.d.ts +2 -0
- package/dist/_types/apps/announcements/src/single-spa.d.ts +1 -0
- package/dist/_types/apps/announcements/src/types/announcements.types.d.ts +172 -0
- package/dist/_types/apps/announcements/src/types/index.d.ts +1 -0
- package/dist/_types/apps/clients/src/types/client-role.types.d.ts +6 -0
- package/dist/_types/apps/clients/src/types/index.d.ts +2 -0
- package/dist/_types/apps/clients/src/types/user-role.types.d.ts +6 -0
- package/dist/_types/apps/rbac/src/api/health-context.api.d.ts +2482 -0
- package/dist/_types/apps/rbac/src/api/index.d.ts +2 -0
- package/dist/_types/apps/rbac/src/api/rbac.api.d.ts +10383 -0
- package/dist/_types/apps/rbac/src/components/AccessRequestsPanel.d.ts +6 -0
- package/dist/_types/apps/rbac/src/components/AuditTrailPanel.d.ts +1 -0
- package/dist/_types/apps/rbac/src/components/ChangeRequestsPanel.d.ts +9 -0
- package/dist/_types/apps/rbac/src/components/EffectiveAccessPanel.d.ts +1 -0
- package/dist/_types/apps/rbac/src/components/GovernanceToolsPanel.d.ts +5 -0
- package/dist/_types/apps/rbac/src/components/HealthContextsPanel.d.ts +1 -0
- package/dist/_types/apps/rbac/src/components/ImportExportPanel.d.ts +11 -0
- package/dist/_types/apps/rbac/src/components/PermissionCatalogPanel.d.ts +12 -0
- package/dist/_types/apps/rbac/src/components/PolicySimulatorPanel.d.ts +25 -0
- package/dist/_types/apps/rbac/src/components/RoleTemplatesPanel.d.ts +8 -0
- package/dist/_types/apps/rbac/src/components/SyncDriftPanel.d.ts +5 -0
- package/dist/_types/apps/rbac/src/index.d.ts +5 -0
- package/dist/_types/apps/rbac/src/pages/rbac-management.page.d.ts +1 -0
- package/dist/_types/apps/rbac/src/root.component.d.ts +2 -0
- package/dist/_types/apps/rbac/src/routes.d.ts +2 -0
- package/dist/_types/apps/rbac/src/types/health-context.types.d.ts +92 -0
- package/dist/_types/apps/rbac/src/types/index.d.ts +2 -0
- package/dist/_types/apps/rbac/src/types/rbac.types.d.ts +451 -0
- package/dist/_types/apps/users/src/api/index.d.ts +1 -0
- package/dist/_types/apps/users/src/api/users.api.d.ts +1799 -0
- package/dist/_types/apps/users/src/components/EnableUserModal.d.ts +8 -0
- package/dist/_types/apps/users/src/components/ResetPasswordModal.d.ts +8 -0
- package/dist/_types/apps/users/src/components/UserFilters.d.ts +12 -0
- package/dist/_types/apps/users/src/components/access-control/UserAccessPanel.d.ts +5 -0
- package/dist/_types/apps/users/src/components/create-user-panel.d.ts +9 -0
- package/dist/_types/apps/users/src/components/useEnableUserModal.d.ts +9 -0
- package/dist/_types/apps/users/src/components/useResetPasswordModal.d.ts +9 -0
- package/dist/_types/apps/users/src/index.d.ts +6 -0
- package/dist/_types/apps/users/src/pages/user-actions-menu.component.d.ts +11 -0
- package/dist/_types/apps/users/src/pages/user-bulk-actions.component.d.ts +11 -0
- package/dist/_types/apps/users/src/pages/user.component.d.ts +1 -0
- package/dist/_types/apps/users/src/root.component.d.ts +2 -0
- package/dist/_types/apps/users/src/routes.d.ts +2 -0
- package/dist/_types/apps/users/src/types/index.d.ts +1 -0
- package/dist/_types/apps/users/src/types/user.types.d.ts +26 -0
- package/dist/_types/packages/api/src/api/baseApi.d.ts +2 -0
- package/dist/_types/packages/api/src/index.d.ts +1 -0
- package/dist/_types/packages/auth/src/api/auth.api.d.ts +531 -0
- package/dist/_types/packages/auth/src/api/health-context.api.d.ts +374 -0
- package/dist/_types/packages/auth/src/auth/AuthBootstrap.d.ts +1 -0
- package/dist/_types/packages/auth/src/auth/HealthContextProvider.d.ts +20 -0
- package/dist/_types/packages/auth/src/auth/PermissionGuard.d.ts +10 -0
- package/dist/_types/packages/auth/src/auth/auth.selectors.d.ts +896 -0
- package/dist/_types/packages/auth/src/auth/auth.slice.d.ts +14 -0
- package/dist/_types/packages/auth/src/auth/auth.types.d.ts +61 -0
- package/dist/_types/packages/auth/src/auth/login-url.d.ts +2 -0
- package/dist/_types/packages/auth/src/auth/permissions.d.ts +58 -0
- package/dist/_types/packages/auth/src/auth/rbac.d.ts +8 -0
- package/dist/_types/packages/auth/src/auth/system-launch-url.d.ts +9 -0
- package/dist/_types/packages/auth/src/auth/useAuthorization.d.ts +14 -0
- package/dist/_types/packages/auth/src/index.d.ts +14 -0
- package/dist/_types/packages/config/src/appMeta.d.ts +3 -0
- package/dist/_types/packages/config/src/index.d.ts +6 -0
- package/dist/_types/packages/config/src/lib/constants/api.constants.d.ts +178 -0
- package/dist/_types/packages/config/src/lib/constants/document-templates.d.ts +11 -0
- package/dist/_types/packages/config/src/lib/errors/errorMessages.d.ts +2 -0
- package/dist/_types/packages/config/src/lib/errors/errorSeverity.d.ts +3 -0
- package/dist/_types/packages/config/src/lib/errors/errorTypes.d.ts +1 -0
- package/dist/_types/packages/microfrontend/src/basename.d.ts +1 -0
- package/dist/_types/packages/microfrontend/src/index.d.ts +6 -0
- package/dist/_types/packages/microfrontend/src/lifecycle.d.ts +6 -0
- package/dist/_types/packages/microfrontend/src/navigation.d.ts +2 -0
- package/dist/_types/packages/microfrontend/src/props.d.ts +44 -0
- package/dist/_types/packages/microfrontend/src/react-lifecycle.d.ts +11 -0
- package/dist/_types/packages/microfrontend/src/routes.d.ts +13 -0
- package/dist/_types/packages/state/src/clients/clients.selectors.d.ts +534 -0
- package/dist/_types/packages/state/src/clients/clients.slice.d.ts +4 -0
- package/dist/_types/packages/state/src/document/documents.selectors.d.ts +1 -0
- package/dist/_types/packages/state/src/index.d.ts +29 -0
- package/dist/_types/packages/state/src/ui/ui.state.d.ts +1 -0
- package/dist/_types/packages/types/src/index.d.ts +6 -0
- package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
- package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
- package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
- package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
- package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
- package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
- package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
- package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
- package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
- package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
- package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
- package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
- package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
- package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
- package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
- package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
- package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
- package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
- package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
- package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
- package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/index.d.ts +16 -0
- package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
- package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
- package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
- package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
- package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
- package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
- package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
- package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
- package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
- package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
- package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
- package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
- package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
- package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
- package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
- package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
- package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
- package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
- package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
- package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
- package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
- package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
- package/dist/_types/packages/utils/src/index.d.ts +1 -0
- package/dist/_types/packages/utils/src/utils/utils.d.ts +16 -0
- package/dist/api.d.ts +1 -0
- package/dist/api.js +50 -0
- package/dist/api.js.map +1 -0
- package/dist/assets/announcement.api-Di1LFSh_.js +312 -0
- package/dist/assets/announcement.api-Di1LFSh_.js.map +1 -0
- package/dist/assets/announcements-BzR5RE3Z.css +1 -0
- package/dist/assets/root.component-BuA-VwR7.js +2227 -0
- package/dist/assets/root.component-BuA-VwR7.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/routes.d.ts +1 -0
- package/dist/routes.js +32 -0
- package/dist/routes.js.map +1 -0
- package/dist/single-spa.d.ts +1 -0
- package/dist/single-spa.js +32 -0
- package/dist/single-spa.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/package.json +65 -4
|
@@ -0,0 +1,2227 @@
|
|
|
1
|
+
import { jsxs as d, jsx as a, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { Search as He, Dropdown as oe, Button as I, InlineLoading as z, OverflowMenu as ze, OverflowMenuItem as Y, Form as Qe, Stack as le, TextInput as B, TextArea as Ce, Select as ye, SelectItem as v, DatePicker as ve, DatePickerInput as Ie, FormGroup as Be, MultiSelect as te, Checkbox as ne, Tile as ge, Tag as q, Link as je, DataTable as Xe, Table as Ve, TableHead as Ye, TableRow as Ae, TableSelectAll as Ke, TableHeader as We, TableBody as Je, TableSelectRow as Ze, TableCell as F, Pagination as et } from "@carbon/react";
|
|
3
|
+
import { Send as tt, Save as nt, Add as be, Download as at, TrashCan as st, Link as $e, Attachment as _e } from "@carbon/react/icons";
|
|
4
|
+
import { useState as w, useEffect as Re, useMemo as H, useRef as it } from "react";
|
|
5
|
+
import { n as ot, j as rt, w as lt, t as ct, e as dt, b as ut, d as mt, v as pt, k as yt, o as ht, u as gt, f as _t, r as Rt, g as bt } from "./announcement.api-Di1LFSh_.js";
|
|
6
|
+
import { useToast as ce, useHeaderPanel as St, useModal as ft, PageShell as Tt, ErrorState as Ct } from "@moh-sso/ui";
|
|
7
|
+
import { formatDateTime as Ue, isAnnouncementActive as Le, getTagType as vt, getStatusTagType as It } from "@moh-sso/utils";
|
|
8
|
+
import { useAvailableHealthContexts as At } from "@moh-sso/auth";
|
|
9
|
+
import { baseApi as Se } from "@moh-sso/api";
|
|
10
|
+
import "react-redux";
|
|
11
|
+
import { API as D } from "@moh-sso/config";
|
|
12
|
+
function Ut({
|
|
13
|
+
search: t,
|
|
14
|
+
status: e,
|
|
15
|
+
level: n,
|
|
16
|
+
audience: s,
|
|
17
|
+
pin: u,
|
|
18
|
+
statusOptions: T,
|
|
19
|
+
levelOptions: p,
|
|
20
|
+
audienceOptions: C,
|
|
21
|
+
pinOptions: o,
|
|
22
|
+
onSearchChange: f,
|
|
23
|
+
onStatusChange: A,
|
|
24
|
+
onLevelChange: b,
|
|
25
|
+
onAudienceChange: E,
|
|
26
|
+
onPinChange: U,
|
|
27
|
+
onReset: P
|
|
28
|
+
}) {
|
|
29
|
+
const L = [...T], k = [...p], x = [...C], h = [...o];
|
|
30
|
+
return /* @__PURE__ */ d("div", { className: "announcement-filter-grid", children: [
|
|
31
|
+
/* @__PURE__ */ a(
|
|
32
|
+
He,
|
|
33
|
+
{
|
|
34
|
+
id: "announcement-search",
|
|
35
|
+
labelText: "Search announcements",
|
|
36
|
+
placeholder: "Search by title, message, tag, level, status...",
|
|
37
|
+
value: t,
|
|
38
|
+
onChange: (c) => f(c.target.value)
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ a(
|
|
42
|
+
oe,
|
|
43
|
+
{
|
|
44
|
+
id: "announcement-status-filter",
|
|
45
|
+
titleText: "Status",
|
|
46
|
+
label: "Status",
|
|
47
|
+
items: L,
|
|
48
|
+
itemToString: (c) => c?.label ?? "",
|
|
49
|
+
selectedItem: L.find((c) => c.id === e),
|
|
50
|
+
onChange: ({ selectedItem: c }) => {
|
|
51
|
+
c && A(c.id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ a(
|
|
56
|
+
oe,
|
|
57
|
+
{
|
|
58
|
+
id: "announcement-level-filter",
|
|
59
|
+
titleText: "Level",
|
|
60
|
+
label: "Level",
|
|
61
|
+
items: k,
|
|
62
|
+
itemToString: (c) => c?.label ?? "",
|
|
63
|
+
selectedItem: k.find((c) => c.id === n),
|
|
64
|
+
onChange: ({ selectedItem: c }) => {
|
|
65
|
+
c && b(c.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ a(
|
|
70
|
+
oe,
|
|
71
|
+
{
|
|
72
|
+
id: "announcement-audience-filter",
|
|
73
|
+
titleText: "Audience",
|
|
74
|
+
label: "Audience",
|
|
75
|
+
items: x,
|
|
76
|
+
itemToString: (c) => c?.label ?? "",
|
|
77
|
+
selectedItem: x.find((c) => c.id === s),
|
|
78
|
+
onChange: ({ selectedItem: c }) => {
|
|
79
|
+
c && E(c.id);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ a(
|
|
84
|
+
oe,
|
|
85
|
+
{
|
|
86
|
+
id: "announcement-pin-filter",
|
|
87
|
+
titleText: "Pin",
|
|
88
|
+
label: "Pin",
|
|
89
|
+
items: h,
|
|
90
|
+
itemToString: (c) => c?.label ?? "",
|
|
91
|
+
selectedItem: h.find((c) => c.id === u),
|
|
92
|
+
onChange: ({ selectedItem: c }) => {
|
|
93
|
+
c && U(c.id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ a(I, { kind: "ghost", onClick: P, children: "Clear filters" })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
function Lt({
|
|
101
|
+
announcements: t,
|
|
102
|
+
loadingAction: e,
|
|
103
|
+
onPublish: n,
|
|
104
|
+
onMoveToDraft: s,
|
|
105
|
+
onArchive: u,
|
|
106
|
+
onPin: T,
|
|
107
|
+
onUnpin: p,
|
|
108
|
+
onDelete: C
|
|
109
|
+
}) {
|
|
110
|
+
if (t.length === 0) return null;
|
|
111
|
+
const o = !!e;
|
|
112
|
+
return /* @__PURE__ */ d("div", { className: "announcement-bulk-actions", children: [
|
|
113
|
+
/* @__PURE__ */ d("strong", { children: [
|
|
114
|
+
t.length,
|
|
115
|
+
" selected"
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ d("div", { className: "announcement-bulk-actions__buttons", children: [
|
|
118
|
+
o && /* @__PURE__ */ a(z, { description: "Processing…" }),
|
|
119
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "secondary", disabled: o, onClick: n, children: "Publish" }),
|
|
120
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "ghost", disabled: o, onClick: s, children: "Move to draft" }),
|
|
121
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "ghost", disabled: o, onClick: T, children: "Pin" }),
|
|
122
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "ghost", disabled: o, onClick: p, children: "Unpin" }),
|
|
123
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "ghost", disabled: o, onClick: u, children: "Archive" }),
|
|
124
|
+
/* @__PURE__ */ a(I, { size: "sm", kind: "danger--tertiary", disabled: o, onClick: C, children: "Delete" })
|
|
125
|
+
] })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
function xt({
|
|
129
|
+
announcement: t,
|
|
130
|
+
onEdit: e,
|
|
131
|
+
onPublish: n,
|
|
132
|
+
onMoveToDraft: s,
|
|
133
|
+
onTogglePin: u,
|
|
134
|
+
onArchive: T,
|
|
135
|
+
onDelete: p
|
|
136
|
+
}) {
|
|
137
|
+
return /* @__PURE__ */ d(ze, { size: "sm", flipped: !0, children: [
|
|
138
|
+
/* @__PURE__ */ a(Y, { itemText: "Edit", onClick: e }),
|
|
139
|
+
t.status !== "PUBLISHED" && /* @__PURE__ */ a(Y, { itemText: "Publish now", onClick: n }),
|
|
140
|
+
t.status !== "DRAFT" && /* @__PURE__ */ a(Y, { itemText: "Move to draft", onClick: s }),
|
|
141
|
+
/* @__PURE__ */ a(Y, { itemText: t.is_pinned ? "Unpin" : "Pin", onClick: u }),
|
|
142
|
+
t.status !== "ARCHIVED" && /* @__PURE__ */ a(Y, { itemText: "Archive", onClick: T }),
|
|
143
|
+
/* @__PURE__ */ a(Y, { itemText: "Delete", onClick: p, isDelete: !0, hasDivider: !0 })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
const l = "/admin/rbac", Pt = Se.injectEndpoints({
|
|
147
|
+
endpoints: (t) => ({
|
|
148
|
+
registerRbacSystem: t.mutation({
|
|
149
|
+
query: (e) => ({ url: `${l}/systems`, method: "POST", body: e }),
|
|
150
|
+
transformResponse: (e) => e.data,
|
|
151
|
+
invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
|
|
152
|
+
}),
|
|
153
|
+
listRbacSystems: t.query({
|
|
154
|
+
query: () => `${l}/systems`,
|
|
155
|
+
transformResponse: (e) => e.data,
|
|
156
|
+
providesTags: [{ type: "RbacSystem", id: "LIST" }]
|
|
157
|
+
}),
|
|
158
|
+
getRbacSystem: t.query({
|
|
159
|
+
query: (e) => `${l}/systems/${encodeURIComponent(e)}`,
|
|
160
|
+
transformResponse: (e) => e.data,
|
|
161
|
+
providesTags: (e, n, s) => [{ type: "RbacSystem", id: s }]
|
|
162
|
+
}),
|
|
163
|
+
updateRbacSystem: t.mutation({
|
|
164
|
+
query: ({ clientId: e, data: n }) => ({
|
|
165
|
+
url: `${l}/systems/${encodeURIComponent(e)}`,
|
|
166
|
+
method: "PUT",
|
|
167
|
+
body: n
|
|
168
|
+
}),
|
|
169
|
+
transformResponse: (e) => e.data,
|
|
170
|
+
invalidatesTags: (e, n, { clientId: s }) => [
|
|
171
|
+
{ type: "RbacSystem", id: "LIST" },
|
|
172
|
+
{ type: "RbacSystem", id: s }
|
|
173
|
+
]
|
|
174
|
+
}),
|
|
175
|
+
transitionRbacSystem: t.mutation({
|
|
176
|
+
query: ({ clientId: e, ...n }) => ({
|
|
177
|
+
url: `${l}/systems/${encodeURIComponent(e)}/lifecycle`,
|
|
178
|
+
method: "POST",
|
|
179
|
+
body: n
|
|
180
|
+
}),
|
|
181
|
+
transformResponse: (e) => e.data,
|
|
182
|
+
invalidatesTags: (e, n, { clientId: s }) => [
|
|
183
|
+
{ type: "RbacSystem", id: "LIST" },
|
|
184
|
+
{ type: "RbacSystem", id: s },
|
|
185
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
186
|
+
]
|
|
187
|
+
}),
|
|
188
|
+
listRbacPermissions: t.query({
|
|
189
|
+
query: () => `${l}/permissions`,
|
|
190
|
+
transformResponse: (e) => e.data,
|
|
191
|
+
providesTags: [{ type: "RbacPermission", id: "LIST" }]
|
|
192
|
+
}),
|
|
193
|
+
updateRbacPermissionMetadata: t.mutation({
|
|
194
|
+
query: ({ permissionKey: e, data: n }) => ({
|
|
195
|
+
url: `${l}/permissions/${encodeURIComponent(e)}`,
|
|
196
|
+
method: "PUT",
|
|
197
|
+
body: n
|
|
198
|
+
}),
|
|
199
|
+
transformResponse: (e) => e.data,
|
|
200
|
+
invalidatesTags: [{ type: "RbacPermission", id: "LIST" }]
|
|
201
|
+
}),
|
|
202
|
+
listSystemRoles: t.query({
|
|
203
|
+
query: (e) => `${l}/systems/${encodeURIComponent(e)}/roles`,
|
|
204
|
+
transformResponse: (e) => e.data,
|
|
205
|
+
providesTags: (e, n, s) => [{ type: "RbacSystem", id: s }]
|
|
206
|
+
}),
|
|
207
|
+
createSystemRole: t.mutation(
|
|
208
|
+
{
|
|
209
|
+
query: ({ clientId: e, data: n }) => ({
|
|
210
|
+
url: `${l}/systems/${encodeURIComponent(e)}/roles`,
|
|
211
|
+
method: "POST",
|
|
212
|
+
body: n
|
|
213
|
+
}),
|
|
214
|
+
transformResponse: (e) => e.data,
|
|
215
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
updateSystemRole: t.mutation({
|
|
219
|
+
query: ({ roleId: e, data: n }) => ({
|
|
220
|
+
url: `${l}/roles/${encodeURIComponent(e)}`,
|
|
221
|
+
method: "PUT",
|
|
222
|
+
body: n
|
|
223
|
+
}),
|
|
224
|
+
transformResponse: (e) => e.data,
|
|
225
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
226
|
+
}),
|
|
227
|
+
deleteSystemRole: t.mutation({
|
|
228
|
+
query: ({ roleId: e }) => ({
|
|
229
|
+
url: `${l}/roles/${encodeURIComponent(e)}`,
|
|
230
|
+
method: "DELETE"
|
|
231
|
+
}),
|
|
232
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
233
|
+
}),
|
|
234
|
+
getRoleUsage: t.query({
|
|
235
|
+
query: (e) => `${l}/roles/${encodeURIComponent(e)}/usage`,
|
|
236
|
+
transformResponse: (e) => e.data
|
|
237
|
+
}),
|
|
238
|
+
copyRolePermissions: t.mutation({
|
|
239
|
+
query: ({ roleId: e, data: n }) => ({
|
|
240
|
+
url: `${l}/roles/${encodeURIComponent(e)}/copy-permissions`,
|
|
241
|
+
method: "POST",
|
|
242
|
+
body: n
|
|
243
|
+
}),
|
|
244
|
+
transformResponse: (e) => e.data,
|
|
245
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
246
|
+
}),
|
|
247
|
+
assignSystemRolePermission: t.mutation({
|
|
248
|
+
query: ({ roleId: e, data: n }) => ({
|
|
249
|
+
url: `${l}/roles/${encodeURIComponent(e)}/permissions`,
|
|
250
|
+
method: "POST",
|
|
251
|
+
body: n
|
|
252
|
+
}),
|
|
253
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
254
|
+
}),
|
|
255
|
+
removeSystemRolePermission: t.mutation({
|
|
256
|
+
query: ({ roleId: e, permissionKey: n }) => ({
|
|
257
|
+
url: `${l}/roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(n)}`,
|
|
258
|
+
method: "DELETE"
|
|
259
|
+
}),
|
|
260
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
261
|
+
}),
|
|
262
|
+
listRealmRolePermissions: t.query({
|
|
263
|
+
query: () => `${l}/realm-roles`,
|
|
264
|
+
transformResponse: (e) => e.data,
|
|
265
|
+
providesTags: [{ type: "RbacRealmRole", id: "LIST" }]
|
|
266
|
+
}),
|
|
267
|
+
listRbacGroups: t.query({
|
|
268
|
+
query: () => `${l}/groups`,
|
|
269
|
+
transformResponse: (e) => e.data,
|
|
270
|
+
providesTags: [{ type: "RbacGroup", id: "LIST" }]
|
|
271
|
+
}),
|
|
272
|
+
getRbacGroup: t.query({
|
|
273
|
+
query: (e) => `${l}/groups/${encodeURIComponent(e)}`,
|
|
274
|
+
transformResponse: (e) => e.data,
|
|
275
|
+
providesTags: (e, n, s) => [{ type: "RbacGroup", id: s }]
|
|
276
|
+
}),
|
|
277
|
+
listRbacGroupMembers: t.query({
|
|
278
|
+
query: (e) => `${l}/groups/${encodeURIComponent(e)}/members`,
|
|
279
|
+
transformResponse: (e) => e.data,
|
|
280
|
+
providesTags: (e, n, s) => [{ type: "RbacGroup", id: `${s}:members` }]
|
|
281
|
+
}),
|
|
282
|
+
upsertRbacGroup: t.mutation({
|
|
283
|
+
query: (e) => ({
|
|
284
|
+
url: `${l}/groups`,
|
|
285
|
+
method: "POST",
|
|
286
|
+
body: e
|
|
287
|
+
}),
|
|
288
|
+
transformResponse: (e) => e.data,
|
|
289
|
+
invalidatesTags: [
|
|
290
|
+
{ type: "RbacGroup", id: "LIST" },
|
|
291
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
292
|
+
]
|
|
293
|
+
}),
|
|
294
|
+
addRbacGroupMember: t.mutation({
|
|
295
|
+
query: ({ groupId: e, data: n }) => ({
|
|
296
|
+
url: `${l}/groups/${encodeURIComponent(e)}/members`,
|
|
297
|
+
method: "POST",
|
|
298
|
+
body: n
|
|
299
|
+
}),
|
|
300
|
+
transformResponse: (e) => e.data,
|
|
301
|
+
invalidatesTags: (e, n, { groupId: s, data: u }) => [
|
|
302
|
+
{ type: "RbacGroup", id: s },
|
|
303
|
+
{ type: "RbacGroup", id: `${s}:members` },
|
|
304
|
+
{ type: "RbacGroup", id: "LIST" },
|
|
305
|
+
{ type: "RbacAudit", id: "LIST" },
|
|
306
|
+
{ type: "User", id: u.userId }
|
|
307
|
+
]
|
|
308
|
+
}),
|
|
309
|
+
removeRbacGroupMember: t.mutation({
|
|
310
|
+
query: ({ groupId: e, userId: n }) => ({
|
|
311
|
+
url: `${l}/groups/${encodeURIComponent(e)}/members/${encodeURIComponent(n)}`,
|
|
312
|
+
method: "DELETE"
|
|
313
|
+
}),
|
|
314
|
+
transformResponse: (e) => e.data,
|
|
315
|
+
invalidatesTags: (e, n, { groupId: s, userId: u }) => [
|
|
316
|
+
{ type: "RbacGroup", id: s },
|
|
317
|
+
{ type: "RbacGroup", id: `${s}:members` },
|
|
318
|
+
{ type: "RbacGroup", id: "LIST" },
|
|
319
|
+
{ type: "RbacAudit", id: "LIST" },
|
|
320
|
+
{ type: "User", id: u }
|
|
321
|
+
]
|
|
322
|
+
}),
|
|
323
|
+
syncRbacGroupMembers: t.mutation({
|
|
324
|
+
query: (e) => ({
|
|
325
|
+
url: `${l}/groups/${encodeURIComponent(e)}/sync-members`,
|
|
326
|
+
method: "POST"
|
|
327
|
+
}),
|
|
328
|
+
transformResponse: (e) => e.data,
|
|
329
|
+
invalidatesTags: (e, n, s) => [
|
|
330
|
+
{ type: "RbacGroup", id: s },
|
|
331
|
+
{ type: "RbacGroup", id: `${s}:members` },
|
|
332
|
+
{ type: "RbacGroup", id: "LIST" },
|
|
333
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
334
|
+
]
|
|
335
|
+
}),
|
|
336
|
+
replaceRbacGroupMembers: t.mutation({
|
|
337
|
+
query: ({ groupId: e, data: n }) => ({
|
|
338
|
+
url: `${l}/groups/${encodeURIComponent(e)}/members`,
|
|
339
|
+
method: "PUT",
|
|
340
|
+
body: n
|
|
341
|
+
}),
|
|
342
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
343
|
+
{ type: "RbacGroup", id: s },
|
|
344
|
+
{ type: "RbacGroup", id: "LIST" },
|
|
345
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
346
|
+
]
|
|
347
|
+
}),
|
|
348
|
+
assignGroupPermission: t.mutation(
|
|
349
|
+
{
|
|
350
|
+
query: ({ groupId: e, data: n }) => ({
|
|
351
|
+
url: `${l}/groups/${encodeURIComponent(e)}/permissions`,
|
|
352
|
+
method: "POST",
|
|
353
|
+
body: n
|
|
354
|
+
}),
|
|
355
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
356
|
+
{ type: "RbacGroup", id: s },
|
|
357
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
),
|
|
361
|
+
removeGroupPermission: t.mutation({
|
|
362
|
+
query: ({ groupId: e, permissionKey: n }) => ({
|
|
363
|
+
url: `${l}/groups/${encodeURIComponent(e)}/permissions/${encodeURIComponent(n)}`,
|
|
364
|
+
method: "DELETE"
|
|
365
|
+
}),
|
|
366
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
367
|
+
{ type: "RbacGroup", id: s },
|
|
368
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
369
|
+
]
|
|
370
|
+
}),
|
|
371
|
+
assignGroupRealmRole: t.mutation({
|
|
372
|
+
query: ({ groupId: e, data: n }) => ({
|
|
373
|
+
url: `${l}/groups/${encodeURIComponent(e)}/realm-roles`,
|
|
374
|
+
method: "POST",
|
|
375
|
+
body: n
|
|
376
|
+
}),
|
|
377
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
378
|
+
{ type: "RbacGroup", id: s },
|
|
379
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
380
|
+
]
|
|
381
|
+
}),
|
|
382
|
+
removeGroupRealmRole: t.mutation({
|
|
383
|
+
query: ({ groupId: e, realmRole: n }) => ({
|
|
384
|
+
url: `${l}/groups/${encodeURIComponent(e)}/realm-roles/${encodeURIComponent(n)}`,
|
|
385
|
+
method: "DELETE"
|
|
386
|
+
}),
|
|
387
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
388
|
+
{ type: "RbacGroup", id: s },
|
|
389
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
390
|
+
]
|
|
391
|
+
}),
|
|
392
|
+
assignGroupSystemRole: t.mutation({
|
|
393
|
+
query: ({ groupId: e, data: n }) => ({
|
|
394
|
+
url: `${l}/groups/${encodeURIComponent(e)}/system-roles`,
|
|
395
|
+
method: "POST",
|
|
396
|
+
body: n
|
|
397
|
+
}),
|
|
398
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
399
|
+
{ type: "RbacGroup", id: s },
|
|
400
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
401
|
+
]
|
|
402
|
+
}),
|
|
403
|
+
removeGroupSystemRole: t.mutation({
|
|
404
|
+
query: ({ groupId: e, clientId: n, roleName: s }) => ({
|
|
405
|
+
url: `${l}/groups/${encodeURIComponent(e)}/system-roles/${encodeURIComponent(n)}/${encodeURIComponent(s)}`,
|
|
406
|
+
method: "DELETE"
|
|
407
|
+
}),
|
|
408
|
+
invalidatesTags: (e, n, { groupId: s }) => [
|
|
409
|
+
{ type: "RbacGroup", id: s },
|
|
410
|
+
{ type: "RbacGroup", id: "LIST" }
|
|
411
|
+
]
|
|
412
|
+
}),
|
|
413
|
+
getRealmRoleUsage: t.query({
|
|
414
|
+
query: (e) => `${l}/realm-roles/${encodeURIComponent(e)}/usage`,
|
|
415
|
+
transformResponse: (e) => e.data
|
|
416
|
+
}),
|
|
417
|
+
assignRealmRolePermission: t.mutation({
|
|
418
|
+
query: ({ realmRole: e, data: n }) => ({
|
|
419
|
+
url: `${l}/realm-roles/${encodeURIComponent(e)}/permissions`,
|
|
420
|
+
method: "POST",
|
|
421
|
+
body: n
|
|
422
|
+
}),
|
|
423
|
+
invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
|
|
424
|
+
}),
|
|
425
|
+
removeRealmRolePermission: t.mutation(
|
|
426
|
+
{
|
|
427
|
+
query: ({ realmRole: e, permissionKey: n }) => ({
|
|
428
|
+
url: `${l}/realm-roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(n)}`,
|
|
429
|
+
method: "DELETE"
|
|
430
|
+
}),
|
|
431
|
+
invalidatesTags: [{ type: "RbacRealmRole", id: "LIST" }]
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
addSystemAccessRole: t.mutation({
|
|
435
|
+
query: ({ clientId: e, data: n }) => ({
|
|
436
|
+
url: `${l}/systems/${encodeURIComponent(e)}/access-roles`,
|
|
437
|
+
method: "POST",
|
|
438
|
+
body: n
|
|
439
|
+
}),
|
|
440
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
441
|
+
}),
|
|
442
|
+
removeSystemAccessRole: t.mutation({
|
|
443
|
+
query: ({ clientId: e, roleName: n, force: s }) => ({
|
|
444
|
+
url: `${l}/systems/${encodeURIComponent(e)}/access-roles/${encodeURIComponent(n)}${s ? "?force=true" : ""}`,
|
|
445
|
+
method: "DELETE"
|
|
446
|
+
}),
|
|
447
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
448
|
+
}),
|
|
449
|
+
getRbacDrift: t.query({
|
|
450
|
+
query: () => `${l}/drift`,
|
|
451
|
+
transformResponse: (e) => e.data,
|
|
452
|
+
providesTags: [{ type: "RbacSystem", id: "DRIFT" }]
|
|
453
|
+
}),
|
|
454
|
+
previewRbacRealmExportDrift: t.mutation({
|
|
455
|
+
query: (e) => ({
|
|
456
|
+
url: `${l}/drift/realm-export`,
|
|
457
|
+
method: "POST",
|
|
458
|
+
body: e
|
|
459
|
+
}),
|
|
460
|
+
transformResponse: (e) => e.data
|
|
461
|
+
}),
|
|
462
|
+
previewRbacSync: t.mutation({
|
|
463
|
+
query: (e) => ({
|
|
464
|
+
url: `${l}/sync/preview`,
|
|
465
|
+
method: "POST",
|
|
466
|
+
body: e
|
|
467
|
+
}),
|
|
468
|
+
transformResponse: (e) => e.data
|
|
469
|
+
}),
|
|
470
|
+
applyRbacSync: t.mutation({
|
|
471
|
+
query: (e) => ({
|
|
472
|
+
url: `${l}/sync/apply`,
|
|
473
|
+
method: "POST",
|
|
474
|
+
body: e
|
|
475
|
+
}),
|
|
476
|
+
transformResponse: (e) => e.data,
|
|
477
|
+
invalidatesTags: [
|
|
478
|
+
{ type: "RbacSystem", id: "LIST" },
|
|
479
|
+
{ type: "RbacSystem", id: "DRIFT" },
|
|
480
|
+
{ type: "RbacRealmRole", id: "LIST" }
|
|
481
|
+
]
|
|
482
|
+
}),
|
|
483
|
+
getRbacEffectiveAccess: t.query({
|
|
484
|
+
query: ({ userId: e = "lookup", username: n, email: s }) => {
|
|
485
|
+
const u = new URLSearchParams();
|
|
486
|
+
n && u.set("username", n), s && u.set("email", s);
|
|
487
|
+
const T = u.toString();
|
|
488
|
+
return `${l}/effective-access/users/${encodeURIComponent(e)}${T ? `?${T}` : ""}`;
|
|
489
|
+
},
|
|
490
|
+
transformResponse: (e) => e.data
|
|
491
|
+
}),
|
|
492
|
+
getAssignableUserAccess: t.query({
|
|
493
|
+
query: () => `${l}/user-access/assignable`,
|
|
494
|
+
transformResponse: (e) => e.data,
|
|
495
|
+
providesTags: [{ type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" }]
|
|
496
|
+
}),
|
|
497
|
+
getUserAccessProfile: t.query({
|
|
498
|
+
query: (e) => `${l}/user-access/users/${encodeURIComponent(e)}`,
|
|
499
|
+
transformResponse: (e) => e.data,
|
|
500
|
+
providesTags: (e, n, s) => [
|
|
501
|
+
{ type: "RbacSystem", id: "USER_ACCESS_ASSIGNABLE" },
|
|
502
|
+
{ type: "User", id: s },
|
|
503
|
+
{ type: "UserClientRole", id: `LIST-${s}` }
|
|
504
|
+
]
|
|
505
|
+
}),
|
|
506
|
+
updateUserAccess: t.mutation({
|
|
507
|
+
query: ({ userId: e, data: n }) => ({
|
|
508
|
+
url: `${l}/user-access/users/${encodeURIComponent(e)}`,
|
|
509
|
+
method: "PUT",
|
|
510
|
+
body: n
|
|
511
|
+
}),
|
|
512
|
+
transformResponse: (e) => e.data,
|
|
513
|
+
invalidatesTags: (e, n, { userId: s }) => [
|
|
514
|
+
{ type: "User", id: s },
|
|
515
|
+
{ type: "User", id: "LIST" },
|
|
516
|
+
{ type: "UserClientRole", id: `LIST-${s}` },
|
|
517
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
518
|
+
]
|
|
519
|
+
}),
|
|
520
|
+
previewRbacChange: t.mutation({
|
|
521
|
+
query: (e) => ({ url: `${l}/changes/preview`, method: "POST", body: e }),
|
|
522
|
+
transformResponse: (e) => e.data
|
|
523
|
+
}),
|
|
524
|
+
exportRbacSeed: t.query({
|
|
525
|
+
query: () => `${l}/export`,
|
|
526
|
+
transformResponse: (e) => e.data
|
|
527
|
+
}),
|
|
528
|
+
previewRbacImport: t.mutation({
|
|
529
|
+
query: (e) => ({ url: `${l}/import/preview`, method: "POST", body: e }),
|
|
530
|
+
transformResponse: (e) => e.data
|
|
531
|
+
}),
|
|
532
|
+
applyRbacImport: t.mutation({
|
|
533
|
+
query: (e) => ({ url: `${l}/import/apply`, method: "POST", body: e }),
|
|
534
|
+
transformResponse: (e) => e.data,
|
|
535
|
+
invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
|
|
536
|
+
}),
|
|
537
|
+
listRbacAuditEvents: t.query({
|
|
538
|
+
query: (e) => {
|
|
539
|
+
const n = new URLSearchParams();
|
|
540
|
+
e?.actor && n.set("actor", e.actor), e?.systemClientId && n.set("systemClientId", e.systemClientId), e?.roleName && n.set("roleName", e.roleName), e?.permissionKey && n.set("permissionKey", e.permissionKey), e?.action && n.set("action", e.action), e?.from && n.set("from", e.from), e?.to && n.set("to", e.to), e?.limit && n.set("limit", String(e.limit));
|
|
541
|
+
const s = n.toString();
|
|
542
|
+
return `${l}/audit${s ? `?${s}` : ""}`;
|
|
543
|
+
},
|
|
544
|
+
transformResponse: (e) => e.data,
|
|
545
|
+
providesTags: [{ type: "RbacAudit", id: "LIST" }]
|
|
546
|
+
}),
|
|
547
|
+
listRbacRoleTemplates: t.query({
|
|
548
|
+
query: () => `${l}/role-templates`,
|
|
549
|
+
transformResponse: (e) => e.data
|
|
550
|
+
}),
|
|
551
|
+
createRoleFromTemplate: t.mutation({
|
|
552
|
+
query: ({ clientId: e, data: n }) => ({
|
|
553
|
+
url: `${l}/systems/${encodeURIComponent(e)}/roles/from-template`,
|
|
554
|
+
method: "POST",
|
|
555
|
+
body: n
|
|
556
|
+
}),
|
|
557
|
+
transformResponse: (e) => e.data,
|
|
558
|
+
invalidatesTags: (e, n, { clientId: s }) => [{ type: "RbacSystem", id: s }]
|
|
559
|
+
}),
|
|
560
|
+
bulkAssignPermission: t.mutation({
|
|
561
|
+
query: (e) => ({ url: `${l}/bulk/assign-permission`, method: "POST", body: e }),
|
|
562
|
+
invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
|
|
563
|
+
}),
|
|
564
|
+
bulkRemovePermission: t.mutation({
|
|
565
|
+
query: (e) => ({ url: `${l}/bulk/remove-permission`, method: "POST", body: e }),
|
|
566
|
+
invalidatesTags: [{ type: "RbacSystem", id: "LIST" }]
|
|
567
|
+
}),
|
|
568
|
+
listAccessRequests: t.query({
|
|
569
|
+
query: () => `${l}/access-requests`,
|
|
570
|
+
transformResponse: (e) => e.data,
|
|
571
|
+
providesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
|
|
572
|
+
}),
|
|
573
|
+
createAccessRequest: t.mutation({
|
|
574
|
+
query: (e) => ({ url: "/access-requests", method: "POST", body: e }),
|
|
575
|
+
transformResponse: (e) => e.data,
|
|
576
|
+
invalidatesTags: [{ type: "RbacAccessRequest", id: "LIST" }]
|
|
577
|
+
}),
|
|
578
|
+
decideAccessRequest: t.mutation({
|
|
579
|
+
query: ({ id: e, decision: n, data: s }) => ({
|
|
580
|
+
url: `${l}/access-requests/${encodeURIComponent(e)}/${n}`,
|
|
581
|
+
method: "POST",
|
|
582
|
+
body: s ?? {}
|
|
583
|
+
}),
|
|
584
|
+
transformResponse: (e) => e.data,
|
|
585
|
+
invalidatesTags: [
|
|
586
|
+
{ type: "RbacAccessRequest", id: "LIST" },
|
|
587
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
588
|
+
]
|
|
589
|
+
}),
|
|
590
|
+
listChangeRequests: t.query({
|
|
591
|
+
query: () => `${l}/change-requests`,
|
|
592
|
+
transformResponse: (e) => e.data,
|
|
593
|
+
providesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
|
|
594
|
+
}),
|
|
595
|
+
createChangeRequest: t.mutation({
|
|
596
|
+
query: (e) => ({ url: `${l}/change-requests`, method: "POST", body: e }),
|
|
597
|
+
transformResponse: (e) => e.data,
|
|
598
|
+
invalidatesTags: [{ type: "RbacChangeRequest", id: "LIST" }]
|
|
599
|
+
}),
|
|
600
|
+
decideChangeRequest: t.mutation({
|
|
601
|
+
query: ({ id: e, decision: n, data: s }) => ({
|
|
602
|
+
url: `${l}/change-requests/${encodeURIComponent(e)}/${n}`,
|
|
603
|
+
method: "POST",
|
|
604
|
+
body: s ?? {}
|
|
605
|
+
}),
|
|
606
|
+
transformResponse: (e) => e.data,
|
|
607
|
+
invalidatesTags: [
|
|
608
|
+
{ type: "RbacChangeRequest", id: "LIST" },
|
|
609
|
+
{ type: "RbacAudit", id: "LIST" }
|
|
610
|
+
]
|
|
611
|
+
}),
|
|
612
|
+
simulateRbacAccess: t.mutation({
|
|
613
|
+
query: (e) => ({ url: `${l}/simulate`, method: "POST", body: e }),
|
|
614
|
+
transformResponse: (e) => e.data
|
|
615
|
+
})
|
|
616
|
+
})
|
|
617
|
+
}), {
|
|
618
|
+
useApplyRbacSyncMutation: dn,
|
|
619
|
+
useApplyRbacImportMutation: un,
|
|
620
|
+
useAddSystemAccessRoleMutation: mn,
|
|
621
|
+
useAddRbacGroupMemberMutation: pn,
|
|
622
|
+
useAssignGroupPermissionMutation: yn,
|
|
623
|
+
useAssignGroupRealmRoleMutation: hn,
|
|
624
|
+
useAssignGroupSystemRoleMutation: gn,
|
|
625
|
+
useAssignRealmRolePermissionMutation: _n,
|
|
626
|
+
useAssignSystemRolePermissionMutation: Rn,
|
|
627
|
+
useBulkAssignPermissionMutation: bn,
|
|
628
|
+
useBulkRemovePermissionMutation: Sn,
|
|
629
|
+
useCopyRolePermissionsMutation: fn,
|
|
630
|
+
useCreateAccessRequestMutation: Tn,
|
|
631
|
+
useCreateChangeRequestMutation: Cn,
|
|
632
|
+
useCreateRoleFromTemplateMutation: vn,
|
|
633
|
+
useCreateSystemRoleMutation: In,
|
|
634
|
+
useDecideAccessRequestMutation: An,
|
|
635
|
+
useDecideChangeRequestMutation: Un,
|
|
636
|
+
useDeleteSystemRoleMutation: Ln,
|
|
637
|
+
useExportRbacSeedQuery: xn,
|
|
638
|
+
useGetRbacDriftQuery: Pn,
|
|
639
|
+
useGetRbacEffectiveAccessQuery: $n,
|
|
640
|
+
useGetRbacGroupQuery: En,
|
|
641
|
+
useGetAssignableUserAccessQuery: qn,
|
|
642
|
+
useGetUserAccessProfileQuery: wn,
|
|
643
|
+
useGetRealmRoleUsageQuery: kn,
|
|
644
|
+
useGetRoleUsageQuery: Nn,
|
|
645
|
+
useListAccessRequestsQuery: Dn,
|
|
646
|
+
useListChangeRequestsQuery: Mn,
|
|
647
|
+
useListRbacAuditEventsQuery: On,
|
|
648
|
+
useGetRbacSystemQuery: Gn,
|
|
649
|
+
useListRbacPermissionsQuery: Fn,
|
|
650
|
+
useListRbacGroupMembersQuery: Hn,
|
|
651
|
+
useListRbacGroupsQuery: $t,
|
|
652
|
+
useListRbacRoleTemplatesQuery: zn,
|
|
653
|
+
useListRbacSystemsQuery: Et,
|
|
654
|
+
useListRealmRolePermissionsQuery: qt,
|
|
655
|
+
useListSystemRolesQuery: Qn,
|
|
656
|
+
usePreviewRbacChangeMutation: Bn,
|
|
657
|
+
usePreviewRbacImportMutation: jn,
|
|
658
|
+
usePreviewRbacRealmExportDriftMutation: Xn,
|
|
659
|
+
usePreviewRbacSyncMutation: Vn,
|
|
660
|
+
useRemoveGroupPermissionMutation: Yn,
|
|
661
|
+
useRemoveRbacGroupMemberMutation: Kn,
|
|
662
|
+
useRemoveGroupRealmRoleMutation: Wn,
|
|
663
|
+
useRemoveGroupSystemRoleMutation: Jn,
|
|
664
|
+
useRemoveRealmRolePermissionMutation: Zn,
|
|
665
|
+
useRemoveSystemAccessRoleMutation: ea,
|
|
666
|
+
useRemoveSystemRolePermissionMutation: ta,
|
|
667
|
+
useSimulateRbacAccessMutation: na,
|
|
668
|
+
useSyncRbacGroupMembersMutation: aa,
|
|
669
|
+
useUpdateUserAccessMutation: sa,
|
|
670
|
+
useUpdateRbacPermissionMetadataMutation: ia,
|
|
671
|
+
useUpdateRbacSystemMutation: oa,
|
|
672
|
+
useRegisterRbacSystemMutation: ra,
|
|
673
|
+
useTransitionRbacSystemMutation: la,
|
|
674
|
+
useUpdateSystemRoleMutation: ca,
|
|
675
|
+
useUpsertRbacGroupMutation: da,
|
|
676
|
+
useReplaceRbacGroupMembersMutation: ua
|
|
677
|
+
} = Pt, M = "/admin/health-contexts", wt = Se.injectEndpoints({
|
|
678
|
+
endpoints: (t) => ({
|
|
679
|
+
listHealthContexts: t.query({
|
|
680
|
+
query: (e) => {
|
|
681
|
+
const n = new URLSearchParams();
|
|
682
|
+
e?.includeDisabled && n.set("includeDisabled", "true"), e?.type && n.set("type", e.type);
|
|
683
|
+
const s = n.toString();
|
|
684
|
+
return `${M}${s ? `?${s}` : ""}`;
|
|
685
|
+
},
|
|
686
|
+
transformResponse: (e) => e.data,
|
|
687
|
+
providesTags: [{ type: "HealthContext", id: "LIST" }]
|
|
688
|
+
}),
|
|
689
|
+
createHealthContext: t.mutation({
|
|
690
|
+
query: (e) => ({ url: M, method: "POST", body: e }),
|
|
691
|
+
transformResponse: (e) => e.data,
|
|
692
|
+
invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
|
|
693
|
+
}),
|
|
694
|
+
updateHealthContext: t.mutation({
|
|
695
|
+
query: ({ contextId: e, body: n }) => ({
|
|
696
|
+
url: `${M}/${encodeURIComponent(e)}`,
|
|
697
|
+
method: "PUT",
|
|
698
|
+
body: n
|
|
699
|
+
}),
|
|
700
|
+
transformResponse: (e) => e.data,
|
|
701
|
+
invalidatesTags: (e, n, { contextId: s }) => [
|
|
702
|
+
{ type: "HealthContext", id: "LIST" },
|
|
703
|
+
{ type: "HealthContext", id: s }
|
|
704
|
+
]
|
|
705
|
+
}),
|
|
706
|
+
deleteHealthContext: t.mutation({
|
|
707
|
+
query: (e) => ({
|
|
708
|
+
url: `${M}/${encodeURIComponent(e)}`,
|
|
709
|
+
method: "DELETE"
|
|
710
|
+
}),
|
|
711
|
+
invalidatesTags: [{ type: "HealthContext", id: "LIST" }]
|
|
712
|
+
}),
|
|
713
|
+
listHealthContextAliases: t.query({
|
|
714
|
+
query: (e) => `${M}/${encodeURIComponent(e)}/aliases`,
|
|
715
|
+
transformResponse: (e) => e.data,
|
|
716
|
+
providesTags: (e, n, s) => [
|
|
717
|
+
{ type: "HealthContext", id: `${s}:aliases` }
|
|
718
|
+
]
|
|
719
|
+
}),
|
|
720
|
+
upsertHealthContextAlias: t.mutation({
|
|
721
|
+
query: ({ contextId: e, ...n }) => ({
|
|
722
|
+
url: `${M}/${encodeURIComponent(e)}/aliases`,
|
|
723
|
+
method: "PUT",
|
|
724
|
+
body: n
|
|
725
|
+
}),
|
|
726
|
+
transformResponse: (e) => e.data,
|
|
727
|
+
invalidatesTags: (e, n, { contextId: s }) => [
|
|
728
|
+
{ type: "HealthContext", id: `${s}:aliases` }
|
|
729
|
+
]
|
|
730
|
+
}),
|
|
731
|
+
deleteHealthContextAlias: t.mutation({
|
|
732
|
+
query: ({ contextId: e, aliasId: n }) => ({
|
|
733
|
+
url: `${M}/${encodeURIComponent(e)}/aliases/${encodeURIComponent(n)}`,
|
|
734
|
+
method: "DELETE"
|
|
735
|
+
}),
|
|
736
|
+
invalidatesTags: (e, n, { contextId: s }) => [
|
|
737
|
+
{ type: "HealthContext", id: `${s}:aliases` }
|
|
738
|
+
]
|
|
739
|
+
}),
|
|
740
|
+
listUserHealthContexts: t.query({
|
|
741
|
+
query: (e) => `/admin/users/${encodeURIComponent(e)}/health-contexts`,
|
|
742
|
+
transformResponse: (e) => e.data,
|
|
743
|
+
providesTags: (e, n, s) => [
|
|
744
|
+
{ type: "HealthContext", id: `user:${s}` }
|
|
745
|
+
]
|
|
746
|
+
}),
|
|
747
|
+
replaceUserHealthContexts: t.mutation({
|
|
748
|
+
query: ({ targetId: e, assignments: n }) => ({
|
|
749
|
+
url: `/admin/users/${encodeURIComponent(e)}/health-contexts`,
|
|
750
|
+
method: "PUT",
|
|
751
|
+
body: { assignments: n }
|
|
752
|
+
}),
|
|
753
|
+
invalidatesTags: (e, n, { targetId: s }) => [
|
|
754
|
+
{ type: "HealthContext", id: `user:${s}` }
|
|
755
|
+
]
|
|
756
|
+
}),
|
|
757
|
+
listGroupHealthContexts: t.query({
|
|
758
|
+
query: (e) => `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
|
|
759
|
+
transformResponse: (e) => e.data,
|
|
760
|
+
providesTags: (e, n, s) => [
|
|
761
|
+
{ type: "HealthContext", id: `group:${s}` }
|
|
762
|
+
]
|
|
763
|
+
}),
|
|
764
|
+
replaceGroupHealthContexts: t.mutation({
|
|
765
|
+
query: ({ targetId: e, assignments: n }) => ({
|
|
766
|
+
url: `/admin/rbac/groups/${encodeURIComponent(e)}/health-contexts`,
|
|
767
|
+
method: "PUT",
|
|
768
|
+
body: { assignments: n }
|
|
769
|
+
}),
|
|
770
|
+
invalidatesTags: (e, n, { targetId: s }) => [
|
|
771
|
+
{ type: "HealthContext", id: `group:${s}` }
|
|
772
|
+
]
|
|
773
|
+
}),
|
|
774
|
+
getHealthContextDrift: t.query({
|
|
775
|
+
query: () => `${M}/drift`,
|
|
776
|
+
transformResponse: (e) => e.data,
|
|
777
|
+
providesTags: [{ type: "HealthContext", id: "DRIFT" }]
|
|
778
|
+
}),
|
|
779
|
+
previewHealthContextSync: t.mutation({
|
|
780
|
+
query: (e) => ({
|
|
781
|
+
url: `${M}/sync/preview`,
|
|
782
|
+
method: "POST",
|
|
783
|
+
body: e
|
|
784
|
+
}),
|
|
785
|
+
transformResponse: (e) => e.data
|
|
786
|
+
}),
|
|
787
|
+
applyHealthContextSync: t.mutation({
|
|
788
|
+
query: (e) => ({
|
|
789
|
+
url: `${M}/sync/apply`,
|
|
790
|
+
method: "POST",
|
|
791
|
+
body: e
|
|
792
|
+
}),
|
|
793
|
+
transformResponse: (e) => e.data,
|
|
794
|
+
invalidatesTags: [
|
|
795
|
+
{ type: "HealthContext", id: "DRIFT" },
|
|
796
|
+
{ type: "HealthContext", id: "LIST" }
|
|
797
|
+
]
|
|
798
|
+
})
|
|
799
|
+
})
|
|
800
|
+
}), {
|
|
801
|
+
useApplyHealthContextSyncMutation: ma,
|
|
802
|
+
useCreateHealthContextMutation: pa,
|
|
803
|
+
useDeleteHealthContextAliasMutation: ya,
|
|
804
|
+
useDeleteHealthContextMutation: ha,
|
|
805
|
+
useListGroupHealthContextsQuery: ga,
|
|
806
|
+
useGetHealthContextDriftQuery: _a,
|
|
807
|
+
useListHealthContextAliasesQuery: Ra,
|
|
808
|
+
useListHealthContextsQuery: ba,
|
|
809
|
+
useListUserHealthContextsQuery: Sa,
|
|
810
|
+
useReplaceGroupHealthContextsMutation: fa,
|
|
811
|
+
useReplaceUserHealthContextsMutation: Ta,
|
|
812
|
+
usePreviewHealthContextSyncMutation: Ca,
|
|
813
|
+
useUpdateHealthContextMutation: va,
|
|
814
|
+
useUpsertHealthContextAliasMutation: Ia
|
|
815
|
+
} = wt, re = (t) => {
|
|
816
|
+
const e = t.enabled ?? t.isActive ?? !1;
|
|
817
|
+
return {
|
|
818
|
+
...t,
|
|
819
|
+
enabled: e,
|
|
820
|
+
isActive: t.isActive ?? e,
|
|
821
|
+
realmRoles: t.realmRoles ?? [],
|
|
822
|
+
clientRoles: t.clientRoles ?? {}
|
|
823
|
+
};
|
|
824
|
+
}, kt = (t) => ({
|
|
825
|
+
username: t.username,
|
|
826
|
+
email: t.email,
|
|
827
|
+
first_name: t.firstName,
|
|
828
|
+
last_name: t.lastName,
|
|
829
|
+
enabled: t.enabled,
|
|
830
|
+
email_verified: t.emailVerified,
|
|
831
|
+
realm_roles: t.realmRoles,
|
|
832
|
+
client_roles: t.clientRoles
|
|
833
|
+
}), Nt = (t) => ({
|
|
834
|
+
email: t.email,
|
|
835
|
+
first_name: t.firstName,
|
|
836
|
+
last_name: t.lastName,
|
|
837
|
+
enabled: t.enabled,
|
|
838
|
+
email_verified: t.emailVerified,
|
|
839
|
+
realm_roles: t.realmRoles,
|
|
840
|
+
client_roles: t.clientRoles
|
|
841
|
+
}), Dt = Se.injectEndpoints({
|
|
842
|
+
endpoints: (t) => ({
|
|
843
|
+
/* --------------------------------
|
|
844
|
+
* List users
|
|
845
|
+
* -------------------------------- */
|
|
846
|
+
listUsers: t.query({
|
|
847
|
+
query: () => ({
|
|
848
|
+
url: D.admin.users.list(),
|
|
849
|
+
credentials: "include"
|
|
850
|
+
}),
|
|
851
|
+
transformResponse: (e) => e.data.map(re),
|
|
852
|
+
providesTags: (e) => e ? [
|
|
853
|
+
...e.map((n) => ({ type: "User", id: n.id })),
|
|
854
|
+
{ type: "User", id: "LIST" }
|
|
855
|
+
] : [{ type: "User", id: "LIST" }]
|
|
856
|
+
}),
|
|
857
|
+
/* --------------------------------
|
|
858
|
+
* Get single user
|
|
859
|
+
* -------------------------------- */
|
|
860
|
+
getUser: t.query({
|
|
861
|
+
query: (e) => ({
|
|
862
|
+
url: D.admin.users.byId(e),
|
|
863
|
+
credentials: "include"
|
|
864
|
+
}),
|
|
865
|
+
transformResponse: (e) => re(e.data),
|
|
866
|
+
providesTags: (e, n, s) => [{ type: "User", id: s }]
|
|
867
|
+
}),
|
|
868
|
+
/* --------------------------------
|
|
869
|
+
* Create user
|
|
870
|
+
* -------------------------------- */
|
|
871
|
+
createUser: t.mutation({
|
|
872
|
+
query: (e) => ({
|
|
873
|
+
url: D.admin.users.create(),
|
|
874
|
+
method: "POST",
|
|
875
|
+
body: kt(e),
|
|
876
|
+
credentials: "include"
|
|
877
|
+
}),
|
|
878
|
+
transformResponse: (e) => re(e.data),
|
|
879
|
+
invalidatesTags: [{ type: "User", id: "LIST" }]
|
|
880
|
+
}),
|
|
881
|
+
/* --------------------------------
|
|
882
|
+
* Update user
|
|
883
|
+
* -------------------------------- */
|
|
884
|
+
updateUser: t.mutation({
|
|
885
|
+
query: ({ id: e, data: n }) => ({
|
|
886
|
+
url: D.admin.users.update(e),
|
|
887
|
+
method: "PUT",
|
|
888
|
+
body: Nt(n),
|
|
889
|
+
credentials: "include"
|
|
890
|
+
}),
|
|
891
|
+
transformResponse: (e) => re(e.data),
|
|
892
|
+
invalidatesTags: (e, n, { id: s }) => [
|
|
893
|
+
{ type: "User", id: s },
|
|
894
|
+
{ type: "User", id: "LIST" }
|
|
895
|
+
]
|
|
896
|
+
}),
|
|
897
|
+
/* --------------------------------
|
|
898
|
+
* Reset password
|
|
899
|
+
* -------------------------------- */
|
|
900
|
+
resetUserPassword: t.mutation({
|
|
901
|
+
query: (e) => ({
|
|
902
|
+
url: D.admin.users.passwordResetEmail(e),
|
|
903
|
+
method: "POST",
|
|
904
|
+
credentials: "include"
|
|
905
|
+
}),
|
|
906
|
+
transformResponse: () => {
|
|
907
|
+
},
|
|
908
|
+
invalidatesTags: (e, n, s) => [{ type: "User", id: s }]
|
|
909
|
+
}),
|
|
910
|
+
/* --------------------------------
|
|
911
|
+
* Delete user
|
|
912
|
+
* -------------------------------- */
|
|
913
|
+
deleteUser: t.mutation({
|
|
914
|
+
query: (e) => ({
|
|
915
|
+
url: D.admin.users.delete(e),
|
|
916
|
+
method: "DELETE",
|
|
917
|
+
credentials: "include"
|
|
918
|
+
}),
|
|
919
|
+
transformResponse: () => {
|
|
920
|
+
},
|
|
921
|
+
invalidatesTags: (e, n, s) => [
|
|
922
|
+
{ type: "User", id: s },
|
|
923
|
+
{ type: "User", id: "LIST" }
|
|
924
|
+
]
|
|
925
|
+
}),
|
|
926
|
+
/* --------------------------------
|
|
927
|
+
* Enable / Disable user
|
|
928
|
+
* -------------------------------- */
|
|
929
|
+
toggleUser: t.mutation({
|
|
930
|
+
query: ({ id: e, enabled: n }) => ({
|
|
931
|
+
url: D.admin.users.toggle(e),
|
|
932
|
+
method: "PATCH",
|
|
933
|
+
body: { enabled: n },
|
|
934
|
+
credentials: "include"
|
|
935
|
+
}),
|
|
936
|
+
transformResponse: () => {
|
|
937
|
+
},
|
|
938
|
+
invalidatesTags: (e, n, { id: s }) => [
|
|
939
|
+
{ type: "User", id: s },
|
|
940
|
+
{ type: "User", id: "LIST" }
|
|
941
|
+
]
|
|
942
|
+
}),
|
|
943
|
+
/* --------------------------------
|
|
944
|
+
* Get user client roles (ADMIN)
|
|
945
|
+
* GET /admin/users/:id/client-roles
|
|
946
|
+
* -------------------------------- */
|
|
947
|
+
getUserClientRoles: t.query({
|
|
948
|
+
query: (e) => ({
|
|
949
|
+
url: `${D.admin.base}/users/${e}/client-roles`,
|
|
950
|
+
credentials: "include"
|
|
951
|
+
}),
|
|
952
|
+
transformResponse: (e) => e.data,
|
|
953
|
+
providesTags: (e, n, s) => e ? [
|
|
954
|
+
...e.map((u) => ({
|
|
955
|
+
type: "UserClientRole",
|
|
956
|
+
id: `${s}-${u.id}`
|
|
957
|
+
})),
|
|
958
|
+
{ type: "UserClientRole", id: `LIST-${s}` }
|
|
959
|
+
] : [{ type: "UserClientRole", id: `LIST-${s}` }]
|
|
960
|
+
}),
|
|
961
|
+
/* --------------------------------
|
|
962
|
+
* Get user client roles for a client (ADMIN)
|
|
963
|
+
* -------------------------------- */
|
|
964
|
+
getUserClientRolesForClient: t.query({
|
|
965
|
+
query: ({ userId: e, clientId: n }) => ({
|
|
966
|
+
url: D.admin.users.clientRoles.list(e, n),
|
|
967
|
+
credentials: "include"
|
|
968
|
+
}),
|
|
969
|
+
transformResponse: (e) => e.data,
|
|
970
|
+
providesTags: (e, n, { userId: s, clientId: u }) => [
|
|
971
|
+
{ type: "UserClientRole", id: `${s}-${u}` }
|
|
972
|
+
]
|
|
973
|
+
}),
|
|
974
|
+
/* --------------------------------
|
|
975
|
+
* Update user client roles (ADMIN – bulk)
|
|
976
|
+
* -------------------------------- */
|
|
977
|
+
updateUserClientRoles: t.mutation({
|
|
978
|
+
query: ({ userId: e, clientId: n, clientUuid: s, roles: u }) => ({
|
|
979
|
+
url: D.admin.users.clientRoles.update(e),
|
|
980
|
+
method: "PUT",
|
|
981
|
+
body: {
|
|
982
|
+
clientId: n,
|
|
983
|
+
clientUuid: s,
|
|
984
|
+
roles: u
|
|
985
|
+
},
|
|
986
|
+
credentials: "include"
|
|
987
|
+
}),
|
|
988
|
+
invalidatesTags: (e, n, { userId: s, clientUuid: u }) => [
|
|
989
|
+
{
|
|
990
|
+
type: "UserClientRole",
|
|
991
|
+
id: `${s}-${u}`
|
|
992
|
+
},
|
|
993
|
+
{ type: "UserClientRole", id: `LIST-${s}` },
|
|
994
|
+
{ type: "User", id: s },
|
|
995
|
+
{ type: "User", id: "LIST" }
|
|
996
|
+
]
|
|
997
|
+
})
|
|
998
|
+
})
|
|
999
|
+
}), {
|
|
1000
|
+
useListUsersQuery: Mt,
|
|
1001
|
+
useGetUserQuery: Aa,
|
|
1002
|
+
useCreateUserMutation: Ua,
|
|
1003
|
+
useUpdateUserMutation: La,
|
|
1004
|
+
useResetUserPasswordMutation: xa,
|
|
1005
|
+
useDeleteUserMutation: Pa,
|
|
1006
|
+
useToggleUserMutation: $a,
|
|
1007
|
+
useGetUserClientRolesQuery: Ea,
|
|
1008
|
+
useGetUserClientRolesForClientQuery: qa,
|
|
1009
|
+
useUpdateUserClientRolesMutation: wa
|
|
1010
|
+
} = Dt, Ee = {
|
|
1011
|
+
title: "",
|
|
1012
|
+
message: "",
|
|
1013
|
+
summary: "",
|
|
1014
|
+
level: "INFO",
|
|
1015
|
+
tag: "",
|
|
1016
|
+
link_url: "",
|
|
1017
|
+
link_label: "",
|
|
1018
|
+
priority: 0,
|
|
1019
|
+
is_pinned: !1,
|
|
1020
|
+
status: "DRAFT",
|
|
1021
|
+
audience_type: "ALL_USERS",
|
|
1022
|
+
client_ids: [],
|
|
1023
|
+
role_names: [],
|
|
1024
|
+
user_ids: [],
|
|
1025
|
+
group_ids: [],
|
|
1026
|
+
health_context_ids: [],
|
|
1027
|
+
publish_at: "",
|
|
1028
|
+
expires_at: "",
|
|
1029
|
+
notify_by_email: !1,
|
|
1030
|
+
notify_by_sms: !1,
|
|
1031
|
+
sms_message: ""
|
|
1032
|
+
};
|
|
1033
|
+
function xe(t) {
|
|
1034
|
+
if (!t) return "";
|
|
1035
|
+
const e = new Date(t);
|
|
1036
|
+
return Number.isNaN(e.getTime()) ? "" : e.toISOString();
|
|
1037
|
+
}
|
|
1038
|
+
function he(t) {
|
|
1039
|
+
return t ? {
|
|
1040
|
+
title: t.title ?? "",
|
|
1041
|
+
message: t.message ?? "",
|
|
1042
|
+
summary: t.summary ?? "",
|
|
1043
|
+
level: t.level ?? "INFO",
|
|
1044
|
+
tag: t.tag ?? "",
|
|
1045
|
+
link_url: t.link_url ?? "",
|
|
1046
|
+
link_label: t.link_label ?? "",
|
|
1047
|
+
priority: typeof t.priority == "number" ? t.priority : 0,
|
|
1048
|
+
is_pinned: !!t.is_pinned,
|
|
1049
|
+
status: t.status ?? "DRAFT",
|
|
1050
|
+
audience_type: t.audience_type ?? "ALL_USERS",
|
|
1051
|
+
client_ids: "client_ids" in t && Array.isArray(t.client_ids) ? t.client_ids : [],
|
|
1052
|
+
role_names: "role_names" in t && Array.isArray(t.role_names) ? t.role_names : [],
|
|
1053
|
+
user_ids: "user_ids" in t && Array.isArray(t.user_ids) ? t.user_ids : [],
|
|
1054
|
+
group_ids: "group_ids" in t && Array.isArray(t.group_ids) ? t.group_ids : [],
|
|
1055
|
+
health_context_ids: "health_context_ids" in t && Array.isArray(t.health_context_ids) ? t.health_context_ids : [],
|
|
1056
|
+
publish_at: xe(t.publish_at),
|
|
1057
|
+
expires_at: xe(t.expires_at),
|
|
1058
|
+
notify_by_email: !!t.notify_by_email,
|
|
1059
|
+
notify_by_sms: !!("notify_by_sms" in t && t.notify_by_sms),
|
|
1060
|
+
sms_message: "sms_message" in t && t.sms_message ? t.sms_message : ""
|
|
1061
|
+
} : Ee;
|
|
1062
|
+
}
|
|
1063
|
+
function Ot({
|
|
1064
|
+
mode: t,
|
|
1065
|
+
initialValues: e,
|
|
1066
|
+
isSubmitting: n = !1,
|
|
1067
|
+
onSubmit: s,
|
|
1068
|
+
onCancel: u,
|
|
1069
|
+
submitLabel: T
|
|
1070
|
+
}) {
|
|
1071
|
+
const p = ce(), C = At(), [o, f] = w(he(e)), { data: A = [], isLoading: b, isError: E } = Et(), {
|
|
1072
|
+
data: U = [],
|
|
1073
|
+
isLoading: P,
|
|
1074
|
+
isError: L
|
|
1075
|
+
} = qt(), { data: k = [], isLoading: x, isError: h } = Mt(), {
|
|
1076
|
+
data: c = [],
|
|
1077
|
+
isLoading: G,
|
|
1078
|
+
isError: K
|
|
1079
|
+
} = $t(), [ae, O] = ot();
|
|
1080
|
+
Re(() => {
|
|
1081
|
+
f(he(e));
|
|
1082
|
+
}, [e]);
|
|
1083
|
+
const se = H(
|
|
1084
|
+
() => A.map((i) => ({
|
|
1085
|
+
id: i.id,
|
|
1086
|
+
text: i.displayName || i.clientId
|
|
1087
|
+
})),
|
|
1088
|
+
[A]
|
|
1089
|
+
), X = H(
|
|
1090
|
+
() => U.map((i) => ({
|
|
1091
|
+
id: i.realmRole,
|
|
1092
|
+
text: i.realmRole
|
|
1093
|
+
})),
|
|
1094
|
+
[U]
|
|
1095
|
+
), W = H(
|
|
1096
|
+
() => k.map((i) => ({
|
|
1097
|
+
id: i.id,
|
|
1098
|
+
text: i.email ? `${i.username} (${i.email})` : i.username
|
|
1099
|
+
})),
|
|
1100
|
+
[k]
|
|
1101
|
+
), J = H(
|
|
1102
|
+
() => c.filter((i) => i.enabled).map((i) => ({
|
|
1103
|
+
id: i.id,
|
|
1104
|
+
text: i.displayName || i.path || i.name
|
|
1105
|
+
})),
|
|
1106
|
+
[c]
|
|
1107
|
+
), Z = H(
|
|
1108
|
+
() => C.filter((i) => i.enabled).map((i) => ({
|
|
1109
|
+
id: i.id,
|
|
1110
|
+
text: `${i.name} (${i.contextType.toLowerCase()})`
|
|
1111
|
+
})),
|
|
1112
|
+
[C]
|
|
1113
|
+
), V = H(() => o.title.trim().length === 0 || o.message.trim().length === 0 ? !1 : o.audience_type === "SPECIFIC_CLIENTS" ? o.client_ids.length > 0 : o.audience_type === "SPECIFIC_ROLES" ? o.role_names.length > 0 : o.audience_type === "SPECIFIC_USERS" ? o.user_ids.length > 0 : o.audience_type === "SPECIFIC_GROUPS" ? o.group_ids.length > 0 : o.audience_type === "SPECIFIC_HEALTH_CONTEXTS" || o.audience_type === "HEALTH_CONTEXT_AND_DESCENDANTS" ? o.health_context_ids.length > 0 : !0, [o]), g = (i, m) => {
|
|
1114
|
+
f((ee) => ({
|
|
1115
|
+
...ee,
|
|
1116
|
+
[i]: m
|
|
1117
|
+
}));
|
|
1118
|
+
}, Q = () => {
|
|
1119
|
+
f(he(e));
|
|
1120
|
+
}, de = () => {
|
|
1121
|
+
const i = {
|
|
1122
|
+
title: o.title.trim(),
|
|
1123
|
+
message: o.message.trim(),
|
|
1124
|
+
level: o.level,
|
|
1125
|
+
priority: Number.isNaN(Number(o.priority)) ? 0 : Number(o.priority),
|
|
1126
|
+
is_pinned: o.is_pinned,
|
|
1127
|
+
status: o.status,
|
|
1128
|
+
audience_type: o.audience_type,
|
|
1129
|
+
notify_by_email: o.notify_by_email,
|
|
1130
|
+
notify_by_sms: o.notify_by_sms
|
|
1131
|
+
};
|
|
1132
|
+
return o.audience_type === "SPECIFIC_CLIENTS" && (i.client_ids = o.client_ids), o.audience_type === "SPECIFIC_ROLES" && (i.role_names = o.role_names), o.audience_type === "SPECIFIC_USERS" && (i.user_ids = o.user_ids), o.audience_type === "SPECIFIC_GROUPS" && (i.group_ids = o.group_ids), (o.audience_type === "SPECIFIC_HEALTH_CONTEXTS" || o.audience_type === "HEALTH_CONTEXT_AND_DESCENDANTS") && (i.health_context_ids = o.health_context_ids), o.summary.trim() && (i.summary = o.summary.trim()), o.tag.trim() && (i.tag = o.tag.trim()), o.link_url.trim() && (i.link_url = o.link_url.trim()), o.link_label.trim() && (i.link_label = o.link_label.trim()), o.publish_at.trim() && (i.publish_at = o.publish_at), o.expires_at.trim() && (i.expires_at = o.expires_at), o.sms_message.trim() && (i.sms_message = o.sms_message.trim()), i;
|
|
1133
|
+
};
|
|
1134
|
+
return /* @__PURE__ */ a(Qe, { onSubmit: async (i) => {
|
|
1135
|
+
if (i.preventDefault(), !V) {
|
|
1136
|
+
p.error(
|
|
1137
|
+
"Invalid",
|
|
1138
|
+
"Please provide a title, message, and the required audience selection."
|
|
1139
|
+
);
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
try {
|
|
1143
|
+
await s(de()), t === "create" ? (p.success("Announcement Created", "Announcement created successfully."), f(Ee)) : p.success("Announcement Updated", "Announcement updated successfully.");
|
|
1144
|
+
} catch (m) {
|
|
1145
|
+
const ee = m?.data?.error || m?.data?.message || m?.message || `Failed to ${t === "create" ? "create" : "update"} announcement.`;
|
|
1146
|
+
p.error(t === "create" ? "Create Failed" : "Update Failed", ee);
|
|
1147
|
+
}
|
|
1148
|
+
}, children: /* @__PURE__ */ d(le, { gap: 6, children: [
|
|
1149
|
+
/* @__PURE__ */ a(
|
|
1150
|
+
B,
|
|
1151
|
+
{
|
|
1152
|
+
id: "announcement-title",
|
|
1153
|
+
labelText: "Title",
|
|
1154
|
+
placeholder: "Enter announcement title",
|
|
1155
|
+
value: o.title,
|
|
1156
|
+
onChange: (i) => g("title", i.target.value),
|
|
1157
|
+
maxLength: 255
|
|
1158
|
+
}
|
|
1159
|
+
),
|
|
1160
|
+
/* @__PURE__ */ a(
|
|
1161
|
+
B,
|
|
1162
|
+
{
|
|
1163
|
+
id: "announcement-summary",
|
|
1164
|
+
labelText: "Summary",
|
|
1165
|
+
placeholder: "Optional short summary",
|
|
1166
|
+
value: o.summary,
|
|
1167
|
+
onChange: (i) => g("summary", i.target.value),
|
|
1168
|
+
maxLength: 500
|
|
1169
|
+
}
|
|
1170
|
+
),
|
|
1171
|
+
/* @__PURE__ */ a(
|
|
1172
|
+
Ce,
|
|
1173
|
+
{
|
|
1174
|
+
id: "announcement-message",
|
|
1175
|
+
labelText: "Message",
|
|
1176
|
+
placeholder: "Write the announcement message",
|
|
1177
|
+
rows: 8,
|
|
1178
|
+
value: o.message,
|
|
1179
|
+
onChange: (i) => g("message", i.target.value),
|
|
1180
|
+
maxCount: 2e3,
|
|
1181
|
+
enableCounter: !0
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
/* @__PURE__ */ d("div", { className: "announcement-form__grid", children: [
|
|
1185
|
+
/* @__PURE__ */ d(
|
|
1186
|
+
ye,
|
|
1187
|
+
{
|
|
1188
|
+
id: "announcement-level",
|
|
1189
|
+
labelText: "Level",
|
|
1190
|
+
value: o.level,
|
|
1191
|
+
onChange: (i) => g("level", i.target.value),
|
|
1192
|
+
children: [
|
|
1193
|
+
/* @__PURE__ */ a(v, { value: "INFO", text: "INFO" }),
|
|
1194
|
+
/* @__PURE__ */ a(v, { value: "SUCCESS", text: "SUCCESS" }),
|
|
1195
|
+
/* @__PURE__ */ a(v, { value: "WARNING", text: "WARNING" }),
|
|
1196
|
+
/* @__PURE__ */ a(v, { value: "CRITICAL", text: "CRITICAL" })
|
|
1197
|
+
]
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
/* @__PURE__ */ d(
|
|
1201
|
+
ye,
|
|
1202
|
+
{
|
|
1203
|
+
id: "announcement-status",
|
|
1204
|
+
labelText: "Status",
|
|
1205
|
+
value: o.status,
|
|
1206
|
+
onChange: (i) => g("status", i.target.value),
|
|
1207
|
+
children: [
|
|
1208
|
+
/* @__PURE__ */ a(v, { value: "DRAFT", text: "DRAFT" }),
|
|
1209
|
+
/* @__PURE__ */ a(v, { value: "SCHEDULED", text: "SCHEDULED" }),
|
|
1210
|
+
/* @__PURE__ */ a(v, { value: "PUBLISHED", text: "PUBLISHED" }),
|
|
1211
|
+
/* @__PURE__ */ a(v, { value: "ARCHIVED", text: "ARCHIVED" })
|
|
1212
|
+
]
|
|
1213
|
+
}
|
|
1214
|
+
),
|
|
1215
|
+
/* @__PURE__ */ d(
|
|
1216
|
+
ye,
|
|
1217
|
+
{
|
|
1218
|
+
id: "announcement-audience-type",
|
|
1219
|
+
labelText: "Audience",
|
|
1220
|
+
value: o.audience_type,
|
|
1221
|
+
onChange: (i) => g("audience_type", i.target.value),
|
|
1222
|
+
children: [
|
|
1223
|
+
/* @__PURE__ */ a(v, { value: "ALL_USERS", text: "ALL_USERS" }),
|
|
1224
|
+
/* @__PURE__ */ a(v, { value: "ADMINS_ONLY", text: "ADMINS_ONLY" }),
|
|
1225
|
+
/* @__PURE__ */ a(v, { value: "SPECIFIC_CLIENTS", text: "SPECIFIC_CLIENTS" }),
|
|
1226
|
+
/* @__PURE__ */ a(v, { value: "SPECIFIC_ROLES", text: "SPECIFIC_ROLES" }),
|
|
1227
|
+
/* @__PURE__ */ a(v, { value: "SPECIFIC_USERS", text: "SPECIFIC_USERS" }),
|
|
1228
|
+
/* @__PURE__ */ a(v, { value: "SPECIFIC_GROUPS", text: "SPECIFIC_GROUPS" }),
|
|
1229
|
+
/* @__PURE__ */ a(v, { value: "SPECIFIC_HEALTH_CONTEXTS", text: "SPECIFIC_HEALTH_CONTEXTS" }),
|
|
1230
|
+
/* @__PURE__ */ a(
|
|
1231
|
+
v,
|
|
1232
|
+
{
|
|
1233
|
+
value: "HEALTH_CONTEXT_AND_DESCENDANTS",
|
|
1234
|
+
text: "HEALTH_CONTEXT_AND_DESCENDANTS"
|
|
1235
|
+
}
|
|
1236
|
+
)
|
|
1237
|
+
]
|
|
1238
|
+
}
|
|
1239
|
+
),
|
|
1240
|
+
/* @__PURE__ */ a(
|
|
1241
|
+
B,
|
|
1242
|
+
{
|
|
1243
|
+
id: "announcement-tag",
|
|
1244
|
+
labelText: "Tag",
|
|
1245
|
+
placeholder: "Optional tag",
|
|
1246
|
+
value: o.tag,
|
|
1247
|
+
onChange: (i) => g("tag", i.target.value)
|
|
1248
|
+
}
|
|
1249
|
+
),
|
|
1250
|
+
/* @__PURE__ */ a(
|
|
1251
|
+
B,
|
|
1252
|
+
{
|
|
1253
|
+
id: "announcement-priority",
|
|
1254
|
+
labelText: "Priority",
|
|
1255
|
+
type: "number",
|
|
1256
|
+
min: 0,
|
|
1257
|
+
value: String(o.priority),
|
|
1258
|
+
onChange: (i) => g("priority", Number(i.target.value || 0))
|
|
1259
|
+
}
|
|
1260
|
+
),
|
|
1261
|
+
/* @__PURE__ */ a(
|
|
1262
|
+
B,
|
|
1263
|
+
{
|
|
1264
|
+
id: "announcement-link-url",
|
|
1265
|
+
labelText: "Link URL",
|
|
1266
|
+
placeholder: "https://example.com",
|
|
1267
|
+
value: o.link_url,
|
|
1268
|
+
onChange: (i) => g("link_url", i.target.value)
|
|
1269
|
+
}
|
|
1270
|
+
),
|
|
1271
|
+
/* @__PURE__ */ a(
|
|
1272
|
+
B,
|
|
1273
|
+
{
|
|
1274
|
+
id: "announcement-link-label",
|
|
1275
|
+
labelText: "Link label",
|
|
1276
|
+
placeholder: "Optional link label",
|
|
1277
|
+
value: o.link_label,
|
|
1278
|
+
onChange: (i) => g("link_label", i.target.value)
|
|
1279
|
+
}
|
|
1280
|
+
),
|
|
1281
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
1282
|
+
ve,
|
|
1283
|
+
{
|
|
1284
|
+
datePickerType: "single",
|
|
1285
|
+
value: o.publish_at ? [o.publish_at] : [],
|
|
1286
|
+
onChange: (i) => {
|
|
1287
|
+
const m = i?.[0];
|
|
1288
|
+
g(
|
|
1289
|
+
"publish_at",
|
|
1290
|
+
m instanceof Date ? m.toISOString() : ""
|
|
1291
|
+
);
|
|
1292
|
+
},
|
|
1293
|
+
children: /* @__PURE__ */ a(
|
|
1294
|
+
Ie,
|
|
1295
|
+
{
|
|
1296
|
+
id: "announcement-publish-date",
|
|
1297
|
+
labelText: "Publish date",
|
|
1298
|
+
placeholder: "yyyy-mm-dd"
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
}
|
|
1302
|
+
) }),
|
|
1303
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
1304
|
+
ve,
|
|
1305
|
+
{
|
|
1306
|
+
datePickerType: "single",
|
|
1307
|
+
value: o.expires_at ? [o.expires_at] : [],
|
|
1308
|
+
onChange: (i) => {
|
|
1309
|
+
const m = i?.[0];
|
|
1310
|
+
g(
|
|
1311
|
+
"expires_at",
|
|
1312
|
+
m instanceof Date ? m.toISOString() : ""
|
|
1313
|
+
);
|
|
1314
|
+
},
|
|
1315
|
+
children: /* @__PURE__ */ a(
|
|
1316
|
+
Ie,
|
|
1317
|
+
{
|
|
1318
|
+
id: "announcement-expiry-date",
|
|
1319
|
+
labelText: "Expiry date",
|
|
1320
|
+
placeholder: "yyyy-mm-dd"
|
|
1321
|
+
}
|
|
1322
|
+
)
|
|
1323
|
+
}
|
|
1324
|
+
) })
|
|
1325
|
+
] }),
|
|
1326
|
+
/* @__PURE__ */ a(Be, { legendText: "Audience targeting", children: /* @__PURE__ */ d(le, { gap: 4, children: [
|
|
1327
|
+
o.audience_type === "ALL_USERS" && /* @__PURE__ */ a("p", { className: "announcement-form__hint", children: "This announcement will be visible to all portal users." }),
|
|
1328
|
+
o.audience_type === "ADMINS_ONLY" && /* @__PURE__ */ a("p", { className: "announcement-form__hint", children: "This announcement will be visible to users with the admin realm role." }),
|
|
1329
|
+
o.audience_type === "SPECIFIC_CLIENTS" && /* @__PURE__ */ d(j, { children: [
|
|
1330
|
+
b && /* @__PURE__ */ a(z, { description: "Loading systems..." }),
|
|
1331
|
+
/* @__PURE__ */ a(
|
|
1332
|
+
te,
|
|
1333
|
+
{
|
|
1334
|
+
id: "announcement-client-audience",
|
|
1335
|
+
titleText: "Systems",
|
|
1336
|
+
label: E ? "Unable to load systems" : "Select systems",
|
|
1337
|
+
items: se,
|
|
1338
|
+
itemToString: (i) => i?.text ?? "",
|
|
1339
|
+
selectedItems: se.filter((i) => o.client_ids.includes(i.id)),
|
|
1340
|
+
disabled: b || E,
|
|
1341
|
+
invalid: o.client_ids.length === 0,
|
|
1342
|
+
invalidText: "Select at least one system.",
|
|
1343
|
+
onChange: ({ selectedItems: i }) => g(
|
|
1344
|
+
"client_ids",
|
|
1345
|
+
(i ?? []).map((m) => m.id)
|
|
1346
|
+
)
|
|
1347
|
+
}
|
|
1348
|
+
)
|
|
1349
|
+
] }),
|
|
1350
|
+
o.audience_type === "SPECIFIC_ROLES" && /* @__PURE__ */ d(j, { children: [
|
|
1351
|
+
P && /* @__PURE__ */ a(z, { description: "Loading roles..." }),
|
|
1352
|
+
/* @__PURE__ */ a(
|
|
1353
|
+
te,
|
|
1354
|
+
{
|
|
1355
|
+
id: "announcement-role-audience",
|
|
1356
|
+
titleText: "Realm roles",
|
|
1357
|
+
label: L ? "Unable to load roles" : "Select realm roles",
|
|
1358
|
+
items: X,
|
|
1359
|
+
itemToString: (i) => i?.text ?? "",
|
|
1360
|
+
selectedItems: X.filter((i) => o.role_names.includes(i.id)),
|
|
1361
|
+
disabled: P || L,
|
|
1362
|
+
invalid: o.role_names.length === 0,
|
|
1363
|
+
invalidText: "Select at least one role.",
|
|
1364
|
+
onChange: ({ selectedItems: i }) => g(
|
|
1365
|
+
"role_names",
|
|
1366
|
+
(i ?? []).map((m) => m.id)
|
|
1367
|
+
)
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
] }),
|
|
1371
|
+
o.audience_type === "SPECIFIC_USERS" && /* @__PURE__ */ d(j, { children: [
|
|
1372
|
+
x && /* @__PURE__ */ a(z, { description: "Loading users..." }),
|
|
1373
|
+
/* @__PURE__ */ a(
|
|
1374
|
+
te,
|
|
1375
|
+
{
|
|
1376
|
+
id: "announcement-user-audience",
|
|
1377
|
+
titleText: "Users",
|
|
1378
|
+
label: h ? "Unable to load users" : "Select users",
|
|
1379
|
+
items: W,
|
|
1380
|
+
itemToString: (i) => i?.text ?? "",
|
|
1381
|
+
selectedItems: W.filter((i) => o.user_ids.includes(i.id)),
|
|
1382
|
+
disabled: x || h,
|
|
1383
|
+
invalid: o.user_ids.length === 0,
|
|
1384
|
+
invalidText: "Select at least one user.",
|
|
1385
|
+
onChange: ({ selectedItems: i }) => g(
|
|
1386
|
+
"user_ids",
|
|
1387
|
+
(i ?? []).map((m) => m.id)
|
|
1388
|
+
)
|
|
1389
|
+
}
|
|
1390
|
+
)
|
|
1391
|
+
] }),
|
|
1392
|
+
o.audience_type === "SPECIFIC_GROUPS" && /* @__PURE__ */ d(j, { children: [
|
|
1393
|
+
G && /* @__PURE__ */ a(z, { description: "Loading groups..." }),
|
|
1394
|
+
/* @__PURE__ */ a(
|
|
1395
|
+
te,
|
|
1396
|
+
{
|
|
1397
|
+
id: "announcement-group-audience",
|
|
1398
|
+
titleText: "Groups",
|
|
1399
|
+
label: K ? "Unable to load groups" : "Select groups",
|
|
1400
|
+
items: J,
|
|
1401
|
+
itemToString: (i) => i?.text ?? "",
|
|
1402
|
+
selectedItems: J.filter((i) => o.group_ids.includes(i.id)),
|
|
1403
|
+
disabled: G || K,
|
|
1404
|
+
invalid: o.group_ids.length === 0,
|
|
1405
|
+
invalidText: "Select at least one group.",
|
|
1406
|
+
onChange: ({ selectedItems: i }) => g(
|
|
1407
|
+
"group_ids",
|
|
1408
|
+
(i ?? []).map((m) => m.id)
|
|
1409
|
+
)
|
|
1410
|
+
}
|
|
1411
|
+
)
|
|
1412
|
+
] }),
|
|
1413
|
+
(o.audience_type === "SPECIFIC_HEALTH_CONTEXTS" || o.audience_type === "HEALTH_CONTEXT_AND_DESCENDANTS") && /* @__PURE__ */ d(j, { children: [
|
|
1414
|
+
/* @__PURE__ */ a(
|
|
1415
|
+
te,
|
|
1416
|
+
{
|
|
1417
|
+
id: "announcement-health-context-audience",
|
|
1418
|
+
titleText: "Health contexts",
|
|
1419
|
+
label: "Select health contexts",
|
|
1420
|
+
items: Z,
|
|
1421
|
+
itemToString: (i) => i?.text ?? "",
|
|
1422
|
+
selectedItems: Z.filter(
|
|
1423
|
+
(i) => o.health_context_ids.includes(i.id)
|
|
1424
|
+
),
|
|
1425
|
+
invalid: o.health_context_ids.length === 0,
|
|
1426
|
+
invalidText: "Select at least one health context.",
|
|
1427
|
+
onChange: ({ selectedItems: i }) => {
|
|
1428
|
+
g(
|
|
1429
|
+
"health_context_ids",
|
|
1430
|
+
(i ?? []).map((m) => m.id)
|
|
1431
|
+
), O.reset();
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ d("div", { className: "announcement-form__audience-preview", children: [
|
|
1436
|
+
/* @__PURE__ */ a(
|
|
1437
|
+
I,
|
|
1438
|
+
{
|
|
1439
|
+
type: "button",
|
|
1440
|
+
kind: "tertiary",
|
|
1441
|
+
size: "sm",
|
|
1442
|
+
disabled: o.health_context_ids.length === 0 || O.isLoading,
|
|
1443
|
+
onClick: async () => {
|
|
1444
|
+
try {
|
|
1445
|
+
const i = {
|
|
1446
|
+
audience_type: o.audience_type,
|
|
1447
|
+
health_context_ids: o.health_context_ids
|
|
1448
|
+
};
|
|
1449
|
+
await ae(i).unwrap();
|
|
1450
|
+
} catch {
|
|
1451
|
+
p.error(
|
|
1452
|
+
"Unable to preview audience",
|
|
1453
|
+
"Confirm that you can access every selected health context."
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
children: "Preview recipients"
|
|
1458
|
+
}
|
|
1459
|
+
),
|
|
1460
|
+
O.isLoading ? /* @__PURE__ */ a(z, { description: "Resolving recipients" }) : null,
|
|
1461
|
+
O.data ? /* @__PURE__ */ d("p", { className: "announcement-form__hint", "aria-live": "polite", children: [
|
|
1462
|
+
O.data.recipient_count,
|
|
1463
|
+
" eligible recipient",
|
|
1464
|
+
O.data.recipient_count === 1 ? "" : "s",
|
|
1465
|
+
"."
|
|
1466
|
+
] }) : null
|
|
1467
|
+
] })
|
|
1468
|
+
] })
|
|
1469
|
+
] }) }),
|
|
1470
|
+
/* @__PURE__ */ d("div", { className: "announcement-form__toggles", children: [
|
|
1471
|
+
/* @__PURE__ */ a(
|
|
1472
|
+
ne,
|
|
1473
|
+
{
|
|
1474
|
+
id: "announcement-pinned",
|
|
1475
|
+
labelText: "Pin this announcement",
|
|
1476
|
+
checked: o.is_pinned,
|
|
1477
|
+
onChange: (i, { checked: m }) => g("is_pinned", !!m)
|
|
1478
|
+
}
|
|
1479
|
+
),
|
|
1480
|
+
/* @__PURE__ */ a(
|
|
1481
|
+
ne,
|
|
1482
|
+
{
|
|
1483
|
+
id: "announcement-notify-by-email",
|
|
1484
|
+
labelText: "Send email notification when this announcement is published",
|
|
1485
|
+
checked: o.notify_by_email,
|
|
1486
|
+
onChange: (i, { checked: m }) => g("notify_by_email", !!m)
|
|
1487
|
+
}
|
|
1488
|
+
),
|
|
1489
|
+
/* @__PURE__ */ a(
|
|
1490
|
+
ne,
|
|
1491
|
+
{
|
|
1492
|
+
id: "announcement-notify-by-sms",
|
|
1493
|
+
labelText: "Send SMS notification when this announcement is published",
|
|
1494
|
+
checked: o.notify_by_sms,
|
|
1495
|
+
onChange: (i, { checked: m }) => g("notify_by_sms", !!m)
|
|
1496
|
+
}
|
|
1497
|
+
),
|
|
1498
|
+
o.notify_by_sms ? /* @__PURE__ */ a(
|
|
1499
|
+
Ce,
|
|
1500
|
+
{
|
|
1501
|
+
id: "announcement-sms-message",
|
|
1502
|
+
labelText: "SMS message",
|
|
1503
|
+
helperText: "Optional. Leave blank to use the announcement summary or message.",
|
|
1504
|
+
placeholder: "Short SMS message",
|
|
1505
|
+
rows: 3,
|
|
1506
|
+
value: o.sms_message,
|
|
1507
|
+
onChange: (i) => g("sms_message", i.target.value),
|
|
1508
|
+
maxCount: 160,
|
|
1509
|
+
enableCounter: !0
|
|
1510
|
+
}
|
|
1511
|
+
) : null,
|
|
1512
|
+
/* @__PURE__ */ a("p", { className: "announcement-form__notification-note", children: "Email and SMS notifications are only queued when the announcement is published and the matching option is enabled. Drafts and scheduled announcements will not notify users until they are published." })
|
|
1513
|
+
] }),
|
|
1514
|
+
/* @__PURE__ */ d("div", { className: "announcement-form__actions", children: [
|
|
1515
|
+
/* @__PURE__ */ a(
|
|
1516
|
+
I,
|
|
1517
|
+
{
|
|
1518
|
+
type: "submit",
|
|
1519
|
+
renderIcon: t === "create" ? tt : nt,
|
|
1520
|
+
disabled: !V || n,
|
|
1521
|
+
children: n ? t === "create" ? "Saving..." : "Updating..." : T ?? (t === "create" ? "Create announcement" : "Save changes")
|
|
1522
|
+
}
|
|
1523
|
+
),
|
|
1524
|
+
/* @__PURE__ */ a(
|
|
1525
|
+
I,
|
|
1526
|
+
{
|
|
1527
|
+
type: "button",
|
|
1528
|
+
kind: "secondary",
|
|
1529
|
+
renderIcon: be,
|
|
1530
|
+
onClick: Q,
|
|
1531
|
+
disabled: n,
|
|
1532
|
+
children: "Reset form"
|
|
1533
|
+
}
|
|
1534
|
+
),
|
|
1535
|
+
u ? /* @__PURE__ */ a(I, { type: "button", kind: "ghost", onClick: u, disabled: n, children: "Cancel" }) : null
|
|
1536
|
+
] })
|
|
1537
|
+
] }) });
|
|
1538
|
+
}
|
|
1539
|
+
const Gt = /* @__PURE__ */ new Set(["pdf", "doc", "docx", "xls", "xlsx", "csv", "png", "jpg", "jpeg"]), Ft = 10 * 1024 * 1024;
|
|
1540
|
+
function Ht(t) {
|
|
1541
|
+
return !Number.isFinite(t) || t <= 0 ? "0 B" : t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
|
|
1542
|
+
}
|
|
1543
|
+
function zt(t) {
|
|
1544
|
+
return t.split(".").pop()?.toLowerCase() ?? "";
|
|
1545
|
+
}
|
|
1546
|
+
function Qt({ announcementId: t }) {
|
|
1547
|
+
const e = ce(), n = it(null), [s, u] = w(!0), [T, p] = w(0), {
|
|
1548
|
+
data: C = [],
|
|
1549
|
+
isFetching: o,
|
|
1550
|
+
refetch: f
|
|
1551
|
+
} = rt(t), [A, b] = lt(), [E] = ct(), [U, P] = dt(), L = async (h) => {
|
|
1552
|
+
const c = h?.[0];
|
|
1553
|
+
if (c) {
|
|
1554
|
+
if (c.size > Ft) {
|
|
1555
|
+
e.error("File too large", "Attachments must be 10 MB or smaller.");
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
if (!Gt.has(zt(c.name))) {
|
|
1559
|
+
e.error("Unsupported file", "Use PDF, Office, CSV, PNG, JPG, or JPEG files.");
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
try {
|
|
1563
|
+
await A({
|
|
1564
|
+
announcementId: t,
|
|
1565
|
+
file: c,
|
|
1566
|
+
include_in_email: s,
|
|
1567
|
+
sort_order: T
|
|
1568
|
+
}).unwrap(), e.success("Attachment uploaded", "The file was added to this announcement."), p((G) => G + 1), n.current && (n.current.value = ""), f();
|
|
1569
|
+
} catch {
|
|
1570
|
+
e.error("Upload failed", "Unable to upload the announcement attachment.");
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}, k = async (h, c) => {
|
|
1574
|
+
try {
|
|
1575
|
+
await E({
|
|
1576
|
+
announcementId: t,
|
|
1577
|
+
attachmentId: h,
|
|
1578
|
+
include_in_email: c
|
|
1579
|
+
}).unwrap();
|
|
1580
|
+
} catch {
|
|
1581
|
+
e.error("Update failed", "Unable to update attachment email settings.");
|
|
1582
|
+
}
|
|
1583
|
+
}, x = async (h) => {
|
|
1584
|
+
try {
|
|
1585
|
+
await U({ announcementId: t, attachmentId: h }).unwrap(), e.success("Attachment removed", "The attachment was removed from this announcement."), f();
|
|
1586
|
+
} catch {
|
|
1587
|
+
e.error("Delete failed", "Unable to remove attachment.");
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
return /* @__PURE__ */ a("section", { "aria-labelledby": "announcement-attachments-title", children: /* @__PURE__ */ d(le, { gap: 4, children: [
|
|
1591
|
+
/* @__PURE__ */ a("div", { children: /* @__PURE__ */ a("h4", { id: "announcement-attachments-title", className: "announcement-attachments__title", children: "Attachments" }) }),
|
|
1592
|
+
/* @__PURE__ */ d("div", { className: "announcement-attachments__upload-row", children: [
|
|
1593
|
+
/* @__PURE__ */ a(
|
|
1594
|
+
B,
|
|
1595
|
+
{
|
|
1596
|
+
id: "announcement-attachment-file",
|
|
1597
|
+
ref: n,
|
|
1598
|
+
type: "file",
|
|
1599
|
+
labelText: "File",
|
|
1600
|
+
accept: ".pdf,.doc,.docx,.xls,.xlsx,.csv,.png,.jpg,.jpeg",
|
|
1601
|
+
onChange: (h) => L(h.target.files)
|
|
1602
|
+
}
|
|
1603
|
+
),
|
|
1604
|
+
/* @__PURE__ */ a(
|
|
1605
|
+
I,
|
|
1606
|
+
{
|
|
1607
|
+
kind: "tertiary",
|
|
1608
|
+
renderIcon: be,
|
|
1609
|
+
disabled: b.isLoading,
|
|
1610
|
+
onClick: () => n.current?.click(),
|
|
1611
|
+
children: "Select"
|
|
1612
|
+
}
|
|
1613
|
+
)
|
|
1614
|
+
] }),
|
|
1615
|
+
/* @__PURE__ */ a(
|
|
1616
|
+
ne,
|
|
1617
|
+
{
|
|
1618
|
+
id: "announcement-attachment-include-email",
|
|
1619
|
+
labelText: "Include new uploads in announcement email",
|
|
1620
|
+
checked: s,
|
|
1621
|
+
onChange: (h, c) => u(!!c.checked)
|
|
1622
|
+
}
|
|
1623
|
+
),
|
|
1624
|
+
(o || b.isLoading || P.isLoading) && /* @__PURE__ */ a(z, { description: "Updating attachments..." }),
|
|
1625
|
+
/* @__PURE__ */ a("div", { className: "announcement-attachments__list", children: C.length === 0 ? /* @__PURE__ */ a("p", { className: "announcement-attachments__empty", children: "No attachments uploaded." }) : C.map((h) => /* @__PURE__ */ d("div", { className: "announcement-attachments__item", children: [
|
|
1626
|
+
/* @__PURE__ */ d("div", { className: "announcement-attachments__file", children: [
|
|
1627
|
+
/* @__PURE__ */ a("strong", { className: "announcement-attachments__file-name", children: h.original_file_name }),
|
|
1628
|
+
/* @__PURE__ */ a("span", { className: "announcement-attachments__file-meta", children: Ht(h.file_size) }),
|
|
1629
|
+
/* @__PURE__ */ a(
|
|
1630
|
+
ne,
|
|
1631
|
+
{
|
|
1632
|
+
id: `announcement-attachment-email-${h.id}`,
|
|
1633
|
+
labelText: "Include in email",
|
|
1634
|
+
checked: h.include_in_email,
|
|
1635
|
+
onChange: (c, G) => k(h.id, !!G.checked)
|
|
1636
|
+
}
|
|
1637
|
+
)
|
|
1638
|
+
] }),
|
|
1639
|
+
/* @__PURE__ */ a(
|
|
1640
|
+
I,
|
|
1641
|
+
{
|
|
1642
|
+
hasIconOnly: !0,
|
|
1643
|
+
kind: "ghost",
|
|
1644
|
+
iconDescription: "Download attachment",
|
|
1645
|
+
renderIcon: at,
|
|
1646
|
+
onClick: () => window.open(
|
|
1647
|
+
ut(t, h.id),
|
|
1648
|
+
"_blank",
|
|
1649
|
+
"noopener,noreferrer"
|
|
1650
|
+
)
|
|
1651
|
+
}
|
|
1652
|
+
),
|
|
1653
|
+
/* @__PURE__ */ a(
|
|
1654
|
+
I,
|
|
1655
|
+
{
|
|
1656
|
+
hasIconOnly: !0,
|
|
1657
|
+
kind: "danger--ghost",
|
|
1658
|
+
iconDescription: "Remove attachment",
|
|
1659
|
+
renderIcon: st,
|
|
1660
|
+
onClick: () => x(h.id)
|
|
1661
|
+
}
|
|
1662
|
+
)
|
|
1663
|
+
] }, h.id)) })
|
|
1664
|
+
] }) });
|
|
1665
|
+
}
|
|
1666
|
+
function Pe({
|
|
1667
|
+
mode: t,
|
|
1668
|
+
announcement: e,
|
|
1669
|
+
onSuccess: n,
|
|
1670
|
+
onCancel: s
|
|
1671
|
+
}) {
|
|
1672
|
+
const u = ce(), [T, p] = mt(), [C, o] = pt(), f = p.isLoading || o.isLoading, A = e?.attachment_count ?? e?.attachments?.length ?? 0, b = e?.link_url?.trim(), E = e?.link_label?.trim() || "Open related link";
|
|
1673
|
+
return /* @__PURE__ */ a(ge, { className: "manage-announcement-panel", children: /* @__PURE__ */ d(le, { gap: 6, children: [
|
|
1674
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1675
|
+
/* @__PURE__ */ a("h3", { className: "manage-announcement-panel__title", children: t === "create" ? "Create Announcement" : "Edit Announcement" }),
|
|
1676
|
+
/* @__PURE__ */ a("p", { className: "manage-announcement-panel__subtitle", children: t === "create" ? "Publish announcements, alerts, and important updates for dashboard users." : "Update the announcement details, audience, status, schedule, and visibility." })
|
|
1677
|
+
] }),
|
|
1678
|
+
/* @__PURE__ */ a(
|
|
1679
|
+
Ot,
|
|
1680
|
+
{
|
|
1681
|
+
mode: t,
|
|
1682
|
+
initialValues: e,
|
|
1683
|
+
isSubmitting: f,
|
|
1684
|
+
onSubmit: async (P) => {
|
|
1685
|
+
try {
|
|
1686
|
+
if (t === "create")
|
|
1687
|
+
await T(P).unwrap(), u.success({
|
|
1688
|
+
title: "Announcement created",
|
|
1689
|
+
subtitle: "The announcement was created successfully."
|
|
1690
|
+
});
|
|
1691
|
+
else {
|
|
1692
|
+
if (!e) return;
|
|
1693
|
+
await C({
|
|
1694
|
+
id: e.id,
|
|
1695
|
+
body: P
|
|
1696
|
+
}).unwrap(), u.success({
|
|
1697
|
+
title: "Announcement updated",
|
|
1698
|
+
subtitle: "The announcement was updated successfully."
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
n?.();
|
|
1702
|
+
} catch {
|
|
1703
|
+
u.error({
|
|
1704
|
+
title: t === "create" ? "Create failed" : "Update failed",
|
|
1705
|
+
subtitle: t === "create" ? "Failed to create announcement." : "Failed to update announcement."
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
onCancel: s
|
|
1710
|
+
}
|
|
1711
|
+
),
|
|
1712
|
+
t === "edit" && (b || A > 0) ? /* @__PURE__ */ d(
|
|
1713
|
+
"section",
|
|
1714
|
+
{
|
|
1715
|
+
"aria-label": "Announcement publishing assets",
|
|
1716
|
+
className: "manage-announcement-panel__assets",
|
|
1717
|
+
children: [
|
|
1718
|
+
/* @__PURE__ */ a("h4", { className: "manage-announcement-panel__asset-title", children: "Publishing assets" }),
|
|
1719
|
+
/* @__PURE__ */ d("div", { className: "manage-announcement-panel__asset-tags", children: [
|
|
1720
|
+
b && /* @__PURE__ */ a(q, { type: "blue", size: "sm", children: /* @__PURE__ */ d("span", { className: "announcements-page__tag-content", children: [
|
|
1721
|
+
/* @__PURE__ */ a($e, { size: 12 }),
|
|
1722
|
+
"Related link"
|
|
1723
|
+
] }) }),
|
|
1724
|
+
A > 0 && /* @__PURE__ */ a(q, { type: "cyan", size: "sm", children: /* @__PURE__ */ d("span", { className: "announcements-page__tag-content", children: [
|
|
1725
|
+
/* @__PURE__ */ a(_e, { size: 12 }),
|
|
1726
|
+
A === 1 ? "1 attachment" : `${A} attachments`
|
|
1727
|
+
] }) })
|
|
1728
|
+
] }),
|
|
1729
|
+
b && /* @__PURE__ */ a(je, { href: b, target: "_blank", rel: "noopener noreferrer", children: E })
|
|
1730
|
+
]
|
|
1731
|
+
}
|
|
1732
|
+
) : null,
|
|
1733
|
+
t === "edit" && e?.id ? /* @__PURE__ */ a(Qt, { announcementId: e.id }) : null
|
|
1734
|
+
] }) });
|
|
1735
|
+
}
|
|
1736
|
+
function Bt(t, e) {
|
|
1737
|
+
if (!t || typeof t != "object")
|
|
1738
|
+
return e;
|
|
1739
|
+
const n = t;
|
|
1740
|
+
return typeof n.data?.message == "string" ? n.data.message : typeof n.data?.error?.message == "string" ? n.data.error.message : typeof n.error == "string" ? n.error : e;
|
|
1741
|
+
}
|
|
1742
|
+
const jt = [
|
|
1743
|
+
{ id: "all", label: "All" },
|
|
1744
|
+
{ id: "published", label: "Published" },
|
|
1745
|
+
{ id: "draft", label: "Draft" },
|
|
1746
|
+
{ id: "scheduled", label: "Scheduled" },
|
|
1747
|
+
{ id: "archived", label: "Archived" }
|
|
1748
|
+
], Xt = [
|
|
1749
|
+
{ id: "all", label: "All" },
|
|
1750
|
+
{ id: "info", label: "Info" },
|
|
1751
|
+
{ id: "success", label: "Success" },
|
|
1752
|
+
{ id: "warning", label: "Warning" },
|
|
1753
|
+
{ id: "critical", label: "Critical" }
|
|
1754
|
+
], Vt = [
|
|
1755
|
+
{ id: "all", label: "All" },
|
|
1756
|
+
{ id: "all_users", label: "All users" },
|
|
1757
|
+
{ id: "admins_only", label: "Admins only" },
|
|
1758
|
+
{ id: "specific_roles", label: "Specific roles" }
|
|
1759
|
+
], Yt = [
|
|
1760
|
+
{ id: "all", label: "All" },
|
|
1761
|
+
{ id: "pinned", label: "Pinned" },
|
|
1762
|
+
{ id: "unpinned", label: "Unpinned" }
|
|
1763
|
+
], Kt = [
|
|
1764
|
+
{ key: "title", header: "Title" },
|
|
1765
|
+
{ key: "level", header: "Level" },
|
|
1766
|
+
{ key: "audience", header: "Audience" },
|
|
1767
|
+
{ key: "status", header: "Status" },
|
|
1768
|
+
{ key: "pinned", header: "Pinned" },
|
|
1769
|
+
{ key: "attachments", header: "Files" },
|
|
1770
|
+
{ key: "active", header: "Active" },
|
|
1771
|
+
{ key: "publishAt", header: "Publish at" },
|
|
1772
|
+
{ key: "expiresAt", header: "Expires at" },
|
|
1773
|
+
{ key: "actions", header: "" },
|
|
1774
|
+
{ key: "raw", header: "" }
|
|
1775
|
+
// hidden
|
|
1776
|
+
];
|
|
1777
|
+
function Wt() {
|
|
1778
|
+
const t = ce(), { openPanel: e, closePanel: n } = St(), { openModal: s, closeModal: u } = ft(), [T, p] = w(null), [C, o] = w(""), [f, A] = w("all"), [b, E] = w("all"), [U, P] = w("all"), [L, k] = w("all"), [x, h] = w(1), [c, G] = w(10), {
|
|
1779
|
+
data: K = [],
|
|
1780
|
+
isLoading: ae,
|
|
1781
|
+
isError: O,
|
|
1782
|
+
error: se,
|
|
1783
|
+
refetch: X
|
|
1784
|
+
} = yt({
|
|
1785
|
+
limit: 500,
|
|
1786
|
+
offset: 0
|
|
1787
|
+
}), [W] = ht(), [J] = gt(), [Z] = _t(), [V] = Rt(), [g] = bt();
|
|
1788
|
+
Re(() => {
|
|
1789
|
+
h(1);
|
|
1790
|
+
}, [C, f, b, U, L]);
|
|
1791
|
+
const Q = H(() => {
|
|
1792
|
+
const r = C.trim().toLowerCase();
|
|
1793
|
+
return K.filter((S) => {
|
|
1794
|
+
const ue = S.status.toLowerCase(), me = S.level.toLowerCase(), ie = S.audience_type.toLowerCase();
|
|
1795
|
+
return f !== "all" && ue !== f || b !== "all" && me !== b || U !== "all" && ie !== U || L === "pinned" && !S.is_pinned || L === "unpinned" && S.is_pinned ? !1 : r ? S.title.toLowerCase().includes(r) || S.message.toLowerCase().includes(r) || S.status.toLowerCase().includes(r) || S.level.toLowerCase().includes(r) || S.audience_type.toLowerCase().includes(r) || (S.summary?.toLowerCase().includes(r) ?? !1) || (S.tag?.toLowerCase().includes(r) ?? !1) : !0;
|
|
1796
|
+
});
|
|
1797
|
+
}, [K, C, f, b, U, L]), de = H(() => {
|
|
1798
|
+
const r = (x - 1) * c;
|
|
1799
|
+
return Q.slice(r, r + c);
|
|
1800
|
+
}, [Q, x, c]);
|
|
1801
|
+
Re(() => {
|
|
1802
|
+
const r = Math.max(1, Math.ceil(Q.length / c));
|
|
1803
|
+
x > r && h(r);
|
|
1804
|
+
}, [Q.length, x, c]);
|
|
1805
|
+
const fe = de.map((r) => ({
|
|
1806
|
+
id: r.id,
|
|
1807
|
+
title: r.title,
|
|
1808
|
+
level: r.level,
|
|
1809
|
+
audience: r.audience_type,
|
|
1810
|
+
status: r.status,
|
|
1811
|
+
pinned: r.is_pinned ? "Yes" : "No",
|
|
1812
|
+
attachments: String(r.attachment_count ?? r.attachments?.length ?? 0),
|
|
1813
|
+
active: Le(r) ? "Yes" : "No",
|
|
1814
|
+
publishAt: Ue(r.publish_at),
|
|
1815
|
+
expiresAt: Ue(r.expires_at),
|
|
1816
|
+
actions: "",
|
|
1817
|
+
raw: r
|
|
1818
|
+
})), i = () => {
|
|
1819
|
+
e({
|
|
1820
|
+
title: "Create announcement",
|
|
1821
|
+
content: /* @__PURE__ */ a(
|
|
1822
|
+
Pe,
|
|
1823
|
+
{
|
|
1824
|
+
mode: "create",
|
|
1825
|
+
onSuccess: () => {
|
|
1826
|
+
n(), X();
|
|
1827
|
+
},
|
|
1828
|
+
onCancel: n
|
|
1829
|
+
}
|
|
1830
|
+
),
|
|
1831
|
+
size: "md"
|
|
1832
|
+
});
|
|
1833
|
+
}, m = (r) => {
|
|
1834
|
+
e({
|
|
1835
|
+
title: "Edit announcement",
|
|
1836
|
+
content: /* @__PURE__ */ a(
|
|
1837
|
+
Pe,
|
|
1838
|
+
{
|
|
1839
|
+
mode: "edit",
|
|
1840
|
+
announcement: r,
|
|
1841
|
+
onSuccess: () => {
|
|
1842
|
+
n(), X();
|
|
1843
|
+
},
|
|
1844
|
+
onCancel: n
|
|
1845
|
+
}
|
|
1846
|
+
),
|
|
1847
|
+
size: "md"
|
|
1848
|
+
});
|
|
1849
|
+
}, ee = async (r) => {
|
|
1850
|
+
await W(r.id).unwrap(), t.success({
|
|
1851
|
+
title: "Announcement published",
|
|
1852
|
+
subtitle: `${r.title} has been published.`
|
|
1853
|
+
});
|
|
1854
|
+
}, qe = async (r) => {
|
|
1855
|
+
await g(r.id).unwrap(), t.warning({
|
|
1856
|
+
title: "Moved to draft",
|
|
1857
|
+
subtitle: `${r.title} has been moved to draft.`
|
|
1858
|
+
});
|
|
1859
|
+
}, we = async (r) => {
|
|
1860
|
+
await J(r.id).unwrap(), t.warning({
|
|
1861
|
+
title: "Announcement archived",
|
|
1862
|
+
subtitle: `${r.title} has been archived.`
|
|
1863
|
+
});
|
|
1864
|
+
}, ke = async (r) => {
|
|
1865
|
+
await V({
|
|
1866
|
+
id: r.id,
|
|
1867
|
+
body: {
|
|
1868
|
+
is_pinned: !r.is_pinned
|
|
1869
|
+
}
|
|
1870
|
+
}).unwrap(), t.success({
|
|
1871
|
+
title: r.is_pinned ? "Announcement unpinned" : "Announcement pinned",
|
|
1872
|
+
subtitle: `${r.title} updated successfully.`
|
|
1873
|
+
});
|
|
1874
|
+
}, Ne = async (r) => {
|
|
1875
|
+
try {
|
|
1876
|
+
await Z(r.id).unwrap(), u(), t.error({
|
|
1877
|
+
title: "Announcement deleted",
|
|
1878
|
+
subtitle: `${r.title} was deleted.`
|
|
1879
|
+
});
|
|
1880
|
+
} catch {
|
|
1881
|
+
t.error({
|
|
1882
|
+
title: "Delete failed",
|
|
1883
|
+
subtitle: "The announcement could not be deleted."
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
}, De = (r) => {
|
|
1887
|
+
s({
|
|
1888
|
+
title: "Delete announcement",
|
|
1889
|
+
onClose: u,
|
|
1890
|
+
content: /* @__PURE__ */ d("p", { children: [
|
|
1891
|
+
"Delete ",
|
|
1892
|
+
/* @__PURE__ */ a("strong", { children: r.title }),
|
|
1893
|
+
"? This action should only be used when you're sure."
|
|
1894
|
+
] }),
|
|
1895
|
+
primaryAction: {
|
|
1896
|
+
label: "Delete",
|
|
1897
|
+
kind: "danger",
|
|
1898
|
+
onClick: () => {
|
|
1899
|
+
Ne(r);
|
|
1900
|
+
}
|
|
1901
|
+
},
|
|
1902
|
+
secondaryAction: {
|
|
1903
|
+
label: "Cancel",
|
|
1904
|
+
onClick: u
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
}, Me = async (r) => {
|
|
1908
|
+
try {
|
|
1909
|
+
p("delete"), await Promise.all(r.map((S) => Z(S.id).unwrap())), u(), t.error({
|
|
1910
|
+
title: "Announcements deleted",
|
|
1911
|
+
subtitle: `${r.length} announcement(s) deleted.`
|
|
1912
|
+
});
|
|
1913
|
+
} catch {
|
|
1914
|
+
t.error({
|
|
1915
|
+
title: "Delete failed",
|
|
1916
|
+
subtitle: "Some announcements could not be deleted."
|
|
1917
|
+
});
|
|
1918
|
+
} finally {
|
|
1919
|
+
p(null);
|
|
1920
|
+
}
|
|
1921
|
+
}, Oe = (r) => {
|
|
1922
|
+
s({
|
|
1923
|
+
title: "Delete announcements",
|
|
1924
|
+
onClose: u,
|
|
1925
|
+
content: /* @__PURE__ */ d("p", { children: [
|
|
1926
|
+
"Delete ",
|
|
1927
|
+
/* @__PURE__ */ a("strong", { children: r.length }),
|
|
1928
|
+
" selected announcement(s)?"
|
|
1929
|
+
] }),
|
|
1930
|
+
primaryAction: {
|
|
1931
|
+
label: "Delete",
|
|
1932
|
+
kind: "danger",
|
|
1933
|
+
onClick: () => {
|
|
1934
|
+
Me(r);
|
|
1935
|
+
}
|
|
1936
|
+
},
|
|
1937
|
+
secondaryAction: {
|
|
1938
|
+
label: "Cancel",
|
|
1939
|
+
onClick: u
|
|
1940
|
+
}
|
|
1941
|
+
});
|
|
1942
|
+
};
|
|
1943
|
+
return /* @__PURE__ */ a("div", { className: "announcements-page", children: /* @__PURE__ */ a(
|
|
1944
|
+
Tt,
|
|
1945
|
+
{
|
|
1946
|
+
title: "Announcements",
|
|
1947
|
+
subtitle: "Manage platform notices, alerts, drafts, schedules, and archived updates.",
|
|
1948
|
+
actions: /* @__PURE__ */ a(I, { renderIcon: be, onClick: i, disabled: ae || O, children: "New announcement" }),
|
|
1949
|
+
children: ae ? /* @__PURE__ */ a(z, { description: "Loading announcements…" }) : O ? /* @__PURE__ */ a(
|
|
1950
|
+
Ct,
|
|
1951
|
+
{
|
|
1952
|
+
title: "Failed to load announcements",
|
|
1953
|
+
description: Bt(se, "Failed to load announcements"),
|
|
1954
|
+
primaryAction: { label: "Retry", onClick: X }
|
|
1955
|
+
}
|
|
1956
|
+
) : /* @__PURE__ */ d(j, { children: [
|
|
1957
|
+
/* @__PURE__ */ a(ge, { className: "announcements-page__filter-tile", children: /* @__PURE__ */ a(
|
|
1958
|
+
Ut,
|
|
1959
|
+
{
|
|
1960
|
+
search: C,
|
|
1961
|
+
status: f,
|
|
1962
|
+
level: b,
|
|
1963
|
+
audience: U,
|
|
1964
|
+
pin: L,
|
|
1965
|
+
statusOptions: jt,
|
|
1966
|
+
levelOptions: Xt,
|
|
1967
|
+
audienceOptions: Vt,
|
|
1968
|
+
pinOptions: Yt,
|
|
1969
|
+
onSearchChange: o,
|
|
1970
|
+
onStatusChange: A,
|
|
1971
|
+
onLevelChange: E,
|
|
1972
|
+
onAudienceChange: P,
|
|
1973
|
+
onPinChange: k,
|
|
1974
|
+
onReset: () => {
|
|
1975
|
+
o(""), A("all"), E("all"), P("all"), k("all");
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
) }),
|
|
1979
|
+
/* @__PURE__ */ d(ge, { className: "announcements-page__table-tile", children: [
|
|
1980
|
+
/* @__PURE__ */ a(Xe, { rows: fe, headers: Kt, children: ({ rows: r, headers: S, getHeaderProps: ue, getRowProps: me, getSelectionProps: ie, selectedRows: Ge }) => {
|
|
1981
|
+
const $ = Ge.map(
|
|
1982
|
+
(_) => _.cells.find((y) => y.info.header === "raw")?.value
|
|
1983
|
+
);
|
|
1984
|
+
return /* @__PURE__ */ d(j, { children: [
|
|
1985
|
+
/* @__PURE__ */ a(
|
|
1986
|
+
Lt,
|
|
1987
|
+
{
|
|
1988
|
+
announcements: $,
|
|
1989
|
+
loadingAction: T,
|
|
1990
|
+
onPublish: async () => {
|
|
1991
|
+
try {
|
|
1992
|
+
p("publish"), await Promise.all(
|
|
1993
|
+
$.map((_) => W(_.id).unwrap())
|
|
1994
|
+
), t.success({
|
|
1995
|
+
title: "Announcements published",
|
|
1996
|
+
subtitle: `${$.length} announcement(s) published.`
|
|
1997
|
+
});
|
|
1998
|
+
} catch {
|
|
1999
|
+
t.error({
|
|
2000
|
+
title: "Publish failed",
|
|
2001
|
+
subtitle: "Some announcements could not be published."
|
|
2002
|
+
});
|
|
2003
|
+
} finally {
|
|
2004
|
+
p(null);
|
|
2005
|
+
}
|
|
2006
|
+
},
|
|
2007
|
+
onMoveToDraft: async () => {
|
|
2008
|
+
try {
|
|
2009
|
+
p("draft"), await Promise.all(
|
|
2010
|
+
$.map((_) => g(_.id).unwrap())
|
|
2011
|
+
), t.warning({
|
|
2012
|
+
title: "Moved to draft",
|
|
2013
|
+
subtitle: `${$.length} announcement(s) moved to draft.`
|
|
2014
|
+
});
|
|
2015
|
+
} catch {
|
|
2016
|
+
t.error({
|
|
2017
|
+
title: "Draft failed",
|
|
2018
|
+
subtitle: "Some announcements could not be moved to draft."
|
|
2019
|
+
});
|
|
2020
|
+
} finally {
|
|
2021
|
+
p(null);
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
onArchive: async () => {
|
|
2025
|
+
try {
|
|
2026
|
+
p("archive"), await Promise.all(
|
|
2027
|
+
$.map((_) => J(_.id).unwrap())
|
|
2028
|
+
), t.warning({
|
|
2029
|
+
title: "Announcements archived",
|
|
2030
|
+
subtitle: `${$.length} announcement(s) archived.`
|
|
2031
|
+
});
|
|
2032
|
+
} catch {
|
|
2033
|
+
t.error({
|
|
2034
|
+
title: "Archive failed",
|
|
2035
|
+
subtitle: "Some announcements could not be archived."
|
|
2036
|
+
});
|
|
2037
|
+
} finally {
|
|
2038
|
+
p(null);
|
|
2039
|
+
}
|
|
2040
|
+
},
|
|
2041
|
+
onPin: async () => {
|
|
2042
|
+
try {
|
|
2043
|
+
p("pin"), await Promise.all(
|
|
2044
|
+
$.map(
|
|
2045
|
+
(_) => V({
|
|
2046
|
+
id: _.id,
|
|
2047
|
+
body: { is_pinned: !0 }
|
|
2048
|
+
}).unwrap()
|
|
2049
|
+
)
|
|
2050
|
+
), t.success({
|
|
2051
|
+
title: "Announcements pinned",
|
|
2052
|
+
subtitle: `${$.length} announcement(s) pinned.`
|
|
2053
|
+
});
|
|
2054
|
+
} catch {
|
|
2055
|
+
t.error({
|
|
2056
|
+
title: "Pin failed",
|
|
2057
|
+
subtitle: "Some announcements could not be pinned."
|
|
2058
|
+
});
|
|
2059
|
+
} finally {
|
|
2060
|
+
p(null);
|
|
2061
|
+
}
|
|
2062
|
+
},
|
|
2063
|
+
onUnpin: async () => {
|
|
2064
|
+
try {
|
|
2065
|
+
p("unpin"), await Promise.all(
|
|
2066
|
+
$.map(
|
|
2067
|
+
(_) => V({
|
|
2068
|
+
id: _.id,
|
|
2069
|
+
body: { is_pinned: !1 }
|
|
2070
|
+
}).unwrap()
|
|
2071
|
+
)
|
|
2072
|
+
), t.success({
|
|
2073
|
+
title: "Announcements unpinned",
|
|
2074
|
+
subtitle: `${$.length} announcement(s) unpinned.`
|
|
2075
|
+
});
|
|
2076
|
+
} catch {
|
|
2077
|
+
t.error({
|
|
2078
|
+
title: "Unpin failed",
|
|
2079
|
+
subtitle: "Some announcements could not be unpinned."
|
|
2080
|
+
});
|
|
2081
|
+
} finally {
|
|
2082
|
+
p(null);
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
onDelete: async () => {
|
|
2086
|
+
Oe($);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
),
|
|
2090
|
+
/* @__PURE__ */ d(Ve, { children: [
|
|
2091
|
+
/* @__PURE__ */ a(Ye, { children: /* @__PURE__ */ d(Ae, { children: [
|
|
2092
|
+
/* @__PURE__ */ a(Ke, { ...ie() }),
|
|
2093
|
+
S.filter((_) => _.key !== "raw").map((_) => {
|
|
2094
|
+
const { key: y, ...pe } = ue({ header: _ });
|
|
2095
|
+
return /* @__PURE__ */ a(We, { ...pe, children: _.header }, y);
|
|
2096
|
+
})
|
|
2097
|
+
] }) }),
|
|
2098
|
+
/* @__PURE__ */ a(Je, { children: r.map((_) => {
|
|
2099
|
+
const y = _.cells.find((R) => R.info.header === "raw")?.value, { key: pe, ...Fe } = me({ row: _ });
|
|
2100
|
+
return /* @__PURE__ */ d(Ae, { ...Fe, children: [
|
|
2101
|
+
/* @__PURE__ */ a(Ze, { ...ie({ row: _ }) }),
|
|
2102
|
+
_.cells.map((R) => {
|
|
2103
|
+
if (R.info.header === "raw") return null;
|
|
2104
|
+
if (R.info.header === "title") {
|
|
2105
|
+
const N = y.attachment_count ?? y.attachments?.length ?? 0, Te = !!y.link_url?.trim();
|
|
2106
|
+
return /* @__PURE__ */ a(F, { children: /* @__PURE__ */ d("div", { className: "announcements-page__table-title", children: [
|
|
2107
|
+
/* @__PURE__ */ a("strong", { children: y.title }),
|
|
2108
|
+
y.summary && /* @__PURE__ */ a("span", { className: "announcements-page__summary", children: y.summary }),
|
|
2109
|
+
y.tag && /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(q, { size: "sm", type: "warm-gray", children: y.tag }) }),
|
|
2110
|
+
(Te || N > 0) && /* @__PURE__ */ d("span", { className: "announcements-page__tag-list", children: [
|
|
2111
|
+
Te && /* @__PURE__ */ a(q, { size: "sm", type: "blue", children: /* @__PURE__ */ d("span", { className: "announcements-page__tag-content", children: [
|
|
2112
|
+
/* @__PURE__ */ a($e, { size: 12 }),
|
|
2113
|
+
"Link"
|
|
2114
|
+
] }) }),
|
|
2115
|
+
N > 0 && /* @__PURE__ */ a(q, { size: "sm", type: "cyan", children: /* @__PURE__ */ d("span", { className: "announcements-page__tag-content", children: [
|
|
2116
|
+
/* @__PURE__ */ a(_e, { size: 12 }),
|
|
2117
|
+
N === 1 ? "1 attachment" : `${N} attachments`
|
|
2118
|
+
] }) })
|
|
2119
|
+
] })
|
|
2120
|
+
] }) }, R.id);
|
|
2121
|
+
}
|
|
2122
|
+
if (R.info.header === "attachments") {
|
|
2123
|
+
const N = y.attachment_count ?? y.attachments?.length ?? 0;
|
|
2124
|
+
return /* @__PURE__ */ a(F, { children: N > 0 ? /* @__PURE__ */ a(q, { type: "cyan", size: "sm", children: /* @__PURE__ */ d("span", { className: "announcements-page__tag-content", children: [
|
|
2125
|
+
/* @__PURE__ */ a(_e, { size: 12 }),
|
|
2126
|
+
N
|
|
2127
|
+
] }) }) : /* @__PURE__ */ a(q, { type: "gray", size: "sm", children: "None" }) }, R.id);
|
|
2128
|
+
}
|
|
2129
|
+
if (R.info.header === "level")
|
|
2130
|
+
return /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(q, { type: vt(y.level), children: y.level }) }, R.id);
|
|
2131
|
+
if (R.info.header === "status")
|
|
2132
|
+
return /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(q, { type: It(y.status), children: y.status }) }, R.id);
|
|
2133
|
+
if (R.info.header === "pinned")
|
|
2134
|
+
return /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(q, { type: y.is_pinned ? "warm-gray" : "gray", children: y.is_pinned ? "Pinned" : "No" }) }, R.id);
|
|
2135
|
+
if (R.info.header === "active") {
|
|
2136
|
+
const N = Le(y);
|
|
2137
|
+
return /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(q, { type: N ? "green" : "gray", children: N ? "Active" : "Inactive" }) }, R.id);
|
|
2138
|
+
}
|
|
2139
|
+
return R.info.header === "actions" ? /* @__PURE__ */ a(F, { children: _.isSelected && /* @__PURE__ */ a(
|
|
2140
|
+
xt,
|
|
2141
|
+
{
|
|
2142
|
+
announcement: y,
|
|
2143
|
+
onEdit: () => m(y),
|
|
2144
|
+
onPublish: async () => {
|
|
2145
|
+
try {
|
|
2146
|
+
await ee(y);
|
|
2147
|
+
} catch {
|
|
2148
|
+
t.error({
|
|
2149
|
+
title: "Publish failed",
|
|
2150
|
+
subtitle: "Failed to publish announcement."
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
},
|
|
2154
|
+
onMoveToDraft: async () => {
|
|
2155
|
+
try {
|
|
2156
|
+
await qe(y);
|
|
2157
|
+
} catch {
|
|
2158
|
+
t.error({
|
|
2159
|
+
title: "Draft failed",
|
|
2160
|
+
subtitle: "Failed to move announcement to draft."
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
},
|
|
2164
|
+
onTogglePin: async () => {
|
|
2165
|
+
try {
|
|
2166
|
+
await ke(y);
|
|
2167
|
+
} catch {
|
|
2168
|
+
t.error({
|
|
2169
|
+
title: "Pin update failed",
|
|
2170
|
+
subtitle: "Failed to update pin state."
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
},
|
|
2174
|
+
onArchive: async () => {
|
|
2175
|
+
try {
|
|
2176
|
+
await we(y);
|
|
2177
|
+
} catch {
|
|
2178
|
+
t.error({
|
|
2179
|
+
title: "Archive failed",
|
|
2180
|
+
subtitle: "Failed to archive announcement."
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
onDelete: async () => {
|
|
2185
|
+
try {
|
|
2186
|
+
await De(y);
|
|
2187
|
+
} catch {
|
|
2188
|
+
t.error({
|
|
2189
|
+
title: "Delete failed",
|
|
2190
|
+
subtitle: "Failed to delete announcement."
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
) }, R.id) : /* @__PURE__ */ a(F, { children: R.value || "—" }, R.id);
|
|
2196
|
+
})
|
|
2197
|
+
] }, pe);
|
|
2198
|
+
}) })
|
|
2199
|
+
] })
|
|
2200
|
+
] });
|
|
2201
|
+
} }),
|
|
2202
|
+
/* @__PURE__ */ a(
|
|
2203
|
+
et,
|
|
2204
|
+
{
|
|
2205
|
+
page: x,
|
|
2206
|
+
pageSize: c,
|
|
2207
|
+
pageSizes: [10, 20, 30, 50],
|
|
2208
|
+
totalItems: Q.length,
|
|
2209
|
+
onChange: ({ page: r, pageSize: S }) => {
|
|
2210
|
+
h(r), G(S);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
)
|
|
2214
|
+
] })
|
|
2215
|
+
] })
|
|
2216
|
+
}
|
|
2217
|
+
) });
|
|
2218
|
+
}
|
|
2219
|
+
function ka(t) {
|
|
2220
|
+
return /* @__PURE__ */ a("div", { className: "moh-microfrontend-root", children: /* @__PURE__ */ a(Wt, {}) });
|
|
2221
|
+
}
|
|
2222
|
+
export {
|
|
2223
|
+
Wt as A,
|
|
2224
|
+
Pe as M,
|
|
2225
|
+
ka as a
|
|
2226
|
+
};
|
|
2227
|
+
//# sourceMappingURL=root.component-BuA-VwR7.js.map
|