Skip to content

Commit 85d02d6

Browse files
authored
feat(Modules): Add icon from ModuleTemplates (#3550)
* feat(Modules): Add icon from ModuleTemplates * add checking if image exist * remove clgs * some change, idk how to name it * fix csses * comment rebase
1 parent e30bee1 commit 85d02d6

10 files changed

+53
-8
lines changed

.github/workflows/pull-integration-cluster-k3d.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
comment_on_pr: false
2828
- uses: actions/checkout@v4
29-
- uses: ./.github/actions/rebase
29+
# - uses: ./.github/actions/rebase
3030
- name: Create Single Cluster
3131
uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0
3232
with:

.github/workflows/pull-integration-namespace-k3d.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
comment_on_pr: false
2828
- uses: actions/checkout@v4
29-
- uses: ./.github/actions/rebase
29+
# - uses: ./.github/actions/rebase
3030
- name: Create Single Cluster
3131
uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0
3232
with:

.github/workflows/pull-kyma-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
comment_on_pr: false
2323
- uses: actions/checkout@v4
24-
- uses: ./.github/actions/rebase
24+
# - uses: ./.github/actions/rebase
2525
- name: Install k3d
2626
env:
2727
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh

.github/workflows/pull-lighthouse.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
with:
2020
comment_on_pr: false
2121
- uses: actions/checkout@v4
22-
- uses: ./.github/actions/rebase
22+
# - uses: ./.github/actions/rebase
2323
- name: Create Single Cluster
2424
uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0
2525
with:

.github/workflows/pull-smoke-test-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
comment_on_pr: false
2323
- uses: actions/checkout@v4
24-
- uses: ./.github/actions/rebase
24+
# - uses: ./.github/actions/rebase
2525
- name: Install k3d
2626
env:
2727
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh

.github/workflows/pull-smoke-test-stage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
comment_on_pr: false
2323
- uses: actions/checkout@v4
24-
- uses: ./.github/actions/rebase
24+
# - uses: ./.github/actions/rebase
2525
- name: Install k3d
2626
env:
2727
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh

.github/workflows/pull-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
comment_on_pr: false
2020
- uses: actions/checkout@v4
21-
- uses: ./.github/actions/rebase
21+
# - uses: ./.github/actions/rebase
2222
- uses: actions/setup-node@v4
2323
with:
2424
node-version: 20

src/components/KymaModules/KymaModulesAddModule.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export default function KymaModulesAddModule({
102102
],
103103
docsUrl:
104104
module.metadata.annotations['operator.kyma-project.io/doc-url'],
105+
icon: {
106+
link: module.spec?.info?.icons[0]?.link,
107+
name: module.spec?.info?.icons[0]?.name,
108+
},
105109
isMetaRelease: false,
106110
});
107111
} else if (existingModule) {
@@ -130,6 +134,10 @@ export default function KymaModulesAddModule({
130134
},
131135
],
132136
docsUrl: module.spec.info.documentation,
137+
icon: {
138+
link: module.spec?.info?.icons[0]?.link,
139+
name: module.spec?.info?.icons[0]?.name,
140+
},
133141
});
134142
} else {
135143
acc

src/components/KymaModules/KymaModulesAddModule.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
}
5151

5252
.settings-panel {
53+
width: 350px;
54+
5355
&::part(header) {
5456
font-family: var(--sapFontFamily);
5557
font-size: var(--sapFontSize);

src/components/KymaModules/ModulesCard.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ import '@ui5/webcomponents/dist/features/InputElementsFormSupport.js';
1313
import { ExternalLink } from 'shared/components/ExternalLink/ExternalLink';
1414
import { useTranslation } from 'react-i18next';
1515
import { spacing } from '@ui5/webcomponents-react-base';
16+
import { useEffect, useState } from 'react';
17+
18+
async function isImageAvailable(url) {
19+
try {
20+
const response = await fetch(url, { method: 'HEAD' });
21+
return response.ok;
22+
} catch (error) {
23+
return false;
24+
}
25+
}
26+
async function getImageSrc(module) {
27+
const defaultImage = '/assets/sap-logo.svg';
28+
const iconLink = module.icon.link;
29+
30+
if (iconLink && (await isImageAvailable(iconLink))) {
31+
return iconLink;
32+
} else {
33+
return defaultImage;
34+
}
35+
}
1636

1737
export default function ModulesCard({
1838
module,
@@ -26,6 +46,15 @@ export default function ModulesCard({
2646
checkIfStatusModuleIsBeta,
2747
}) {
2848
const { t } = useTranslation();
49+
const [imageSrc, setImageSrc] = useState('');
50+
51+
useEffect(() => {
52+
async function checkImage() {
53+
const src = await getImageSrc(module);
54+
setImageSrc(src);
55+
}
56+
checkImage();
57+
}, [module]);
2958

3059
return (
3160
<Card key={module.name} className="addModuleCard">
@@ -52,7 +81,13 @@ export default function ModulesCard({
5281
: t('kyma-modules.no-version')}
5382
</Text>
5483
</div>
55-
<img className="avatar" alt="SAP" src="\assets\sap-logo.svg" />
84+
{imageSrc !== '' && (
85+
<img
86+
className="avatar"
87+
alt={module.icon.name ? module.icon.name : 'SAP'}
88+
src={imageSrc}
89+
/>
90+
)}
5691
</StandardListItem>
5792
<div className="content">
5893
{module.docsUrl && (

0 commit comments

Comments
 (0)