-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acacf48
commit 9efbd5e
Showing
12 changed files
with
1,073 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import React from "react"; | ||
import { Card, CardHeader, CardContent, CardActions, Skeleton } from "@mui/material"; | ||
import { Card, CardHeader, CardContent, CardActions, Skeleton, Box } from "@mui/material"; | ||
|
||
export default function CippButtonCard({ title, CardButton, children, isFetching = false }) { | ||
return ( | ||
<Card sx={{ width: "100%" }}> | ||
<CardHeader title={title} /> | ||
<CardContent sx={{ padding: "1rem" }}>{isFetching ? <Skeleton /> : children}</CardContent> | ||
{CardButton && <CardActions>{CardButton}</CardActions>} | ||
</Card> | ||
<Box | ||
sx={{ | ||
py: 4, | ||
}} | ||
> | ||
<Card> | ||
<CardHeader title={title} /> | ||
<CardContent>{isFetching ? <Skeleton /> : children}</CardContent> | ||
{CardButton && <CardActions>{CardButton}</CardActions>} | ||
</Card> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { | ||
Box, | ||
Card, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react"; | ||
import { CippFormComponent } from "./CippFormComponent"; | ||
import { useWatch } from "react-hook-form"; | ||
|
||
export const CippFormDomainSelector = ({ | ||
formControl, | ||
name, | ||
label, | ||
allTenants = false, | ||
type = "multiple", | ||
...other | ||
}) => { | ||
const currentTenant = useWatch({ control: formControl.control, name: "tenantFilter" }); | ||
return ( | ||
<CippFormComponent | ||
name={name} | ||
label={label} | ||
type="autoComplete" | ||
formControl={formControl} | ||
multiple={false} | ||
api={{ | ||
autoSelectFirstItem: true, | ||
tenantFilter: currentTenant?.value, | ||
queryKey: `ListDomains-${currentTenant?.value}`, | ||
url: "/api/ListGraphRequest", | ||
dataKey: "Results", | ||
labelField: (option) => `${option.id}`, | ||
valueField: "id", | ||
data: { | ||
Endpoint: "domains", | ||
manualPagination: true, | ||
$count: true, | ||
$top: 99, | ||
}, | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { CippFormComponent } from "./CippFormComponent"; | ||
import { useWatch } from "react-hook-form"; | ||
|
||
export const CippFormUserSelector = ({ | ||
formControl, | ||
name, | ||
label, | ||
allTenants = false, | ||
multiple = false, | ||
type = "multiple", | ||
...other | ||
}) => { | ||
const currentTenant = useWatch({ control: formControl.control, name: "tenantFilter" }); | ||
return ( | ||
<CippFormComponent | ||
name={name} | ||
label={label} | ||
type="autoComplete" | ||
formControl={formControl} | ||
multiple={multiple} | ||
api={{ | ||
tenantFilter: currentTenant ? currentTenant.value : undefined, | ||
url: "/api/ListGraphRequest", | ||
dataKey: "Results", | ||
labelField: (option) => `${option.displayName} (${option.userPrincipalName})`, | ||
valueField: "id", | ||
queryKey: `ListUsers-${currentTenant?.value}`, | ||
data: { | ||
Endpoint: "users", | ||
manualPagination: true, | ||
$select: "id,userPrincipalName,displayName", | ||
$count: true, | ||
$orderby: "displayName", | ||
$top: 999, | ||
}, | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { useRouter } from "next/router"; | ||
import { | ||
Box, | ||
Container, | ||
Stack, | ||
Button, | ||
SvgIcon, | ||
Typography, | ||
Card, | ||
CardContent, | ||
CardActions, | ||
} from "@mui/material"; | ||
import ArrowLeftIcon from "@mui/icons-material/ArrowLeft"; | ||
import Head from "next/head"; | ||
|
||
const CippFormPage = (props) => { | ||
const { title, backButtonTitle, formPageType = "Add", children, formControl, ...other } = props; | ||
const router = useRouter(); | ||
|
||
const handleBackClick = () => { | ||
router.back(); // Navigate to the previous page when the button is clicked | ||
}; | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>{title}</title> | ||
</Head> | ||
<Box | ||
sx={{ | ||
flexGrow: 1, | ||
py: 4, | ||
}} | ||
> | ||
<Container maxWidth="lg"> | ||
<Stack spacing={4}> | ||
<Stack spacing={2}> | ||
<div> | ||
<Button | ||
color="inherit" | ||
onClick={handleBackClick} // Go back to the previous page | ||
startIcon={ | ||
<SvgIcon fontSize="small"> | ||
<ArrowLeftIcon /> | ||
</SvgIcon> | ||
} | ||
> | ||
{backButtonTitle} | ||
</Button> | ||
</div> | ||
<div> | ||
<Typography variant="h4"> | ||
{formPageType} - {title} | ||
</Typography> | ||
</div> | ||
</Stack> | ||
<Card> | ||
<CardContent>{children}</CardContent> | ||
<CardActions sx={{ justifyContent: "flex-end" }}> | ||
<Button type="submit" variant="contained"> | ||
Submit | ||
</Button> | ||
</CardActions> | ||
</Card> | ||
</Stack> | ||
</Container> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default CippFormPage; |
Oops, something went wrong.