Skip to content

Commit

Permalink
[MergeDups] Reorganize (#2366)
Browse files Browse the repository at this point in the history
* [MergeDups] Reorganize

* Make naming uniform

* Remove unnecessary useCallback
  • Loading branch information
imnasnainaec authored Jul 11, 2023
1 parent e238b16 commit 97e5a30
Show file tree
Hide file tree
Showing 37 changed files with 190 additions and 200 deletions.
2 changes: 1 addition & 1 deletion src/components/App/DefaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defaultState as createProjectState } from "components/ProjectScreen/Cre
import { defaultState as pronunciationsState } from "components/Pronunciations/Redux/PronunciationsReduxTypes";
import { defaultState as treeViewState } from "components/TreeView/Redux/TreeViewReduxTypes";
import { defaultState as characterInventoryState } from "goals/CharacterInventory/Redux/CharacterInventoryReducer";
import { defaultState as mergeDuplicateGoal } from "goals/MergeDupGoal/Redux/MergeDupReducer";
import { defaultState as mergeDuplicateGoal } from "goals/MergeDuplicates/Redux/MergeDupsReducer";
import { defaultState as reviewEntriesState } from "goals/ReviewEntries/ReviewEntriesComponent/Redux/ReviewEntriesReduxTypes";
import { defaultState as analyticsState } from "types/Redux/analyticsReduxTypes";

Expand Down
4 changes: 2 additions & 2 deletions src/components/GoalTimeline/GoalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { useTranslation } from "react-i18next";

import { CharInvChangesGoalList } from "goals/CharacterInventory/CharInvCompleted";
import { CharInvChanges } from "goals/CharacterInventory/CharacterInventoryTypes";
import { MergesCount } from "goals/MergeDupGoal/MergeDupComponent/MergeDupsCompleted";
import { MergesCompleted } from "goals/MergeDupGoal/MergeDupsTypes";
import { MergesCount } from "goals/MergeDuplicates/MergeDupsCompleted";
import { MergesCompleted } from "goals/MergeDuplicates/MergeDupsTypes";
import { Goal, GoalStatus, GoalType } from "types/goals";

