Skip to content

Commit c803c23

Browse files
authored
Merge pull request #188 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 874b968 + a661a64 commit c803c23

File tree

9 files changed

+382
-137
lines changed

9 files changed

+382
-137
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { EyeIcon } from "@heroicons/react/24/outline";
2+
import {
3+
AdminPanelSettings,
4+
GppBad,
5+
HourglassBottom,
6+
LockReset,
7+
OpenInNew,
8+
PlayArrow,
9+
} from "@mui/icons-material";
10+
import { Alert, Typography } from "@mui/material";
11+
12+
export const CippGdapActions = () => [
13+
{
14+
label: "View Relationship",
15+
link: "/tenant/gdap-management/relationships/relationship?id=[id]",
16+
color: "primary",
17+
icon: <EyeIcon />,
18+
},
19+
{
20+
label: "Start Onboarding",
21+
link: "/tenant/gdap-management/onboarding/start?id=[id]",
22+
color: "primary",
23+
icon: <PlayArrow />,
24+
showInActionsMenu: true,
25+
},
26+
{
27+
label: "Open Relationship in Partner Center",
28+
link: "https://partner.microsoft.com/en-us/dashboard/commerce2/customers/[customer.tenantId]/adminrelationships/[id]",
29+
color: "info",
30+
icon: <OpenInNew />,
31+
showInActionsMenu: true,
32+
},
33+
{
34+
label: "Enable automatic extension",
35+
type: "GET",
36+
url: "/api/ExecAutoExtendGDAP",
37+
data: { ID: "id" },
38+
confirmText: "Are you sure you want to enable auto-extend for this relationship?",
39+
color: "info",
40+
icon: <HourglassBottom />,
41+
},
42+
{
43+
label: "Remove Global Administrator from Relationship",
44+
type: "GET",
45+
url: "/api/ExecGDAPRemoveGArole",
46+
data: { GDAPID: "id" },
47+
confirmText: "Are you sure you want to remove Global Administrator from this relationship?",
48+
color: "danger",
49+
icon: <AdminPanelSettings />,
50+
},
51+
{
52+
label: "Reset Group Mappings",
53+
type: "POST",
54+
url: "/api/ExecGDAPAccessAssignment",
55+
icon: <LockReset />,
56+
data: { Id: "id", Action: "ResetMappings" },
57+
fields: [
58+
{
59+
name: "RoleTemplateId",
60+
label: "Role Template",
61+
placeholder: "Select a role template to apply to this relationship.",
62+
type: "select",
63+
api: {
64+
url: "/api/ExecGDAPRoleTemplate",
65+
queryKey: "GDAPRoleTemplate",
66+
dataKey: "Results",
67+
valueField: "TemplateId",
68+
labelField: "TemplateId",
69+
showRefresh: true,
70+
},
71+
},
72+
],
73+
confirmText: (
74+
<>
75+
<Typography variant="body1">
76+
Are you sure you want to reset the group mappings for this relationship?
77+
</Typography>
78+
<Alert severity="warning">
79+
This action will remove all existing group mappings and apply the selected role template
80+
to the relationship. Use this to fix incorrect group mappings or permission overlap issues
81+
(e.g removing AdminAgents or HelpdeskAgents).
82+
</Alert>
83+
</>
84+
),
85+
},
86+
{
87+
label: "Terminate Relationship",
88+
type: "GET",
89+
url: "/api/ExecDeleteGDAPRelationship",
90+
data: { GDAPID: "id" },
91+
confirmText: "Are you sure you want to terminate this relationship?",
92+
color: "error",
93+
icon: <GppBad />,
94+
},
95+
];
96+
97+
export default CippGdapActions;

