Skip to content

Commit b4f70af

Browse files
committed
chore: extract type for categories
1 parent 813b2ae commit b4f70af

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
* Copyright (c) 2024. Devtron Inc.
33
*/
44

5+
import { ScanCategoriesWithLicense } from '../../types'
56
import { CATEGORY_LABELS, SUB_CATEGORY_LABELS } from '../constants'
67
import { CATEGORIES, SUB_CATEGORIES, SidebarDataType } from '../types'
78

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

1312
return [

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
StatusType,
1515
SecurityModalStateType,
1616
} from './types'
17+
import { ScanCategoriesWithLicense } from '../types'
1718

1819
export const DEFAULT_SECURITY_MODAL_IMAGE_STATE = {
1920
category: CATEGORIES.IMAGE_SCAN,
@@ -34,7 +35,7 @@ const DEFAULT_SECURITY_MODAL_MANIFEST_STATE = {
3435
}
3536

3637
export const getDefaultSecurityModalState = (
37-
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES] | 'imageScanLicenseRisks', boolean>,
38+
categoriesConfig: Record<ScanCategoriesWithLicense, boolean>,
3839
): SecurityModalStateType => {
3940
if (categoriesConfig.imageScan) {
4041
return DEFAULT_SECURITY_MODAL_IMAGE_STATE

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { GenericEmptyStateType } from '@Common/Types'
77
import { LastExecutionResultType, NodeType, Nodes } from '@Shared/types'
88
import { SegmentedBarChartProps } from '@Common/SegmentedBarChart'
99
import { ServerErrors } from '@Common/ServerError'
10+
import { ScanCategories, ScanSubCategories } from '../types'
1011

1112
export interface GetResourceScanDetailsPayloadType {
1213
name: string
@@ -100,8 +101,8 @@ export type DetailViewDataType = {
100101
InfoCardPropsType
101102

102103
export type SecurityModalStateType = {
103-
category: (typeof CATEGORIES)[keyof typeof CATEGORIES]
104-
subCategory: (typeof SUB_CATEGORIES)[keyof typeof SUB_CATEGORIES]
104+
category: ScanCategories
105+
subCategory: ScanSubCategories
105106
detailViewData: DetailViewDataType[]
106107
}
107108

@@ -264,8 +265,8 @@ export interface IndexedTextDisplayPropsType {
264265
export type SidebarDataChildType = {
265266
label: string
266267
value: {
267-
category: (typeof CATEGORIES)[keyof typeof CATEGORIES]
268-
subCategory: (typeof SUB_CATEGORIES)[keyof typeof SUB_CATEGORIES]
268+
category: ScanCategories
269+
subCategory: ScanSubCategories
269270
}
270271
}
271272

src/Shared/Components/Security/types.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { CATEGORIES, SUB_CATEGORIES } from './SecurityModal/types'
33
export type ScanCategories = (typeof CATEGORIES)[keyof typeof CATEGORIES]
44
export type ScanSubCategories = (typeof SUB_CATEGORIES)[keyof typeof SUB_CATEGORIES]
55

6+
export type ScanCategoriesWithLicense = ScanCategories | 'imageScanLicenseRisks'
7+
68
export type CategoriesConfig = {
79
imageScan: boolean
810
codeScan: boolean

0 commit comments

Comments
 (0)