From 860b42efff8a70d4f785dc4543c6010dc4970ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20R=C3=BCsch?= Date: Fri, 29 Dec 2023 01:09:38 +0100 Subject: [PATCH] Extract routes into global enum and rename them --- src/App.tsx | 9 +++++---- src/components/BacklogView/BacklogView.tsx | 5 +++-- src/components/EpicView/EpicView.tsx | 5 +++-- src/components/Login/Login.tsx | 3 ++- src/components/ProjectsView/Table/ProjectsTable.tsx | 3 ++- src/components/layout/LayoutHeader.tsx | 7 ++++--- src/components/layout/StoryMapMenu.tsx | 7 ++++--- src/route-names.ts | 6 ++++++ 8 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 src/route-names.ts diff --git a/src/App.tsx b/src/App.tsx index de7ff626..467598ec 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,16 +6,17 @@ import { BacklogView } from "./components/BacklogView" import { EpicView } from "./components/EpicView" import { StoryMapView } from "./components/StoryMapView" import { StoryMapDashboard } from "./components/StoryMapView/StoryMapDashboard" +import { RouteNames } from "./route-names"; export function App() { return ( } /> }> - } /> - } /> - } /> - + } /> + } /> + } /> + } /> } /> diff --git a/src/components/BacklogView/BacklogView.tsx b/src/components/BacklogView/BacklogView.tsx index 6fbf4eff..f4914fc1 100644 --- a/src/components/BacklogView/BacklogView.tsx +++ b/src/components/BacklogView/BacklogView.tsx @@ -33,6 +33,7 @@ import { DraggableIssuesWrapper } from "./IssuesWrapper/DraggableIssuesWrapper" import { SprintsPanel } from "./IssuesWrapper/SprintsPanel" import { ReloadButton } from "./ReloadButton" import { useColorScheme } from "../../common/color-scheme"; +import { RouteNames } from "../../route-names"; export function BacklogView() { const colorScheme = useColorScheme() @@ -164,7 +165,7 @@ export function BacklogView() { Please go back to the Projects View section and select a project - + )} @@ -175,7 +176,7 @@ export function BacklogView() { navigate("/projectsview")} + onClick={() => navigate(RouteNames.PROJECTS_VIEW)} style={{ ":hover": { textDecoration: "underline", diff --git a/src/components/EpicView/EpicView.tsx b/src/components/EpicView/EpicView.tsx index dfeb609b..d51e9202 100644 --- a/src/components/EpicView/EpicView.tsx +++ b/src/components/EpicView/EpicView.tsx @@ -8,6 +8,7 @@ import {Issue} from "../../../types"; import {EpicWrapper} from "./EpicWrapper"; import {getEpics} from "./helpers/queryFetchers"; import {useColorScheme} from "../../common/color-scheme"; +import {RouteNames} from "../../route-names"; @@ -51,7 +52,7 @@ export function EpicView() { Please go back to the Projects View section and select a project - + )} @@ -62,7 +63,7 @@ export function EpicView() { navigate("/projectsview")} + onClick={() => navigate(RouteNames.PROJECTS_VIEW)} style={{ ":hover": { textDecoration: "underline", diff --git a/src/components/Login/Login.tsx b/src/components/Login/Login.tsx index 2bef1728..07ad2a4c 100644 --- a/src/components/Login/Login.tsx +++ b/src/components/Login/Login.tsx @@ -9,11 +9,12 @@ import { ColorSchemeToggle } from "../common/ColorSchemeToggle" import { JiraCloudLogin } from "./jira-cloud/JiraCloudLogin" import { JiraServerLogin } from "./jira-server/JiraServerLogin" import { useColorScheme } from "../../common/color-scheme"; +import { RouteNames } from "../../route-names"; export function Login() { const [providerLogin, setProviderLogin] = useState("") const navigateTo = useNavigate() - const onSuccess = () => navigateTo("/projectsview") + const onSuccess = () => navigateTo(RouteNames.PROJECTS_VIEW) const goBack = () => setProviderLogin("") const { t } = useTranslation("login") const colorScheme = useColorScheme() diff --git a/src/components/ProjectsView/Table/ProjectsTable.tsx b/src/components/ProjectsView/Table/ProjectsTable.tsx index 3ed41b2b..202b4311 100644 --- a/src/components/ProjectsView/Table/ProjectsTable.tsx +++ b/src/components/ProjectsView/Table/ProjectsTable.tsx @@ -11,6 +11,7 @@ import { useEffect, useState, ChangeEvent } from "react" import { useNavigate } from "react-router-dom" import { useCanvasStore } from "../../../lib/Store" import { sortData } from "./TableHelper" +import { RouteNames } from "../../../route-names" import classes from "./ProjectsTable.module.css"; @@ -48,7 +49,7 @@ export function ProjectsTable({ data }: { data: Project[] }) { const onClickRow = async (row: Project) => { setSelectedProject(row) setSelectedProjectBoardIds(await window.provider.getBoardIds(row.key)) - navigate("/backlogview") + navigate(RouteNames.BACKLOG_VIEW) } const header = data && data.length > 0 && Object.keys(data[0]).map((key) => { diff --git a/src/components/layout/LayoutHeader.tsx b/src/components/layout/LayoutHeader.tsx index 4ff95480..f8319737 100644 --- a/src/components/layout/LayoutHeader.tsx +++ b/src/components/layout/LayoutHeader.tsx @@ -6,6 +6,7 @@ import { CreateIssueModal } from "../CreateIssue/CreateIssueModal" import { LogoutButton } from "./LogoutButton" import { StoryMapMenu } from "./StoryMapMenu" +import { RouteNames } from "../../route-names" import classes from "./LayoutHeader.module.css" @@ -31,21 +32,21 @@ export function LayoutHeader() { navigate("/projectsview")} + onClick={() => navigate(RouteNames.PROJECTS_VIEW)} > Projects navigate("/backlogview")} + onClick={() => navigate(RouteNames.BACKLOG_VIEW)} > Backlog navigate("/epicview")}> + onClick={() => navigate(RouteNames.EPIC_VIEW)}> Epics diff --git a/src/components/layout/StoryMapMenu.tsx b/src/components/layout/StoryMapMenu.tsx index d8416d94..62764602 100644 --- a/src/components/layout/StoryMapMenu.tsx +++ b/src/components/layout/StoryMapMenu.tsx @@ -7,6 +7,7 @@ import { } from "@tabler/icons-react" import { useNavigate } from "react-router-dom" import { useStoryMapStore } from "../StoryMapView/StoryMapStore" +import { RouteNames } from "../../route-names"; export function StoryMapMenu() { const navigate = useNavigate() @@ -20,7 +21,7 @@ export function StoryMapMenu() { navigate("/storymapview")} + onClick={() => navigate(RouteNames.STORY_MAP_VIEW)} style={{ display: "flex", }} @@ -34,7 +35,7 @@ export function StoryMapMenu() { } key={`layout-header-story-map-${storyMap.id}`} - onClick={() => navigate(`/storymapview/${storyMap.id}`)} + onClick={() => navigate(`${RouteNames.STORY_MAP_VIEW}/${storyMap.id}`)} > {storyMap.name} @@ -43,7 +44,7 @@ export function StoryMapMenu() { {storyMaps?.length > 0 && } } - onClick={() => navigate("/storymapview")} + onClick={() => navigate(RouteNames.STORY_MAP_VIEW)} > View All Story Maps diff --git a/src/route-names.ts b/src/route-names.ts new file mode 100644 index 00000000..36f2707a --- /dev/null +++ b/src/route-names.ts @@ -0,0 +1,6 @@ +export enum RouteNames { + PROJECTS_VIEW = '/projectsView', + BACKLOG_VIEW = '/backlogView', + EPIC_VIEW = '/epicView', + STORY_MAP_VIEW = '/storyMapView', +}