Skip to content

Commit

Permalink
Consolidate root Redux elements (#3054)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Jun 12, 2024
1 parent b75ccd0 commit 8ca63d9
Show file tree
Hide file tree
Showing 109 changed files with 255 additions and 219 deletions.
4 changes: 2 additions & 2 deletions docs/style_guide/ts_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ function Component(props: { name: string }) {
**Good**

```ts
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";

function Component(): ReactElement {
const dispatch = useAppDispatch();
Expand Down
4 changes: 2 additions & 2 deletions src/components/AnnouncementBanner/AnnouncementBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { BannerType } from "api/models";
import { getBannerText } from "backend";
import { getClosedBanner, setClosedBanner } from "backend/localStorage";
import { topBarHeight } from "components/LandingPage/TopBar";
import { StoreState } from "types";
import { useAppSelector } from "types/hooks";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Path } from "types/path";
import theme, { themeColors } from "types/theme";

Expand Down
4 changes: 2 additions & 2 deletions src/components/App/AppLoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Statistics from "components/Statistics/Statistics";
import UserSettings from "components/UserSettings/UserSettings";
import NextGoalScreen from "goals/DefaultGoal/NextGoalScreen";
import { updateLangFromUser } from "i18n";
import { StoreState } from "types";
import { useAppSelector } from "types/hooks";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Path } from "types/path";
import FontContext, { ProjectFonts } from "utilities/fontContext";
import { getProjCss } from "utilities/fontCssUtilities";
Expand Down
4 changes: 2 additions & 2 deletions src/components/App/SignalRHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
success,
} from "components/ProjectExport/Redux/ExportProjectActions";
import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";

/** A central hub for monitoring export status on SignalR */
export default function SignalRHub(): ReactElement {
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppBar/NavigationButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
buttonMinHeight,
tabColor,
} from "components/AppBar/AppBarTypes";
import { StoreState } from "types";
import { useAppSelector } from "types/hooks";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Path } from "types/path";
import { useWindowSize } from "utilities/useWindowSize";

Expand Down
2 changes: 1 addition & 1 deletion src/components/AppBar/ProjectButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
tabColor,
} from "components/AppBar/AppBarTypes";
import SpeakerMenu from "components/AppBar/SpeakerMenu";
import { StoreState } from "types";
import { type StoreState } from "rootRedux/types";
import { GoalStatus, GoalType } from "types/goals";
import { Path } from "types/path";

Expand Down
4 changes: 2 additions & 2 deletions src/components/AppBar/SpeakerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { type Speaker } from "api/models";
import { getAllSpeakers } from "backend";
import { buttonMinHeight } from "components/AppBar/AppBarTypes";
import { setCurrentSpeaker } from "components/Project/ProjectActions";
import { type StoreState } from "types";
import { useAppDispatch } from "types/hooks";
import { useAppDispatch } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { themeColors } from "types/theme";

const idAffix = "speaker-menu";
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppBar/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
tabColor,
} from "components/AppBar/AppBarTypes";
import { clearCurrentProject } from "components/Project/ProjectActions";
import { useAppDispatch } from "types/hooks";
import { useAppDispatch } from "rootRedux/hooks";
import { Path } from "types/path";
import { RuntimeConfig } from "types/runtimeConfig";
import { openUserGuide } from "utilities/pathUtilities";
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppBar/tests/SpeakerMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import configureMockStore from "redux-mock-store";
import { Speaker } from "api/models";
import SpeakerMenu, { SpeakerMenuList } from "components/AppBar/SpeakerMenu";
import { defaultState } from "components/Project/ProjectReduxTypes";
import { StoreState } from "types";
import { type StoreState } from "rootRedux/types";
import { randomSpeaker } from "types/project";

jest.mock("backend", () => ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataEntry/DataEntryTable/NewEntry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import SenseDialog from "components/DataEntry/DataEntryTable/NewEntry/SenseDialog";
import VernDialog from "components/DataEntry/DataEntryTable/NewEntry/VernDialog";
import PronunciationsFrontend from "components/Pronunciations/PronunciationsFrontend";
import { StoreState } from "types";
import { type StoreState } from "rootRedux/types";
import theme from "types/theme";
import { FileWithSpeakerId } from "types/word";

Expand Down
6 changes: 3 additions & 3 deletions src/components/DataEntry/DataEntryTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import NewEntry from "components/DataEntry/DataEntryTable/NewEntry";
import RecentEntry from "components/DataEntry/DataEntryTable/RecentEntry";
import { filterWordsWithSenses } from "components/DataEntry/utilities";
import { uploadFileFromPronunciation } from "components/Pronunciations/utilities";
import { StoreState } from "types";
import { Hash } from "types/hash";
import { useAppSelector } from "types/hooks";
import { useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { type Hash } from "types/hash";
import theme from "types/theme";
import {
FileWithSpeakerId,
Expand Down
4 changes: 2 additions & 2 deletions src/components/DataEntry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import ExistingDataTable from "components/DataEntry/ExistingDataTable";
import { filterWordsByDomain } from "components/DataEntry/utilities";
import TreeView from "components/TreeView";
import { closeTree, openTree } from "components/TreeView/Redux/TreeViewActions";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { newSemanticDomain } from "types/semanticDomain";
import theme from "types/theme";
import { DomainWord } from "types/word";
Expand Down
4 changes: 2 additions & 2 deletions src/components/DataEntry/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jest.mock("backend", () => ({
jest.mock("components/AppBar/AppBarComponent", () => "div");
jest.mock("components/DataEntry/DataEntryTable", () => "div");
jest.mock("components/TreeView", () => "div");
jest.mock("types/hooks", () => {
jest.mock("rootRedux/hooks", () => {
return {
...jest.requireActual("types/hooks"),
...jest.requireActual("rootRedux/hooks"),
useAppDispatch: () => mockDispatch,
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/GoalTimeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { useTranslation } from "react-i18next";
import { getCurrentPermissions, getGraylistEntries } from "backend";
import GoalList from "components/GoalTimeline/GoalList";
import { asyncAddGoal, asyncGetUserEdits } from "goals/Redux/GoalActions";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Goal, GoalType } from "types/goals";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { requiredPermission, goalTypeToGoal } from "utilities/goalUtilities";
import { useWindowSize } from "utilities/useWindowSize";

Expand Down
2 changes: 1 addition & 1 deletion src/components/GoalTimeline/tests/GoalRedux.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
asyncUpdateGoal,
setCurrentGoal,
} from "goals/Redux/GoalActions";
import { setupStore } from "store";
import { setupStore } from "rootRedux/store";
import { GoalStatus, GoalType } from "types/goals";
import { Path } from "types/path";
import { newUser } from "types/user";
Expand Down
4 changes: 2 additions & 2 deletions src/components/GoalTimeline/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jest.mock("goals/Redux/GoalActions", () => ({
asyncGetUserEdits: () => jest.fn(),
}));
jest.mock("components/Project/ProjectActions", () => ({}));
jest.mock("types/hooks", () => {
jest.mock("rootRedux/hooks", () => {
return {
...jest.requireActual("types/hooks"),
...jest.requireActual("rootRedux/hooks"),
useAppDispatch: () => jest.fn(),
};
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import { LoadingButton } from "components/Buttons";
import Captcha from "components/Login/Captcha";
import { asyncLogIn } from "components/Login/Redux/LoginActions";
import { LoginStatus } from "components/Login/Redux/LoginReduxTypes";
import { reset } from "rootActions";
import { reset } from "rootRedux/actions";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import router from "router/browserRouter";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { Path } from "types/path";
import { RuntimeConfig } from "types/runtimeConfig";
import theme from "types/theme";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Redux/LoginActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
setSignupFailureAction,
setSignupSuccessAction,
} from "components/Login/Redux/LoginReducer";
import { type StoreStateDispatch } from "rootRedux/types";
import router from "router/browserRouter";
import { StoreStateDispatch } from "types/Redux/actions";
import { Path } from "types/path";
import { newUser } from "types/user";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Redux/LoginReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
LoginStatus,
defaultState,
} from "components/Login/Redux/LoginReduxTypes";
import { StoreActionTypes } from "rootActions";
import { StoreActionTypes } from "rootRedux/actions";

const loginSlice = createSlice({
name: "loginState",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Redux/tests/LoginActions.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { User } from "api/models";
import { asyncLogIn, asyncSignUp } from "components/Login/Redux/LoginActions";
import { LoginStatus } from "components/Login/Redux/LoginReduxTypes";
import { setupStore } from "store";
import { setupStore } from "rootRedux/store";
import { newUser } from "types/user";

jest.mock("backend", () => ({
Expand Down
6 changes: 3 additions & 3 deletions src/components/Login/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import { LoadingDoneButton } from "components/Buttons";
import Captcha from "components/Login/Captcha";
import { asyncSignUp } from "components/Login/Redux/LoginActions";
import { LoginStatus } from "components/Login/Redux/LoginReduxTypes";
import { reset } from "rootActions";
import { reset } from "rootRedux/actions";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import router from "router/browserRouter";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { Path } from "types/path";
import { RuntimeConfig } from "types/runtimeConfig";
import {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Login/tests/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jest.mock("components/Login/Redux/LoginActions", () => ({
asyncLogIn: (...args: any[]) => mockAsyncLogIn(...args),
}));
jest.mock("router/browserRouter");
jest.mock("types/hooks", () => {
jest.mock("rootRedux/hooks", () => {
return {
...jest.requireActual("types/hooks"),
...jest.requireActual("rootRedux/hooks"),
useAppDispatch: () => jest.fn(),
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Login/tests/Signup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jest.mock("components/Login/Redux/LoginActions", () => ({
asyncSignUp: (...args: any[]) => mockAsyncSignUp(...args),
}));
jest.mock("router/browserRouter");
jest.mock("types/hooks", () => {
jest.mock("rootRedux/hooks", () => {
return {
...jest.requireActual("types/hooks"),
...jest.requireActual("rootRedux/hooks"),
useAppDispatch: () => jest.fn(),
};
});
Expand Down
3 changes: 1 addition & 2 deletions src/components/Project/ProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
setUsersAction,
} from "components/Project/ProjectReducer";
import i18n from "i18n";
import { type StoreState } from "types";
import { type StoreStateDispatch } from "types/Redux/actions";
import { type StoreState, type StoreStateDispatch } from "rootRedux/types";
import { type Hash } from "types/hash";
import { newProject } from "types/project";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Project/ProjectReducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";

import { defaultState } from "components/Project/ProjectReduxTypes";
import { StoreActionTypes } from "rootActions";
import { StoreActionTypes } from "rootRedux/actions";

const projectSlice = createSlice({
name: "currentProjectState",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Project/tests/ProjectActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
clearCurrentProject,
} from "components/Project/ProjectActions";
import { defaultState as currentProjectState } from "components/Project/ProjectReduxTypes";
import { type RootState, setupStore } from "store";
import { type RootState, setupStore } from "rootRedux/store";
import { newProject } from "types/project";
import { newUser } from "types/user";

Expand Down
4 changes: 2 additions & 2 deletions src/components/ProjectExport/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
asyncResetExport,
} from "components/ProjectExport/Redux/ExportProjectActions";
import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { themeColors } from "types/theme";
import { getDateTimeString } from "utilities/utilities";

Expand Down
4 changes: 2 additions & 2 deletions src/components/ProjectExport/ExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { isFrontierNonempty } from "backend";
import { LoadingButton } from "components/Buttons";
import { asyncExportProject } from "components/ProjectExport/Redux/ExportProjectActions";
import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";

interface ExportButtonProps {
projectId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectExport/Redux/ExportProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
resetExportAction,
successAction,
} from "components/ProjectExport/Redux//ExportProjectReducer";
import { StoreStateDispatch } from "types/Redux/actions";
import { StoreStateDispatch } from "rootRedux/types";

// Action Creation Functions

Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectExport/Redux/ExportProjectReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
defaultState,
ExportStatus,
} from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { StoreActionTypes } from "rootActions";
import { StoreActionTypes } from "rootRedux/actions";

const exportProjectSlice = createSlice({
name: "exportProjectState",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
asyncResetExport,
} from "components/ProjectExport/Redux/ExportProjectActions";
import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes";
import { RootState, setupStore } from "store";
import { RootState, setupStore } from "rootRedux/store";

jest.mock("backend", () => ({
deleteLift: jest.fn,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/ChooseProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useNavigate } from "react-router-dom";
import { type Project } from "api/models";
import { getAllActiveProjects } from "backend";
import { asyncSetNewCurrentProject } from "components/Project/ProjectActions";
import { useAppDispatch } from "types/hooks";
import { useAppDispatch } from "rootRedux/hooks";
import { Path } from "types/path";

export default function ChooseProject(): ReactElement {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/CreateProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
asyncCreateProject,
asyncFinishProject,
} from "components/ProjectScreen/CreateProjectActions";
import { useAppDispatch } from "types/hooks";
import { useAppDispatch } from "rootRedux/hooks";
import theme from "types/theme";
import { newWritingSystem } from "types/writingSystem";

Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/CreateProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { type WritingSystem } from "api/models";
import { createProject, finishUploadLift, getProject } from "backend";
import { asyncSetNewCurrentProject } from "components/Project/ProjectActions";
import { asyncCreateUserEdits } from "goals/Redux/GoalActions";
import { type StoreStateDispatch } from "rootRedux/types";
import router from "router/browserRouter";
import { type StoreStateDispatch } from "types/Redux/actions";
import { Path } from "types/path";
import { newProject } from "types/project";

Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { clearCurrentProject } from "components/Project/ProjectActions";
import ChooseProject from "components/ProjectScreen/ChooseProject";
import CreateProject from "components/ProjectScreen/CreateProject";
import { resetTree } from "components/TreeView/Redux/TreeViewActions";
import { useAppDispatch } from "types/hooks";
import { useAppDispatch } from "rootRedux/hooks";

/** Where users create a project or choose an existing one */
export default function ProjectScreen(): ReactElement {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/tests/ChooseProject.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { randomIntString } from "utilities/utilities";
jest.mock("backend", () => ({
getAllActiveProjects: () => mockGetProjects(),
}));
jest.mock("types/hooks");
jest.mock("rootRedux/hooks");
jest.mock("react-router-dom", () => ({
useNavigate: jest.fn(),
}));
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ProjectScreen from "components/ProjectScreen";

jest.mock("components/ProjectScreen/ChooseProject", () => "div");
jest.mock("components/ProjectScreen/CreateProject", () => "div");
jest.mock("types/hooks", () => ({
jest.mock("rootRedux/hooks", () => ({
useAppDispatch: () => () => mockDispatch(),
}));

Expand Down
4 changes: 2 additions & 2 deletions src/components/ProjectSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import ProjectSelect from "components/ProjectSettings/ProjectSelect";
import ActiveProjectUsers from "components/ProjectUsers/ActiveProjectUsers";
import AddProjectUsers from "components/ProjectUsers/AddProjectUsers";
import ProjectSpeakersList from "components/ProjectUsers/ProjectSpeakersList";
import { type StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import { useAppDispatch, useAppSelector } from "rootRedux/hooks";
import { type StoreState } from "rootRedux/types";
import { Path } from "types/path";

export enum ProjectSettingsTab {
Expand Down
Loading

0 comments on commit 8ca63d9

Please sign in to comment.