Skip to content

Commit ac64e18

Browse files
authored
Merge pull request #704 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 120d577 + e36c360 commit ac64e18

File tree

4 files changed

+374
-115
lines changed

4 files changed

+374
-115
lines changed

src/components/CippCards/CippBannerListCard.jsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useState, useCallback } from "react";
33
import {
44
Box,
55
Card,
6+
Checkbox,
67
Collapse,
78
Divider,
89
IconButton,
@@ -16,13 +17,34 @@ import { CippPropertyListCard } from "./CippPropertyListCard";
1617
import { CippDataTable } from "../CippTable/CippDataTable";
1718

1819
export const CippBannerListCard = (props) => {
19-
const { items = [], isCollapsible = false, isFetching = false, children, ...other } = props;
20+
const {
21+
items = [],
22+
isCollapsible = false,
23+
isFetching = false,
24+
children,
25+
onSelectionChange,
26+
selectedItems = [],
27+
...other
28+
} = props;
2029
const [expanded, setExpanded] = useState(null);
2130

2231
const handleExpand = useCallback((itemId) => {
2332
setExpanded((prevState) => (prevState === itemId ? null : itemId));
2433
}, []);
2534

35+
const handleCheckboxChange = useCallback(
36+
(itemId, checked) => {
37+
if (onSelectionChange) {
38+
if (checked) {
39+
onSelectionChange([...selectedItems, itemId]);
40+
} else {
41+
onSelectionChange(selectedItems.filter((id) => id !== itemId));
42+
}
43+
}
44+
},
45+
[onSelectionChange, selectedItems]
46+
);
47+
2648
const hasItems = items.length > 0;
2749

2850
if (isFetching) {
@@ -91,6 +113,16 @@ export const CippBannerListCard = (props) => {
91113
alignItems="center"
92114
sx={{ flex: 1, minWidth: 0 }}
93115
>
116+
{onSelectionChange && (
117+
<Checkbox
118+
checked={selectedItems.includes(item.id)}
119+
onChange={(e) => {
120+
e.stopPropagation();
121+
handleCheckboxChange(item.id, e.target.checked);
122+
}}
123+
onClick={(e) => e.stopPropagation()}
124+
/>
125+
)}
94126
<Box
95127
sx={{
96128
alignItems: "center",
@@ -224,4 +256,6 @@ CippBannerListCard.propTypes = {
224256
).isRequired,
225257
isCollapsible: PropTypes.bool,
226258
isFetching: PropTypes.bool,
259+
onSelectionChange: PropTypes.func,
260+
selectedItems: PropTypes.array,
227261
};

src/components/CippTestDetail/CippTestDetailOffCanvas.jsx

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { KeyboardArrowRight } from "@mui/icons-material";
44
import ReactMarkdown from "react-markdown";
55
import remarkGfm from "remark-gfm";
66
import { Grid } from "@mui/system";
7+
import standardsData from "/src/data/standards.json";
78

89
const getStatusColor = (status) => {
910
switch (status?.toLowerCase()) {
@@ -46,6 +47,23 @@ const getImpactColor = (impact) => {
4647
}
4748
};
4849

50+
const checkCIPPStandardAvailable = (testName) => {
51+
if (!testName) return "No";
52+
console.log(testName);
53+
// Check if any standard's tag array contains a reference to this test
54+
const hasStandard = standardsData.some((standard) => {
55+
if (!standard.tag || !Array.isArray(standard.tag)) return false;
56+
// Check if any tag matches the test name or contains it
57+
return standard.tag.some((tag) => {
58+
const tagLower = tag.toLowerCase();
59+
const testLower = testName.toLowerCase();
60+
return tagLower.includes(testLower) || testLower.includes(tagLower);
61+
});
62+
});
63+
64+
return hasStandard ? "Yes" : "No";
65+
};
66+
4967
// Shared markdown styling for consistent rendering
5068
const markdownStyles = {
5169
"& a": {
@@ -109,7 +127,7 @@ export const CippTestDetailOffCanvas = ({ row }) => {
109127
<Card>
110128
<Grid container>
111129
<Grid
112-
size={{ xs: 12, md: 4 }}
130+
size={{ xs: 12, md: 3 }}
113131
sx={{
114132
borderBottom: (theme) => ({
115133
xs: `1px solid ${theme.palette.divider}`,
@@ -123,7 +141,7 @@ export const CippTestDetailOffCanvas = ({ row }) => {
123141
<Stack alignItems="center" direction="row" spacing={1} sx={{ p: 1 }}>
124142
<Box>
125143
<Typography color="text.secondary" variant="overline">
126-
Risk Level
144+
Risk
127145
</Typography>
128146
<Box>
129147
<Chip label={row.Risk || "N/A"} color={getRiskColor(row.Risk)} size="small" />
@@ -132,7 +150,7 @@ export const CippTestDetailOffCanvas = ({ row }) => {
132150
</Stack>
133151
</Grid>
134152
<Grid
135-
size={{ xs: 12, md: 4 }}
153+
size={{ xs: 12, md: 3 }}
136154
sx={{
137155
borderBottom: (theme) => ({
138156
xs: `1px solid ${theme.palette.divider}`,
@@ -159,15 +177,21 @@ export const CippTestDetailOffCanvas = ({ row }) => {
159177
</Stack>
160178
</Grid>
161179
<Grid
162-
size={{ xs: 12, md: 4 }}
180+
size={{ xs: 12, md: 3 }}
163181
sx={{
164-
borderBottom: "none",
182+
borderBottom: (theme) => ({
183+
xs: `1px solid ${theme.palette.divider}`,
184+
md: "none",
185+
}),
186+
borderRight: (theme) => ({
187+
md: `1px solid ${theme.palette.divider}`,
188+
}),
165189
}}
166190
>
167191
<Stack alignItems="center" direction="row" spacing={1} sx={{ p: 1 }}>
168192
<Box>
169193
<Typography color="text.secondary" variant="overline">
170-
Implementation Effort
194+
Effort
171195
</Typography>
172196
<Box sx={{ mt: 0.5 }}>
173197
<Chip
@@ -179,6 +203,27 @@ export const CippTestDetailOffCanvas = ({ row }) => {
179203
</Box>
180204
</Stack>
181205
</Grid>
206+
<Grid
207+
size={{ xs: 12, md: 3 }}
208+
sx={{
209+
borderBottom: "none",
210+
}}
211+
>
212+
<Stack alignItems="center" direction="row" spacing={1} sx={{ p: 1 }}>
213+
<Box>
214+
<Typography color="text.secondary" variant="overline">
215+
Standard Available
216+
</Typography>
217+
<Box sx={{ mt: 0.5 }}>
218+
<Chip
219+
label={checkCIPPStandardAvailable(row.RowKey)}
220+
color={checkCIPPStandardAvailable(row.RowKey) === "Yes" ? "success" : "default"}
221+
size="small"
222+
/>
223+
</Box>
224+
</Box>
225+
</Stack>
226+
</Grid>
182227
</Grid>
183228
</Card>
184229

src/data/standards.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,8 @@
10291029
"EIDSCA.AP08",
10301030
"EIDSCA.AP09",
10311031
"Essential 8 (1175)",
1032-
"NIST CSF 2.0 (PR.AA-05)"
1032+
"NIST CSF 2.0 (PR.AA-05)",
1033+
"ZTNA21807"
10331034
],
10341035
"helpText": "Disables users from being able to consent to applications, except for those specified in the field below",
10351036
"docsDescription": "Requires users to get administrator consent before sharing data with applications. You can preapprove specific applications.",

0 commit comments

Comments
 (0)