From ec62dd1b3f65ad433e43e432f046b0e7fbdc9a31 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Wed, 1 Nov 2023 12:41:10 -0400 Subject: [PATCH 1/3] Port TreeView to redux-toolkit --- src/components/DataEntry/index.tsx | 11 +- src/components/DataEntry/tests/index.test.tsx | 11 +- src/components/ProjectScreen/index.tsx | 4 +- .../TreeView/Redux/TreeViewActions.ts | 67 ++++++------ .../TreeView/Redux/TreeViewReducer.ts | 70 ++++++------ .../TreeView/Redux/TreeViewReduxTypes.tsx | 14 --- .../Redux/tests/TreeViewActions.test.tsx | 100 +++++++++++------- .../Redux/tests/TreeViewReducer.test.tsx | 62 ----------- src/components/TreeView/index.tsx | 4 +- src/rootReducer.ts | 2 +- 10 files changed, 136 insertions(+), 209 deletions(-) delete mode 100644 src/components/TreeView/Redux/tests/TreeViewReducer.test.tsx diff --git a/src/components/DataEntry/index.tsx b/src/components/DataEntry/index.tsx index 6b37c8e8d0..68f157f849 100644 --- a/src/components/DataEntry/index.tsx +++ b/src/components/DataEntry/index.tsx @@ -15,10 +15,7 @@ import DataEntryTable from "components/DataEntry/DataEntryTable"; import ExistingDataTable from "components/DataEntry/ExistingDataTable"; import { filterWordsByDomain } from "components/DataEntry/utilities"; import TreeView from "components/TreeView"; -import { - closeTreeAction, - openTreeAction, -} from "components/TreeView/Redux/TreeViewActions"; +import { closeTree, openTree } from "components/TreeView/Redux/TreeViewActions"; import { StoreState } from "types"; import { useAppDispatch, useAppSelector } from "types/hooks"; import { newSemanticDomain } from "types/semanticDomain"; @@ -73,7 +70,7 @@ export default function DataEntry(): ReactElement { // On first render, open tree. useLayoutEffect(() => { - dispatch(openTreeAction()); + dispatch(openTree()); }, [dispatch]); // When window width changes, check if there's space for the sidebar. @@ -99,7 +96,7 @@ export default function DataEntry(): ReactElement { setDomainWords( filterWordsByDomain(await getFrontierWords(), id, analysisLang) ); - dispatch(closeTreeAction()); + dispatch(closeTree()); }, [analysisLang, dispatch, id]); return ( @@ -116,7 +113,7 @@ export default function DataEntry(): ReactElement { hasDrawerButton={isSmallScreen && domainWords.length > 0} hideQuestions={() => setQuestionsVisible(false)} isTreeOpen={open} - openTree={() => dispatch(openTreeAction())} + openTree={() => dispatch(openTree())} semanticDomain={currentDomain} showExistingData={() => setDrawerOpen(true)} updateHeight={updateHeight} diff --git a/src/components/DataEntry/tests/index.test.tsx b/src/components/DataEntry/tests/index.test.tsx index 85a4ec1aff..a459dc7ef9 100644 --- a/src/components/DataEntry/tests/index.test.tsx +++ b/src/components/DataEntry/tests/index.test.tsx @@ -9,11 +9,8 @@ import DataEntry, { treeViewDialogId, } from "components/DataEntry"; import { defaultState as currentProjectState } from "components/Project/ProjectReduxTypes"; -import { openTreeAction } from "components/TreeView/Redux/TreeViewActions"; -import { - TreeViewAction, - TreeViewState, -} from "components/TreeView/Redux/TreeViewReduxTypes"; +import { openTree } from "components/TreeView/Redux/TreeViewActions"; +import { TreeViewState } from "components/TreeView/Redux/TreeViewReduxTypes"; import { newSemanticDomainTreeNode } from "types/semanticDomain"; import * as useWindowSize from "utilities/useWindowSize"; @@ -39,7 +36,7 @@ jest.mock("types/hooks", () => { }; }); -const mockDispatch = jest.fn((action: TreeViewAction) => action); +const mockDispatch = jest.fn((action: any) => action); const mockDomain = newSemanticDomainTreeNode("mockId", "mockName", "mockLang"); const mockGetSemanticDomainFull = jest.fn(); const mockStore = createMockStore(); @@ -72,7 +69,7 @@ describe("DataEntry", () => { it("dispatches to open the tree", async () => { await renderDataEntry({ currentDomain: mockDomain }); - expect(mockDispatch).toHaveBeenCalledWith(openTreeAction()); + expect(mockDispatch).toHaveBeenCalledWith(openTree()); }); it("fetches domain", async () => { diff --git a/src/components/ProjectScreen/index.tsx b/src/components/ProjectScreen/index.tsx index 67af430b19..363b8d88d2 100644 --- a/src/components/ProjectScreen/index.tsx +++ b/src/components/ProjectScreen/index.tsx @@ -4,7 +4,7 @@ import { ReactElement, useEffect } from "react"; import { clearCurrentProject } from "components/Project/ProjectActions"; import ChooseProject from "components/ProjectScreen/ChooseProject"; import CreateProject from "components/ProjectScreen/CreateProject"; -import { resetTreeAction } from "components/TreeView/Redux/TreeViewActions"; +import { resetTree } from "components/TreeView/Redux/TreeViewActions"; import { useAppDispatch } from "types/hooks"; /** Where users create a project or choose an existing one */ @@ -13,7 +13,7 @@ export default function ProjectScreen(): ReactElement { /* Disable Data Entry, Data Cleanup, Project Settings until a project is selected or created. */ useEffect(() => { dispatch(clearCurrentProject()); - dispatch(resetTreeAction()); + dispatch(resetTree()); }, [dispatch]); return ( diff --git a/src/components/TreeView/Redux/TreeViewActions.ts b/src/components/TreeView/Redux/TreeViewActions.ts index 808adf7b83..ec9b82d199 100644 --- a/src/components/TreeView/Redux/TreeViewActions.ts +++ b/src/components/TreeView/Redux/TreeViewActions.ts @@ -1,60 +1,57 @@ +import { Action, PayloadAction } from "@reduxjs/toolkit"; + import { SemanticDomain, SemanticDomainTreeNode } from "api/models"; import { getSemanticDomainTreeNode } from "backend"; import { - TreeActionType, - TreeViewAction, -} from "components/TreeView/Redux/TreeViewReduxTypes"; + resetAction, + setCurrentDomainAction, + setDomainLanguageAction, + setTreeOpenAction, +} from "components/TreeView/Redux/TreeViewReducer"; import { StoreState } from "types"; import { StoreStateDispatch } from "types/Redux/actions"; -export function closeTreeAction(): TreeViewAction { - return { type: TreeActionType.CLOSE_TREE }; +// Action Creation Functions + +export function closeTree(): PayloadAction { + return setTreeOpenAction(false); } -export function openTreeAction(): TreeViewAction { - return { type: TreeActionType.OPEN_TREE }; +export function openTree(): PayloadAction { + return setTreeOpenAction(true); } -export function setDomainAction( - domain: SemanticDomainTreeNode -): TreeViewAction { - return { type: TreeActionType.SET_CURRENT_DOMAIN, domain }; +export function resetTree(): Action { + return resetAction(); } -export function setDomainLanguageAction(language: string): TreeViewAction { - return { type: TreeActionType.SET_DOMAIN_LANGUAGE, language }; +export function setCurrentDomain( + domain: SemanticDomainTreeNode +): PayloadAction { + return setCurrentDomainAction(domain); } -export function resetTreeAction(): TreeViewAction { - return { type: TreeActionType.RESET_TREE }; +export function setDomainLanguage(language: string): PayloadAction { + return setDomainLanguageAction(language); } +// Dispatch Functions + export function traverseTree(domain: SemanticDomain) { return async (dispatch: StoreStateDispatch) => { - if (domain) { - await getSemanticDomainTreeNode(domain.id, domain.lang).then( - (response) => { - if (response) { - dispatch(setDomainAction(response)); - } - } - ); - } - }; -} - -export function updateTreeLanguage(language: string) { - return (dispatch: StoreStateDispatch) => { - if (language) { - dispatch(setDomainLanguageAction(language)); + if (domain.id) { + const dom = await getSemanticDomainTreeNode(domain.id, domain.lang); + if (dom) { + dispatch(setCurrentDomain(dom)); + } } }; } -export function initTreeDomain(language = "") { +export function initTreeDomain(lang = "") { return async (dispatch: StoreStateDispatch, getState: () => StoreState) => { - const currentDomain = getState().treeViewState.currentDomain; - currentDomain.lang = language; - await dispatch(traverseTree(currentDomain)); + await dispatch( + traverseTree({ ...getState().treeViewState.currentDomain, lang }) + ); }; } diff --git a/src/components/TreeView/Redux/TreeViewReducer.ts b/src/components/TreeView/Redux/TreeViewReducer.ts index 148fa5c314..c67a1a21a9 100644 --- a/src/components/TreeView/Redux/TreeViewReducer.ts +++ b/src/components/TreeView/Redux/TreeViewReducer.ts @@ -1,39 +1,33 @@ -import { - TreeViewAction, - TreeActionType, - TreeViewState, - defaultState, -} from "components/TreeView/Redux/TreeViewReduxTypes"; -import { StoreAction, StoreActionTypes } from "rootActions"; +import { createSlice } from "@reduxjs/toolkit"; -export const treeViewReducer = ( - state: TreeViewState = defaultState, - action: StoreAction | TreeViewAction -): TreeViewState => { - switch (action.type) { - case TreeActionType.CLOSE_TREE: - return { ...state, open: false }; - case TreeActionType.OPEN_TREE: - return { ...state, open: true }; - case TreeActionType.RESET_TREE: - return defaultState; - case TreeActionType.SET_DOMAIN_LANGUAGE: - if (!action.language) { - throw new Error("Cannot set domain language to undefined."); - } - return { - ...state, - currentDomain: { ...state.currentDomain, lang: action.language }, - language: action.language, - }; - case TreeActionType.SET_CURRENT_DOMAIN: - if (!action.domain) { - throw new Error("Cannot set the current domain to undefined."); - } - return { ...state, currentDomain: action.domain }; - case StoreActionTypes.RESET: - return defaultState; - default: - return state; - } -}; +import { defaultState } from "components/TreeView/Redux/TreeViewReduxTypes"; +import { StoreActionTypes } from "rootActions"; + +const treeViewSlice = createSlice({ + name: "treeViewState", + initialState: defaultState, + reducers: { + resetAction: () => defaultState, + setCurrentDomainAction: (state, action) => { + state.currentDomain = action.payload; + }, + setDomainLanguageAction: (state, action) => { + state.currentDomain.lang = action.payload; + state.language = action.payload; + }, + setTreeOpenAction: (state, action) => { + state.open = action.payload; + }, + }, + extraReducers: (builder) => + builder.addCase(StoreActionTypes.RESET, () => defaultState), +}); + +export const { + resetAction, + setCurrentDomainAction, + setDomainLanguageAction, + setTreeOpenAction, +} = treeViewSlice.actions; + +export default treeViewSlice.reducer; diff --git a/src/components/TreeView/Redux/TreeViewReduxTypes.tsx b/src/components/TreeView/Redux/TreeViewReduxTypes.tsx index b210d50f51..922a2e62b8 100644 --- a/src/components/TreeView/Redux/TreeViewReduxTypes.tsx +++ b/src/components/TreeView/Redux/TreeViewReduxTypes.tsx @@ -1,20 +1,6 @@ import { SemanticDomainTreeNode } from "api/models"; import { newSemanticDomainTreeNode } from "types/semanticDomain"; -export enum TreeActionType { - CLOSE_TREE = "CLOSE_TREE", - OPEN_TREE = "OPEN_TREE", - RESET_TREE = "RESET_TREE", - SET_DOMAIN_LANGUAGE = "SET_DOMAIN_LANGUAGE", - SET_CURRENT_DOMAIN = "SET_CURRENT_DOMAIN", -} - -export interface TreeViewAction { - type: TreeActionType; - domain?: SemanticDomainTreeNode; - language?: string; -} - export interface TreeViewState { currentDomain: SemanticDomainTreeNode; language: string; diff --git a/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx b/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx index d00025db16..7ea3769b8c 100644 --- a/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx +++ b/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx @@ -1,19 +1,19 @@ -import configureMockStore from "redux-mock-store"; -import thunk from "redux-thunk"; +import { PreloadedState } from "redux"; +import { defaultState } from "components/App/DefaultState"; import { - setDomainLanguageAction, + initTreeDomain, + setDomainLanguage, traverseTree, } from "components/TreeView/Redux/TreeViewActions"; +import { RootState, setupStore } from "store"; import { - defaultState, - TreeActionType, -} from "components/TreeView/Redux/TreeViewReduxTypes"; -import { newSemanticDomainTreeNode } from "types/semanticDomain"; + newSemanticDomain, + newSemanticDomainTreeNode, +} from "types/semanticDomain"; jest.mock("backend", () => ({ - getSemanticDomainTreeNode: (id: string, lang: string) => - mockGetSemDomTreeNode(id, lang), + getSemanticDomainTreeNode: (...args: any[]) => mockGetSemDomTreeNode(...args), })); const mockGetSemDomTreeNode = jest.fn(); @@ -21,41 +21,59 @@ const mockGetSemDomTreeNode = jest.fn(); // Mock the track and identify methods of segment analytics. global.analytics = { identify: jest.fn(), track: jest.fn() } as any; -const createMockStore = configureMockStore([thunk]); -const mockState = defaultState; - -describe("TraverseTreeAction", () => { - it("SetDomainLanguage returns correct action", async () => { - const language = "lang"; - const action = { - type: TreeActionType.SET_DOMAIN_LANGUAGE, - language, - }; - const mockStore = createMockStore(mockState); - await mockStore.dispatch(setDomainLanguageAction("lang")); - expect(mockStore.getActions()).toEqual([action]); - }); +const mockId = "id"; +const mockLang = "lang"; + +// Preloaded values for store when testing +const persistedDefaultState: PreloadedState = { + ...defaultState, + _persist: { version: 1, rehydrated: false }, +}; - it("TraverseTreeAction dispatches on successful", async () => { - const mockDomainReturned = newSemanticDomainTreeNode("id", "name"); - mockGetSemDomTreeNode.mockResolvedValue(mockDomainReturned); - const domain = { id: "id", name: "name", guid: "", lang: "" }; - const action = { - type: TreeActionType.SET_CURRENT_DOMAIN, - domain: mockDomainReturned, - }; - const mockStore = createMockStore(mockState); - - await mockStore.dispatch(traverseTree(domain)); - expect(mockStore.getActions()).toEqual([action]); +describe("TreeViewActions", () => { + describe("setDomainLanguage", () => { + it("correctly affects state", async () => { + const store = setupStore(); + store.dispatch(setDomainLanguage(mockLang)); + const { currentDomain, language } = store.getState().treeViewState; + expect(currentDomain.lang).toEqual(mockLang); + expect(language).toEqual(mockLang); + }); }); - it("TraverseTreeAction does not dispatch on null return", async () => { - mockGetSemDomTreeNode.mockResolvedValue(undefined); - const domain = { id: "id", name: "name", guid: "", lang: "" }; - const mockStore = createMockStore(mockState); + describe("traverseTree", () => { + it("dispatches on successful", async () => { + const store = setupStore(); + const dom = newSemanticDomain("id"); + mockGetSemDomTreeNode.mockResolvedValue(dom); + await store.dispatch(traverseTree(dom)); + const { currentDomain } = store.getState().treeViewState; + expect(currentDomain.id).toEqual(dom.id); + }); + + it("does not dispatch on undefined", async () => { + const store = setupStore(); + mockGetSemDomTreeNode.mockResolvedValue(undefined); + const dom = newSemanticDomain("id"); + await store.dispatch(traverseTree(dom)); + const { currentDomain } = store.getState().treeViewState; + expect(currentDomain.id).not.toEqual(dom.id); + }); + }); - await mockStore.dispatch(traverseTree(domain)); - expect(mockStore.getActions()).toEqual([]); + describe("initTreeDomain", () => { + it("changes domain lang but not id", async () => { + const nonDefaultState = { + currentDomain: newSemanticDomainTreeNode(mockId), + language: "", + open: true, + }; + const store = setupStore({ + ...persistedDefaultState, + treeViewState: nonDefaultState, + }); + await store.dispatch(initTreeDomain(mockLang)); + expect(mockGetSemDomTreeNode).toBeCalledWith(mockId, mockLang); + }); }); }); diff --git a/src/components/TreeView/Redux/tests/TreeViewReducer.test.tsx b/src/components/TreeView/Redux/tests/TreeViewReducer.test.tsx deleted file mode 100644 index 58b03da1f7..0000000000 --- a/src/components/TreeView/Redux/tests/TreeViewReducer.test.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { treeViewReducer } from "components/TreeView/Redux/TreeViewReducer"; -import { - defaultState, - TreeActionType, - TreeViewAction, - TreeViewState, -} from "components/TreeView/Redux/TreeViewReduxTypes"; -import { StoreAction, StoreActionTypes } from "rootActions"; -import { newSemanticDomainTreeNode } from "types/semanticDomain"; - -describe("Test the TreeViewReducer", () => { - it("Returns defaultState when passed undefined", () => { - expect(treeViewReducer(undefined, {} as TreeViewAction)).toEqual( - defaultState - ); - }); - - it("Returns default state when tree reset action is passed", () => { - const action: TreeViewAction = { type: TreeActionType.RESET_TREE }; - expect(treeViewReducer({} as TreeViewState, action)).toEqual(defaultState); - }); - - it("Returns default state when store reset action is passed", () => { - const action: StoreAction = { type: StoreActionTypes.RESET }; - expect(treeViewReducer({} as TreeViewState, action)).toEqual(defaultState); - }); - - it("Returns state passed in when passed an invalid action", () => { - const badAction = { type: "Nothing" } as any as TreeViewAction; - expect(treeViewReducer({ ...defaultState, open: true }, badAction)).toEqual( - { ...defaultState, open: true } - ); - }); - - it("Closes the tree when requested", () => { - expect( - treeViewReducer( - { ...defaultState, open: true }, - { type: TreeActionType.CLOSE_TREE } - ) - ).toEqual({ ...defaultState, open: false }); - }); - - it("Opens the tree when requested", () => { - expect( - treeViewReducer( - { ...defaultState, open: false }, - { type: TreeActionType.OPEN_TREE } - ) - ).toEqual({ ...defaultState, open: true }); - }); - - it("Returns state with a new SemanticDomain when requested to change this value", () => { - const payload = newSemanticDomainTreeNode("testId", "testName"); - expect( - treeViewReducer(defaultState, { - type: TreeActionType.SET_CURRENT_DOMAIN, - domain: payload, - }) - ).toEqual({ ...defaultState, currentDomain: payload }); - }); -}); diff --git a/src/components/TreeView/index.tsx b/src/components/TreeView/index.tsx index 09602f8d7f..1527363fcf 100644 --- a/src/components/TreeView/index.tsx +++ b/src/components/TreeView/index.tsx @@ -9,8 +9,8 @@ import { SemanticDomain, WritingSystem } from "api"; import { IconButtonWithTooltip } from "components/Buttons"; import { initTreeDomain, + setDomainLanguage, traverseTree, - updateTreeLanguage, } from "components/TreeView/Redux/TreeViewActions"; import { defaultTreeNode } from "components/TreeView/Redux/TreeViewReduxTypes"; import TreeDepiction from "components/TreeView/TreeDepiction"; @@ -57,7 +57,7 @@ export default function TreeView(props: TreeViewProps): ReactElement { const newLang = getSemDomWritingSystem(semDomWritingSystem)?.bcp47 ?? resolvedLanguage; if (newLang && newLang !== semDomLanguage) { - dispatch(updateTreeLanguage(newLang)); + dispatch(setDomainLanguage(newLang)); } dispatch(initTreeDomain(newLang)); }, [semDomLanguage, semDomWritingSystem, dispatch, resolvedLanguage]); diff --git a/src/rootReducer.ts b/src/rootReducer.ts index b0863ed7f0..747da60da4 100644 --- a/src/rootReducer.ts +++ b/src/rootReducer.ts @@ -5,7 +5,7 @@ import { loginReducer } from "components/Login/Redux/LoginReducer"; import { projectReducer } from "components/Project/ProjectReducer"; import exportProjectReducer from "components/ProjectExport/Redux/ExportProjectReducer"; import { pronunciationsReducer } from "components/Pronunciations/Redux/PronunciationsReducer"; -import { treeViewReducer } from "components/TreeView/Redux/TreeViewReducer"; +import treeViewReducer from "components/TreeView/Redux/TreeViewReducer"; import { characterInventoryReducer } from "goals/CharacterInventory/Redux/CharacterInventoryReducer"; import { mergeDupStepReducer } from "goals/MergeDuplicates/Redux/MergeDupsReducer"; import { reviewEntriesReducer } from "goals/ReviewEntries/ReviewEntriesComponent/Redux/ReviewEntriesReducer"; From 6b84ee5af5fa711314cf32570d91a7c5b18b20d2 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Wed, 1 Nov 2023 12:47:23 -0400 Subject: [PATCH 2/3] Tidy --- .../TreeView/Redux/tests/TreeViewActions.test.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx b/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx index 7ea3769b8c..19eebad99b 100644 --- a/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx +++ b/src/components/TreeView/Redux/tests/TreeViewActions.test.tsx @@ -44,20 +44,19 @@ describe("TreeViewActions", () => { describe("traverseTree", () => { it("dispatches on successful", async () => { const store = setupStore(); - const dom = newSemanticDomain("id"); + const dom = newSemanticDomain(mockId); mockGetSemDomTreeNode.mockResolvedValue(dom); await store.dispatch(traverseTree(dom)); const { currentDomain } = store.getState().treeViewState; - expect(currentDomain.id).toEqual(dom.id); + expect(currentDomain.id).toEqual(mockId); }); it("does not dispatch on undefined", async () => { const store = setupStore(); mockGetSemDomTreeNode.mockResolvedValue(undefined); - const dom = newSemanticDomain("id"); - await store.dispatch(traverseTree(dom)); + await store.dispatch(traverseTree(newSemanticDomain(mockId))); const { currentDomain } = store.getState().treeViewState; - expect(currentDomain.id).not.toEqual(dom.id); + expect(currentDomain.id).not.toEqual(mockId); }); }); From d59330056766890b7b7dd614a070d8156cbdbab9 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Wed, 8 Nov 2023 11:26:42 -0500 Subject: [PATCH 3/3] Rename resetAction -> resetTreeAction --- src/components/TreeView/Redux/TreeViewActions.ts | 4 ++-- src/components/TreeView/Redux/TreeViewReducer.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/TreeView/Redux/TreeViewActions.ts b/src/components/TreeView/Redux/TreeViewActions.ts index ec9b82d199..f193907f47 100644 --- a/src/components/TreeView/Redux/TreeViewActions.ts +++ b/src/components/TreeView/Redux/TreeViewActions.ts @@ -3,7 +3,7 @@ import { Action, PayloadAction } from "@reduxjs/toolkit"; import { SemanticDomain, SemanticDomainTreeNode } from "api/models"; import { getSemanticDomainTreeNode } from "backend"; import { - resetAction, + resetTreeAction, setCurrentDomainAction, setDomainLanguageAction, setTreeOpenAction, @@ -22,7 +22,7 @@ export function openTree(): PayloadAction { } export function resetTree(): Action { - return resetAction(); + return resetTreeAction(); } export function setCurrentDomain( diff --git a/src/components/TreeView/Redux/TreeViewReducer.ts b/src/components/TreeView/Redux/TreeViewReducer.ts index c67a1a21a9..8de4cdedb7 100644 --- a/src/components/TreeView/Redux/TreeViewReducer.ts +++ b/src/components/TreeView/Redux/TreeViewReducer.ts @@ -7,7 +7,7 @@ const treeViewSlice = createSlice({ name: "treeViewState", initialState: defaultState, reducers: { - resetAction: () => defaultState, + resetTreeAction: () => defaultState, setCurrentDomainAction: (state, action) => { state.currentDomain = action.payload; }, @@ -24,7 +24,7 @@ const treeViewSlice = createSlice({ }); export const { - resetAction, + resetTreeAction, setCurrentDomainAction, setDomainLanguageAction, setTreeOpenAction,