Skip to content
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

[pull] dev from KelvinTegelaar:dev #40

Merged
merged 6 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
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
26 changes: 17 additions & 9 deletions src/components/CippCards/CippBannerListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CippPropertyListCard } from "./CippPropertyListCard";
import { CippDataTable } from "../CippTable/CippDataTable";

export const CippBannerListCard = (props) => {
const { items = [], isCollapsible = false, isFetching = false, ...other } = props;
const { items = [], isCollapsible = false, isFetching = false, children, ...other } = props;
const [expanded, setExpanded] = useState(null);

const handleExpand = useCallback((itemId) => {
Expand Down Expand Up @@ -145,14 +145,18 @@ export const CippBannerListCard = (props) => {
{isCollapsible && (
<Collapse in={isExpanded}>
<Divider />
{item?.propertyItems?.length > 0 && (
<CippPropertyListCard
propertyItems={item.propertyItems || []}
layout="dual"
isFetching={item.isFetching || false}
/>
)}
{item?.table && <CippDataTable {...item.table} />}
<Stack spacing={1}>
{item?.propertyItems?.length > 0 && (
<CippPropertyListCard
propertyItems={item.propertyItems || []}
layout="dual"
isFetching={item.isFetching || false}
/>
)}
{item?.table && <CippDataTable {...item.table} />}
{item?.children && <Box sx={{ pl: 3 }}>{item.children}</Box>}
{item?.actionButton && <Box sx={{ pl: 3, pb: 2 }}>{item.actionButton}</Box>}
</Stack>
</Collapse>
)}
</li>
Expand Down Expand Up @@ -180,8 +184,12 @@ CippBannerListCard.propTypes = {
subtext: PropTypes.string,
statusColor: PropTypes.string,
statusText: PropTypes.string,
actionButton: PropTypes.element,
propertyItems: PropTypes.array,
table: PropTypes.object,
actionButton: PropTypes.element,
isFetching: PropTypes.bool,
children: PropTypes.node,
})
).isRequired,
isCollapsible: PropTypes.bool,
Expand Down
52 changes: 52 additions & 0 deletions src/components/CippComponents/CippLocationDialog.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
import { useState } from "react";
import dynamic from "next/dynamic"; // Import dynamic from next/dynamic
import { CippPropertyList } from "./CippPropertyList"; // Import CippPropertyList
import { LocationOn } from "@mui/icons-material";

const CippMap = dynamic(() => import("./CippMap"), { ssr: false }); // Dynamic import for CippMap

export const CippLocationDialog = ({ location }) => {
const [open, setOpen] = useState(false);

const handleOpen = () => {
setOpen(true);
};

const handleClose = () => {
setOpen(false);
};

const markers = [
{
position: [location.geoCoordinates.latitude, location.geoCoordinates.longitude],
popup: `${location.city}, ${location.state}, ${location.countryOrRegion}`,
},
];

const properties = [
{ label: "City", value: location.city },
{ label: "State", value: location.state },
{ label: "Country/Region", value: location.countryOrRegion },
];

return (
<>
<Button size="small" variant="outlined" onClick={handleOpen} startIcon={<LocationOn />}>
Show Map
</Button>
<Dialog fullWidth maxWidth="sm" onClose={handleClose} open={open}>
<DialogTitle>Location Details</DialogTitle>
<DialogContent>
<CippPropertyList propertyItems={properties} showDivider={false} />
<CippMap markers={markers} zoom={10} mapSx={{ height: "300px", width: "100%" }} />
</DialogContent>
<DialogActions>
<Button color="inherit" onClick={handleClose}>
Close
</Button>
</DialogActions>
</Dialog>
</>
);
};
9 changes: 7 additions & 2 deletions src/components/CippTable/util-columnsFromAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ const mergeKeys = (dataArray) => {

export const utilColumnsFromAPI = (dataArray) => {
const dataSample = mergeKeys(dataArray);

const skipRecursion = ["location"];
const generateColumns = (obj, parentKey = "") => {
return Object.keys(obj)
.map((key) => {
const accessorKey = parentKey ? `${parentKey}.${key}` : key;
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
if (
typeof obj[key] === "object" &&
obj[key] !== null &&
!Array.isArray(obj[key]) &&
!skipRecursion.includes(key)
) {
return generateColumns(obj[key], accessorKey);
}

Expand Down
17 changes: 17 additions & 0 deletions src/data/signinErrorCodes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"0": "Success",
"50126": "Invalid username or password",
"70044": "The session has expired or is invalid due to sign-in frequency checks by conditional access",
"50089": "Flow token expired",
"53003": "Access has been blocked by Conditional Access policies",
"50140": "This error occurred due to 'Keep me signed in' interrupt when the user was signing-in",
"50097": "Device authentication required",
"65001": "Application X doesn't have permission to access application Y or the permission has been revoked",
"50053": "Account is locked because user tried to sign in too many times with an incorrect user ID or password",
"50020": "The user is unauthorized",
"50125": "Sign-in was interrupted due to a password reset or password registration entry",
"50074": "User did not pass the MFA challenge",
"50133": "Session is invalid due to expiration or recent password change",
"530002": "Your device is required to be compliant to access this resource",
"9001011": "Device policy contains unsupported required device state"
}
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