fix: sibling issue redirection and fetching issue resolved (#4603)

This commit is contained in:
Anmol Singh Bhatia 2024-05-27 16:04:05 +05:30 committed by GitHub
parent aaf3484ee5
commit 2e6ad61f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 15 deletions

View File

@ -56,7 +56,7 @@ export const IssueParentDetail: FC<TIssueParentDetail> = observer((props) => {
Sibling issues Sibling issues
</div> </div>
<IssueParentSiblings currentIssue={issue} parentIssue={parentIssue} /> <IssueParentSiblings workspaceSlug={workspaceSlug} currentIssue={issue} parentIssue={parentIssue} />
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={() => issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: null })} onClick={() => issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: null })}

View File

@ -1,4 +1,5 @@
import { FC } from "react"; import { FC } from "react";
import { observer } from "mobx-react";
import Link from "next/link"; import Link from "next/link";
// ui // ui
import { CustomMenu, LayersIcon } from "@plane/ui"; import { CustomMenu, LayersIcon } from "@plane/ui";
@ -6,15 +7,15 @@ import { CustomMenu, LayersIcon } from "@plane/ui";
import { useIssueDetail, useProject } from "@/hooks/store"; import { useIssueDetail, useProject } from "@/hooks/store";
type TIssueParentSiblingItem = { type TIssueParentSiblingItem = {
workspaceSlug: string;
issueId: string; issueId: string;
}; };
export const IssueParentSiblingItem: FC<TIssueParentSiblingItem> = (props) => { export const IssueParentSiblingItem: FC<TIssueParentSiblingItem> = observer((props) => {
const { issueId } = props; const { workspaceSlug, issueId } = props;
// hooks // hooks
const { getProjectById } = useProject(); const { getProjectById } = useProject();
const { const {
peekIssue,
issue: { getIssueById }, issue: { getIssueById },
} = useIssueDetail(); } = useIssueDetail();
@ -27,7 +28,7 @@ export const IssueParentSiblingItem: FC<TIssueParentSiblingItem> = (props) => {
<> <>
<CustomMenu.MenuItem key={issueDetail.id}> <CustomMenu.MenuItem key={issueDetail.id}>
<Link <Link
href={`/${peekIssue?.workspaceSlug}/projects/${issueDetail?.project_id as string}/issues/${issueDetail.id}`} href={`/${workspaceSlug}/projects/${issueDetail?.project_id as string}/issues/${issueDetail.id}`}
className="flex items-center gap-2 py-2" className="flex items-center gap-2 py-2"
> >
<LayersIcon className="h-4 w-4" /> <LayersIcon className="h-4 w-4" />
@ -36,4 +37,4 @@ export const IssueParentSiblingItem: FC<TIssueParentSiblingItem> = (props) => {
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
</> </>
); );
}; });

View File

@ -1,4 +1,5 @@
import { FC } from "react"; import { FC } from "react";
import { observer } from "mobx-react";
import useSWR from "swr"; import useSWR from "swr";
import { TIssue } from "@plane/types"; import { TIssue } from "@plane/types";
// components // components
@ -8,25 +9,25 @@ import { useIssueDetail } from "@/hooks/store";
import { IssueParentSiblingItem } from "./sibling-item"; import { IssueParentSiblingItem } from "./sibling-item";
export type TIssueParentSiblings = { export type TIssueParentSiblings = {
workspaceSlug: string;
currentIssue: TIssue; currentIssue: TIssue;
parentIssue: TIssue; parentIssue: TIssue;
}; };
export const IssueParentSiblings: FC<TIssueParentSiblings> = (props) => { export const IssueParentSiblings: FC<TIssueParentSiblings> = observer((props) => {
const { currentIssue, parentIssue } = props; const { workspaceSlug, currentIssue, parentIssue } = props;
// hooks // hooks
const { const {
peekIssue,
fetchSubIssues, fetchSubIssues,
subIssues: { subIssuesByIssueId }, subIssues: { subIssuesByIssueId },
} = useIssueDetail(); } = useIssueDetail();
const { isLoading } = useSWR( const { isLoading } = useSWR(
peekIssue && parentIssue && parentIssue.project_id parentIssue && parentIssue.project_id
? `ISSUE_PARENT_CHILD_ISSUES_${peekIssue?.workspaceSlug}_${parentIssue.project_id}_${parentIssue.id}` ? `ISSUE_PARENT_CHILD_ISSUES_${workspaceSlug}_${parentIssue.project_id}_${parentIssue.id}`
: null, : null,
peekIssue && parentIssue && parentIssue.project_id parentIssue && parentIssue.project_id
? () => fetchSubIssues(peekIssue?.workspaceSlug, parentIssue.project_id, parentIssue.id) ? () => fetchSubIssues(workspaceSlug, parentIssue.project_id, parentIssue.id)
: null : null
); );
@ -40,7 +41,10 @@ export const IssueParentSiblings: FC<TIssueParentSiblings> = (props) => {
</div> </div>
) : subIssueIds && subIssueIds.length > 0 ? ( ) : subIssueIds && subIssueIds.length > 0 ? (
subIssueIds.map( subIssueIds.map(
(issueId) => currentIssue.id != issueId && <IssueParentSiblingItem key={issueId} issueId={issueId} /> (issueId) =>
currentIssue.id != issueId && (
<IssueParentSiblingItem key={issueId} workspaceSlug={workspaceSlug} issueId={issueId} />
)
) )
) : ( ) : (
<div className="flex items-center gap-2 whitespace-nowrap px-1 py-1 text-left text-xs text-custom-text-200"> <div className="flex items-center gap-2 whitespace-nowrap px-1 py-1 text-left text-xs text-custom-text-200">
@ -49,4 +53,4 @@ export const IssueParentSiblings: FC<TIssueParentSiblings> = (props) => {
)} )}
</div> </div>
); );
}; });