Add icon to open node commands

This commit is contained in:
Elias Meire 2024-10-30 15:01:41 +01:00
parent 0fa88529b1
commit 0fd507e753
No known key found for this signature in database

View file

@ -1628,10 +1628,16 @@ const getAllNodesCommands = computed<NinjaKeysCommand[]>(() => {
return editableWorkflow.value.nodes.map((node) => { return editableWorkflow.value.nodes.map((node) => {
const { id, name } = node; const { id, name } = node;
const nodeType = nodeTypesStore.getNodeType(node.type, node.typeVersion);
const src = getIconSource(nodeType);
return { return {
id, id,
title: `Open "${name}" Node`, title: `Open "${name}" Node`,
parent: 'Open node', parent: 'Open node',
icon: src?.path
? `<img src="${src.path}" style="width: 24px;object-fit: contain;height: 24px;" />`
: '',
handler: () => { handler: () => {
setNodeActive(id); setNodeActive(id);
}, },
@ -1639,7 +1645,9 @@ const getAllNodesCommands = computed<NinjaKeysCommand[]>(() => {
}); });
}); });
function getIconSource(nodeType: SimplifiedNodeType) { function getIconSource(nodeType: SimplifiedNodeType | null) {
if (!nodeType) return {};
const baseUrl = rootStore.baseUrl; const baseUrl = rootStore.baseUrl;
const iconUrl = getNodeIconUrl(nodeType, uiStore.appliedTheme); const iconUrl = getNodeIconUrl(nodeType, uiStore.appliedTheme);
@ -1676,7 +1684,9 @@ const addNodeCommand = computed<NinjaKeysCommand[]>(() => {
return { return {
id: name, id: name,
title: `Add ${displayName} Node`, title: `Add ${displayName} Node`,
icon: `<img src="${src?.path}" style="width: 24px;object-fit: contain;height: 24px;" />`, icon: src?.path
? `<img src="${src.path}" style="width: 24px;object-fit: contain;height: 24px;" />`
: '',
parent: 'Add node', parent: 'Add node',
handler: async () => { handler: async () => {
await addNodes([{ type: name }]); await addNodes([{ type: name }]);