Skip to content

Commit ba2ffcc

Browse files
authored
Merge pull request #6678 from FlowFuse/6669-wrong-url-and-favicon
Use correct favicon and use provided link to package
2 parents caa8232 + 96bf6ef commit ba2ffcc

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

frontend/src/components/expert/resource-cards/PackageResourceCard.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="package-card"
77
>
88
<img
9-
:src="'https://www.google.com/s2/favicons?domain=flows.nodered.org'"
9+
:src="getFaviconUrl(nodePackage.metadata?.source || nodePackage.url)"
1010
alt="Node-RED"
1111
class="package-favicon"
1212
@error="handleImageError"
@@ -15,7 +15,7 @@
1515
<div class="package-name">{{ getPackageName(nodePackage) }}</div>
1616
<div class="package-url">{{ getPackageUrl(nodePackage) }}</div>
1717
<div class="package-actions">
18-
<template v-if="canManagePalette">
18+
<template v-if="canManagePalette && !isCorePackage(nodePackage)">
1919
<ff-button v-if="isPackageInstalled(nodePackage)" class="w-20" size="small" kind="secondary" @click.stop.prevent="managePackage(nodePackage)">Manage</ff-button>
2020
<ff-button v-else class="w-20" size="small" kind="secondary" @click.stop.prevent="installPackage(nodePackage)">Install</ff-button>
2121
</template>
@@ -46,8 +46,17 @@ export default {
4646
return typeof pkg === 'object' ? (pkg.id || pkg.name) : pkg
4747
},
4848
getPackageUrl (pkg) {
49-
const packageName = this.getPackageName(pkg)
50-
return `https://flows.nodered.org/node/${packageName}`
49+
if (!pkg) return 'https://flows.nodered.org/'
50+
return pkg.url || pkg.metadata?.source || pkg.metadata?.url || `https://flows.nodered.org/node/${this.getPackageName(pkg)}`
51+
},
52+
getFaviconUrl (url) {
53+
try {
54+
const urlObj = new URL(url)
55+
return `https://www.google.com/s2/favicons?domain=${urlObj.hostname}`
56+
} catch (e) {
57+
// If URL parsing fails, return empty string to trigger error handler
58+
return 'flows.nodered.org'
59+
}
5160
},
5261
isPackageInstalled (pkg) {
5362
return !!this.$store.state.product.assistant?.palette?.[pkg.id]
@@ -77,6 +86,9 @@ export default {
7786
const packageName = this.getPackageName(nodePackage)
7887
this.manageNodePackage(packageName)
7988
// TODO: hide the ff-expert panel after managing. Ideally after a "success" message is received from the assistant
89+
},
90+
isCorePackage (nodePackage) {
91+
return nodePackage.type === 'core-node' || this.getPackageName(nodePackage).startsWith('node-red:')
8092
}
8193
}
8294
}

0 commit comments

Comments
 (0)