Skip to content

Commit c1cf181

Browse files
committed
Enhance CippExchangeSettingsForm and user exchange page with mailbox permissions management
- Added cardLabelBoxActions to CippBannerListCard for displaying action buttons. - Introduced mailbox permissions management in CippExchangeSettingsForm, including form controls for adding Full Access, Send-as, and Send On Behalf permissions. - Implemented a dialog for adding mailbox permissions with validation and submission handling. - Refactored user exchange page to integrate new permissions functionality and manage state for permissions submission.
1 parent 840e4ea commit c1cf181

File tree

3 files changed

+300
-213
lines changed

3 files changed

+300
-213
lines changed

src/components/CippCards/CippBannerListCard.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const CippBannerListCard = (props) => {
127127
<Typography variant="body2">{item.statusText}</Typography>
128128
</Stack>
129129
)}
130+
{item?.cardLabelBoxActions && item.cardLabelBoxActions}
130131
{isCollapsible && (
131132
<IconButton onClick={() => handleExpand(item.id)}>
132133
<SvgIcon
@@ -190,6 +191,7 @@ CippBannerListCard.propTypes = {
190191
actionButton: PropTypes.element,
191192
isFetching: PropTypes.bool,
192193
children: PropTypes.node,
194+
cardLabelBoxActions: PropTypes.element,
193195
})
194196
).isRequired,
195197
isCollapsible: PropTypes.bool,

src/components/CippFormPages/CippExchangeSettingsForm.jsx

Lines changed: 2 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ApiGetCall, ApiPostCall } from "../../api/ApiCall";
1919
import { useSettings } from "../../hooks/use-settings";
2020
import { Grid } from "@mui/system";
2121
import { CippApiResults } from "../CippComponents/CippApiResults";
22-
import { useWatch, useFormContext } from "react-hook-form";
22+
import { useWatch } from "react-hook-form";
2323

2424
const CippExchangeSettingsForm = (props) => {
2525
const userSettingsDefaults = useSettings();
@@ -50,9 +50,7 @@ const CippExchangeSettingsForm = (props) => {
5050
});
5151

