mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
refactor(editor): Remove unused return fields from ui store (#15594)
This commit is contained in:
@@ -38,7 +38,6 @@ describe('useContextMenu', () => {
|
|||||||
} as never);
|
} as never);
|
||||||
|
|
||||||
uiStore = useUIStore();
|
uiStore = useUIStore();
|
||||||
uiStore.selectedNodes = selectedNodes;
|
|
||||||
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(false);
|
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(false);
|
||||||
|
|
||||||
workflowsStore = useWorkflowsStore();
|
workflowsStore = useWorkflowsStore();
|
||||||
|
|||||||
@@ -181,11 +181,9 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { type, index, mode } = parseCanvasConnectionHandleString(connection.sourceHandle);
|
const { type, mode } = parseCanvasConnectionHandleString(connection.sourceHandle);
|
||||||
|
|
||||||
uiStore.lastSelectedNode = sourceNode.name;
|
uiStore.lastSelectedNode = sourceNode.name;
|
||||||
uiStore.lastSelectedNodeEndpointUuid = connection.sourceHandle ?? null;
|
|
||||||
uiStore.lastSelectedNodeOutputIndex = index;
|
|
||||||
|
|
||||||
if (isVueFlowConnection(connection)) {
|
if (isVueFlowConnection(connection)) {
|
||||||
uiStore.lastInteractedWithNodeConnection = connection;
|
uiStore.lastInteractedWithNodeConnection = connection;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import {
|
|||||||
} from '@/constants';
|
} from '@/constants';
|
||||||
import { STORES } from '@n8n/stores';
|
import { STORES } from '@n8n/stores';
|
||||||
import type {
|
import type {
|
||||||
INodeUi,
|
|
||||||
XYPosition,
|
XYPosition,
|
||||||
Modals,
|
Modals,
|
||||||
NewCredentialsModal,
|
NewCredentialsModal,
|
||||||
@@ -85,14 +84,6 @@ try {
|
|||||||
|
|
||||||
type UiStore = ReturnType<typeof useUIStore>;
|
type UiStore = ReturnType<typeof useUIStore>;
|
||||||
|
|
||||||
type Draggable = {
|
|
||||||
isDragging: boolean;
|
|
||||||
type: string;
|
|
||||||
data: string;
|
|
||||||
canDrop: boolean;
|
|
||||||
stickyPosition: null | XYPosition;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useUIStore = defineStore(STORES.UI, () => {
|
export const useUIStore = defineStore(STORES.UI, () => {
|
||||||
const activeActions = ref<string[]>([]);
|
const activeActions = ref<string[]>([]);
|
||||||
const activeCredentialType = ref<string | null>(null);
|
const activeCredentialType = ref<string | null>(null);
|
||||||
@@ -213,21 +204,9 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
const sidebarMenuCollapsedPreference = useLocalStorage<boolean>('sidebar.collapsed', false);
|
const sidebarMenuCollapsedPreference = useLocalStorage<boolean>('sidebar.collapsed', false);
|
||||||
const sidebarMenuCollapsed = ref<boolean>(sidebarMenuCollapsedPreference.value);
|
const sidebarMenuCollapsed = ref<boolean>(sidebarMenuCollapsedPreference.value);
|
||||||
const currentView = ref<string>('');
|
const currentView = ref<string>('');
|
||||||
const draggable = ref<Draggable>({
|
|
||||||
isDragging: false,
|
|
||||||
type: '',
|
|
||||||
data: '',
|
|
||||||
canDrop: false,
|
|
||||||
stickyPosition: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
const stateIsDirty = ref<boolean>(false);
|
const stateIsDirty = ref<boolean>(false);
|
||||||
const lastSelectedNode = ref<string | null>(null);
|
const lastSelectedNode = ref<string | null>(null);
|
||||||
const lastSelectedNodeOutputIndex = ref<number | null>(null);
|
|
||||||
const lastSelectedNodeEndpointUuid = ref<string | null>(null);
|
|
||||||
const nodeViewOffsetPosition = ref<[number, number]>([0, 0]);
|
const nodeViewOffsetPosition = ref<[number, number]>([0, 0]);
|
||||||
const nodeViewMoveInProgress = ref<boolean>(false);
|
|
||||||
const selectedNodes = ref<INodeUi[]>([]);
|
|
||||||
const nodeViewInitialized = ref<boolean>(false);
|
const nodeViewInitialized = ref<boolean>(false);
|
||||||
const addFirstStepOnLoad = ref<boolean>(false);
|
const addFirstStepOnLoad = ref<boolean>(false);
|
||||||
const bannersHeight = ref<number>(0);
|
const bannersHeight = ref<number>(0);
|
||||||
@@ -317,13 +296,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
} as const;
|
} as const;
|
||||||
});
|
});
|
||||||
|
|
||||||
const getLastSelectedNode = computed(() => {
|
|
||||||
if (lastSelectedNode.value) {
|
|
||||||
return workflowsStore.getNodeByName(lastSelectedNode.value);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
const lastInteractedWithNode = computed(() => {
|
const lastInteractedWithNode = computed(() => {
|
||||||
if (lastInteractedWithNodeId.value) {
|
if (lastInteractedWithNodeId.value) {
|
||||||
return workflowsStore.getNodeById(lastInteractedWithNodeId.value);
|
return workflowsStore.getNodeById(lastInteractedWithNodeId.value);
|
||||||
@@ -332,10 +304,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isVersionsOpen = computed(() => {
|
|
||||||
return modalsById.value[VERSIONS_MODAL_KEY].open;
|
|
||||||
});
|
|
||||||
|
|
||||||
const isModalActiveById = computed(() =>
|
const isModalActiveById = computed(() =>
|
||||||
Object.keys(modalsById.value).reduce((acc: { [key: string]: boolean }, name) => {
|
Object.keys(modalsById.value).reduce((acc: { [key: string]: boolean }, name) => {
|
||||||
acc[name] = name === modalStack.value[0];
|
acc[name] = name === modalStack.value[0];
|
||||||
@@ -360,25 +328,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
}, {}),
|
}, {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const getSelectedNodes = computed(() => {
|
|
||||||
const seen = new Set();
|
|
||||||
return selectedNodes.value.filter((node) => {
|
|
||||||
// dedupe for instances when same node is selected in different ways
|
|
||||||
if (!seen.has(node)) {
|
|
||||||
seen.add(node);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const isNodeSelected = computed(() =>
|
|
||||||
selectedNodes.value.reduce((acc: { [nodeName: string]: true }, node) => {
|
|
||||||
acc[node.name] = true;
|
|
||||||
return acc;
|
|
||||||
}, {}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const headerHeight = computed(() => {
|
const headerHeight = computed(() => {
|
||||||
const style = getComputedStyle(document.body);
|
const style = getComputedStyle(document.body);
|
||||||
return Number(style.getPropertyValue('--header-height'));
|
return Number(style.getPropertyValue('--header-height'));
|
||||||
@@ -450,40 +399,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
modalStack.value = modalStack.value.filter((openModalName) => name !== openModalName);
|
modalStack.value = modalStack.value.filter((openModalName) => name !== openModalName);
|
||||||
};
|
};
|
||||||
|
|
||||||
const draggableStartDragging = (type: string, data: string) => {
|
|
||||||
draggable.value = {
|
|
||||||
isDragging: true,
|
|
||||||
type,
|
|
||||||
data,
|
|
||||||
canDrop: false,
|
|
||||||
stickyPosition: null,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const draggableStopDragging = () => {
|
|
||||||
draggable.value = {
|
|
||||||
isDragging: false,
|
|
||||||
type: '',
|
|
||||||
data: '',
|
|
||||||
canDrop: false,
|
|
||||||
stickyPosition: null,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const setDraggableStickyPos = (position: XYPosition) => {
|
|
||||||
draggable.value = {
|
|
||||||
...draggable.value,
|
|
||||||
stickyPosition: position,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const setDraggableCanDrop = (canDrop: boolean) => {
|
|
||||||
draggable.value = {
|
|
||||||
...draggable.value,
|
|
||||||
canDrop,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const openDeleteUserModal = (id: string) => {
|
const openDeleteUserModal = (id: string) => {
|
||||||
setActiveId(DELETE_USER_MODAL_KEY, id);
|
setActiveId(DELETE_USER_MODAL_KEY, id);
|
||||||
openModal(DELETE_USER_MODAL_KEY);
|
openModal(DELETE_USER_MODAL_KEY);
|
||||||
@@ -561,33 +476,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSelectedNode = (node: INodeUi) => {
|
|
||||||
const isAlreadySelected = selectedNodes.value.some((n) => n.name === node.name);
|
|
||||||
if (!isAlreadySelected) {
|
|
||||||
selectedNodes.value.push(node);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeNodeFromSelection = (node: INodeUi) => {
|
|
||||||
for (const [index] of selectedNodes.value.entries()) {
|
|
||||||
if (selectedNodes.value[index].name === node.name) {
|
|
||||||
selectedNodes.value.splice(Number(index), 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetSelectedNodes = () => {
|
|
||||||
selectedNodes.value = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
const setCurlCommand = (payload: { name: string; command: string }) => {
|
|
||||||
modalsById.value[payload.name] = {
|
|
||||||
...modalsById.value[payload.name],
|
|
||||||
curlCommand: payload.command,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleSidebarMenuCollapse = () => {
|
const toggleSidebarMenuCollapse = () => {
|
||||||
const newCollapsedState = !sidebarMenuCollapsed.value;
|
const newCollapsedState = !sidebarMenuCollapsed.value;
|
||||||
sidebarMenuCollapsedPreference.value = newCollapsedState;
|
sidebarMenuCollapsedPreference.value = newCollapsedState;
|
||||||
@@ -627,10 +515,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
pendingNotificationsForViews.value[view] = notifications;
|
pendingNotificationsForViews.value[view] = notifications;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteNotificationsForView = (view: VIEWS) => {
|
|
||||||
delete pendingNotificationsForViews.value[view];
|
|
||||||
};
|
|
||||||
|
|
||||||
function resetLastInteractedWith() {
|
function resetLastInteractedWith() {
|
||||||
lastInteractedWithNodeConnection.value = undefined;
|
lastInteractedWithNodeConnection.value = undefined;
|
||||||
lastInteractedWithNodeHandle.value = null;
|
lastInteractedWithNodeHandle.value = null;
|
||||||
@@ -650,29 +534,21 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
appGridDimensions,
|
appGridDimensions,
|
||||||
appliedTheme,
|
appliedTheme,
|
||||||
contextBasedTranslationKeys,
|
contextBasedTranslationKeys,
|
||||||
getLastSelectedNode,
|
|
||||||
isVersionsOpen,
|
|
||||||
isModalActiveById,
|
isModalActiveById,
|
||||||
isReadOnlyView,
|
isReadOnlyView,
|
||||||
isActionActive,
|
isActionActive,
|
||||||
activeActions,
|
activeActions,
|
||||||
getSelectedNodes,
|
|
||||||
isNodeSelected,
|
|
||||||
headerHeight,
|
headerHeight,
|
||||||
stateIsDirty,
|
stateIsDirty,
|
||||||
lastSelectedNodeOutputIndex,
|
|
||||||
activeCredentialType,
|
activeCredentialType,
|
||||||
lastSelectedNode,
|
lastSelectedNode,
|
||||||
selectedNodes,
|
|
||||||
bannersHeight,
|
bannersHeight,
|
||||||
lastSelectedNodeEndpointUuid,
|
|
||||||
lastInteractedWithNodeConnection,
|
lastInteractedWithNodeConnection,
|
||||||
lastInteractedWithNodeHandle,
|
lastInteractedWithNodeHandle,
|
||||||
lastInteractedWithNodeId,
|
lastInteractedWithNodeId,
|
||||||
lastInteractedWithNode,
|
lastInteractedWithNode,
|
||||||
lastCancelledConnectionPosition,
|
lastCancelledConnectionPosition,
|
||||||
nodeViewOffsetPosition,
|
nodeViewOffsetPosition,
|
||||||
nodeViewMoveInProgress,
|
|
||||||
nodeViewInitialized,
|
nodeViewInitialized,
|
||||||
addFirstStepOnLoad,
|
addFirstStepOnLoad,
|
||||||
sidebarMenuCollapsed,
|
sidebarMenuCollapsed,
|
||||||
@@ -686,17 +562,10 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
activeModals,
|
activeModals,
|
||||||
isProcessingExecutionResults,
|
isProcessingExecutionResults,
|
||||||
setTheme,
|
setTheme,
|
||||||
setMode,
|
|
||||||
setActiveId,
|
|
||||||
setShowAuthSelector,
|
|
||||||
setModalData,
|
setModalData,
|
||||||
openModalWithData,
|
openModalWithData,
|
||||||
openModal,
|
openModal,
|
||||||
closeModal,
|
closeModal,
|
||||||
draggableStartDragging,
|
|
||||||
draggableStopDragging,
|
|
||||||
setDraggableStickyPos,
|
|
||||||
setDraggableCanDrop,
|
|
||||||
openDeleteUserModal,
|
openDeleteUserModal,
|
||||||
openExistingCredential,
|
openExistingCredential,
|
||||||
openNewCredential,
|
openNewCredential,
|
||||||
@@ -705,18 +574,12 @@ export const useUIStore = defineStore(STORES.UI, () => {
|
|||||||
openCommunityPackageUpdateConfirmModal,
|
openCommunityPackageUpdateConfirmModal,
|
||||||
addActiveAction,
|
addActiveAction,
|
||||||
removeActiveAction,
|
removeActiveAction,
|
||||||
addSelectedNode,
|
|
||||||
removeNodeFromSelection,
|
|
||||||
resetSelectedNodes,
|
|
||||||
setCurlCommand,
|
|
||||||
toggleSidebarMenuCollapse,
|
toggleSidebarMenuCollapse,
|
||||||
removeBannerFromStack,
|
|
||||||
dismissBanner,
|
dismissBanner,
|
||||||
updateBannersHeight,
|
updateBannersHeight,
|
||||||
pushBannerToStack,
|
pushBannerToStack,
|
||||||
clearBannerStack,
|
clearBannerStack,
|
||||||
setNotificationsForView,
|
setNotificationsForView,
|
||||||
deleteNotificationsForView,
|
|
||||||
resetLastInteractedWith,
|
resetLastInteractedWith,
|
||||||
setProcessingExecutionResults,
|
setProcessingExecutionResults,
|
||||||
openDeleteFolderModal,
|
openDeleteFolderModal,
|
||||||
|
|||||||
Reference in New Issue
Block a user