feat(editor): Add registerCustomAction to new canvas (no-changelog) (#10359)

This commit is contained in:
Alex Grozav 2024-08-16 10:45:12 +03:00 committed by GitHub
parent c5a0c049ea
commit 90a5fcc541
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 27 deletions

View file

@ -47,7 +47,7 @@ import AskAssistantFloatingButton from '@/components/AskAssistant/AskAssistantFl
import { HIRING_BANNER, VIEWS } from '@/constants'; import { HIRING_BANNER, VIEWS } from '@/constants';
import { loadLanguage } from '@/plugins/i18n'; import { loadLanguage } from '@/plugins/i18n';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions'; import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import { useExternalHooks } from '@/composables/useExternalHooks'; import { useExternalHooks } from '@/composables/useExternalHooks';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
import { useCloudPlanStore } from '@/stores/cloudPlan.store'; import { useCloudPlanStore } from '@/stores/cloudPlan.store';

View file

@ -10,7 +10,7 @@ const state = reactive({
delegatedClickHandler: null as null | ((e: MouseEvent) => void), delegatedClickHandler: null as null | ((e: MouseEvent) => void),
}); });
export default () => { export function useGlobalLinkActions() {
function registerCustomAction({ key, action }: { key: string; action: Function }) { function registerCustomAction({ key, action }: { key: string; action: Function }) {
state.customActions[key] = action; state.customActions[key] = action;
} }
@ -76,4 +76,4 @@ export default () => {
registerCustomAction, registerCustomAction,
unregisterCustomAction, unregisterCustomAction,
}; };
}; }

View file

@ -18,6 +18,7 @@ import CanvasRunWorkflowButton from '@/components/canvas/elements/buttons/Canvas
import { useI18n } from '@/composables/useI18n'; import { useI18n } from '@/composables/useI18n';
import { useWorkflowsStore } from '@/stores/workflows.store'; import { useWorkflowsStore } from '@/stores/workflows.store';
import { useRunWorkflow } from '@/composables/useRunWorkflow'; import { useRunWorkflow } from '@/composables/useRunWorkflow';
import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import type { import type {
AddedNodesAndConnections, AddedNodesAndConnections,
IExecutionResponse, IExecutionResponse,
@ -135,6 +136,7 @@ const templatesStore = useTemplatesStore();
const canvasEventBus = createEventBus(); const canvasEventBus = createEventBus();
const { registerCustomAction } = useGlobalLinkActions();
const { runWorkflow, stopCurrentExecution, stopWaitingForWebhook } = useRunWorkflow({ router }); const { runWorkflow, stopCurrentExecution, stopWaitingForWebhook } = useRunWorkflow({ router });
const { const {
updateNodePosition, updateNodePosition,
@ -844,6 +846,10 @@ async function onOpenSelectiveNodeCreator(node: string, connectionType: NodeConn
nodeCreatorStore.openSelectiveNodeCreator({ node, connectionType }); nodeCreatorStore.openSelectiveNodeCreator({ node, connectionType });
} }
async function onOpenNodeCreatorForTriggerNodes(source: NodeCreatorOpenSource) {
nodeCreatorStore.openNodeCreatorForTriggerNodes(source);
}
function onOpenNodeCreatorFromCanvas(source: NodeCreatorOpenSource) { function onOpenNodeCreatorFromCanvas(source: NodeCreatorOpenSource) {
onOpenNodeCreator({ createNodeActive: true, source }); onOpenNodeCreator({ createNodeActive: true, source });
} }
@ -1347,29 +1353,36 @@ function onClickPane(position: CanvasNode['position']) {
*/ */
function registerCustomActions() { function registerCustomActions() {
// @TODO Implement these registerCustomAction({
// this.registerCustomAction({ key: 'openNodeDetail',
// key: 'openNodeDetail', action: ({ node }: { node: string }) => {
// action: ({ node }: { node: string }) => { setNodeActiveByName(node);
// this.nodeSelectedByName(node, true); },
// }, });
// });
// registerCustomAction({
// this.registerCustomAction({ key: 'openSelectiveNodeCreator',
// key: 'openSelectiveNodeCreator', action: ({
// action: this.openSelectiveNodeCreator, connectiontype: connectionType,
// }); node,
// }: {
// this.registerCustomAction({ connectiontype: NodeConnectionType;
// key: 'showNodeCreator', node: string;
// action: () => { }) => {
// this.ndvStore.activeNodeName = null; void onOpenSelectiveNodeCreator(node, connectionType);
// },
// void this.$nextTick(() => { });
// this.showTriggerCreator(NODE_CREATOR_OPEN_SOURCES.TAB);
// }); registerCustomAction({
// }, key: 'showNodeCreator',
// }); action: () => {
ndvStore.activeNodeName = null;
void nextTick(() => {
void onOpenNodeCreatorForTriggerNodes(NODE_CREATOR_OPEN_SOURCES.TAB);
});
},
});
} }
/** /**

View file

@ -261,7 +261,7 @@ import {
VALID_WORKFLOW_IMPORT_URL_REGEX, VALID_WORKFLOW_IMPORT_URL_REGEX,
} from '@/constants'; } from '@/constants';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions'; import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import { useNodeHelpers } from '@/composables/useNodeHelpers'; import { useNodeHelpers } from '@/composables/useNodeHelpers';
import useCanvasMouseSelect from '@/composables/useCanvasMouseSelect'; import useCanvasMouseSelect from '@/composables/useCanvasMouseSelect';
import { useExecutionDebugging } from '@/composables/useExecutionDebugging'; import { useExecutionDebugging } from '@/composables/useExecutionDebugging';