From 98189269de52cd82d34f45518a01a7e0c83ba2a7 Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Tue, 12 Jan 2021 17:51:08 -0500 Subject: [PATCH] Remove GoalSwitcher (unused) (#908) --- src/components/App/DefaultState.tsx | 2 +- .../GoalSelectorScroll/GoalSelectorAction.tsx | 0 .../GoalSelectorReducer.tsx | 6 +-- .../GoalSelectorScroll/GoalSelectorScroll.tsx | 12 +++--- .../GoalSelectorScroll/index.tsx | 12 +++--- .../tests/GoalSelectorAction.test.tsx | 4 +- .../tests/GoalSelectorReducer.test.tsx | 8 ++-- .../tests/GoalSelectorScroll.test.tsx | 4 +- .../GoalSelectorScroll.test.tsx.snap | 0 .../GoalSwitcher/GoalSwitcherComponent.tsx | 38 ------------------- .../GoalTimeline/GoalSwitcher/index.tsx | 25 ------------ .../GoalSwitcher/tests/GoalSwitcher.test.tsx | 32 ---------------- src/rootReducer.tsx | 2 +- 13 files changed, 25 insertions(+), 120 deletions(-) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/GoalSelectorAction.tsx (100%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/GoalSelectorReducer.tsx (84%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/GoalSelectorScroll.tsx (98%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/index.tsx (89%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx (100%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx (87%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx (97%) rename src/components/GoalTimeline/{GoalSwitcher => }/GoalSelectorScroll/tests/__snapshots__/GoalSelectorScroll.test.tsx.snap (100%) delete mode 100644 src/components/GoalTimeline/GoalSwitcher/GoalSwitcherComponent.tsx delete mode 100644 src/components/GoalTimeline/GoalSwitcher/index.tsx delete mode 100644 src/components/GoalTimeline/GoalSwitcher/tests/GoalSwitcher.test.tsx diff --git a/src/components/App/DefaultState.tsx b/src/components/App/DefaultState.tsx index dd48c18cf7..416d94ecb0 100644 --- a/src/components/App/DefaultState.tsx +++ b/src/components/App/DefaultState.tsx @@ -4,7 +4,7 @@ import { defaultState as reviewEntriesState } from "../../goals/ReviewEntries/Re import { defaultProject } from "../../types/project"; import { defaultState as loginState } from "../Login/LoginReducer"; import { defaultState as goalTimelineState } from "../GoalTimeline/DefaultState"; -import { defaultState as goalSelectorState } from "../GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorReducer"; +import { defaultState as goalSelectorState } from "../GoalTimeline/GoalSelectorScroll/GoalSelectorReducer"; import { defaultState as passwordResetState } from "../PasswordReset/reducer"; import { defaultState as exportProjectState } from "../ProjectExport/ExportProjectReducer"; import { defaultState as createProjectState } from "../ProjectScreen/CreateProject/CreateProjectReducer"; diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorAction.tsx b/src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorAction.tsx similarity index 100% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorAction.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorAction.tsx diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorReducer.tsx b/src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorReducer.tsx similarity index 84% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorReducer.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorReducer.tsx index 9dc1f0fa29..32aa326334 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorReducer.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorReducer.tsx @@ -1,10 +1,10 @@ +import { StoreAction, StoreActions } from "../../../rootActions"; +import { GoalSelectorState } from "../../../types/goals"; import { GoalScrollAction, - SELECT_ACTION, MOUSE_ACTION, + SELECT_ACTION, } from "./GoalSelectorAction"; -import { GoalSelectorState } from "../../../../types/goals"; -import { StoreAction, StoreActions } from "../../../../rootActions"; export const defaultState: GoalSelectorState = { selectedIndex: 0, diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorScroll.tsx b/src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorScroll.tsx similarity index 98% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorScroll.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorScroll.tsx index 9470a9eead..1a9158a981 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorScroll.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/GoalSelectorScroll.tsx @@ -1,15 +1,15 @@ -import React, { ReactElement } from "react"; - import Card from "@material-ui/core/Card"; import { Button, CardContent, Typography } from "@material-ui/core"; -import { Goal, GoalName } from "../../../../types/goals"; +import React, { ReactElement } from "react"; import { LocalizeContextProps, - withLocalize, Translate, + withLocalize, } from "react-localize-redux"; -import ContextMenu from "../../../ContextMenu/ContextMenu"; -import { styleAddendum } from "../../../../types/theme"; + +import { Goal, GoalName } from "../../../types/goals"; +import { styleAddendum } from "../../../types/theme"; +import ContextMenu from "../../ContextMenu/ContextMenu"; const CLICK_SENSITIVITY: number = 10; diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/index.tsx b/src/components/GoalTimeline/GoalSelectorScroll/index.tsx similarity index 89% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/index.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/index.tsx index 88a6e5719c..18ce4f0bb1 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/index.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/index.tsx @@ -1,14 +1,14 @@ -import GoalSelectorScroll from "./GoalSelectorScroll"; +import { connect } from "react-redux"; +import { Dispatch } from "redux"; + +import { StoreState } from "../../../types"; +import { GoalSelectorState } from "../../../types/goals"; import { GoalScrollAction, scrollSelectorIndexAction, scrollSelectorMouseAction, } from "./GoalSelectorAction"; - -import { connect } from "react-redux"; -import { StoreState } from "../../../../types"; -import { GoalSelectorState } from "../../../../types/goals"; -import { Dispatch } from "redux"; +import GoalSelectorScroll from "./GoalSelectorScroll"; export function mapStateToProps(state: StoreState): GoalSelectorState { return { diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx similarity index 100% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx index 64ce732382..57c7977e9d 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorAction.test.tsx @@ -1,9 +1,9 @@ import { - SELECT_ACTION, GoalScrollAction, + MOUSE_ACTION, + SELECT_ACTION, scrollSelectorIndexAction, scrollSelectorMouseAction, - MOUSE_ACTION, } from "../GoalSelectorAction"; const VAL = 5; diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx similarity index 87% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx index b06b4bdb51..2e123275a1 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorReducer.test.tsx @@ -1,11 +1,11 @@ -import { goalSelectReducer, defaultState } from "../GoalSelectorReducer"; +import { StoreActions, StoreAction } from "../../../../rootActions"; +import { GoalSelectorState } from "../../../../types/goals"; import { - SELECT_ACTION, GoalScrollAction, MOUSE_ACTION, + SELECT_ACTION, } from "../GoalSelectorAction"; -import { GoalSelectorState } from "../../../../../types/goals"; -import { StoreActions, StoreAction } from "../../../../../rootActions"; +import { defaultState, goalSelectReducer } from "../GoalSelectorReducer"; const VAL = 5; const scrollAct: GoalScrollAction = { diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx similarity index 97% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx rename to src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx index c580315cc7..0da52c5835 100644 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx +++ b/src/components/GoalTimeline/GoalSelectorScroll/tests/GoalSelectorScroll.test.tsx @@ -7,8 +7,8 @@ import renderer, { import configureMockStore from "redux-mock-store"; import thunk from "redux-thunk"; -import { Goal, GoalName, GoalSelectorState } from "../../../../../types/goals"; -import { User } from "../../../../../types/user"; +import { Goal, GoalName, GoalSelectorState } from "../../../../types/goals"; +import { User } from "../../../../types/user"; import GoalSelectorScroll from "../"; import { GoalScrollAction, diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/__snapshots__/GoalSelectorScroll.test.tsx.snap b/src/components/GoalTimeline/GoalSelectorScroll/tests/__snapshots__/GoalSelectorScroll.test.tsx.snap similarity index 100% rename from src/components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/tests/__snapshots__/GoalSelectorScroll.test.tsx.snap rename to src/components/GoalTimeline/GoalSelectorScroll/tests/__snapshots__/GoalSelectorScroll.test.tsx.snap diff --git a/src/components/GoalTimeline/GoalSwitcher/GoalSwitcherComponent.tsx b/src/components/GoalTimeline/GoalSwitcher/GoalSwitcherComponent.tsx deleted file mode 100644 index 6db9bcc8d4..0000000000 --- a/src/components/GoalTimeline/GoalSwitcher/GoalSwitcherComponent.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from "react"; - -import { Goal, GoalName } from "../../../types/goals"; -import { withLocalize, LocalizeContextProps } from "react-localize-redux"; -import GoalSelectorScroll from "./GoalSelectorScroll"; - -export interface GoalSwitcherProps { - chooseGoal: (goal: Goal) => void; - goals: Goal[]; -} - -/* - * Holds a component that provides the user with a choice for the next goal - * they want to work on. - */ -export class GoalSwitcher extends React.Component< - GoalSwitcherProps & LocalizeContextProps -> { - constructor(props: GoalSwitcherProps & LocalizeContextProps) { - super(props); - this.handleChange = this.handleChange.bind(this); - } - - // Given a change event, find which goal the user selected, and choose it - // as the next goal to work on. - handleChange(name: GoalName) { - let goal: Goal | undefined = this.props.goals.find((g) => g.name === name); - if (goal) { - this.props.chooseGoal(goal); - } - } - - render() { - return ; - } -} - -export default withLocalize(GoalSwitcher); diff --git a/src/components/GoalTimeline/GoalSwitcher/index.tsx b/src/components/GoalTimeline/GoalSwitcher/index.tsx deleted file mode 100644 index 05faa28f3c..0000000000 --- a/src/components/GoalTimeline/GoalSwitcher/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { Goal, GoalSwitcherState } from "../../../types/goals"; -import GoalSwitcher from "./GoalSwitcherComponent"; - -import { connect } from "react-redux"; -import { StoreState } from "../../../types"; -import { ThunkDispatch } from "redux-thunk"; -import { asyncAddGoalToHistory, AddGoalToHistoryAction } from "../GoalsActions"; - -export function mapStateToProps(state: StoreState): GoalSwitcherState { - return { - goals: state.goalsState.allPossibleGoals, - }; -} - -export function mapDispatchToProps( - dispatch: ThunkDispatch -) { - return { - chooseGoal: (goal: Goal) => { - dispatch(asyncAddGoalToHistory(goal)); - }, - }; -} - -export default connect(mapStateToProps, mapDispatchToProps)(GoalSwitcher); diff --git a/src/components/GoalTimeline/GoalSwitcher/tests/GoalSwitcher.test.tsx b/src/components/GoalTimeline/GoalSwitcher/tests/GoalSwitcher.test.tsx deleted file mode 100644 index 47e7d732a9..0000000000 --- a/src/components/GoalTimeline/GoalSwitcher/tests/GoalSwitcher.test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import { act } from "react-dom/test-utils"; -import configureMockStore from "redux-mock-store"; -import { defaultState } from "../../DefaultState"; -import { defaultState as selectorState } from "../GoalSelectorScroll/GoalSelectorReducer"; -import { Provider } from "react-redux"; -import GoalSwitcher from "../../GoalSwitcher"; - -const createMockStore = configureMockStore([]); - -it("renders without crashing", () => { - const mockStore = createMockStore({ - goalsState: { - ...defaultState, - }, - goalSelectorState: { - ...selectorState, - }, - }); - const container = document.createElement("div"); - act(() => { - ReactDOM.render( - - - , - container - ); - }); - - ReactDOM.unmountComponentAtNode(container); -}); diff --git a/src/rootReducer.tsx b/src/rootReducer.tsx index b3f56b1722..80385220d3 100644 --- a/src/rootReducer.tsx +++ b/src/rootReducer.tsx @@ -2,7 +2,7 @@ import { localizeReducer } from "react-localize-redux"; import { combineReducers, Reducer } from "redux"; import { goalsReducer } from "./components/GoalTimeline/GoalsReducer"; -import { goalSelectReducer } from "./components/GoalTimeline/GoalSwitcher/GoalSelectorScroll/GoalSelectorReducer"; +import { goalSelectReducer } from "./components/GoalTimeline/GoalSelectorScroll/GoalSelectorReducer"; import { loginReducer } from "./components/Login/LoginReducer"; import { passwordResetReducer } from "./components/PasswordReset/reducer"; import { projectReducer } from "./components/Project/ProjectReducer";