src/components/CippTable/CippDataTable.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const CippDataTable = (props) => {
5353
incorrectDataMessage = "Data not in correct format",
5454
onChange,
5555
filters,
56+
maxHeightOffset = "380px",
5657
} = props;
5758
const [columnVisibility, setColumnVisibility] = useState(initialColumnVisibility);
5859
const [configuredSimpleColumns, setConfiguredSimpleColumns] = useState(simpleColumns);
@@ -156,7 +157,15 @@ export const CippDataTable = (props) => {
156157

157158
// Apply the modeInfo directly
158159
const [modeInfo] = useState(
159-
utilTableMode(columnVisibility, simple, actions, configuredSimpleColumns, offCanvas, onChange)
160+
utilTableMode(
161+
columnVisibility,
162+
simple,
163+
actions,
164+
configuredSimpleColumns,
165+
offCanvas,
166+
onChange,
167+
maxHeightOffset
168+
)
160169
);
161170
//create memoized version of usedColumns, and usedData
162171
const memoizedColumns = useMemo(() => usedColumns, [usedColumns]);

src/components/CippTable/util-tablemode.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export const utilTableMode = (
66
actions,
77
simpleColumns,
88
offCanvas,
9-
onChange
9+
onChange,
10+
maxHeightOffset = "380px"
1011
) => {
1112
const settings = useSettings();
1213
if (mode === true) {
@@ -20,7 +21,7 @@ export const utilTableMode = (
2021
rowsPerPageOptions: [25, 50, 100, 250, 500],
2122
},
2223
muiTableContainerProps: {
23-
sx: { maxHeight: `calc(100vh - 380px)` },
24+
sx: { maxHeight: `calc(100vh - ${maxHeightOffset})` },
2425
},
2526
initialState: {
2627
columnOrder: [...simpleColumns],
@@ -57,7 +58,7 @@ export const utilTableMode = (
5758
rowsPerPageOptions: [25, 50, 100, 250, 500],
5859
},
5960
muiTableContainerProps: {
60-
sx: { maxHeight: `calc(100vh - 380px)` },
61+
sx: { maxHeight: `calc(100vh - ${maxHeightOffset})` },
6162
},
6263
displayColumnDefOptions: {
6364
"mrt-row-actions": {

src/components/actions-menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const ActionsMenu = (props) => {
5757
}}
5858
>
5959
{actions
60-
?.filter((action) => !action.link)
60+
?.filter((action) => !action.link || action.showInActionsMenu)
6161
.map((action, index) => (
6262
<MenuItem
6363
disabled={handleActionDisabled(data, action)}

src/layouts/HeaderedTabbedLayout.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ import {
1818
import { ActionsMenu } from "/src/components/actions-menu";
1919

2020
export const HeaderedTabbedLayout = (props) => {
21-
const { children, tabOptions, title, subtitle, actions, actionsData, isFetching = false } = props;
21+
const {
22+
children,
23+
tabOptions,
24+
title,
25+
subtitle,
26+
actions,
27+
actionsData,
28+
isFetching = false,
29+
backUrl,
30+
} = props;
2231

2332
const router = useRouter();
2433
const pathname = usePathname();
@@ -53,7 +62,7 @@ export const HeaderedTabbedLayout = (props) => {
5362
<div>
5463
<Button
5564
color="inherit"
56-
onClick={() => router.back()}
65+
onClick={() => (backUrl ? router.push(backUrl) : router.back())}
5766
startIcon={
5867
<SvgIcon fontSize="small">
5968
<ArrowLeftIcon />
@@ -108,7 +117,15 @@ export const HeaderedTabbedLayout = (props) => {
108117
<Divider />
109118
</div>
110119
</Stack>
111-
{children}
120+
<Box
121+
sx={{
122+
flexGrow: 1,
123+
overflow: "auto",
124+
height: "calc(100vh - 400px)",
125+
}}
126+
>
127+
{children}
128+
</Box>
112129
</Stack>
113130
</Container>
114131
</Box>

src/pages/tenant/gdap-management/relationships/index.js

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,11 @@ import { TabbedLayout } from "/src/layouts/TabbedLayout";
22
import { Layout as DashboardLayout } from "/src/layouts/index.js";
33
import tabOptions from "../tabOptions";
44
import CippTablePage from "/src/components/CippComponents/CippTablePage";
5-
import { EyeIcon } from "@heroicons/react/24/outline";
6-
import {
7-
AdminPanelSettings,
8-
GppBad,
9-
HourglassBottom,
10-
OpenInNew,
11-
PlayArrow,
12-
} from "@mui/icons-material";
5+
import CippGdapActions from "/src/components/CippComponents/CippGdapActions";
136

147
const pageTitle = "GDAP Relationships";
158

16-
const actions = [
17-
{
18-
label: "View Relationship",
19-
link: "/tenant/gdap-management/relationships/relationship?id=[id]",
20-
color: "primary",
21-
icon: <EyeIcon />,
22-
},
23-
{
24-
label: "Start Onboarding",
25-
link: "/tenant/gdap-management/onboarding/start?id=[id]",
26-
color: "primary",
27-
icon: <PlayArrow />,
28-
},
29-
{
30-
label: "Open Relationship in Partner Center",
31-
link: "https://partner.microsoft.com/en-us/dashboard/commerce2/customers/[customer.tenantId]/adminrelationships/[id]",
32-
color: "info",
33-
icon: <OpenInNew />,
34-
},
35-
{
36-
label: "Enable automatic extension",
37-
type: "GET",
38-
url: "/api/ExecAutoExtendGDAP",
39-
data: { ID: "id" },
40-
confirmText: "Are you sure you want to enable auto-extend for this relationship?",
41-
color: "info",
42-
icon: <HourglassBottom />,
43-
},
44-
{
45-
label: "Remove Global Administrator from Relationship",
46-
type: "GET",
47-
url: "/api/ExecGDAPRemoveGArole",
48-
data: { GDAPID: "id" },
49-
confirmText: "Are you sure you want to remove Global Administrator from this relationship?",
50-
color: "danger",
51-
icon: <AdminPanelSettings />,
52-
},
53-
{
54-
label: "Terminate Relationship",
55-
type: "GET",
56-
url: "/api/ExecDeleteGDAPRelationship",
57-
data: { GDAPID: "id" },
58-
confirmText: "Are you sure you want to terminate this relationship?",
59-
color: "error",
60-
icon: <GppBad />,
61-
},
62-
];
9+
const actions = CippGdapActions();
6310

6411
const simpleColumns = [
6512
"customer.displayName",

src/pages/tenant/gdap-management/relationships/relationship/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import CIPPDefaultGDAPRoles from "/src/data/CIPPDefaultGDAPRoles.json";
1515
import { CippCopyToClipBoard } from "../../../../../components/CippComponents/CippCopyToClipboard";
1616
import { Schedule } from "@mui/icons-material";
1717
import { useEffect, useState } from "react";
18+
import CippGdapActions from "../../../../../components/CippComponents/CippGdapActions";
1819

1920
const Page = () => {
2021
const router = useRouter();
2122
const { id } = router.query;
2223
const [relationshipProperties, setRelationshipProperties] = useState([]);
24+
const [relationshipData, setRelationshipData] = useState({});
2325

2426
const relationshipRequest = ApiGetCall({
2527
url: `/api/ListGraphRequest?Endpoint=tenantRelationships/delegatedAdminRelationships/${id}`,
@@ -67,7 +69,7 @@ const Page = () => {
6769
useEffect(() => {
6870
if (relationshipRequest.isSuccess) {
6971
const data = relationshipRequest?.data?.Results?.[0];
70-
72+
setRelationshipData(data);
7173
var properties = [
7274
{
7375
label: "Customer",
@@ -135,6 +137,9 @@ const Page = () => {
135137
title={title}
136138
subtitle={subtitle}
137139
isFetching={relationshipRequest.isLoading}
140+
actions={CippGdapActions()}
141+
actionsData={relationshipData}
142+
backUrl="/tenant/gdap-management/relationships"
138143
>
139144
{relationshipRequest.isLoading && <CippFormSkeleton layout={[2, 1, 2, 2]} />}
140145
{relationshipRequest.isSuccess && (

src/pages/tenant/gdap-management/relationships/relationship/mappings.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { Layout as DashboardLayout } from "/src/layouts/index.js";
2-
import { useSettings } from "/src/hooks/use-settings";
32
import { useRouter } from "next/router";
43
import { ApiGetCall } from "/src/api/ApiCall";
5-
import CippFormSkeleton from "/src/components/CippFormPages/CippFormSkeleton";
64
import { HeaderedTabbedLayout } from "/src/layouts/HeaderedTabbedLayout";
75
import tabOptions from "./tabOptions.json";
8-
import { Box, Grid, Stack } from "@mui/system";
96
import { CippTimeAgo } from "../../../../../components/CippComponents/CippTimeAgo";
10-
import { getCippTranslation } from "../../../../../utils/get-cipp-translation";
11-
import { CippPropertyListCard } from "../../../../../components/CippCards/CippPropertyListCard";
12-
import { getCippFormatting } from "../../../../../utils/get-cipp-formatting";
137
import { CippDataTable } from "../../../../../components/CippTable/CippDataTable";
14-
import { Alert, Divider, Link, Typography } from "@mui/material";
15-
import CIPPDefaultGDAPRoles from "/src/data/CIPPDefaultGDAPRoles.json";
16-
import { CippCopyToClipBoard } from "../../../../../components/CippComponents/CippCopyToClipboard";
178
import { Schedule } from "@mui/icons-material";
189

1910
const Page = () => {
@@ -56,6 +47,7 @@ const Page = () => {
5647
title={title}
5748
subtitle={subtitle}
5849
isFetching={relationshipRequest.isLoading}
50+
backUrl="/tenant/gdap-management/relationships"
5951
>
6052
{id && (
6153
<CippDataTable
@@ -67,6 +59,7 @@ const Page = () => {
6759
queryKey: `AccessAssignments-${id}`,
6860
}}
6961
simpleColumns={["group.displayName", "status", "createdDateTime", "roles", "members"]}
62+
maxHeightOffset="550px"
7063
/>
7164
)}
7265
</HeaderedTabbedLayout>

0 commit comments

Comments
 (0)