mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat: add template
This commit is contained in:
parent
fa597ce627
commit
1c9d20b615
|
@ -1521,7 +1521,7 @@ onBeforeMount(() => {
|
|||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
canvasStore.startLoading();
|
||||
|
||||
documentTitle.reset();
|
||||
|
@ -1553,6 +1553,11 @@ onMounted(() => {
|
|||
addImportEventBindings();
|
||||
addExecutionOpenedEventBindings();
|
||||
registerCustomActions();
|
||||
|
||||
await templatesStore.getWorkflows({
|
||||
categories: ['AI'],
|
||||
search: '',
|
||||
});
|
||||
});
|
||||
|
||||
onActivated(async () => {
|
||||
|
@ -1586,6 +1591,7 @@ type NinjaKeysCommand = {
|
|||
const hotkeys = computed<NinjaKeysCommand[]>(() => {
|
||||
const allOpenNodeCommands = getAllNodesCommands.value;
|
||||
const allAddNodeCommands = addNodeCommand.value;
|
||||
const allTemplateCommands = allTemplateCommand.value;
|
||||
const rootCommands: NinjaKeysCommand[] = [
|
||||
{
|
||||
id: 'Add node',
|
||||
|
@ -1599,9 +1605,18 @@ const hotkeys = computed<NinjaKeysCommand[]>(() => {
|
|||
children: allOpenNodeCommands.map((cmd) => cmd.id),
|
||||
section: 'Nodes',
|
||||
},
|
||||
{
|
||||
id: 'Add template',
|
||||
title: 'Add template',
|
||||
children: allTemplateCommands.map((cmd) => cmd.id),
|
||||
section: 'Templates',
|
||||
},
|
||||
];
|
||||
|
||||
return rootCommands.concat(allOpenNodeCommands).concat(addNodeCommand.value);
|
||||
return rootCommands
|
||||
.concat(allOpenNodeCommands)
|
||||
.concat(addNodeCommand.value)
|
||||
.concat(allTemplateCommand.value);
|
||||
});
|
||||
|
||||
const getAllNodesCommands = computed<NinjaKeysCommand[]>(() => {
|
||||
|
@ -1637,6 +1652,22 @@ const addNodeCommand = computed<NinjaKeysCommand[]>(() => {
|
|||
};
|
||||
});
|
||||
});
|
||||
|
||||
const allTemplateCommand = computed<NinjaKeysCommand[]>(() => {
|
||||
const templateWorkflows = Object.values(templatesStore.workflows);
|
||||
|
||||
return templateWorkflows.map((template) => {
|
||||
const { id, name } = template;
|
||||
return {
|
||||
id: id.toString(),
|
||||
title: `Add ${name} Template`,
|
||||
parent: 'Add template',
|
||||
handler: async () => {
|
||||
await openWorkflowTemplate(id.toString());
|
||||
},
|
||||
};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in a new issue