Match SSH connection name to specific icon (e.g. Linode, Portainer) before falling back to generic Linux icon
This commit is contained in:
parent
437f14e330
commit
03159ecde4
1 changed files with 24 additions and 1 deletions
|
|
@ -107,6 +107,29 @@ const cdnIconCandidatesByIntegrationType: Record<string, string[]> = {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SSH connections are named by the user after whatever host/service they point at
|
||||||
|
// (e.g. "Linode", "Portainer") — match known keywords in the connection name to a
|
||||||
|
// more specific icon before falling back to the generic Linux icon above.
|
||||||
|
const sshNameIconCandidates: { keyword: string; candidates: string[] }[] = [
|
||||||
|
{ keyword: 'linode', candidates: [
|
||||||
|
'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/linode.png',
|
||||||
|
'https://api.iconify.design/simple-icons/linode.svg',
|
||||||
|
] },
|
||||||
|
{ keyword: 'portainer', candidates: [
|
||||||
|
'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/portainer.png',
|
||||||
|
'https://api.iconify.design/simple-icons/portainer.svg',
|
||||||
|
] },
|
||||||
|
]
|
||||||
|
|
||||||
|
function iconCandidatesForNode(node: NodeTile): string[] {
|
||||||
|
if (node.integrationType === 'ssh') {
|
||||||
|
const name = ('isGroup' in node ? node.integration : node.name).toLowerCase()
|
||||||
|
const match = sshNameIconCandidates.find((m) => name.includes(m.keyword))
|
||||||
|
if (match) return [...match.candidates, ...cdnIconCandidatesByIntegrationType.ssh]
|
||||||
|
}
|
||||||
|
return cdnIconCandidatesByIntegrationType[node.integrationType] ?? []
|
||||||
|
}
|
||||||
|
|
||||||
interface NodeGroup {
|
interface NodeGroup {
|
||||||
isGroup: true
|
isGroup: true
|
||||||
integration: string
|
integration: string
|
||||||
|
|
@ -385,7 +408,7 @@ export default function Infrastructure() {
|
||||||
<span style={{ width: '7px', height: '7px', borderRadius: '50%', backgroundColor: nodeStatusColor[node.status], boxShadow: `0 0 6px ${nodeStatusColor[node.status]}` }} />
|
<span style={{ width: '7px', height: '7px', borderRadius: '50%', backgroundColor: nodeStatusColor[node.status], boxShadow: `0 0 6px ${nodeStatusColor[node.status]}` }} />
|
||||||
<TileIcon
|
<TileIcon
|
||||||
customUrl={node.iconUrl}
|
customUrl={node.iconUrl}
|
||||||
candidates={cdnIconCandidatesByIntegrationType[node.integrationType] ?? []}
|
candidates={iconCandidatesForNode(node)}
|
||||||
fallback={NodeIcon}
|
fallback={NodeIcon}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue