refactor(editor): Fix typescript issues in composables and misc files (no-changelog) (#9583)
This commit is contained in:
@@ -3,8 +3,8 @@ import { MAIN_HEADER_TABS } from '@/constants';
|
||||
import { render } from '@testing-library/vue';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { useHistoryHelper } from '../useHistoryHelper';
|
||||
import { defineComponent } from 'vue';
|
||||
import type { Route } from 'vue-router';
|
||||
import { defineComponent, type PropType } from 'vue';
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
||||
|
||||
const undoMock = vi.fn();
|
||||
const redoMock = vi.fn();
|
||||
@@ -37,11 +37,12 @@ vi.mock('vue-router', () => ({
|
||||
const TestComponent = defineComponent({
|
||||
props: {
|
||||
route: {
|
||||
type: Object,
|
||||
type: Object as PropType<RouteLocationNormalizedLoaded>,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
useHistoryHelper(props.route as Route);
|
||||
useHistoryHelper(props.route);
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
@@ -58,8 +58,8 @@ describe('useUniqueNodeName', () => {
|
||||
name: 'S3',
|
||||
description: '',
|
||||
version: 1,
|
||||
inputs: [''],
|
||||
outputs: [''],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
group: [''],
|
||||
properties: [],
|
||||
defaults: {
|
||||
|
||||
@@ -8,14 +8,14 @@ import { useUIStore } from '@/stores/ui.store';
|
||||
import { onMounted, onUnmounted, nextTick } from 'vue';
|
||||
import { useDeviceSupport } from 'n8n-design-system';
|
||||
import { getNodeViewTab } from '@/utils/canvasUtils';
|
||||
import type { Route } from 'vue-router';
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
||||
import { useTelemetry } from './useTelemetry';
|
||||
import { useDebounce } from '@/composables/useDebounce';
|
||||
|
||||
const UNDO_REDO_DEBOUNCE_INTERVAL = 100;
|
||||
const ELEMENT_UI_OVERLAY_SELECTOR = '.el-overlay';
|
||||
|
||||
export function useHistoryHelper(activeRoute: Route) {
|
||||
export function useHistoryHelper(activeRoute: RouteLocationNormalizedLoaded) {
|
||||
const telemetry = useTelemetry();
|
||||
|
||||
const ndvStore = useNDVStore();
|
||||
|
||||
@@ -77,10 +77,14 @@ export function useNodeHelpers() {
|
||||
|
||||
if (!isObject(parameters)) return false;
|
||||
|
||||
const { resource, operation } = parameters;
|
||||
if (!isString(resource) || !isString(operation)) return false;
|
||||
if ('resource' in parameters && 'operation' in parameters) {
|
||||
const { resource, operation } = parameters;
|
||||
if (!isString(resource) || !isString(operation)) return false;
|
||||
|
||||
return resource.includes(CUSTOM_API_CALL_KEY) || operation.includes(CUSTOM_API_CALL_KEY);
|
||||
return resource.includes(CUSTOM_API_CALL_KEY) || operation.includes(CUSTOM_API_CALL_KEY);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getParameterValue(nodeValues: INodeParameters, parameterName: string, path: string) {
|
||||
@@ -520,7 +524,7 @@ export function useNodeHelpers() {
|
||||
workflowsStore.setNodeIssue({
|
||||
node: node.name,
|
||||
type: 'credentials',
|
||||
value: issues === null ? null : issues.credentials,
|
||||
value: issues?.credentials ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -712,12 +716,12 @@ export function useNodeHelpers() {
|
||||
|
||||
const allNodeConnections = workflowsStore.outgoingConnectionsByNodeName(sourceNode.name);
|
||||
|
||||
const connectionType = Object.keys(allNodeConnections)[0];
|
||||
const connectionType = Object.keys(allNodeConnections)[0] as NodeConnectionType;
|
||||
const nodeConnections = allNodeConnections[connectionType];
|
||||
const outputMap = NodeViewUtils.getOutputSummary(
|
||||
data,
|
||||
nodeConnections || [],
|
||||
(connectionType as ConnectionTypes) ?? NodeConnectionType.Main,
|
||||
connectionType ?? NodeConnectionType.Main,
|
||||
);
|
||||
const sourceNodeType = nodeTypesStore.getNodeType(sourceNode.type, sourceNode.typeVersion);
|
||||
|
||||
@@ -732,7 +736,7 @@ export function useNodeHelpers() {
|
||||
parseInt(sourceOutputIndex, 10),
|
||||
targetNode,
|
||||
parseInt(targetInputIndex, 10),
|
||||
connectionType as ConnectionTypes,
|
||||
connectionType,
|
||||
sourceNodeType,
|
||||
canvasStore.jsPlumbInstance,
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ExpressionError, type IPinData, type IRunData, type Workflow } from 'n8n-workflow';
|
||||
import type * as router from 'vue-router';
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
useRootStore: vi.fn().mockReturnValue({ pushConnectionActive: true }),
|
||||
@@ -77,7 +78,7 @@ vi.mock('@/composables/useTitleChange', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('vue-router', async (importOriginal) => {
|
||||
const { RouterLink } = await importOriginal();
|
||||
const { RouterLink } = await importOriginal<typeof router>();
|
||||
return {
|
||||
RouterLink,
|
||||
useRouter: vi.fn().mockReturnValue({
|
||||
|
||||
Reference in New Issue
Block a user