Skip to content

Commit a274c31

Browse files
committed
feat: replace severity chips
1 parent 81bd2b8 commit a274c31

File tree

3 files changed

+34
-75
lines changed

3 files changed

+34
-75
lines changed

src/components/ResourceBrowser/ResourceList/ClusterSelector.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import ReactSelect, { Props as SelectProps, SelectInstance } from 'react-select'
2121
import {
2222
APP_SELECTOR_STYLES,
2323
AppSelectorDropdownIndicator,
24+
Badge,
25+
ComponentSizeType,
2426
DocLink,
2527
DocLinkProps,
2628
Icon,
@@ -114,7 +116,7 @@ const ClusterSelector: React.FC<ClusterSelectorType> = ({
114116
}}
115117
/>
116118

117-
{defaultOption?.isProd && <span className="px-6 py-2 br-4 bcb-1 cb-7 fs-12 lh-16 fw-5">Production</span>}
119+
{defaultOption?.isProd && <Badge label="Production" size={ComponentSizeType.xxs} />}
118120

119121
<PopupMenu autoClose>
120122
<PopupMenu.Button rootClassName="flex ml-auto p-4 border__secondary" isKebab>

src/components/common/helpers/Helpers.tsx

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
useMainContext,
3131
SelectPickerOptionType,
3232
InfoBlock,
33+
Badge,
34+
SeveritiesDTO,
3335
} from '@devtron-labs/devtron-fe-common-lib'
3436
import YAML from 'yaml'
3537
import { Link } from 'react-router-dom'
@@ -1099,32 +1101,36 @@ export const getPluginIdsFromBuildStage = (
10991101
}
11001102

11011103
export const getSeverityWithCount = (severityCount: SeverityCount) => {
1102-
if (severityCount.critical) {
1103-
return (
1104-
<span className="severity-chip severity-chip--critical dc__w-fit-content">
1105-
{severityCount.critical} Critical
1106-
</span>
1107-
)
1108-
}
1109-
if (severityCount.high) {
1110-
return <span className="severity-chip severity-chip--high dc__w-fit-content">{severityCount.high} High</span>
1111-
}
1112-
if (severityCount.medium) {
1113-
return (
1114-
<span className="severity-chip severity-chip--medium dc__w-fit-content">{severityCount.medium} Medium</span>
1115-
)
1116-
}
1117-
if (severityCount.low) {
1118-
return <span className="severity-chip severity-chip--low dc__w-fit-content">{severityCount.low} Low</span>
1119-
}
1120-
if (severityCount.unknown) {
1121-
return (
1122-
<span className="severity-chip severity-chip--unknown dc__w-fit-content">
1123-
{severityCount.unknown} Unknown
1124-
</span>
1125-
)
1104+
const order = [
1105+
{ key: SeveritiesDTO.CRITICAL, label: 'Critical', variant: 'negative' },
1106+
{ key: SeveritiesDTO.HIGH, label: 'High', variant: 'custom', fontColor: 'R500', bgColor: 'R100' },
1107+
{ key: SeveritiesDTO.MEDIUM, label: 'Medium', variant: 'custom', fontColor: 'O600', bgColor: 'O100' },
1108+
{ key: SeveritiesDTO.LOW, label: 'Low', variant: 'warning' },
1109+
{ key: SeveritiesDTO.UNKNOWN, label: 'Unknown', variant: 'neutral' },
1110+
] as const
1111+
1112+
for (const item of order) {
1113+
if (severityCount[item.key]) {
1114+
if (item.variant === 'custom') {
1115+
return (
1116+
<Badge
1117+
label={`${severityCount[item.key]} ${item.label}`}
1118+
variant="custom"
1119+
fontColor={item.fontColor}
1120+
bgColor={item.bgColor}
1121+
/>
1122+
);
1123+
} else {
1124+
return (
1125+
<Badge
1126+
label={`${severityCount[item.key]} ${item.label}`}
1127+
variant={item.variant}
1128+
/>
1129+
);
1130+
}
1131+
}
11261132
}
1127-
return <span className="severity-chip severity-chip--passed dc__w-fit-content">Passed</span>
1133+
return <Badge label='Passed' variant='positive' />
11281134
}
11291135

11301136
// FIXME: Ideally whole branch calculations should be in fe-lib

src/css/base.scss

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4826,55 +4826,6 @@ textarea::placeholder {
48264826
background-color: var(--Y200);
48274827
}
48284828

4829-
.severity-chip {
4830-
display: flex;
4831-
padding: 0px 6px;
4832-
align-items: center;
4833-
gap: 4px;
4834-
border-radius: 4px;
4835-
font-size: 12px;
4836-
font-style: normal;
4837-
font-weight: 600;
4838-
line-height: 20px;
4839-
text-transform: capitalize;
4840-
4841-
&--passed {
4842-
color: var(--G500);
4843-
border: 1px solid var(--G200);
4844-
background: var(--G100);
4845-
}
4846-
4847-
&--critical {
4848-
color: var(--R700);
4849-
border: 1px solid var(--R700);
4850-
background: var(--R100);
4851-
}
4852-
4853-
&--high {
4854-
color: var(--R500);
4855-
border: 1px solid var(--R200);
4856-
background: var(--R100);
4857-
}
4858-
4859-
&--medium {
4860-
color: var(--O600);
4861-
border: 1px solid var(--O200);
4862-
background: var(--O100);
4863-
}
4864-
4865-
&--low {
4866-
color: var(--Y700);
4867-
border: 1px solid var(--Y200);
4868-
background: var(--Y100);
4869-
}
4870-
4871-
&--unknown {
4872-
color: var(--N700);
4873-
border: 1px solid var(--N200);
4874-
background: var(--N100);
4875-
}
4876-
}
4877-
48784829
.dc__grid-full {
48794830
display: grid;
48804831
grid-template-columns: 100% 0;

0 commit comments

Comments
 (0)