Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/editor-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import Telemetry from '@/components/Telemetry.vue';
import { HIRING_BANNER, VIEWS } from '@/constants';

import { loadLanguage } from '@/plugins/i18n';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useToast } from '@/composables/useToast';
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/composables/useGlobalLinkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const state = reactive({
delegatedClickHandler: null as null | ((e: MouseEvent) => void),
});

export default () => {
export function useGlobalLinkActions() {
function registerCustomAction({ key, action }: { key: string; action: Function }) {
state.customActions[key] = action;
}
Expand Down Expand Up @@ -76,4 +76,4 @@ export default () => {
registerCustomAction,
unregisterCustomAction,
};
};
}
59 changes: 36 additions & 23 deletions packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CanvasRunWorkflowButton from '@/components/canvas/elements/buttons/Canvas
import { useI18n } from '@/composables/useI18n';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useRunWorkflow } from '@/composables/useRunWorkflow';
import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import type {
AddedNodesAndConnections,
IExecutionResponse,
Expand Down Expand Up @@ -134,6 +135,7 @@ const templatesStore = useTemplatesStore();

const canvasEventBus = createEventBus();

const { registerCustomAction } = useGlobalLinkActions();
const { runWorkflow, stopCurrentExecution, stopWaitingForWebhook } = useRunWorkflow({ router });
const {
updateNodePosition,
Expand Down Expand Up @@ -841,6 +843,10 @@ async function onOpenSelectiveNodeCreator(node: string, connectionType: NodeConn
nodeCreatorStore.openSelectiveNodeCreator({ node, connectionType });
}

async function onOpenNodeCreatorForTriggerNodes(source: NodeCreatorOpenSource) {
nodeCreatorStore.openNodeCreatorForTriggerNodes(source);
}

function onOpenNodeCreatorFromCanvas(source: NodeCreatorOpenSource) {
onOpenNodeCreator({ createNodeActive: true, source });
}
Expand Down Expand Up @@ -1344,29 +1350,36 @@ function onClickPane(position: CanvasNode['position']) {
*/

function registerCustomActions() {
// @TODO Implement these
// this.registerCustomAction({
// key: 'openNodeDetail',
// action: ({ node }: { node: string }) => {
// this.nodeSelectedByName(node, true);
// },
// });
//
// this.registerCustomAction({
// key: 'openSelectiveNodeCreator',
// action: this.openSelectiveNodeCreator,
// });
//
// this.registerCustomAction({
// key: 'showNodeCreator',
// action: () => {
// this.ndvStore.activeNodeName = null;
//
// void this.$nextTick(() => {
// this.showTriggerCreator(NODE_CREATOR_OPEN_SOURCES.TAB);
// });
// },
// });
registerCustomAction({
key: 'openNodeDetail',
action: ({ node }: { node: string }) => {
setNodeActiveByName(node);
},
});

registerCustomAction({
key: 'openSelectiveNodeCreator',
action: ({
connectiontype: connectionType,
node,
}: {
connectiontype: NodeConnectionType;
node: string;
}) => {
void onOpenSelectiveNodeCreator(node, connectionType);
},
});

registerCustomAction({
key: 'showNodeCreator',
action: () => {
ndvStore.activeNodeName = null;

void nextTick(() => {
void onOpenNodeCreatorForTriggerNodes(NODE_CREATOR_OPEN_SOURCES.TAB);
});
},
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ import {
VALID_WORKFLOW_IMPORT_URL_REGEX,
} from '@/constants';

import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
import { useGlobalLinkActions } from '@/composables/useGlobalLinkActions';
import { useNodeHelpers } from '@/composables/useNodeHelpers';
import useCanvasMouseSelect from '@/composables/useCanvasMouseSelect';
import { useExecutionDebugging } from '@/composables/useExecutionDebugging';
Expand Down
Loading