Skip to content

Commit

Permalink
mailbox rules table
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Jan 25, 2025
1 parent 4bc4026 commit c1bf7fe
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions src/pages/identity/administration/users/user/exchange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -156,6 +166,79 @@ const Page = () => {
})) || [],
},
];

const mailboxRuleActions = [
{
label: "Remove Mailbox Rule",
type: "GET",
icon: <TrashIcon />,
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 ? (
<CircularProgress size="25px" color="inherit" />
) : mailboxRulesRequest.data?.length !== 0 ? (
<Check />
) : (
<Error />
),
},
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 (
<CippPropertyListCard
cardSx={{ p: 0, m: -2 }}
title="Rule Details"
propertyItems={properties}
actionItems={mailboxRuleActions}
/>
);
},
},
},
},
];

return (
<HeaderedTabbedLayout
tabOptions={tabOptions}
Expand Down Expand Up @@ -215,6 +298,11 @@ const Page = () => {
items={calCard}
isCollapsible={calPermissions.data?.length !== 0}
/>
<CippBannerListCard
isFetching={mailboxRulesRequest.isLoading}
items={mailboxRulesCard}
isCollapsible={mailboxRulesRequest.data?.length !== 0}
/>
<CippExchangeSettingsForm
userId={userId}
calPermissions={calPermissions.data}
Expand Down

0 comments on commit c1bf7fe

Please sign in to comment.