mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-465] improvement: redirect to issue detail on click on the sub-issue count property. (#3731)
This commit is contained in:
parent
fb442d6dfe
commit
c851ec7034
@ -2,7 +2,7 @@ import { observer } from "mobx-react-lite";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { CalendarCheck2, CalendarClock, Layers, Link, Paperclip } from "lucide-react";
|
import { CalendarCheck2, CalendarClock, Layers, Link, Paperclip } from "lucide-react";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useEstimate, useLabel } from "hooks/store";
|
import { useEventTracker, useEstimate, useLabel, useApplication } from "hooks/store";
|
||||||
// components
|
// components
|
||||||
import { IssuePropertyLabels } from "../properties/labels";
|
import { IssuePropertyLabels } from "../properties/labels";
|
||||||
import { Tooltip } from "@plane/ui";
|
import { Tooltip } from "@plane/ui";
|
||||||
@ -35,6 +35,9 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {
|
|||||||
// store hooks
|
// store hooks
|
||||||
const { labelMap } = useLabel();
|
const { labelMap } = useLabel();
|
||||||
const { captureIssueEvent } = useEventTracker();
|
const { captureIssueEvent } = useEventTracker();
|
||||||
|
const {
|
||||||
|
router: { workspaceSlug },
|
||||||
|
} = useApplication();
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { areEstimatesEnabledForCurrentProject } = useEstimate();
|
const { areEstimatesEnabledForCurrentProject } = useEstimate();
|
||||||
@ -137,6 +140,15 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const redirectToIssueDetail = () => {
|
||||||
|
router.push({
|
||||||
|
pathname: `/${workspaceSlug}/projects/${issue.project_id}/${issue.archived_at ? "archived-issues" : "issues"}/${
|
||||||
|
issue.id
|
||||||
|
}`,
|
||||||
|
hash: "sub-issues",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (!displayProperties) return null;
|
if (!displayProperties) return null;
|
||||||
|
|
||||||
const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || [];
|
const defaultLabelOptions = issue?.label_ids?.map((id) => labelMap[id]) || [];
|
||||||
@ -261,7 +273,10 @@ export const IssueProperties: React.FC<IIssueProperties> = observer((props) => {
|
|||||||
shouldRenderProperty={!!issue?.sub_issues_count}
|
shouldRenderProperty={!!issue?.sub_issues_count}
|
||||||
>
|
>
|
||||||
<Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
|
<Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
|
||||||
<div className="flex h-5 flex-shrink-0 items-center justify-center gap-2 overflow-hidden rounded border-[0.5px] border-custom-border-300 px-2.5 py-1">
|
<div
|
||||||
|
onClick={redirectToIssueDetail}
|
||||||
|
className="flex h-5 flex-shrink-0 items-center justify-center gap-2 overflow-hidden rounded border-[0.5px] border-custom-border-300 hover:bg-custom-background-80 px-2.5 py-1 cursor-pointer"
|
||||||
|
>
|
||||||
<Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
|
<Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
|
||||||
<div className="text-xs">{issue.sub_issues_count}</div>
|
<div className="text-xs">{issue.sub_issues_count}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
// hooks
|
// hooks
|
||||||
|
import { useApplication } from "hooks/store";
|
||||||
|
// types
|
||||||
import { TIssue } from "@plane/types";
|
import { TIssue } from "@plane/types";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -9,9 +12,27 @@ type Props = {
|
|||||||
|
|
||||||
export const SpreadsheetSubIssueColumn: React.FC<Props> = observer((props: Props) => {
|
export const SpreadsheetSubIssueColumn: React.FC<Props> = observer((props: Props) => {
|
||||||
const { issue } = props;
|
const { issue } = props;
|
||||||
|
// router
|
||||||
|
const router = useRouter();
|
||||||
|
// hooks
|
||||||
|
const {
|
||||||
|
router: { workspaceSlug },
|
||||||
|
} = useApplication();
|
||||||
|
|
||||||
|
const redirectToIssueDetail = () => {
|
||||||
|
router.push({
|
||||||
|
pathname: `/${workspaceSlug}/projects/${issue.project_id}/${issue.archived_at ? "archived-issues" : "issues"}/${
|
||||||
|
issue.id
|
||||||
|
}`,
|
||||||
|
hash: "sub-issues",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-11 w-full items-center px-2.5 py-1 text-xs border-b-[0.5px] border-custom-border-200 hover:bg-custom-background-80">
|
<div
|
||||||
|
onClick={redirectToIssueDetail}
|
||||||
|
className="flex h-11 w-full items-center px-2.5 py-1 text-xs border-b-[0.5px] border-custom-border-200 hover:bg-custom-background-80 cursor-pointer"
|
||||||
|
>
|
||||||
{issue?.sub_issues_count} {issue?.sub_issues_count === 1 ? "sub-issue" : "sub-issues"}
|
{issue?.sub_issues_count} {issue?.sub_issues_count === 1 ? "sub-issue" : "sub-issues"}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -89,6 +89,25 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const scrollToSubIssuesView = useCallback(() => {
|
||||||
|
if (router.asPath.split("#")[1] === "sub-issues") {
|
||||||
|
setTimeout(() => {
|
||||||
|
const subIssueDiv = document.getElementById(`sub-issues`);
|
||||||
|
if (subIssueDiv)
|
||||||
|
subIssueDiv.scrollIntoView({
|
||||||
|
behavior: "smooth",
|
||||||
|
block: "start",
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}, [router.asPath]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (router.asPath) {
|
||||||
|
scrollToSubIssuesView();
|
||||||
|
}
|
||||||
|
}, [router.asPath, scrollToSubIssuesView]);
|
||||||
|
|
||||||
const handleIssueCrudState = (
|
const handleIssueCrudState = (
|
||||||
key: "create" | "existing" | "update" | "delete",
|
key: "create" | "existing" | "update" | "delete",
|
||||||
_parentIssueId: string | null,
|
_parentIssueId: string | null,
|
||||||
@ -287,7 +306,7 @@ export const SubIssuesRoot: FC<ISubIssuesRoot> = observer((props) => {
|
|||||||
|
|
||||||
if (!issue) return <></>;
|
if (!issue) return <></>;
|
||||||
return (
|
return (
|
||||||
<div className="h-full w-full space-y-2">
|
<div id="sub-issues" className="h-full w-full space-y-2">
|
||||||
{!subIssues ? (
|
{!subIssues ? (
|
||||||
<div className="py-3 text-center text-sm font-medium text-custom-text-300">Loading...</div>
|
<div className="py-3 text-center text-sm font-medium text-custom-text-300">Loading...</div>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user