feat(editor): Node Creator AI nodes improvements (#9484)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg
2024-05-30 16:53:33 +02:00
committed by GitHub
parent e68a3fd6ce
commit be4f54de15
62 changed files with 661 additions and 204 deletions

View File

@@ -250,6 +250,7 @@ import {
UPDATE_WEBHOOK_ID_NODE_TYPES,
TIME,
AI_ASSISTANT_LOCAL_STORAGE_KEY,
CANVAS_AUTO_ADD_MANUAL_TRIGGER_EXPERIMENT,
} from '@/constants';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
@@ -395,6 +396,7 @@ import type { ProjectSharingData } from '@/features/projects/projects.types';
import { useAIStore } from '@/stores/ai.store';
import { useStorage } from '@/composables/useStorage';
import { isJSPlumbEndpointElement } from '@/utils/typeGuards';
import { usePostHog } from '@/stores/posthog.store';
import { ProjectTypes } from '@/features/projects/projects.utils';
interface AddNodeOptions {
@@ -944,6 +946,17 @@ export default defineComponent({
action: this.openSelectiveNodeCreator,
});
this.registerCustomAction({
key: 'showNodeCreator',
action: () => {
this.ndvStore.activeNodeName = null;
void this.$nextTick(() => {
this.showTriggerCreator(NODE_CREATOR_OPEN_SOURCES.TAB);
});
},
});
this.readOnlyEnvRouteCheck();
this.canvasStore.isDemo = this.isDemo;
},
@@ -1177,12 +1190,6 @@ export default defineComponent({
? this.$locale.baseText('nodeView.addOrEnableTriggerNode')
: this.$locale.baseText('nodeView.addATriggerNodeFirst');
this.registerCustomAction({
key: 'showNodeCreator',
action: () =>
this.showTriggerCreator(NODE_CREATOR_OPEN_SOURCES.NO_TRIGGER_EXECUTION_TOOLTIP),
});
const notice = this.showMessage({
type: 'info',
title: this.$locale.baseText('nodeView.cantExecuteNoTrigger'),
@@ -1257,9 +1264,15 @@ export default defineComponent({
},
showTriggerCreator(source: NodeCreatorOpenSource) {
if (this.createNodeActive) return;
this.ndvStore.activeNodeName = null;
this.nodeCreatorStore.setSelectedView(TRIGGER_NODE_CREATOR_VIEW);
this.nodeCreatorStore.setShowScrim(true);
this.onToggleNodeCreator({ source, createNodeActive: true });
this.onToggleNodeCreator({
source,
createNodeActive: true,
nodeCreatorView: TRIGGER_NODE_CREATOR_VIEW,
});
},
async openExecution(executionId: string) {
this.canvasStore.startLoading();
@@ -3659,6 +3672,7 @@ export default defineComponent({
this.workflowsStore.workflow.scopes = scopes;
},
async newWorkflow(): Promise<void> {
const { getVariant } = usePostHog();
this.canvasStore.startLoading();
this.resetWorkspace();
this.workflowData = await this.workflowsStore.getNewWorkflowData(
@@ -3670,15 +3684,24 @@ export default defineComponent({
this.uiStore.stateIsDirty = false;
this.canvasStore.setZoomLevel(1, [0, 0]);
await this.tryToAddWelcomeSticky();
this.canvasStore.zoomToFit();
this.uiStore.nodeViewInitialized = true;
this.historyStore.reset();
this.executionsStore.activeExecution = null;
this.makeNewWorkflowShareable();
this.canvasStore.stopLoading();
},
async tryToAddWelcomeSticky(): Promise<void> {
this.canvasStore.zoomToFit();
// Pre-populate the canvas with the manual trigger node if the experiment is enabled and the user is in the variant group
if (
getVariant(CANVAS_AUTO_ADD_MANUAL_TRIGGER_EXPERIMENT.name) ===
CANVAS_AUTO_ADD_MANUAL_TRIGGER_EXPERIMENT.variant
) {
const manualTriggerNode = this.canvasStore.getAutoAddManualTriggerNode();
if (manualTriggerNode) {
await this.addNodes([manualTriggerNode]);
this.uiStore.lastSelectedNode = manualTriggerNode.name;
}
}
},
async initView(): Promise<void> {
if (this.$route.params.action === 'workflowSave') {
@@ -5375,4 +5398,3 @@ export default defineComponent({
);
}
</style>
, IRun, IPushDataExecutionFinished