forked from KelvinTegelaar/CIPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Connection Filter functionality to the front end.
- Loading branch information
Showing
6 changed files
with
229 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
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,17 @@ | ||
|
||
import { Layout as DashboardLayout } from "/src/layouts/index.js"; | ||
|
||
const Page = () => { | ||
const pageTitle = "Apply Spamfilter Template"; | ||
|
||
return ( | ||
<div> | ||
<h1>{pageTitle}</h1> | ||
<p>This is a placeholder page for the apply spamfilter template section.</p> | ||
</div> | ||
); | ||
}; | ||
|
||
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>; | ||
|
||
export default Page; |
87 changes: 87 additions & 0 deletions
87
src/pages/email/connectionfilter/list-connectionfilter/add.jsx
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,87 @@ | ||
import React, { useEffect } from "react"; | ||
import { Grid, Divider } from "@mui/material"; | ||
import { useForm, useWatch } from "react-hook-form"; | ||
import { Layout as DashboardLayout } from "/src/layouts/index.js"; | ||
import CippFormPage from "/src/components/CippFormPages/CippFormPage"; | ||
import CippFormComponent from "/src/components/CippComponents/CippFormComponent"; | ||
import { CippFormTenantSelector } from "/src/components/CippComponents/CippFormTenantSelector"; | ||
|
||
const AddPolicy = () => { | ||
const formControl = useForm({ | ||
mode: "onChange", | ||
defaultValues: { | ||
selectedTenants: [], | ||
TemplateList: null, | ||
PowerShellCommand: "", | ||
}, | ||
}); | ||
|
||
const templateListVal = useWatch({ control: formControl.control, name: "TemplateList" }); | ||
|
||
useEffect(() => { | ||
if (templateListVal?.value) { | ||
formControl.setValue("PowerShellCommand", JSON.stringify(templateListVal?.value)); | ||
} | ||
}, [templateListVal, formControl]); | ||
|
||
return ( | ||
<CippFormPage | ||
formControl={formControl} | ||
queryKey="AddConnectionFilter" | ||
title="Add Connection Filter" | ||
backButtonTitle="Connection Filter Overview" | ||
postUrl="/api/AddConnectionFilter" | ||
> | ||
<Grid container spacing={2}> | ||
<Grid item xs={12}> | ||
<CippFormTenantSelector | ||
label="Select Tenants" | ||
formControl={formControl} | ||
name="selectedTenants" | ||
type="multiple" | ||
allTenants={true} | ||
validators={{ required: "At least one tenant must be selected" }} | ||
/> | ||
</Grid> | ||
|
||
<Divider sx={{ my: 2, width: "100%" }} /> | ||
|
||
{/* TemplateList */} | ||
<Grid item xs={12} md={12}> | ||
<CippFormComponent | ||
type="autoComplete" | ||
label="Select a template (optional)" | ||
name="TemplateList" | ||
formControl={formControl} | ||
multiple={false} | ||
api={{ | ||
queryKey: `TemplateListConnectionFilter`, | ||
labelField: "name", | ||
valueField: (option) => option, | ||
url: "/api/ListConnectionFilterTemplates", | ||
}} | ||
placeholder="Select a template or enter PowerShell JSON manually" | ||
/> | ||
</Grid> | ||
|
||
<Divider sx={{ my: 2, width: "100%" }} /> | ||
|
||
<Grid item xs={12}> | ||
<CippFormComponent | ||
type="textField" | ||
label="Parameters (JSON)" | ||
name="PowerShellCommand" | ||
formControl={formControl} | ||
multiline | ||
rows={6} | ||
validators={{ required: "Please enter the PowerShell parameters as JSON." }} | ||
/> | ||
</Grid> | ||
</Grid> | ||
</CippFormPage> | ||
); | ||
}; | ||
|
||
AddPolicy.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>; | ||
|
||
export default AddPolicy; |
62 changes: 62 additions & 0 deletions
62
src/pages/email/connectionfilter/list-connectionfilter/index.js
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,62 @@ | ||
import { Layout as DashboardLayout } from "/src/layouts/index.js"; | ||
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx"; | ||
import { Button } from "@mui/material"; | ||
import Link from "next/link"; | ||
|
||
const Page = () => { | ||
const pageTitle = "Connection Filters"; | ||
|
||
const actions = [ | ||
{ | ||
label: "Create template based on rule", | ||
type: "POST", | ||
url: "/api/AddConnectionfilterTemplate", | ||
dataFunction: (data) => { | ||
return { ...data }; | ||
}, | ||
confirmText: "Are you sure you want to create a template based on this rule?", | ||
}, | ||
]; | ||
|
||
const offCanvas = { | ||
extendedInfoFields: [ | ||
"DistinguishedName", | ||
"DirectoryBasedEdgeBlockMode", | ||
"ExchangeVersion", | ||
"ExchangeObjectId", | ||
"OrganizationalUnitRoot", | ||
"WhenCreated", | ||
"WhenChanged", | ||
"Guid", | ||
], | ||
actions: actions, | ||
}; | ||
|
||
const simpleColumns = [ | ||
"Name", | ||
"IsDefault", | ||
"IPAllowList", | ||
"IPBlockList", | ||
"EnableSafeList", | ||
]; | ||
|
||
return ( | ||
<CippTablePage | ||
title={pageTitle} | ||
apiUrl="/api/ListConnectionFilter" | ||
actions={actions} | ||
offCanvas={offCanvas} | ||
simpleColumns={simpleColumns} | ||
cardButton={ | ||
<> | ||
<Button component={Link} href="/email/connectionfilter/list-connectionfilter/add"> | ||
Deploy ConnectionFilter | ||
</Button> | ||
</> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>; | ||
export default Page; |
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,59 @@ | ||
import { Layout as DashboardLayout } from "/src/layouts/index.js"; | ||
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx"; | ||
import { EyeIcon, TrashIcon } from "@heroicons/react/24/outline"; | ||
|
||
const Page = () => { | ||
const pageTitle = "Connection filter Templates"; | ||
|
||
const actions = [ | ||
{ | ||
label: "View Template", | ||
icon: <EyeIcon />, // Placeholder for the view icon | ||
color: "success", | ||
offCanvas: true, | ||
}, | ||
{ | ||
label: "Delete Template", | ||
type: "POST", | ||
url: "/api/RemoveConnectionfilterTemplate", | ||
data: { ID: "GUID" }, | ||
confirmText: "Do you want to delete the template?", | ||
icon: <TrashIcon />, // Placeholder for the delete icon | ||
color: "danger", | ||
}, | ||
]; | ||
|
||
const offCanvas = { | ||
extendedInfoFields: [ | ||
"name", | ||
"IsDefault", | ||
"IPAllowList", | ||
"IPBlockList", | ||
"EnableSafeList", | ||
"GUID", | ||
], | ||
actions: actions, | ||
}; | ||
|
||
const simpleColumns = [ | ||
"name", | ||
"IsDefault", | ||
"IPAllowList", | ||
"IPBlockList", | ||
"EnableSafeList", | ||
"GUID", | ||
]; | ||
|
||
return ( | ||
<CippTablePage | ||
title={pageTitle} | ||
apiUrl="/api/ListConnectionfilterTemplates" | ||
actions={actions} | ||
offCanvas={offCanvas} | ||
simpleColumns={simpleColumns} | ||
/> | ||
); | ||
}; | ||
|
||
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>; | ||
export default Page; |