Skip to content

Commit e862322

Browse files
feat(ui): adding Kubernetes logo (#5285)
* feat(ui): adding Kubernetes logo Signed-off-by: Kamalesh-Seervi <[email protected]> * Refactor FaultCard to include GCP in chartName check Signed-off-by: Kamalesh-Seervi <[email protected]> --------- Signed-off-by: Kamalesh-Seervi <[email protected]> Co-authored-by: Pritesh Kiri <[email protected]>
1 parent b96912b commit e862322

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

chaoscenter/web/src/views/ChaosHub/ChaosFaults/ChaosFaults.tsx

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import { Icon } from '@harnessio/icons';
44
import { FontVariation, Color } from '@harnessio/design-system';
55
import { Link, useParams } from 'react-router-dom';
66
import { withErrorBoundary } from 'react-error-boundary';
7-
import { toTitleCase } from '@utils';
7+
import { toTitleCase, getScope } from '@utils';
88
import { useStrings } from '@strings';
99
import NoExperiments from '@images/NoExperiments.svg';
1010
import { Fallback } from '@errors';
1111
import Loader from '@components/Loader';
1212
import { useSearchParams, useRouteWithBaseUrl } from '@hooks';
1313
import type { ListFaultResponse } from '@api/core';
14+
import config from '@config';
1415
import css from './ChaosFaults.module.scss';
1516

1617
interface ChaosFaultsProps {
@@ -41,6 +42,7 @@ function ChaosFaults({ hubDetails, faultCategories, loading, searchValue }: Chao
4142
const searchParams = useSearchParams();
4243
const hubName = searchParams.get('hubName');
4344
const isDefault = searchParams.get('isDefault');
45+
const scope = getScope();
4446
const tags: TagProps[] = [];
4547
const faultsArray: Fault[] = [];
4648
const [activeTag, setActiveTag] = React.useState<string>('All');
@@ -89,12 +91,6 @@ function ChaosFaults({ hubDetails, faultCategories, loading, searchValue }: Chao
8991
};
9092

9193
const FaultCard = (fault: Fault): React.ReactElement => {
92-
const isAzureFault = fault.tag.toLowerCase() === 'azure';
93-
const isChartNameAws = fault.chartName.toLowerCase().includes('aws');
94-
const isK6Fault = fault.name.toLowerCase().includes('k6-loadgen');
95-
const isGcpFault = fault.tag.toLowerCase() === 'gcp';
96-
const isSpringbootFault = fault.chartName.toLowerCase() === 'spring-boot';
97-
9894
return (
9995
<Link
10096
to={{
@@ -105,35 +101,15 @@ function ChaosFaults({ hubDetails, faultCategories, loading, searchValue }: Chao
105101
<Card key={fault.name} interactive className={css.insideCard}>
106102
<Layout.Vertical spacing="medium">
107103
<Layout.Horizontal spacing="small">
108-
{isAzureFault ? (
109-
<img
110-
src="https://hub.litmuschaos.io/api/icon/3.22.0/azure/azure-instance-stop.png"
111-
alt="Azure"
112-
width={23}
113-
height={23}
114-
style={{ objectFit: 'contain' }}
115-
/>
116-
) : isChartNameAws ? (
117-
<img
118-
src="https://hub.litmuschaos.io/api/icon/3.22.0/aws/aws-az-chaos.png"
119-
alt="AWS"
120-
width={23}
121-
height={23}
122-
style={{ objectFit: 'contain' }}
123-
/>
124-
) : isK6Fault ? (
125-
<img
126-
src="https://hub.litmuschaos.io/api/icon/3.22.0/load/k6-loadgen.png"
127-
alt="k6-logo"
128-
className={css.k6Logo}
129-
/>
130-
) : isGcpFault ? (
104+
{fault.chartName.toLowerCase() === 'kubernetes' || fault.chartName.toLowerCase() === 'spring-boot' || fault.chartName.toLowerCase() === 'k6-loadgen' || fault.chartName.toLowerCase() === 'azure' || fault.chartName.toLowerCase() === 'gcp' || fault.chartName.toLowerCase() === 'aws' || fault.chartName.toLowerCase() === 'k6-logo' ? (
131105
<img
132-
src="https://hub.litmuschaos.io/api/icon/3.22.0/gcp/gcp-vm-instance-stop.png"
133-
alt="GCP"
134-
width={23}
135-
height={23}
136-
style={{ objectFit: 'contain' }}
106+
src={
107+
isDefault === 'true'
108+
? `${config.restEndpoints?.chaosManagerUri}/icon/default/${hubName}/${fault.chartName}/${fault.name}.png`
109+
: `${config.restEndpoints?.chaosManagerUri}/icon/${scope.projectID}/${hubName}/${fault.chartName}/${fault.name}.png`
110+
}
111+
alt={`${fault.name} icon`}
112+
style={{ width: 23, height: 23, objectFit: 'contain' }}
137113
/>
138114
) : isSpringbootFault ? (
139115
<img

0 commit comments

Comments
 (0)