mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
feat(editor): Move AI Assistant button to canvas action buttons (#16879)
This commit is contained in:
@@ -19,7 +19,9 @@ import type {
|
||||
} from '@/Interface';
|
||||
import { useActions } from './NodeCreator/composables/useActions';
|
||||
import KeyboardShortcutTooltip from '@/components/KeyboardShortcutTooltip.vue';
|
||||
import AssistantIcon from '@n8n/design-system/components/AskAssistantIcon/AssistantIcon.vue';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
|
||||
type Props = {
|
||||
nodeViewScale: number;
|
||||
@@ -44,6 +46,7 @@ const uiStore = useUIStore();
|
||||
const focusPanelStore = useFocusPanelStore();
|
||||
const posthogStore = usePostHog();
|
||||
const i18n = useI18n();
|
||||
const assistantStore = useAssistantStore();
|
||||
|
||||
const { getAddedNodesAndConnections } = useActions();
|
||||
|
||||
@@ -82,6 +85,17 @@ function nodeTypeSelected(value: NodeTypeSelectedPayload[]) {
|
||||
emit('addNodes', getAddedNodesAndConnections(value));
|
||||
closeNodeCreator(true);
|
||||
}
|
||||
|
||||
function onAskAssistantButtonClick() {
|
||||
if (!assistantStore.chatWindowOpen)
|
||||
assistantStore.trackUserOpenedAssistant({
|
||||
source: 'canvas',
|
||||
task: 'placeholder',
|
||||
has_existing_session: !assistantStore.isSessionEnded,
|
||||
});
|
||||
|
||||
assistantStore.toggleChatOpen();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -125,6 +139,24 @@ function nodeTypeSelected(value: NodeTypeSelectedPayload[]) {
|
||||
@click="focusPanelStore.toggleFocusPanel"
|
||||
/>
|
||||
</KeyboardShortcutTooltip>
|
||||
<n8n-tooltip placement="left">
|
||||
<template #content> {{ i18n.baseText('aiAssistant.tooltip') }}</template>
|
||||
<n8n-button
|
||||
v-if="assistantStore.canShowAssistantButtonsOnCanvas"
|
||||
type="tertiary"
|
||||
size="large"
|
||||
square
|
||||
:class="$style.icon"
|
||||
data-test-id="ask-assistant-canvas-action-button"
|
||||
@click="onAskAssistantButtonClick"
|
||||
>
|
||||
<template #default>
|
||||
<div>
|
||||
<AssistantIcon size="large" />
|
||||
</div>
|
||||
</template>
|
||||
</n8n-button>
|
||||
</n8n-tooltip>
|
||||
</div>
|
||||
<Suspense>
|
||||
<LazyNodeCreator
|
||||
@@ -146,4 +178,14 @@ function nodeTypeSelected(value: NodeTypeSelectedPayload[]) {
|
||||
padding: var(--spacing-s);
|
||||
pointer-events: all !important;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user