Skip to content

Commit

Permalink
exchange window
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Nov 17, 2024
1 parent 239da0b commit d70ad08
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 302 deletions.
193 changes: 193 additions & 0 deletions src/components/CippCards/CippExchangeInfoCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import PropTypes from "prop-types";
import { Card, CardHeader, Divider, Skeleton, Chip } from "@mui/material";
import { PropertyList } from "/src/components/property-list";
import { PropertyListItem } from "/src/components/property-list-item";
import { getCippFormatting } from "../../utils/get-cipp-formatting";
import { Check as CheckIcon, Close as CloseIcon } from "@mui/icons-material";
import { LinearProgressWithLabel } from "../linearProgressWithLabel";
import { getCippTranslation } from "../../utils/get-cipp-translation";

export const CippExchangeInfoCard = (props) => {
const { exchangeData, isFetching = false, ...other } = props;

// Define the protocols array
const protocols = [
{ name: "EWS", enabled: exchangeData?.EWSEnabled },
{ name: "MAPI", enabled: exchangeData?.MailboxMAPIEnabled },
{ name: "OWA", enabled: exchangeData?.MailboxOWAEnabled },
{ name: "IMAP", enabled: exchangeData?.MailboxImapEnabled },
{ name: "POP", enabled: exchangeData?.MailboxPopEnabled },
{ name: "ActiveSync", enabled: exchangeData?.MailboxActiveSyncEnabled },
];

return (
<Card {...other}>
<CardHeader title="Exchange Details" />
<Divider />
<PropertyList>
<PropertyListItem
divider
label="Mailbox Type"
value={
isFetching ? (
<Skeleton variant="text" width={120} />
) : (
getCippTranslation(exchangeData?.RecipientTypeDetails) || "N/A"
)
}
/>
<PropertyListItem
divider
label="Mailbox Usage"
value={
isFetching ? (
<Skeleton variant="text" width={80} />
) : exchangeData?.TotalItemSize != null ? (
<LinearProgressWithLabel
sx={{ width: "100%" }}
variant="determinate"
value={
Math.round(
(exchangeData?.TotalItemSize / exchangeData?.ProhibitSendReceiveQuota) *
100 *
100
) / 100
}
/>
) : (
"N/A"
)
}
/>
<PropertyListItem
divider
label="Hidden From Address Lists"
value={
isFetching ? (
<Skeleton variant="text" width={60} />
) : (
getCippFormatting(exchangeData?.HiddenFromAddressLists, "HiddenFromAddressLists")
)
}
/>
<PropertyListItem
label="Forward and Deliver"
value={
isFetching ? (
<Skeleton variant="text" width={60} />
) : (
getCippFormatting(exchangeData?.ForwardAndDeliver, "ForwardAndDeliver")
)
}
/>
<PropertyListItem
divider
label="Forwarding Address"
value={
isFetching ? (
<Skeleton variant="text" width={180} />
) : (
exchangeData?.ForwardingAddress || "N/A"
)
}
/>
<PropertyListItem
label="Archive Mailbox Enabled"
value={
isFetching ? (
<Skeleton variant="text" width={60} />
) : (
getCippFormatting(exchangeData?.ArchiveMailBox, "ArchiveMailBox")
)
}
/>
<PropertyListItem
label="Auto Expanding Archive"
value={
isFetching ? (
<Skeleton variant="text" width={80} />
) : (
getCippFormatting(exchangeData?.AutoExpandingArchive, "AutoExpandingArchive")
)
}
/>
<PropertyListItem
label="Total Archive Item Size"
value={
isFetching ? (
<Skeleton variant="text" width={80} />
) : exchangeData?.TotalArchiveItemSize != null ? (
`${exchangeData.TotalArchiveItemSize} GB`
) : (
"N/A"
)
}
/>
<PropertyListItem
divider
label="Total Archive Item Count"
value={
isFetching ? (
<Skeleton variant="text" width={80} />
) : exchangeData?.TotalArchiveItemCount != null ? (
exchangeData.TotalArchiveItemCount
) : (
"N/A"
)
}
/>
<PropertyListItem
divider
label="Litigation Hold"
value={
isFetching ? (
<Skeleton variant="text" width={60} />
) : (
getCippFormatting(exchangeData?.LitigationHold, "LitigationHold")
)
}
/>
{/* Combine protocols into a single PropertyListItem */}
<PropertyListItem
divider
label="Mailbox Protocols"
value={
isFetching ? (
<Skeleton variant="text" width={200} />
) : (
<div>
{protocols.map((protocol) => (
<Chip
key={protocol.name}
label={protocol.name}
icon={protocol.enabled ? <CheckIcon /> : <CloseIcon />}
color={protocol.enabled ? "success" : "default"}
variant="outlined"
size="small"
sx={{ mr: 1, mb: 1 }}
/>
))}
</div>
)
}
/>
<PropertyListItem
divider
label="Blocked For Spam"
value={
isFetching ? (
<Skeleton variant="text" width={60} />
) : (
getCippFormatting(exchangeData?.BlockedForSpam, "BlockedForSpam")
)
}
/>
</PropertyList>
</Card>
);
};

CippExchangeInfoCard.propTypes = {
exchangeData: PropTypes.object,
isFetching: PropTypes.bool,
};
6 changes: 1 addition & 5 deletions src/components/linearProgressWithLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ export const LinearProgressWithLabel = (props) => {
<Box sx={{ width: "100%", mr: 1 }}>
<LinearProgress variant="determinate" {...props} />
</Box>
<Box sx={{ minWidth: 35 }}>
<Typography variant="body2" sx={{ color: "text.secondary" }}>
{`${Math.round(props.value)}%`}
</Typography>
</Box>
<Box sx={{ minWidth: 35 }}>{`${Math.round(props.value)}%`}</Box>
</Box>
);
};
2 changes: 1 addition & 1 deletion src/components/property-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export const PropertyListItem = (props) => {
}
sx={{
alignItems: "flex-start",
display: "flex",
flexDirection: align === "vertical" ? "column" : "row",
my: 0,
width: "100%",
}}
/>
</ListItem>
Expand Down
Loading

0 comments on commit d70ad08

Please sign in to comment.