From 77805eb4ecc289b25486d97d04a6c870cf27ec9d Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Tue, 16 Apr 2024 13:24:30 -0400 Subject: [PATCH 1/6] Filtered Resources by response, added helper directory for helper functions --- .../components/ReadySetCyber/RSCQuestion.tsx | 92 ++++++++++--------- .../ReadySetCyber/helpers/filterResources.ts | 4 + .../components/ReadySetCyber/helpers/index.ts | 1 + 3 files changed, 56 insertions(+), 41 deletions(-) create mode 100644 frontend/src/components/ReadySetCyber/helpers/filterResources.ts create mode 100644 frontend/src/components/ReadySetCyber/helpers/index.ts diff --git a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx index e7143bd0..d6a8b869 100644 --- a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx +++ b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx @@ -3,6 +3,8 @@ import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import Button from '@mui/material/Button'; +import { VideoLibrary, Article, LibraryBooks } from '@mui/icons-material'; +import { isResourceVisible } from './helpers/index'; interface Props { categories: Category[]; @@ -33,6 +35,11 @@ interface Resource { url: string; } +// const isResourceVisible = (response: string) => { +// const r = response.toLowerCase(); +// return r === "no" || r === "not in scope" || r === "not started" ? true : false; +// } + export const RSCQuestion: React.FC = ({ categories }) => { return (
@@ -71,48 +78,51 @@ export const RSCQuestion: React.FC = ({ categories }) => { Response: {entry.selection} - {entry.question.resources.length > 0 && ( - - - Recommended Resources - - {entry.question.resources.map((resource, resIndex) => ( - - - {resource.type} - - - {resource.name} - - - {resource.description} - - - - ))} - - )} + + + {resource.type.charAt(0).toUpperCase() + + resource.type.slice(1)} + + + {resource.name} + + + {resource.description} + + + + ))} + + )} ))} diff --git a/frontend/src/components/ReadySetCyber/helpers/filterResources.ts b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts new file mode 100644 index 00000000..d8abb811 --- /dev/null +++ b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts @@ -0,0 +1,4 @@ +export const isResourceVisible = (response: string) => { + const r = response.toLowerCase(); + return r === 'no' || r === 'not in scope' || r === 'not started'; +}; diff --git a/frontend/src/components/ReadySetCyber/helpers/index.ts b/frontend/src/components/ReadySetCyber/helpers/index.ts new file mode 100644 index 00000000..0586bd18 --- /dev/null +++ b/frontend/src/components/ReadySetCyber/helpers/index.ts @@ -0,0 +1 @@ +export * from './filterResources'; From 705a3ddf4aaf7964eb47c1f155bea92354b33c9d Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Wed, 17 Apr 2024 11:40:48 -0400 Subject: [PATCH 2/6] Fixed question number diplay, Added Resource icon filter, Added components directory --- .../components/ReadySetCyber/RSCQuestion.tsx | 15 +++++------ .../ReadySetCyber/components/IconType.tsx | 14 ++++++++++ .../ReadySetCyber/helpers/filterResources.ts | 27 +++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 frontend/src/components/ReadySetCyber/components/IconType.tsx diff --git a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx index d6a8b869..fa7236c9 100644 --- a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx +++ b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx @@ -3,8 +3,8 @@ import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import Stack from '@mui/material/Stack'; import Button from '@mui/material/Button'; -import { VideoLibrary, Article, LibraryBooks } from '@mui/icons-material'; -import { isResourceVisible } from './helpers/index'; +import { isResourceVisible, getIconType } from './helpers/index'; +import IconFilter from './components/IconType'; interface Props { categories: Category[]; @@ -35,10 +35,9 @@ interface Resource { url: string; } -// const isResourceVisible = (response: string) => { -// const r = response.toLowerCase(); -// return r === "no" || r === "not in scope" || r === "not started" ? true : false; -// } +const questionNumber = (n: string) => { + return n.charAt(n.length - 2) === '0' ? n.slice(-1) : n.slice(-2); +}; export const RSCQuestion: React.FC = ({ categories }) => { return ( @@ -65,7 +64,7 @@ export const RSCQuestion: React.FC = ({ categories }) => { }} > - Question {entry.question.number} + Question {questionNumber(entry.question.number)} {entry.question.longForm} @@ -101,7 +100,7 @@ export const RSCQuestion: React.FC = ({ categories }) => { }} > - + {resource.type.charAt(0).toUpperCase() + resource.type.slice(1)} diff --git a/frontend/src/components/ReadySetCyber/components/IconType.tsx b/frontend/src/components/ReadySetCyber/components/IconType.tsx new file mode 100644 index 00000000..f0f19937 --- /dev/null +++ b/frontend/src/components/ReadySetCyber/components/IconType.tsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { getIconType } from '../helpers'; + +// Filter the resource type and return the corresponding icon +const IconFilter = ({ type }: { type: string }) => { + const IconType = getIconType(type); + return ( + <> + + + ); +}; + +export default IconFilter; diff --git a/frontend/src/components/ReadySetCyber/helpers/filterResources.ts b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts index d8abb811..81db4900 100644 --- a/frontend/src/components/ReadySetCyber/helpers/filterResources.ts +++ b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts @@ -1,4 +1,31 @@ +import React from 'react'; +import { + VideoLibrary, + Article, + LibraryBooks, + Handyman, + NotificationsActive +} from '@mui/icons-material'; + +interface ResourceTypes { + [key: string]: React.ElementType; +} + +const resourcetypes: ResourceTypes = { + video: VideoLibrary, + article: Article, + tool: Handyman, + alerts: NotificationsActive +}; + +// Filter resoucre visibility by response export const isResourceVisible = (response: string) => { const r = response.toLowerCase(); return r === 'no' || r === 'not in scope' || r === 'not started'; }; + +// Filter the resource type and return the corresponding icon +export const getIconType = (type: string) => { + const ResourceIcon = resourcetypes[type]; + return ResourceIcon ? ResourceIcon : LibraryBooks; +}; From a27cb70134198b79f4aaf521c5f3d9f4907f27d3 Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Wed, 17 Apr 2024 11:44:47 -0400 Subject: [PATCH 3/6] Fixed import statement to pull from /helpers/index.ts --- frontend/src/components/ReadySetCyber/components/IconType.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/ReadySetCyber/components/IconType.tsx b/frontend/src/components/ReadySetCyber/components/IconType.tsx index f0f19937..f47e170d 100644 --- a/frontend/src/components/ReadySetCyber/components/IconType.tsx +++ b/frontend/src/components/ReadySetCyber/components/IconType.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { getIconType } from '../helpers'; +import { getIconType } from '../helpers/index'; // Filter the resource type and return the corresponding icon const IconFilter = ({ type }: { type: string }) => { From 8ae8772bcfdd3a42d35d0e702013e70d7cb04a9c Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Thu, 18 Apr 2024 15:34:24 -0400 Subject: [PATCH 4/6] Fixed resource type alignment with icon type --- .../components/ReadySetCyber/RSCQuestion.tsx | 26 +++++++++++-------- .../ReadySetCyber/components/IconType.tsx | 4 +-- .../ReadySetCyber/components/index.ts | 1 + 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 frontend/src/components/ReadySetCyber/components/index.ts diff --git a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx index fa7236c9..758721a6 100644 --- a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx +++ b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx @@ -1,10 +1,7 @@ import React from 'react'; -import Box from '@mui/material/Box'; -import Typography from '@mui/material/Typography'; -import Stack from '@mui/material/Stack'; -import Button from '@mui/material/Button'; -import { isResourceVisible, getIconType } from './helpers/index'; -import IconFilter from './components/IconType'; +import { Box, Button, Grid, Typography } from '@mui/material'; +import { isResourceVisible } from './helpers/index'; +import { IconFilter } from './components/index'; interface Props { categories: Category[]; @@ -99,11 +96,18 @@ export const RSCQuestion: React.FC = ({ categories }) => { marginBottom: 1 }} > - - - {resource.type.charAt(0).toUpperCase() + - resource.type.slice(1)} - + + + + + + + + {resource.type.charAt(0).toUpperCase() + + resource.type.slice(1)} + + + {resource.name} diff --git a/frontend/src/components/ReadySetCyber/components/IconType.tsx b/frontend/src/components/ReadySetCyber/components/IconType.tsx index f47e170d..230ecc47 100644 --- a/frontend/src/components/ReadySetCyber/components/IconType.tsx +++ b/frontend/src/components/ReadySetCyber/components/IconType.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { getIconType } from '../helpers/index'; // Filter the resource type and return the corresponding icon -const IconFilter = ({ type }: { type: string }) => { +export const IconFilter = ({ type }: { type: string }) => { const IconType = getIconType(type); return ( <> @@ -10,5 +10,3 @@ const IconFilter = ({ type }: { type: string }) => { ); }; - -export default IconFilter; diff --git a/frontend/src/components/ReadySetCyber/components/index.ts b/frontend/src/components/ReadySetCyber/components/index.ts new file mode 100644 index 00000000..a84e94f7 --- /dev/null +++ b/frontend/src/components/ReadySetCyber/components/index.ts @@ -0,0 +1 @@ +export { default } from './IconType'; From 667deb8fec339daaa0223039eda286c68a052ec3 Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Mon, 22 Apr 2024 09:38:55 -0400 Subject: [PATCH 5/6] Edit Displayed User Response; Correct helpers/index Exports --- .../components/ReadySetCyber/RSCQuestion.tsx | 36 +++++++++++++++---- .../ReadySetCyber/components/index.ts | 2 +- .../ReadySetCyber/helpers/filterResources.ts | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx index 758721a6..21e0f039 100644 --- a/frontend/src/components/ReadySetCyber/RSCQuestion.tsx +++ b/frontend/src/components/ReadySetCyber/RSCQuestion.tsx @@ -1,5 +1,12 @@ import React from 'react'; -import { Box, Button, Grid, Typography } from '@mui/material'; +import { + Box, + Button, + Grid, + Typography, + FormControlLabel, + Radio +} from '@mui/material'; import { isResourceVisible } from './helpers/index'; import { IconFilter } from './components/index'; @@ -31,7 +38,7 @@ interface Resource { type: string; url: string; } - +// Concatenates the last one or two characters of a string const questionNumber = (n: string) => { return n.charAt(n.length - 2) === '0' ? n.slice(-1) : n.slice(-2); }; @@ -72,7 +79,24 @@ export const RSCQuestion: React.FC = ({ categories }) => { )} - Response: {entry.selection} + Response: + + + + + + {entry.selection} + + {entry.question.resources.length > 0 && isResourceVisible(entry.selection) && ( @@ -96,12 +120,12 @@ export const RSCQuestion: React.FC = ({ categories }) => { marginBottom: 1 }} > - - + + - + {resource.type.charAt(0).toUpperCase() + resource.type.slice(1)} diff --git a/frontend/src/components/ReadySetCyber/components/index.ts b/frontend/src/components/ReadySetCyber/components/index.ts index a84e94f7..0e342ed0 100644 --- a/frontend/src/components/ReadySetCyber/components/index.ts +++ b/frontend/src/components/ReadySetCyber/components/index.ts @@ -1 +1 @@ -export { default } from './IconType'; +export * from './IconType'; diff --git a/frontend/src/components/ReadySetCyber/helpers/filterResources.ts b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts index 81db4900..3049d429 100644 --- a/frontend/src/components/ReadySetCyber/helpers/filterResources.ts +++ b/frontend/src/components/ReadySetCyber/helpers/filterResources.ts @@ -18,7 +18,7 @@ const resourcetypes: ResourceTypes = { alerts: NotificationsActive }; -// Filter resoucre visibility by response +// Filter resource visibility by response export const isResourceVisible = (response: string) => { const r = response.toLowerCase(); return r === 'no' || r === 'not in scope' || r === 'not started'; From 22c529a16b98bd12a666fd074e1309f1293ba093 Mon Sep 17 00:00:00 2001 From: Chrtorres Date: Mon, 22 Apr 2024 10:03:03 -0400 Subject: [PATCH 6/6] Revert Dockerfile; Remove Unused Imports --- backend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index b1be91bb..a45d7240 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,7 +1,7 @@ FROM node:18-alpine3.17 USER root -RUN apk update && apk upgrade && apk add --no-cache g++ make py3-pip +RUN apk update && apk upgrade WORKDIR /app COPY ./package* ./