type Orientation = "horizontal" | "vertical";
Expand Down
6 changes: 3 additions & 3 deletions src/components/GoalTimeline/Redux/GoalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
LoadUserEditsAction,
SetCurrentGoalAction,
} from "components/GoalTimeline/Redux/GoalReduxTypes";
import { MergeDupData } from "goals/MergeDupGoal/MergeDupsTypes";
import { MergeDupsData } from "goals/MergeDuplicates/MergeDupsTypes";
import {
dispatchMergeStepData,
loadMergeDupsData,
} from "goals/MergeDupGoal/Redux/MergeDupActions";
} from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { StoreState } from "types";
import { StoreStateDispatch } from "types/Redux/actions";
import { Goal, GoalStatus, GoalType } from "types/goals";
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function loadGoalData(goal: Goal): Promise<boolean> {
export function updateStepFromData(goal: Goal): boolean {
switch (goal.goalType) {
case GoalType.MergeDups:
const currentGoalData = goal.data as MergeDupData;
const currentGoalData = goal.data as MergeDupsData;
goal.steps[goal.currentStep] = {
words: currentGoalData.plannedWords[goal.currentStep],
};
Expand Down
26 changes: 12 additions & 14 deletions src/components/GoalTimeline/tests/GoalActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ import {
} from "components/GoalTimeline/Redux/GoalReduxTypes";
import { CreateCharInv } from "goals/CharacterInventory/CharacterInventoryTypes";
import { HandleFlags } from "goals/HandleFlags/HandleFlags";
import { MergeDups } from "goals/MergeDupGoal/MergeDups";
import { MergeDupData, MergeStepData } from "goals/MergeDupGoal/MergeDupsTypes";
import { goalDataMock } from "goals/MergeDupGoal/Redux/tests/MergeDupDataMock";
import {
MergeDups,
MergeDupsData,
MergeStepData,
} from "goals/MergeDuplicates/MergeDupsTypes";
import { goalDataMock } from "goals/MergeDuplicates/Redux/tests/MergeDupsDataMock";
import { Goal } from "types/goals";
import { newUser } from "types/user";
import { maxNumSteps } from "utilities/goalUtilities";

jest.mock("goals/MergeDupGoal/Redux/MergeDupActions", () => {
const realMergeDupActions = jest.requireActual(
"goals/MergeDupGoal/Redux/MergeDupActions"
);
return {
...realMergeDupActions,
dispatchMergeStepData: (goal: MergeDups) => mockDispatchMergeStepData(goal),
loadMergeDupsData: (goal: MergeDups) => mockLoadMergeDupsData(goal),
};
});
jest.mock("goals/MergeDuplicates/Redux/MergeDupsActions", () => ({
...jest.requireActual("goals/MergeDuplicates/Redux/MergeDupsActions"),
dispatchMergeStepData: (goal: MergeDups) => mockDispatchMergeStepData(goal),
loadMergeDupsData: (goal: MergeDups) => mockLoadMergeDupsData(goal),
}));

jest.mock("backend", () => ({
addGoalToUserEdit: (id: string, goal: Goal) =>
Expand Down Expand Up @@ -324,7 +322,7 @@ describe("GoalActions", () => {

actions.updateStepFromData(goal);
expect((goal.steps[0] as MergeStepData).words).toEqual(
(goal.data as MergeDupData).plannedWords[0]
(goal.data as MergeDupsData).plannedWords[0]
);
expect(goal.currentStep).toEqual(0);
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoalTimeline/tests/GoalReducer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "components/GoalTimeline/Redux/GoalReduxTypes";
import { CreateCharInv } from "goals/CharacterInventory/CharacterInventoryTypes";
import { HandleFlags } from "goals/HandleFlags/HandleFlags";
import { MergeDups } from "goals/MergeDupGoal/MergeDups";
import { MergeDups } from "goals/MergeDuplicates/MergeDupsTypes";
import { ReviewEntries } from "goals/ReviewEntries/ReviewEntries";
import { SpellCheckGloss } from "goals/SpellCheckGloss/SpellCheckGloss";
import { ValidateChars } from "goals/ValidateChars/ValidateChars";
Expand Down
4 changes: 2 additions & 2 deletions src/goals/DefaultGoal/BaseGoalScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { setCurrentGoal } from "components/GoalTimeline/Redux/GoalActions";
import PageNotFound from "components/PageNotFound/component";
import DisplayProgress from "goals/DefaultGoal/DisplayProgress";
import Loading from "goals/DefaultGoal/Loading";
import { clearTree } from "goals/MergeDupGoal/Redux/MergeDupActions";
import { clearTree } from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { clearReviewEntriesState } from "goals/ReviewEntries/ReviewEntriesComponent/Redux/ReviewEntriesActions";
import { StoreState } from "types";
import { Goal, GoalStatus, GoalType } from "types/goals";
import { useAppDispatch, useAppSelector } from "types/hooks";

const CharacterInventory = loadable(() => import("goals/CharacterInventory"));
const MergeDup = loadable(() => import("goals/MergeDupGoal/MergeDupComponent"));
const MergeDup = loadable(() => import("goals/MergeDuplicates"));
const ReviewEntriesComponent = loadable(
() => import("goals/ReviewEntries/ReviewEntriesComponent")
);
Expand Down
4 changes: 2 additions & 2 deletions src/goals/DefaultGoal/NextGoalScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from "react-router-dom";

import { asyncAddGoal } from "components/GoalTimeline/Redux/GoalActions";
import PageNotFound from "components/PageNotFound/component";
import { MergeDupContinueDialog } from "goals/MergeDupGoal/MergeDupComponent/MergeDupContinueDialog";
import MergeDupsContinueDialog from "goals/MergeDuplicates/MergeDupsContinueDialog";
import { StoreState } from "types";
import { GoalType } from "types/goals";
import { useAppDispatch, useAppSelector } from "types/hooks";
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function NextGoalScreen(): ReactElement {

switch (goalType) {
case GoalType.MergeDups:
return <MergeDupContinueDialog onSelection={loadNextGoal} />;
return <MergeDupsContinueDialog onSelection={loadNextGoal} />;
default:
return <PageNotFound />;
}
Expand Down
2 changes: 1 addition & 1 deletion src/goals/DefaultGoal/tests/DisplayProgress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import thunk from "redux-thunk";
import "tests/reactI18nextMock";

import DisplayProgress from "goals/DefaultGoal/DisplayProgress";
import { MergeDups } from "goals/MergeDupGoal/MergeDups";
import { MergeDups } from "goals/MergeDuplicates/MergeDupsTypes";
import { Goal } from "types/goals";

const createMockStore = configureMockStore([thunk]);
Expand Down
10 changes: 0 additions & 10 deletions src/goals/MergeDupGoal/MergeDupComponent/index.tsx

This file was deleted.

71 changes: 0 additions & 71 deletions src/goals/MergeDupGoal/MergeDupStep/MergeDupStepComponent.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/goals/MergeDupGoal/MergeDupStep/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/goals/MergeDupGoal/MergeDups.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Flag, MergeUndoIds, Sense, Word } from "api/models";
import { getFrontierWords, getWord, undoMerge } from "backend";
import { FlagButton } from "components/Buttons";
import { CancelConfirmDialog } from "components/Dialogs";
import SenseCardContent from "goals/MergeDupGoal/MergeDupStep/SenseCardContent";
import { MergesCompleted } from "goals/MergeDupGoal/MergeDupsTypes";
import SenseCardContent from "goals/MergeDuplicates/MergeDupsStep/SenseCardContent";
import { MergesCompleted } from "goals/MergeDuplicates/MergeDupsTypes";
import { StoreState } from "types";
import theme from "types/theme";
import { newFlag } from "types/word";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Button, Dialog, DialogActions, DialogTitle } from "@mui/material";
import React, { ReactElement } from "react";
import { useTranslation } from "react-i18next";

export interface MergeDupContinueDialogProps {
export interface MergeDupsContinueDialogProps {
onSelection: (shouldContinue: boolean) => void;
}

export function MergeDupContinueDialog(
props: MergeDupContinueDialogProps
export default function MergeDupsContinueDialog(
props: MergeDupsContinueDialogProps
): ReactElement {
const [open, setOpen] = React.useState<boolean>(true);
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Card } from "@mui/material";
import { ReactElement, useCallback, useEffect, useState } from "react";
import { Draggable } from "react-beautiful-dnd";

import { trashId } from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/MergeDragDrop";
import { MergeTreeSense } from "goals/MergeDupGoal/MergeDupStep/MergeDupsTree";
import SenseCardContent from "goals/MergeDupGoal/MergeDupStep/SenseCardContent";
import { setSidebar } from "goals/MergeDupGoal/Redux/MergeDupActions";
import { trashId } from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop";
import SenseCardContent from "goals/MergeDuplicates/MergeDupsStep/SenseCardContent";
import { MergeTreeSense } from "goals/MergeDuplicates/MergeDupsTreeTypes";
import { setSidebar } from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import theme from "types/theme";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { useTranslation } from "react-i18next";

import { Flag } from "api/models";
import { FlagButton, IconButtonWithTooltip } from "components/Buttons";
import DragSense from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/DragSense";
import { flagWord, setVern } from "goals/MergeDupGoal/Redux/MergeDupActions";
import { MergeTreeState } from "goals/MergeDupGoal/Redux/MergeDupReduxTypes";
import DragSense from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/DragSense";
import {
flagWord,
setVern,
} from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { MergeTreeState } from "goals/MergeDuplicates/Redux/MergeDupsReduxTypes";
import { useAppDispatch } from "types/hooks";
import theme from "types/theme";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Card } from "@mui/material";
import { ReactElement } from "react";
import { Draggable } from "react-beautiful-dnd";

import { trashId } from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/MergeDragDrop";
import { trashId } from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop";
import SenseCardContent from "goals/MergeDuplicates/MergeDupsStep/SenseCardContent";
import {
MergeTreeReference,
MergeTreeSense,
Sidebar,
} from "goals/MergeDupGoal/MergeDupStep/MergeDupsTree";
import SenseCardContent from "goals/MergeDupGoal/MergeDupStep/SenseCardContent";
} from "goals/MergeDuplicates/MergeDupsTreeTypes";
import theme from "types/theme";

interface SidebarDragSenseProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { IconButton, Typography } from "@mui/material";
import { ReactElement } from "react";
import { Droppable } from "react-beautiful-dnd";

import SidebarDragSense from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/SidebarDragSense";
import SidebarDragSense from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/SidebarDragSense";
import {
MergeTreeSense,
Sidebar,
} from "goals/MergeDupGoal/MergeDupStep/MergeDupsTree";
import { setSidebar } from "goals/MergeDupGoal/Redux/MergeDupActions";
} from "goals/MergeDuplicates/MergeDupsTreeTypes";
import { setSidebar } from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { useAppDispatch } from "types/hooks";

interface SidebarDropProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { v4 } from "uuid";

import { appBarHeight } from "components/AppBar/AppBarTypes";
import { CancelConfirmDialog } from "components/Dialogs";
import DropWord from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/DropWord";
import SidebarDrop from "goals/MergeDupGoal/MergeDupStep/DragDropComponents/SidebarDrop";
import { MergeTreeReference } from "goals/MergeDupGoal/MergeDupStep/MergeDupsTree";
import DropWord from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/DropWord";
import SidebarDrop from "goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/SidebarDrop";
import { MergeTreeReference } from "goals/MergeDuplicates/MergeDupsTreeTypes";
import {
combineSense,
deleteSense,
moveSense,
orderSense,
} from "goals/MergeDupGoal/Redux/MergeDupActions";
} from "goals/MergeDuplicates/Redux/MergeDupsActions";
import { StoreState } from "types";
import { useAppDispatch, useAppSelector } from "types/hooks";
import theme from "types/theme";
Expand Down
Loading

0 comments on commit 97e5a30

Please sign in to comment.