Skip to content

Commit 7757538

Browse files
authored
Merge pull request #2772 from devtron-labs/feat/badge
feat: replace severity chips
2 parents e4f9312 + 4de0cbd commit 7757538

File tree

5 files changed

+33
-80
lines changed

5 files changed

+33
-80
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.15.3-pre-1",
7+
"@devtron-labs/devtron-fe-common-lib": "1.15.3-pre-3",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

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
{defaultOption?.value !== String(DEFAULT_CLUSTER_ID) && (
120122
<PopupMenu autoClose>

src/components/common/helpers/Helpers.tsx

Lines changed: 25 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'
@@ -1098,33 +1100,31 @@ export const getPluginIdsFromBuildStage = (
10981100
return pluginIds
10991101
}
11001102

1103+
const SEVERITY_ORDER = [
1104+
{ key: SeveritiesDTO.CRITICAL, label: 'Critical', variant: 'negative' },
1105+
{ key: SeveritiesDTO.HIGH, label: 'High', variant: 'custom', fontColor: 'R500', bgColor: 'R100' },
1106+
{ key: SeveritiesDTO.MEDIUM, label: 'Medium', variant: 'custom', fontColor: 'O600', bgColor: 'O100' },
1107+
{ key: SeveritiesDTO.LOW, label: 'Low', variant: 'warning' },
1108+
{ key: SeveritiesDTO.UNKNOWN, label: 'Unknown', variant: 'neutral' },
1109+
] as const
1110+
11011111
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-
)
1112+
for (const item of SEVERITY_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+
}
1124+
return <Badge label={`${severityCount[item.key]} ${item.label}`} variant={item.variant} />
1125+
}
11261126
}
1127-
return <span className="severity-chip severity-chip--passed dc__w-fit-content">Passed</span>
1127+
return <Badge label="Passed" variant="positive" />
11281128
}
11291129

11301130
// 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;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,10 +1259,10 @@
12591259
dependencies:
12601260
"@jridgewell/trace-mapping" "0.3.9"
12611261

1262-
"@devtron-labs/[email protected]1":
1263-
version "1.15.3-pre-1"
1264-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.15.3-pre-1.tgz#859eb74ae32f495e95ba1bd8f3e9e9c2cb0cb618"
1265-
integrity sha512-W67KUyn9iSO2PW2q682jcLMTb6n2+lKBPmNOJK/Jjst/H4I2P6CtJFY9b6cjFA+bhnSYscysASnAEBUm3qYaMQ==
1262+
"@devtron-labs/[email protected]3":
1263+
version "1.15.3-pre-3"
1264+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.15.3-pre-3.tgz#f80a24b6af7b11c33a3217617dfc428d8cf3576b"
1265+
integrity sha512-4hRZEOSaHqkiga8ObZVPgXuqrlvluBoCwnCqZmYRTxwMOaT0PTtEciVE0TPmUhuqNIOLv1iKk6w8SDWX4m70eg==
12661266
dependencies:
12671267
"@codemirror/lang-json" "6.0.1"
12681268
"@codemirror/lang-yaml" "6.1.2"

0 commit comments

Comments
 (0)