From c1bf7fe5d210a8ba271845a49f86ad42217f7642 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Fri, 24 Jan 2025 19:46:03 -0500 Subject: [PATCH] mailbox rules table --- .../administration/users/user/exchange.jsx | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/pages/identity/administration/users/user/exchange.jsx b/src/pages/identity/administration/users/user/exchange.jsx index a9d325f8f35a..bef693434d29 100644 --- a/src/pages/identity/administration/users/user/exchange.jsx +++ b/src/pages/identity/administration/users/user/exchange.jsx @@ -18,6 +18,10 @@ import CippExchangeSettingsForm from "../../../../../components/CippFormPages/Ci import { useForm } from "react-hook-form"; import { Alert, Button, Collapse, CircularProgress, Typography } from "@mui/material"; import { CippApiResults } from "../../../../../components/CippComponents/CippApiResults"; +import { TrashIcon } from "@heroicons/react/24/outline"; +import { CippPropertyListCard } from "../../../../../components/CippCards/CippPropertyListCard"; +import { getCippTranslation } from "../../../../../utils/get-cipp-translation"; +import { getCippFormatting } from "../../../../../utils/get-cipp-formatting"; const Page = () => { const userSettingsDefaults = useSettings(); @@ -55,6 +59,12 @@ const Page = () => { waiting: waiting, }); + const mailboxRulesRequest = ApiGetCall({ + url: `/api/ListUserMailboxRules?UserId=${userId}&tenantFilter=${userSettingsDefaults.currentTenant}`, + queryKey: `MailboxRules-${userId}`, + waiting: waiting, + }); + useEffect(() => { if (oooRequest.isSuccess) { formControl.setValue("ooo.ExternalMessage", oooRequest.data?.ExternalMessage); @@ -156,6 +166,79 @@ const Page = () => { })) || [], }, ]; + + const mailboxRuleActions = [ + { + label: "Remove Mailbox Rule", + type: "GET", + icon: , + url: "/api/ExecRemoveMailboxRule", + data: { ruleId: "Identity", userPrincipalName: "UserPrincipalName" }, + confirmText: "Are you sure you want to remove this mailbox rule?", + multiPost: false, + }, + ]; + + const mailboxRulesCard = [ + { + id: 1, + cardLabelBox: { + cardLabelBoxHeader: mailboxRulesRequest.isFetching ? ( + + ) : mailboxRulesRequest.data?.length !== 0 ? ( + + ) : ( + + ), + }, + text: "Current Mailbox Rules", + subtext: mailboxRulesRequest.data?.length + ? "Mailbox rules are configured for this user" + : "No mailbox rules configured for this user", + statusColor: "green.main", + table: { + title: "Mailbox Rules", + hideTitle: true, + data: mailboxRulesRequest.data || [], + simpleColumns: [ + "Enabled", + "Name", + "Description", + "Redirect To", + "Copy To Folder", + "Move To Folder", + "Soft Delete Message", + "Delete Message", + ], + actions: mailboxRuleActions, + offCanvas: { + children: (data) => { + const keys = Object.keys(data).filter( + (key) => !key.includes("@odata") && !key.includes("@data") + ); + const properties = []; + keys.forEach((key) => { + if (data[key] && data[key].length > 0) { + properties.push({ + label: getCippTranslation(key), + value: getCippFormatting(data[key], key), + }); + } + }); + return ( + + ); + }, + }, + }, + }, + ]; + return ( { items={calCard} isCollapsible={calPermissions.data?.length !== 0} /> +