Skip to content

mailbox rules table #3465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading