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 #29

Merged
merged 10 commits into from
Jan 23, 2025
38 changes: 22 additions & 16 deletions src/components/CippCards/CippBannerListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "@mui/material";
import ChevronDownIcon from "@heroicons/react/24/outline/ChevronDownIcon";
import { CippPropertyListCard } from "./CippPropertyListCard";
import { CippDataTable } from "../CippTable/CippDataTable";

export const CippBannerListCard = (props) => {
const { items = [], isCollapsible = false, isFetching = false, ...other } = props;
Expand Down Expand Up @@ -113,17 +114,19 @@ export const CippBannerListCard = (props) => {

{/* Right Side: Status and Expand Icon */}
<Stack alignItems="center" direction="row" spacing={2}>
<Stack alignItems="center" direction="row" spacing={1}>
<Box
sx={{
backgroundColor: statusColor,
borderRadius: "50%",
height: 8,
width: 8,
}}
/>
<Typography variant="body2">{item.statusText}</Typography>
</Stack>
{item?.statusText && (
<Stack alignItems="center" direction="row" spacing={1}>
<Box
sx={{
backgroundColor: statusColor,
borderRadius: "50%",
height: 8,
width: 8,
}}
/>
<Typography variant="body2">{item.statusText}</Typography>
</Stack>
)}
{isCollapsible && (
<IconButton onClick={() => handleExpand(item.id)}>
<SvgIcon
Expand All @@ -142,11 +145,14 @@ export const CippBannerListCard = (props) => {
{isCollapsible && (
<Collapse in={isExpanded}>
<Divider />
<CippPropertyListCard
propertyItems={item.propertyItems || []}
layout="dual"
isFetching={item.isFetching || false}
/>
{item?.propertyItems?.length > 0 && (
<CippPropertyListCard
propertyItems={item.propertyItems || []}
layout="dual"
isFetching={item.isFetching || false}
/>
)}
{item?.table && <CippDataTable {...item.table} />}
</Collapse>
)}
</li>
Expand Down
317 changes: 317 additions & 0 deletions src/components/CippComponents/CippUserActions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
import { EyeIcon, MagnifyingGlassIcon, TrashIcon } from "@heroicons/react/24/outline";
import {
Archive,
Block,
Clear,
CloudDone,
Edit,
Email,
ForwardToInbox,
GroupAdd,
LockOpen,
LockPerson,
LockReset,
MeetingRoom,
NoMeetingRoom,
Password,
PersonOff,
PhonelinkLock,
PhonelinkSetup,
Shortcut,
} from "@mui/icons-material";
import { useSettings } from "/src/hooks/use-settings.js";

export const CippUserActions = () => {
const tenant = useSettings().currentTenant;
return [
{
//tested
label: "View User",
link: "/identity/administration/users/user?userId=[id]",
multiPost: false,
icon: <EyeIcon />,
color: "success",
},
{
//tested
label: "Edit User",
link: "/identity/administration/users/user/edit?userId=[id]",
icon: <Edit />,
color: "success",
target: "_self",
},
{
//tested
label: "Research Compromised Account",
type: "GET",
icon: <MagnifyingGlassIcon />,
link: "/identity/administration/users/user/bec?userId=[id]",
confirmText: "Are you sure you want to research this compromised account?",
multiPost: false,
},
{
//tested

label: "Create Temporary Access Password",
type: "GET",
icon: <Password />,
url: "/api/ExecCreateTAP",
data: { ID: "userPrincipalName" },
confirmText: "Are you sure you want to create a Temporary Access Password?",
multiPost: false,
},
{
//tested
label: "Re-require MFA registration",
type: "GET",
icon: <PhonelinkSetup />,
url: "/api/ExecResetMFA",
data: { ID: "userPrincipalName" },
confirmText: "Are you sure you want to reset MFA for this user?",
multiPost: false,
},
{
//tested
label: "Send MFA Push",
type: "POST",
icon: <PhonelinkLock />,
url: "/api/ExecSendPush",
data: { UserEmail: "userPrincipalName" },
confirmText: "Are you sure you want to send an MFA request?",
multiPost: false,
},
{
//tested
label: "Set Per-User MFA",
type: "POST",
icon: <LockPerson />,
url: "/api/ExecPerUserMFA",
data: { userId: "userPrincipalName" },
fields: [
{
type: "autoComplete",
name: "State",
label: "State",
options: [
{ label: "Enforced", value: "Enforced" },
{ label: "Enabled", value: "Enabled" },
{ label: "Disabled", value: "Disabled" },
],
multiple: false,
},
],
confirmText: "Are you sure you want to set per-user MFA for these users?",
multiPost: false,
},
{
//tested
label: "Convert to Shared Mailbox",
type: "GET",
icon: <Email />,
url: "/api/ExecConvertToSharedMailbox",
data: { ID: "userPrincipalName" },
confirmText: "Are you sure you want to convert this user to a shared mailbox?",
multiPost: false,
},
{
label: "Convert to User Mailbox",
type: "GET",
icon: <Email />,
url: "/api/ExecConvertToSharedMailbox",
data: { ID: "userPrincipalName", ConvertToUser: true },
confirmText: "Are you sure you want to convert this user to a user mailbox?",
multiPost: false,
},
{
//tested
label: "Enable Online Archive",
type: "GET",
icon: <Archive />,
url: "/api/ExecEnableArchive",
data: { ID: "userPrincipalName" },
confirmText: "Are you sure you want to enable the online archive for this user?",
multiPost: false,
},
{
//tested
label: "Set Out of Office",
type: "POST",
icon: <MeetingRoom />,
url: "/api/ExecSetOoO",
data: {
userId: "userPrincipalName",
AutoReplyState: { value: "Enabled" },
tenantFilter: "Tenant",
},
fields: [{ type: "richText", name: "input", label: "Out of Office Message" }],
confirmText: "Are you sure you want to set the out of office?",
multiPost: false,
},

{
label: "Disable Out of Office",
type: "POST",
icon: <NoMeetingRoom />,
url: "/api/ExecSetOoO",
data: { user: "userPrincipalName", AutoReplyState: "Disabled" },
confirmText: "Are you sure you want to disable the out of office?",
multiPost: false,
},
{
label: "Add to Group",
type: "POST",
icon: <GroupAdd />,
url: "/api/EditGroup",
data: { addMember: "userPrincipalName" },
fields: [
{
type: "autoComplete",
name: "groupId",
label: "Select a group to add the user to",
multiple: false,
creatable: false,
api: {
url: "/api/ListGroups",
labelField: "displayName",
valueField: "id",
addedField: {
groupType: "calculatedGroupType",
groupName: "displayName",
},
queryKey: `groups-${tenant}`,
},
},
],
confirmText: "Are you sure you want to add the user to this group?",
},
{
label: "Disable Email Forwarding",
type: "POST",
url: "/api/ExecEmailForward",
icon: <ForwardToInbox />,
data: {
username: "userPrincipalName",
userid: "userPrincipalName",
ForwardOption: "!disabled",
},
confirmText: "Are you sure you want to disable forwarding of this user's emails?",
multiPost: false,
},
{
label: "Pre-provision OneDrive",
type: "POST",
icon: <CloudDone />,
url: "/api/ExecOneDriveProvision",
data: { UserPrincipalName: "userPrincipalName" },
confirmText: "Are you sure you want to pre-provision OneDrive for this user?",
multiPost: false,
},
{
label: "Add OneDrive Shortcut",
type: "POST",
icon: <Shortcut />,
url: "/api/ExecOneDriveShortCut",
data: {
username: "userPrincipalName",
userid: "id",
},
fields: [
{
type: "autoComplete",
name: "siteUrl",
label: "Select a Site",
multiple: false,
creatable: false,
api: {
url: "/api/ListSites",
data: { type: "SharePointSiteUsage", URLOnly: true },
labelField: "webUrl",
valueField: "webUrl",
queryKey: `sharepointSites-${tenant}`,
},
},
],
confirmText: "Select a SharePoint site to create a shortcut for:",
multiPost: false,
},
{
label: "Block Sign In",
type: "GET",
icon: <Block />,
url: "/api/ExecDisableUser",
data: { ID: "id" },
confirmText: "Are you sure you want to block the sign-in for this user?",
multiPost: false,
condition: (row) => row.accountEnabled,
},
{
label: "Unblock Sign In",
type: "GET",
icon: <LockOpen />,
url: "/api/ExecDisableUser",
data: { ID: "id", Enable: true },
confirmText: "Are you sure you want to unblock sign-in for this user?",
multiPost: false,
condition: (row) => !row.accountEnabled,
},
{
label: "Reset Password (Must Change)",
type: "GET",
icon: <LockReset />,
url: "/api/ExecResetPass",
data: {
MustChange: true,
ID: "userPrincipalName",
displayName: "displayName",
},
confirmText:
"Are you sure you want to reset the password for this user? The user must change their password at next logon.",
multiPost: false,
},
{
label: "Reset Password",
type: "GET",
icon: <LockReset />,
url: "/api/ExecResetPass",
data: {
MustChange: false,
ID: "userPrincipalName",
displayName: "displayName",
},
confirmText: "Are you sure you want to reset the password for this user?",
multiPost: false,
},
{
label: "Clear Immutable ID",
type: "GET",
icon: <Clear />,
url: "/api/ExecClrImmId",
data: {
ID: "id",
},
confirmText: "Are you sure you want to clear the Immutable ID for this user?",
multiPost: false,
condition: (row) => row.onPremisesSyncEnabled,
},
{
label: "Revoke all user sessions",
type: "GET",
icon: <PersonOff />,
url: "/api/ExecRevokeSessions",
data: { ID: "id", Username: "userPrincipalName" },
confirmText: "Are you sure you want to revoke all sessions for this user?",
multiPost: false,
},
{
label: "Delete User",
type: "GET",
icon: <TrashIcon />,
url: "/api/RemoveUser",
data: { ID: "id" },
confirmText: "Are you sure you want to delete this user?",
multiPost: false,
},
];
};

export default CippUserActions;
9 changes: 7 additions & 2 deletions src/components/CippTable/CippDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const CippDataTable = (props) => {
cardButton,
offCanvas = false,
noCard = false,
hideTitle = false,
refreshFunction,
incorrectDataMessage = "Data not in correct format",
onChange,
Expand Down Expand Up @@ -298,8 +299,12 @@ export const CippDataTable = (props) => {
) : (
// Render the table inside a Card
<Card style={{ width: "100%" }}>
<CardHeader action={cardButton} title={title} />
<Divider />
{cardButton || !hideTitle ? (
<>
<CardHeader action={cardButton} title={hideTitle ? "" : title} />
<Divider />
</>
) : null}
<CardContent sx={{ padding: "1rem" }}>
<Scrollbar>
{!Array.isArray(usedData) && usedData ? (
Expand Down
Loading