5252
const handleSubmit = (type) => {
53-
if (type === "permissions") {
54-
setRelatedQueryKeys([`Mailbox-${userId}`]);
55-
} else if (type === "calendar") {
53+
if (type === "calendar") {
5654
setRelatedQueryKeys([`CalendarPermissions-${userId}`]);
5755
} else if (type === "forwarding") {
5856
setRelatedQueryKeys([`Mailbox-${userId}`]);
@@ -83,7 +81,6 @@ const CippExchangeSettingsForm = (props) => {
8381
}
8482
});
8583
const url = {
86-
permissions: "/api/ExecEditMailboxPermissions",
8784
calendar: "/api/ExecEditCalendarPermissions",
8885
forwarding: "/api/ExecEmailForward",
8986
ooo: "/api/ExecSetOoO",
@@ -101,181 +98,6 @@ const CippExchangeSettingsForm = (props) => {
10198

10299
// Data for each section
103100
const sections = [
104-
{
105-
id: "mailboxPermissions",
106-
cardLabelBox: "-",
107-
text: "Mailbox Permissions",
108-
subtext: "Manage mailbox permissions for users",
109-
formContent: (
110-
<Stack spacing={1.5}>
111-
{/* Full Access Section */}
112-
<Box sx={{
113-
p: 2,
114-
border: '1px solid',
115-
borderColor: 'divider',
116-
borderRadius: 1,
117-
backgroundColor: 'background.paper'
118-
}}>
119-
<Typography variant="subtitle2" gutterBottom>Full Access</Typography>
120-
<Typography variant="caption" color="text.secondary" gutterBottom>
121-
Manage who has full access to this mailbox
122-
</Typography>
123-
<Stack spacing={2} sx={{ mt: 2 }}>
124-
<CippFormComponent
125-
type="autoComplete"
126-
label="Remove Full Access"
127-
name="permissions.RemoveFullAccess"
128-
isFetching={isFetching || usersList.isFetching}
129-
options={
130-
usersList?.data?.Results?.filter((user) =>
131-
currentSettings?.Permissions?.some(
132-
(perm) =>
133-
perm.AccessRights === "FullAccess" && perm.User === user.userPrincipalName
134-
)
135-
).map((user) => ({
136-
value: user.userPrincipalName,
137-
label: `${user.displayName} (${user.userPrincipalName})`,
138-
})) || []
139-
}
140-
formControl={formControl}
141-
/>
142-
<CippFormComponent
143-
type="autoComplete"
144-
label="Add Full Access - Automapping Enabled"
145-
name="permissions.AddFullAccess"
146-
isFetching={isFetching || usersList.isFetching}
147-
options={
148-
usersList?.data?.Results?.map((user) => ({
149-
value: user.userPrincipalName,
150-
label: `${user.displayName} (${user.userPrincipalName})`,
151-
})) || []
152-
}
153-
formControl={formControl}
154-
/>
155-
<CippFormComponent
156-
type="autoComplete"
157-
label="Add Full Access - Automapping Disabled"
158-
name="permissions.AddFullAccessNoAutoMap"
159-
isFetching={isFetching || usersList.isFetching}
160-
options={
161-
usersList?.data?.Results?.map((user) => ({
162-
value: user.userPrincipalName,
163-
label: `${user.displayName} (${user.userPrincipalName})`,
164-
})) || []
165-
}
166-
formControl={formControl}
167-
/>
168-
</Stack>
169-
</Box>
170-
171-
{/* Send As Section */}
172-
<Box sx={{
173-
p: 2,
174-
border: '1px solid',
175-
borderColor: 'divider',
176-
borderRadius: 1,
177-
backgroundColor: 'background.paper'
178-
}}>
179-
<Typography variant="subtitle2" gutterBottom>Send As</Typography>
180-
<Typography variant="caption" color="text.secondary" gutterBottom>
181-
Manage who can send emails as this user
182-
</Typography>
183-
<Stack spacing={2} sx={{ mt: 2 }}>
184-
<CippFormComponent
185-
type="autoComplete"
186-
label="Remove Send-as Permissions"
187-
name="permissions.RemoveSendAs"
188-
isFetching={isFetching || usersList.isFetching}
189-
options={
190-
usersList?.data?.Results?.filter((user) =>
191-
currentSettings?.Permissions?.some(
192-
(perm) => perm.AccessRights === "SendAs" && perm.User === user.userPrincipalName
193-
)
194-
).map((user) => ({
195-
value: user.userPrincipalName,
196-
label: `${user.displayName} (${user.userPrincipalName})`,
197-
})) || []
198-
}
199-
formControl={formControl}
200-
/>
201-
<CippFormComponent
202-
type="autoComplete"
203-
label="Add Send-as Permissions"
204-
name="permissions.AddSendAs"
205-
isFetching={isFetching || usersList.isFetching}
206-
options={
207-
usersList?.data?.Results?.map((user) => ({
208-
value: user.userPrincipalName,
209-
label: `${user.displayName} (${user.userPrincipalName})`,
210-
})) || []
211-
}
212-
formControl={formControl}
213-
/>
214-
</Stack>
215-
</Box>
216-
217-
{/* Send On Behalf Section */}
218-
<Box sx={{
219-
p: 2,
220-
border: '1px solid',
221-
borderColor: 'divider',
222-
borderRadius: 1,
223-
backgroundColor: 'background.paper'
224-
}}>
225-
<Typography variant="subtitle2" gutterBottom>Send On Behalf</Typography>
226-
<Typography variant="caption" color="text.secondary" gutterBottom>
227-
Manage who can send emails on behalf of this user
228-
</Typography>
229-
<Stack spacing={2} sx={{ mt: 2 }}>
230-
<CippFormComponent
231-
type="autoComplete"
232-
label="Remove Send On Behalf Permissions"
233-
name="permissions.RemoveSendOnBehalf"
234-
isFetching={isFetching || usersList.isFetching}
235-
options={
236-
usersList?.data?.Results?.filter((user) =>
237-
currentSettings?.Permissions?.some(
238-
(perm) =>
239-
perm.AccessRights === "SendOnBehalf" && perm.User === user.userPrincipalName
240-
)
241-
).map((user) => ({
242-
value: user.userPrincipalName,
243-
label: `${user.displayName} (${user.userPrincipalName})`,
244-
})) || []
245-
}
246-
formControl={formControl}
247-
/>
248-
<CippFormComponent
249-
type="autoComplete"
250-
label="Add Send On Behalf Permissions"
251-
name="permissions.AddSendOnBehalf"
252-
isFetching={isFetching || usersList.isFetching}
253-
options={
254-
usersList?.data?.Results?.map((user) => ({
255-
value: user.userPrincipalName,
256-
label: `${user.displayName} (${user.userPrincipalName})`,
257-
})) || []
258-
}
259-
formControl={formControl}
260-
/>
261-
</Stack>
262-
</Box>
263-
264-
<Grid item size={12}>
265-
<CippApiResults apiObject={postRequest} />
266-
</Grid>
267-
<Grid>
268-
<Button
269-
onClick={() => handleSubmit("permissions")}
270-
variant="contained"
271-
disabled={!formControl.formState.isValid || postRequest.isPending}
272-
>
273-
Submit
274-
</Button>
275-
</Grid>
276-
</Stack>
277-
),
278-
},
279101
{
280102
id: "calendarPermissions",
281103
cardLabelBox: "-",

0 commit comments

Comments
 (0)