Skip to content

Commit 813b2ae

Browse files
committed
feat: add support for threat count in security modal sidebar
1 parent 1e5300b commit 813b2ae

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/Shared/Components/Security/SecurityModal/SecurityModal.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ComponentSizeType } from '@Shared/constants'
1919
import { Table, InfoCard } from './components'
2020
import { getDefaultSecurityModalState } from './constants'
2121
import { getTableData, getInfoCardData } from './config'
22-
import { SecurityModalPropsType, SecurityModalStateType, DetailViewDataType, SidebarPropsType } from './types'
22+
import { SecurityModalPropsType, SecurityModalStateType, DetailViewDataType } from './types'
2323
import { getEmptyStateValues } from './config/EmptyState'
2424
import './styles.scss'
2525

@@ -44,15 +44,14 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
4444
}) => {
4545
const data = responseData ?? null
4646

47-
const categoriesConfig: SidebarPropsType['categoriesConfig'] = {
48-
imageScan: !!data?.imageScan,
49-
imageScanLicenseRisks: !!data?.imageScan?.license,
50-
codeScan: !!data?.codeScan,
51-
kubernetesManifest: !!data?.kubernetesManifest,
52-
}
53-
5447
const [state, setState] = useState<SecurityModalStateType>(
55-
defaultState ?? getDefaultSecurityModalState(categoriesConfig),
48+
defaultState ??
49+
getDefaultSecurityModalState({
50+
imageScan: !!data?.imageScan,
51+
imageScanLicenseRisks: !!data?.imageScan?.license,
52+
codeScan: !!data?.codeScan,
53+
kubernetesManifest: !!data?.kubernetesManifest,
54+
}),
5655
)
5756

5857
const setDetailViewData = (detailViewData: DetailViewDataType) => {
@@ -162,7 +161,7 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
162161
/* NOTE: the height is restricted to (viewport - header) height since we need overflow-scroll */
163162
<div className="flexbox" style={{ height: 'calc(100vh - 49px)' }}>
164163
{/* NOTE: only show sidebar in AppDetails */}
165-
{Sidebar && <Sidebar modalState={state} setModalState={setState} categoriesConfig={categoriesConfig} />}
164+
{Sidebar && <Sidebar modalState={state} setModalState={setState} scanResult={responseData} />}
166165
<div className="dc__border-right-n1 h-100" />
167166
<div className="dc__overflow-scroll flex-grow-1" style={{ width: '744px' }}>
168167
{selectedDetailViewData && renderDetailViewSubHeader()}

src/Shared/Components/Security/SecurityModal/config/Sidebar.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
*/
44

55
import { CATEGORY_LABELS, SUB_CATEGORY_LABELS } from '../constants'
6-
import { CATEGORIES, SUB_CATEGORIES, SidebarDataType, SidebarPropsType } from '../types'
6+
import { CATEGORIES, SUB_CATEGORIES, SidebarDataType } from '../types'
77

8-
export const getSidebarData = (categoriesConfig: SidebarPropsType['categoriesConfig']): SidebarDataType[] => {
8+
export const getSidebarData = (
9+
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES] | 'imageScanLicenseRisks', boolean>,
10+
): SidebarDataType[] => {
911
const { imageScan, codeScan, kubernetesManifest, imageScanLicenseRisks } = categoriesConfig
1012

1113
return [

src/Shared/Components/Security/SecurityModal/constants.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
SortOrderEnum,
1313
EmptyStateType,
1414
StatusType,
15-
SidebarPropsType,
1615
SecurityModalStateType,
1716
} from './types'
1817

@@ -35,7 +34,7 @@ const DEFAULT_SECURITY_MODAL_MANIFEST_STATE = {
3534
}
3635

3736
export const getDefaultSecurityModalState = (
38-
categoriesConfig: SidebarPropsType['categoriesConfig'],
37+
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES] | 'imageScanLicenseRisks', boolean>,
3938
): SecurityModalStateType => {
4039
if (categoriesConfig.imageScan) {
4140
return DEFAULT_SECURITY_MODAL_IMAGE_STATE

src/Shared/Components/Security/SecurityModal/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ export type SecurityModalStateType = {
105105
detailViewData: DetailViewDataType[]
106106
}
107107

108-
export interface SidebarPropsType {
109-
modalState: SecurityModalStateType
110-
setModalState: React.Dispatch<React.SetStateAction<SecurityModalStateType>>
111-
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES] | 'imageScanLicenseRisks', boolean>
112-
}
113-
114108
export enum SeveritiesDTO {
115109
CRITICAL = 'critical',
116110
HIGH = 'high',
@@ -243,6 +237,12 @@ export type ScanResultDTO = {
243237
[CATEGORIES.KUBERNETES_MANIFEST]: KubernetesManifest
244238
}
245239

240+
export interface SidebarPropsType {
241+
modalState: SecurityModalStateType
242+
setModalState: React.Dispatch<React.SetStateAction<SecurityModalStateType>>
243+
scanResult: ScanResultDTO
244+
}
245+
246246
interface SecurityModalBaseProps {
247247
isLoading: boolean
248248
error: ServerErrors

0 commit comments

Comments
 (0)