Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract routes into global enum and rename them #109

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Routes>
<Route path="/" index element={<Login />} />
<Route element={<Layout />}>
<Route path="projectsview" element={<ProjectsView />} />
<Route path="backlogview" element={<BacklogView />} />
<Route path="epicview" element={<EpicView />} />
<Route path="storymapview">
<Route path={RouteNames.PROJECTS_VIEW} element={<ProjectsView />} />
<Route path={RouteNames.BACKLOG_VIEW} element={<BacklogView />} />
<Route path={RouteNames.EPIC_VIEW} element={<EpicView />} />
<Route path={RouteNames.STORY_MAP_VIEW}>
<Route index element={<StoryMapDashboard />} />
<Route path=":storyMapId" element={<StoryMapView />} />
</Route>
Expand Down
5 changes: 3 additions & 2 deletions src/components/BacklogView/BacklogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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()
Expand Down Expand Up @@ -166,7 +167,7 @@ export function BacklogView() {
<Text>
Please go back to the Projects View section and select a project
</Text>
<Button onClick={() => navigate("/projectsview")}>Go back</Button>
<Button onClick={() => navigate(RouteNames.PROJECTS_VIEW)}>Go back</Button>
</Stack>
)}
</Center>
Expand All @@ -177,7 +178,7 @@ export function BacklogView() {
<Group>
<Group gap="xs" c="dimmed">
<Text
onClick={() => navigate("/projectsview")}
onClick={() => navigate(RouteNames.PROJECTS_VIEW)}
style={{
":hover": {
textDecoration: "underline",
Expand Down
5 changes: 3 additions & 2 deletions src/components/EpicView/EpicView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";



Expand Down Expand Up @@ -51,7 +52,7 @@ export function EpicView() {
<Text>
Please go back to the Projects View section and select a project
</Text>
<Button onClick={() => navigate("/projectsview")}>Go back</Button>
<Button onClick={() => navigate(RouteNames.PROJECTS_VIEW)}>Go back</Button>
</Stack>
)}
</Center>
Expand All @@ -62,7 +63,7 @@ export function EpicView() {
<Group>
<Group gap="xs" c="dimmed">
<Text
onClick={() => navigate("/projectsview")}
onClick={() => navigate(RouteNames.PROJECTS_VIEW)}
style={{
":hover": {
textDecoration: "underline",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/components/ProjectsView/Table/ProjectsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -49,7 +50,7 @@ export function ProjectsTable({ data }: { data: Project[] }) {
setSelectedProject(row)
setSelectedProjectBoardIds(await window.provider.getBoardIds(row.key))
setIssueTypes(await window.provider.getIssueTypesByProject(row.key))
navigate("/backlogview")
navigate(RouteNames.BACKLOG_VIEW)
}

const header = data && data.length > 0 && Object.keys(data[0]).map((key) => {
Expand Down
7 changes: 4 additions & 3 deletions src/components/layout/LayoutHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -31,21 +32,21 @@ export function LayoutHeader() {
<Anchor
component="button"
type="button"
onClick={() => navigate("/projectsview")}
onClick={() => navigate(RouteNames.PROJECTS_VIEW)}
>
Projects
</Anchor>
<Anchor
component="button"
type="button"
onClick={() => navigate("/backlogview")}
onClick={() => navigate(RouteNames.BACKLOG_VIEW)}
>
Backlog
</Anchor>
<Anchor
component="button"
type="button"
onClick={() => navigate("/epicview")}>
onClick={() => navigate(RouteNames.EPIC_VIEW)}>
Epics
</Anchor>
<StoryMapMenu />
Expand Down
7 changes: 4 additions & 3 deletions src/components/layout/StoryMapMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -20,7 +21,7 @@ export function StoryMapMenu() {
<Anchor
component="button"
type="button"
onClick={() => navigate("/storymapview")}
onClick={() => navigate(RouteNames.STORY_MAP_VIEW)}
style={{
display: "flex",
}}
Expand All @@ -34,7 +35,7 @@ export function StoryMapMenu() {
<Menu.Item
leftSection={<IconMap size={14} />}
key={`layout-header-story-map-${storyMap.id}`}
onClick={() => navigate(`/storymapview/${storyMap.id}`)}
onClick={() => navigate(`${RouteNames.STORY_MAP_VIEW}/${storyMap.id}`)}
>
{storyMap.name}
</Menu.Item>
Expand All @@ -43,7 +44,7 @@ export function StoryMapMenu() {
{storyMaps?.length > 0 && <Menu.Divider />}
<Menu.Item
leftSection={<IconLayoutDashboard size={14} />}
onClick={() => navigate("/storymapview")}
onClick={() => navigate(RouteNames.STORY_MAP_VIEW)}
>
View All Story Maps
</Menu.Item>
Expand Down
6 changes: 6 additions & 0 deletions src/route-names.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum RouteNames {
PROJECTS_VIEW = '/projectsView',
BACKLOG_VIEW = '/backlogView',
EPIC_VIEW = '/epicView',
STORY_MAP_VIEW = '/storyMapView',
}