From 8e8bc93a8604c0177d4a213ca948847cc12dec6a Mon Sep 17 00:00:00 2001 From: Jr7468 Date: Wed, 25 Jun 2025 01:00:45 +0100 Subject: [PATCH] Fixed Mailbox Rule offCanvas erroring when attempting to open --- .../administration/users/user/exchange.jsx | 87 +++++++++++++++---- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/src/pages/identity/administration/users/user/exchange.jsx b/src/pages/identity/administration/users/user/exchange.jsx index e40609727478..c7b3e633fc6e 100644 --- a/src/pages/identity/administration/users/user/exchange.jsx +++ b/src/pages/identity/administration/users/user/exchange.jsx @@ -669,13 +669,15 @@ const Page = () => { type: "POST", icon: , url: "/api/ExecSetMailboxRule", - data: { - ruleId: "Identity", - userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, - ruleName: "Name", - Enable: true, + customDataformatter: (row, action, formData) => { + return { + ruleId: row?.Identity, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + ruleName: row?.Name, + Enable: true, + }; }, - condition: (row) => !row.Enabled, + condition: (row) => row && !row.Enabled, confirmText: "Are you sure you want to enable this mailbox rule?", multiPost: false, }, @@ -684,13 +686,15 @@ const Page = () => { type: "POST", icon: , url: "/api/ExecSetMailboxRule", - data: { - ruleId: "Identity", - userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, - ruleName: "Name", - Disable: true, + customDataformatter: (row, action, formData) => { + return { + ruleId: row?.Identity, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + ruleName: row?.Name, + Disable: true, + }; }, - condition: (row) => row.Enabled, + condition: (row) => row && row.Enabled, confirmText: "Are you sure you want to disable this mailbox rule?", multiPost: false, }, @@ -699,10 +703,12 @@ const Page = () => { type: "POST", icon: , url: "/api/ExecRemoveMailboxRule", - data: { - ruleId: "Identity", - ruleName: "Name", - userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + customDataformatter: (row, action, formData) => { + return { + ruleId: row?.Identity, + ruleName: row?.Name, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + }; }, confirmText: "Are you sure you want to remove this mailbox rule?", multiPost: false, @@ -754,7 +760,50 @@ const Page = () => { cardSx={{ p: 0, m: -2 }} title="Rule Details" propertyItems={properties} - actionItems={mailboxRuleActions} + actionItems={[ + { + label: "Enable Mailbox Rule", + type: "POST", + icon: , + url: "/api/ExecSetMailboxRule", + data: { + ruleId: data?.Identity, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + ruleName: data?.Name, + Enable: true, + }, + confirmText: "Are you sure you want to enable this mailbox rule?", + multiPost: false, + }, + { + label: "Disable Mailbox Rule", + type: "POST", + icon: , + url: "/api/ExecSetMailboxRule", + data: { + ruleId: data?.Identity, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + ruleName: data?.Name, + Disable: true, + }, + confirmText: "Are you sure you want to disable this mailbox rule?", + multiPost: false, + }, + { + label: "Remove Mailbox Rule", + type: "POST", + icon: , + url: "/api/ExecRemoveMailboxRule", + data: { + ruleId: data?.Identity, + ruleName: data?.Name, + userPrincipalName: graphUserRequest.data?.[0]?.userPrincipalName, + }, + confirmText: "Are you sure you want to remove this mailbox rule?", + multiPost: false, + relatedQueryKeys: `MailboxRules-${userId}`, + }, + ]} /> ); }, @@ -777,7 +826,7 @@ const Page = () => { confirmText: "Are you sure you want to make this the primary proxy address?", multiPost: false, relatedQueryKeys: `ListUsers-${userId}`, - condition: (row) => !row.Type === "Primary", + condition: (row) => row && row.Type !== "Primary", }, { label: "Remove Proxy Address", @@ -792,7 +841,7 @@ const Page = () => { confirmText: "Are you sure you want to remove this proxy address?", multiPost: false, relatedQueryKeys: `ListUsers-${userId}`, - condition: (row) => !row.Type === "Primary", + condition: (row) => row && row.Type !== "Primary", }, ];