refactor(editor): Remove unused return fields from ui store (#15594)

This commit is contained in:
Suguru Inoue
2025-05-23 09:33:10 +02:00
committed by GitHub
parent 20604983cd
commit 4323204070
3 changed files with 1 additions and 141 deletions

View File

@@ -38,7 +38,6 @@ describe('useContextMenu', () => {
} as never);
uiStore = useUIStore();
uiStore.selectedNodes = selectedNodes;
vi.spyOn(uiStore, 'isReadOnlyView', 'get').mockReturnValue(false);
workflowsStore = useWorkflowsStore();

View File

@@ -181,11 +181,9 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, () => {
return;
}
const { type, index, mode } = parseCanvasConnectionHandleString(connection.sourceHandle);
const { type, mode } = parseCanvasConnectionHandleString(connection.sourceHandle);
uiStore.lastSelectedNode = sourceNode.name;
uiStore.lastSelectedNodeEndpointUuid = connection.sourceHandle ?? null;
uiStore.lastSelectedNodeOutputIndex = index;
if (isVueFlowConnection(connection)) {
uiStore.lastInteractedWithNodeConnection = connection;

View File

@@ -44,7 +44,6 @@ import {
} from '@/constants';
import { STORES } from '@n8n/stores';
import type {
INodeUi,
XYPosition,
Modals,
NewCredentialsModal,
@@ -85,14 +84,6 @@ try {
type UiStore = ReturnType<typeof useUIStore>;
type Draggable = {
isDragging: boolean;
type: string;
data: string;
canDrop: boolean;
stickyPosition: null | XYPosition;
};
export const useUIStore = defineStore(STORES.UI, () => {
const activeActions = ref<string[]>([]);
const activeCredentialType = ref<string | null>(null);
@@ -213,21 +204,9 @@ export const useUIStore = defineStore(STORES.UI, () => {
const sidebarMenuCollapsedPreference = useLocalStorage<boolean>('sidebar.collapsed', false);
const sidebarMenuCollapsed = ref<boolean>(sidebarMenuCollapsedPreference.value);
const currentView = ref<string>('');
const draggable = ref<Draggable>({
isDragging: false,
type: '',
data: '',
canDrop: false,
stickyPosition: null,
});
const stateIsDirty = ref<boolean>(false);
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 nodeViewMoveInProgress = ref<boolean>(false);
const selectedNodes = ref<INodeUi[]>([]);
const nodeViewInitialized = ref<boolean>(false);
const addFirstStepOnLoad = ref<boolean>(false);
const bannersHeight = ref<number>(0);
@@ -317,13 +296,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
} as const;
});
const getLastSelectedNode = computed(() => {
if (lastSelectedNode.value) {
return workflowsStore.getNodeByName(lastSelectedNode.value);
}
return null;
});
const lastInteractedWithNode = computed(() => {
if (lastInteractedWithNodeId.value) {
return workflowsStore.getNodeById(lastInteractedWithNodeId.value);
@@ -332,10 +304,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
return null;
});
const isVersionsOpen = computed(() => {
return modalsById.value[VERSIONS_MODAL_KEY].open;
});
const isModalActiveById = computed(() =>
Object.keys(modalsById.value).reduce((acc: { [key: string]: boolean }, name) => {
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 style = getComputedStyle(document.body);
return Number(style.getPropertyValue('--header-height'));
@@ -450,40 +399,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
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) => {
setActiveId(DELETE_USER_MODAL_KEY, id);
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 newCollapsedState = !sidebarMenuCollapsed.value;
sidebarMenuCollapsedPreference.value = newCollapsedState;
@@ -627,10 +515,6 @@ export const useUIStore = defineStore(STORES.UI, () => {
pendingNotificationsForViews.value[view] = notifications;
};
const deleteNotificationsForView = (view: VIEWS) => {
delete pendingNotificationsForViews.value[view];
};
function resetLastInteractedWith() {
lastInteractedWithNodeConnection.value = undefined;
lastInteractedWithNodeHandle.value = null;
@@ -650,29 +534,21 @@ export const useUIStore = defineStore(STORES.UI, () => {
appGridDimensions,
appliedTheme,
contextBasedTranslationKeys,
getLastSelectedNode,
isVersionsOpen,
isModalActiveById,
isReadOnlyView,
isActionActive,
activeActions,
getSelectedNodes,
isNodeSelected,
headerHeight,
stateIsDirty,
lastSelectedNodeOutputIndex,
activeCredentialType,
lastSelectedNode,
selectedNodes,
bannersHeight,
lastSelectedNodeEndpointUuid,
lastInteractedWithNodeConnection,
lastInteractedWithNodeHandle,
lastInteractedWithNodeId,
lastInteractedWithNode,
lastCancelledConnectionPosition,
nodeViewOffsetPosition,
nodeViewMoveInProgress,
nodeViewInitialized,
addFirstStepOnLoad,
sidebarMenuCollapsed,
@@ -686,17 +562,10 @@ export const useUIStore = defineStore(STORES.UI, () => {
activeModals,
isProcessingExecutionResults,
setTheme,
setMode,
setActiveId,
setShowAuthSelector,
setModalData,
openModalWithData,
openModal,
closeModal,
draggableStartDragging,
draggableStopDragging,
setDraggableStickyPos,
setDraggableCanDrop,
openDeleteUserModal,
openExistingCredential,
openNewCredential,
@@ -705,18 +574,12 @@ export const useUIStore = defineStore(STORES.UI, () => {
openCommunityPackageUpdateConfirmModal,
addActiveAction,
removeActiveAction,
addSelectedNode,
removeNodeFromSelection,
resetSelectedNodes,
setCurlCommand,
toggleSidebarMenuCollapse,
removeBannerFromStack,
dismissBanner,
updateBannersHeight,
pushBannerToStack,
clearBannerStack,
setNotificationsForView,
deleteNotificationsForView,
resetLastInteractedWith,
setProcessingExecutionResults,
openDeleteFolderModal,