Skip to content

Commit e046e9c

Browse files
committed
Added a section to remove proxy addresses and set primary addresses
1 parent afa06ac commit e046e9c

File tree

1 file changed

+104
-3
lines changed

1 file changed

+104
-3
lines changed

src/pages/identity/administration/users/user/exchange.jsx

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
44
import { ApiGetCall } from "/src/api/ApiCall";
55
import CippFormSkeleton from "/src/components/CippFormPages/CippFormSkeleton";
66
import CalendarIcon from "@heroicons/react/24/outline/CalendarIcon";
7-
import { Check, Error, Mail, Fingerprint, Launch } from "@mui/icons-material";
7+
import { Check, Error, Mail, Fingerprint, Launch, Delete, Star } from "@mui/icons-material";
88
import { HeaderedTabbedLayout } from "../../../../../layouts/HeaderedTabbedLayout";
99
import tabOptions from "./tabOptions";
1010
import { CippTimeAgo } from "../../../../../components/CippComponents/CippTimeAgo";
@@ -18,16 +18,20 @@ import CippExchangeSettingsForm from "../../../../../components/CippFormPages/Ci
1818
import { useForm } from "react-hook-form";
1919
import { Alert, Button, Collapse, CircularProgress, Typography } from "@mui/material";
2020
import { CippApiResults } from "../../../../../components/CippComponents/CippApiResults";
21-
import { Block, PlayArrow, DeleteForever } from "@mui/icons-material";
21+
import { Block, PlayArrow } from "@mui/icons-material";
2222
import { CippPropertyListCard } from "../../../../../components/CippCards/CippPropertyListCard";
2323
import { getCippTranslation } from "../../../../../utils/get-cipp-translation";
2424
import { getCippFormatting } from "../../../../../utils/get-cipp-formatting";
2525
import CippExchangeActions from "../../../../../components/CippComponents/CippExchangeActions";
26+
import { CippApiDialog } from "../../../../../components/CippComponents/CippApiDialog";
27+
import { useDialog } from "../../../../../hooks/use-dialog";
2628

2729
const Page = () => {
2830
const userSettingsDefaults = useSettings();
2931
const [waiting, setWaiting] = useState(false);
3032
const [showDetails, setShowDetails] = useState(false);
33+
const [actionData, setActionData] = useState({ ready: false });
34+
const createDialog = useDialog();
3135
const router = useRouter();
3236
const { userId } = router.query;
3337

@@ -221,7 +225,7 @@ const Page = () => {
221225
{
222226
label: "Remove Mailbox Rule",
223227
type: "POST",
224-
icon: <DeleteForever />,
228+
icon: <Delete />,
225229
url: "/api/ExecRemoveMailboxRule",
226230
data: {
227231
ruleId: "Identity",
@@ -287,6 +291,90 @@ const Page = () => {
287291
},
288292
];
289293

294+
const proxyAddressActions = [
295+
{
296+
label: "Make Primary",
297+
type: "POST",
298+
icon: <Star />,
299+
url: "/api/SetUserAliases",
300+
data: {
301+
id: userId,
302+
tenantFilter: userSettingsDefaults.currentTenant,
303+
MakePrimary: "Address",
304+
},
305+
confirmText: "Are you sure you want to make this the primary proxy address?",
306+
multiPost: false,
307+
relatedQueryKeys: `ListUsers-${userId}`,
308+
},
309+
{
310+
label: "Remove Proxy Address",
311+
type: "POST",
312+
icon: <Delete />,
313+
url: "/api/SetUserAliases",
314+
data: {
315+
id: userId,
316+
tenantFilter: userSettingsDefaults.currentTenant,
317+
RemovedAliases: "Address",
318+
},
319+
confirmText: "Are you sure you want to remove this proxy address?",
320+
multiPost: false,
321+
relatedQueryKeys: `ListUsers-${userId}`,
322+
},
323+
];
324+
325+
const proxyAddressesCard = [
326+
{
327+
id: 1,
328+
cardLabelBox: {
329+
cardLabelBoxHeader: graphUserRequest.isFetching ? (
330+
<CircularProgress size="25px" color="inherit" />
331+
) : graphUserRequest.data?.[0]?.proxyAddresses?.length !== 0 ? (
332+
<Check />
333+
) : (
334+
<Error />
335+
),
336+
},
337+
text: "Current Proxy Addresses",
338+
subtext: graphUserRequest.data?.[0]?.proxyAddresses?.length > 1
339+
? "Proxy addresses are configured for this user"
340+
: "No proxy addresses configured for this user",
341+
statusColor: "green.main",
342+
table: {
343+
title: "Proxy Addresses",
344+
hideTitle: true,
345+
data: graphUserRequest.data?.[0]?.proxyAddresses?.map(address => ({
346+
Address: address,
347+
Type: address.startsWith('SMTP:') ? 'Primary' : 'Alias',
348+
})) || [],
349+
refreshFunction: () => graphUserRequest.refetch(),
350+
isFetching: graphUserRequest.isFetching,
351+
simpleColumns: ["Address", "Type"],
352+
actions: proxyAddressActions,
353+
offCanvas: {
354+
children: (data) => {
355+
return (
356+
<CippPropertyListCard
357+
cardSx={{ p: 0, m: -2 }}
358+
title="Address Details"
359+
propertyItems={[
360+
{
361+
label: "Address",
362+
value: data.Address,
363+
},
364+
{
365+
label: "Type",
366+
value: data.Type,
367+
},
368+
]}
369+
actionItems={proxyAddressActions}
370+
/>
371+
);
372+
},
373+
},
374+
},
375+
},
376+
];
377+
290378
return (
291379
<HeaderedTabbedLayout
292380
tabOptions={tabOptions}
@@ -345,6 +433,11 @@ const Page = () => {
345433
</Grid>
346434
<Grid item size={8}>
347435
<Stack spacing={3}>
436+
<CippBannerListCard
437+
isFetching={graphUserRequest.isLoading}
438+
items={proxyAddressesCard}
439+
isCollapsible={graphUserRequest.data?.[0]?.proxyAddresses?.length !== 0}
440+
/>
348441
<CippBannerListCard
349442
isFetching={userRequest.isLoading}
350443
items={permissions}
@@ -374,6 +467,14 @@ const Page = () => {
374467
</Grid>
375468
</Box>
376469
)}
470+
{actionData.ready && (
471+
<CippApiDialog
472+
createDialog={createDialog}
473+
title="Confirmation"
474+
api={actionData.action}
475+
row={actionData.data}
476+
/>
477+
)}
377478
</HeaderedTabbedLayout>
378479
);
379480
};

0 commit comments

Comments
 (0)