Skip to content

Commit 1b43fec

Browse files
authored
fix: adjust badges after overriding functionality (#3627)
* fix: adjust badges * adjust test
1 parent b403c39 commit 1b43fec

File tree

6 files changed

+30
-39
lines changed

6 files changed

+30
-39
lines changed

src/components/Extensibility/components/tests/Badge.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Badge Component', () => {
3636
const value = -2;
3737
const structure = {
3838
highlights: {
39-
negative: 'data < 0',
39+
critical: 'data < 0',
4040
},
4141
};
4242

src/components/Extensibility/helpers/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ export const getTextSearchProperties = ({
269269
};
270270

271271
const TYPE_FALLBACK = new Map([
272-
['success', 'Success'],
273-
['warning', 'Warning'],
274-
['error', 'Error'],
272+
['success', 'Positive'],
273+
['warning', 'Critical'],
274+
['error', 'Negative'],
275275
['info', 'Information'],
276276
]);
277277

@@ -301,11 +301,10 @@ export const getBadgeType = (highlights, value, jsonata, t) => {
301301
type = match[0];
302302
}
303303
}
304-
305-
if (type === 'negative') type = 'Warning';
304+
if (type === 'negative') type = 'Critical';
306305
else if (type === 'informative') type = 'Information';
307-
else if (type === 'positive') type = 'Success';
308-
else if (type === 'critical') type = 'Error';
306+
else if (type === 'positive') type = 'Positive';
307+
else if (type === 'critical') type = 'Negative';
309308
else if (type === 'none') type = 'None';
310309

311310
type = TYPE_FALLBACK.get(type) || type;

src/components/KymaModules/KymaModulesList.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import pluralize from 'pluralize';
4141
import { Spinner } from 'shared/components/Spinner/Spinner';
4242
import { Label } from 'shared/ResourceForm/components/Label';
4343
import { isFormOpenState } from 'state/formOpenAtom';
44-
import { ModuleStatus } from './components/ModuleStatus';
44+
import { ModuleStatus, resolveType } from './components/ModuleStatus';
4545
import { cloneDeep } from 'lodash';
4646
import { StatusBadge } from 'shared/components/StatusBadge/StatusBadge';
4747
import { useNavigate } from 'react-router-dom';
@@ -269,16 +269,7 @@ export default function KymaModulesList({
269269
// Installation State
270270
<StatusBadge
271271
resourceKind="kymas"
272-
type={
273-
moduleStatus?.state === 'Ready'
274-
? 'Positive'
275-
: moduleStatus?.state === 'Processing' ||
276-
moduleStatus?.state === 'Deleting' ||
277-
moduleStatus?.state === 'Unmanaged' ||
278-
moduleStatus?.state === 'Unknown'
279-
? 'None'
280-
: moduleStatus?.state || 'None'
281-
}
272+
type={resolveType(moduleStatus?.state)}
282273
tooltipContent={moduleStatus?.message}
283274
>
284275
{moduleStatus?.state || 'Unknown'}

src/components/KymaModules/components/ModuleStatus.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
import { StatusBadge } from 'shared/components/StatusBadge/StatusBadge';
22
import { useModuleStatus } from '../support';
33

4+
export const resolveType = (status: string) => {
5+
switch (status) {
6+
case 'Ready':
7+
return 'Positive';
8+
case 'Processing':
9+
case 'Deleting':
10+
case 'Unknown':
11+
case 'Unmanaged':
12+
return 'None';
13+
case 'Warning':
14+
return 'Critical';
15+
case 'Error':
16+
return 'Negative';
17+
default:
18+
return 'None';
19+
}
20+
};
21+
422
export const ModuleStatus = ({ resource }: any) => {
523
const { data: status } = useModuleStatus(resource);
624

725
const moduleState = status?.state || 'Unknown';
826
const moduleMessage = status?.description;
927

10-
const resolveType = (status: string) => {
11-
switch (status) {
12-
case 'Ready':
13-
return 'Positive';
14-
case 'Processing':
15-
case 'Deleting':
16-
case 'Unknown':
17-
return 'None';
18-
case 'Warning':
19-
return 'Critical';
20-
case 'Error':
21-
return 'Negative';
22-
default:
23-
return 'None';
24-
}
25-
};
26-
2728
return (
2829
<StatusBadge
2930
resourceKind="kymas"

src/resources/Deployments/DeploymentDetails.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function DeploymentDetails(props) {
6565
return deployment?.status?.conditions?.map(condition => {
6666
const overridenStatus = () => {
6767
if (condition.type === 'ReplicaFailure')
68-
return condition.status === 'True' ? 'Error' : 'Success';
68+
return condition.status === 'True' ? 'Negative' : 'Positive';
6969
return undefined;
7070
};
7171
return {

src/shared/components/ExpandableListItem/ExpandableListItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export const ExpandableListItem = ({
3232
let statusType;
3333
switch (status) {
3434
case 'True':
35-
statusType = 'Success';
35+
statusType = 'Positive';
3636
break;
3737
case 'False':
38-
statusType = 'Error';
38+
statusType = 'Negative';
3939
break;
4040
case 'Unknown':
4141
statusType = 'Information';

0 commit comments

Comments
 (0)