43 lines
2.4 KiB
TypeScript
43 lines
2.4 KiB
TypeScript
import { Navigate, useLocation, useParams } from "react-router";
|
||
import { ProjectGate } from "../../projects/ProjectGate.tsx";
|
||
import { IconBoard, IconHistory, IconList } from "../../ui/index.ts";
|
||
import type { HubModule } from "../types.ts";
|
||
import { BoardPage } from "./board/BoardPage.tsx";
|
||
import { FeedPage } from "./feed/FeedPage.tsx";
|
||
import { useIssueOverlay } from "./issues/overlay.tsx";
|
||
import { IssuesPage } from "./issues/IssuesPage.tsx";
|
||
import { jiraStatus } from "./status.ts";
|
||
import { Summary } from "./Summary.tsx";
|
||
|
||
// прежний адрес → новый; keyParam — параметр пути (ключ задачи), который дописывается к новому адресу
|
||
function LegacyRedirect({ to, keyParam }: { to: string; keyParam?: string }) {
|
||
const { search } = useLocation();
|
||
const params = useParams();
|
||
const key = keyParam ? params[keyParam] : undefined;
|
||
return <Navigate to={{ pathname: key ? `${to}/${encodeURIComponent(key)}` : to, search }} replace />;
|
||
}
|
||
|
||
export const jiraModule: HubModule = {
|
||
name: "jira",
|
||
title: "Jira",
|
||
pages: [
|
||
{ path: "/jira/board", element: <ProjectGate>{(p) => <BoardPage key={p.label} project={p.label} />}</ProjectGate> },
|
||
{ path: "/jira/issues", element: <ProjectGate>{(p) => <IssuesPage key={p.label} project={p.label} />}</ProjectGate> },
|
||
{ path: "/jira/feed", element: <ProjectGate>{(p) => <FeedPage key={p.label} project={p.label} />}</ProjectGate> },
|
||
// прежние адреса (закладки): перенаправление с сохранением строки запроса, без новой записи истории
|
||
{ path: "/board", element: <LegacyRedirect to="/jira/board" /> },
|
||
{ path: "/issues", element: <LegacyRedirect to="/jira/issues" /> },
|
||
{ path: "/issues/:key", element: <LegacyRedirect to="/jira/issues" keyParam="key" /> },
|
||
{ path: "/feed", element: <LegacyRedirect to="/jira/feed" /> },
|
||
],
|
||
nav: [
|
||
{ to: "/jira/board", label: "Доска связей", icon: <IconBoard /> },
|
||
{ to: "/jira/issues", label: "Задачи", icon: <IconList />, padded: true },
|
||
{ to: "/jira/feed", label: "Лента", icon: <IconHistory />, padded: true, keepSearch: true },
|
||
],
|
||
status: jiraStatus,
|
||
Summary,
|
||
useOverlay: useIssueOverlay,
|
||
projectFields: [{ name: "board_id", label: "Номер доски Jira", hint: "scrum или kanban определится сам", kind: "int" }],
|
||
};
|