Skip to content

Commit bf83efa

Browse files
committed
Added Connection Filter
added Connection Filter functionality to the front end.
1 parent aa9494b commit bf83efa

File tree

6 files changed

+229
-1
lines changed

6 files changed

+229
-1
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/layouts/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ export const nativeMenuItems = [
378378
path: "/email/spamfilter",
379379
items: [
380380
{ title: "Spamfilter", path: "/email/spamfilter/list-spamfilter" },
381-
{ title: "Templates", path: "/email/spamfilter/list-templates" },
381+
{ title: "Spamfilter templates", path: "/email/spamfilter/list-templates" },
382+
{ title: "Connection filter", path: "/email/connectionfilter/list-connectionfilter" },
383+
{ title: "Connection filter templates", path: "/email/connectionfilter/list-templates" },
382384
],
383385
},
384386
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
3+
4+
const Page = () => {
5+
const pageTitle = "Apply Spamfilter Template";
6+
7+
return (
8+
<div>
9+
<h1>{pageTitle}</h1>
10+
<p>This is a placeholder page for the apply spamfilter template section.</p>
11+
</div>
12+
);
13+
};
14+
15+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
16+
17+
export default Page;
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import React, { useEffect } from "react";
2+
import { Grid, Divider } from "@mui/material";
3+
import { useForm, useWatch } from "react-hook-form";
4+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
5+
import CippFormPage from "/src/components/CippFormPages/CippFormPage";
6+
import CippFormComponent from "/src/components/CippComponents/CippFormComponent";
7+
import { CippFormTenantSelector } from "/src/components/CippComponents/CippFormTenantSelector";
8+
9+
const AddPolicy = () => {
10+
const formControl = useForm({
11+
mode: "onChange",
12+
defaultValues: {
13+
selectedTenants: [],
14+
TemplateList: null,
15+
PowerShellCommand: "",
16+
},
17+
});
18+
19+
const templateListVal = useWatch({ control: formControl.control, name: "TemplateList" });
20+
21+
useEffect(() => {
22+
if (templateListVal?.value) {
23+
formControl.setValue("PowerShellCommand", JSON.stringify(templateListVal?.value));
24+
}
25+
}, [templateListVal, formControl]);
26+
27+
return (
28+
<CippFormPage
29+
formControl={formControl}
30+
queryKey="AddConnectionFilter"
31+
title="Add Connection Filter"
32+
backButtonTitle="Connection Filter Overview"
33+
postUrl="/api/AddConnectionFilter"
34+
>
35+
<Grid container spacing={2}>
36+
<Grid item xs={12}>
37+
<CippFormTenantSelector
38+
label="Select Tenants"
39+
formControl={formControl}
40+
name="selectedTenants"
41+
type="multiple"
42+
allTenants={true}
43+
validators={{ required: "At least one tenant must be selected" }}
44+
/>
45+
</Grid>
46+
47+
<Divider sx={{ my: 2, width: "100%" }} />
48+
49+
{/* TemplateList */}
50+
<Grid item xs={12} md={12}>
51+
<CippFormComponent
52+
type="autoComplete"
53+
label="Select a template (optional)"
54+
name="TemplateList"
55+
formControl={formControl}
56+
multiple={false}
57+
api={{
58+
queryKey: `TemplateListConnectionFilter`,
59+
labelField: "name",
60+
valueField: (option) => option,
61+
url: "/api/ListConnectionFilterTemplates",
62+
}}
63+
placeholder="Select a template or enter PowerShell JSON manually"
64+
/>
65+
</Grid>
66+
67+
<Divider sx={{ my: 2, width: "100%" }} />
68+
69+
<Grid item xs={12}>
70+
<CippFormComponent
71+
type="textField"
72+
label="Parameters (JSON)"
73+
name="PowerShellCommand"
74+
formControl={formControl}
75+
multiline
76+
rows={6}
77+
validators={{ required: "Please enter the PowerShell parameters as JSON." }}
78+
/>
79+
</Grid>
80+
</Grid>
81+
</CippFormPage>
82+
);
83+
};
84+
85+
AddPolicy.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
86+
87+
export default AddPolicy;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
2+
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
3+
import { Button } from "@mui/material";
4+
import Link from "next/link";
5+
6+
const Page = () => {
7+
const pageTitle = "Connection Filters";
8+
9+
const actions = [
10+
{
11+
label: "Create template based on rule",
12+
type: "POST",
13+
url: "/api/AddConnectionfilterTemplate",
14+
dataFunction: (data) => {
15+
return { ...data };
16+
},
17+
confirmText: "Are you sure you want to create a template based on this rule?",
18+
},
19+
];
20+
21+
const offCanvas = {
22+
extendedInfoFields: [
23+
"DistinguishedName",
24+
"DirectoryBasedEdgeBlockMode",
25+
"ExchangeVersion",
26+
"ExchangeObjectId",
27+
"OrganizationalUnitRoot",
28+
"WhenCreated",
29+
"WhenChanged",
30+
"Guid",
31+
],
32+
actions: actions,
33+
};
34+
35+
const simpleColumns = [
36+
"Name",
37+
"IsDefault",
38+
"IPAllowList",
39+
"IPBlockList",
40+
"EnableSafeList",
41+
];
42+
43+
return (
44+
<CippTablePage
45+
title={pageTitle}
46+
apiUrl="/api/ListConnectionFilter"
47+
actions={actions}
48+
offCanvas={offCanvas}
49+
simpleColumns={simpleColumns}
50+
cardButton={
51+
<>
52+
<Button component={Link} href="/email/connectionfilter/list-connectionfilter/add">
53+
Deploy ConnectionFilter
54+
</Button>
55+
</>
56+
}
57+
/>
58+
);
59+
};
60+
61+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
62+
export default Page;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Layout as DashboardLayout } from "/src/layouts/index.js";
2+
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
3+
import { EyeIcon, TrashIcon } from "@heroicons/react/24/outline";
4+
5+
const Page = () => {
6+
const pageTitle = "Connection filter Templates";
7+
8+
const actions = [
9+
{
10+
label: "View Template",
11+
icon: <EyeIcon />, // Placeholder for the view icon
12+
color: "success",
13+
offCanvas: true,
14+
},
15+
{
16+
label: "Delete Template",
17+
type: "POST",
18+
url: "/api/RemoveConnectionfilterTemplate",
19+
data: { ID: "GUID" },
20+
confirmText: "Do you want to delete the template?",
21+
icon: <TrashIcon />, // Placeholder for the delete icon
22+
color: "danger",
23+
},
24+
];
25+
26+
const offCanvas = {
27+
extendedInfoFields: [
28+
"name",
29+
"IsDefault",
30+
"IPAllowList",
31+
"IPBlockList",
32+
"EnableSafeList",
33+
"GUID",
34+
],
35+
actions: actions,
36+
};
37+
38+
const simpleColumns = [
39+
"name",
40+
"IsDefault",
41+
"IPAllowList",
42+
"IPBlockList",
43+
"EnableSafeList",
44+
"GUID",
45+
];
46+
47+
return (
48+
<CippTablePage
49+
title={pageTitle}
50+
apiUrl="/api/ListConnectionfilterTemplates"
51+
actions={actions}
52+
offCanvas={offCanvas}
53+
simpleColumns={simpleColumns}
54+
/>
55+
);
56+
};
57+
58+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
59+
export default Page;

0 commit comments

Comments
 (0)