[WEB-4017] fix: hooks and store refactoring for issue-details (#7107)
* fix: hooks and store splitting for issue-details * fix: refactoring * fix: refactoring * fix: refactor * fix: css
This commit is contained in:
parent
9cdfb2224a
commit
c7d17d00b7
7 changed files with 32 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ import { useParams } from "next/navigation";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
// plane imports
|
// plane imports
|
||||||
|
import { EIssueServiceType } from "@plane/constants";
|
||||||
import { useTranslation } from "@plane/i18n";
|
import { useTranslation } from "@plane/i18n";
|
||||||
import { Loader } from "@plane/ui";
|
import { Loader } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
|
|
@ -16,6 +17,7 @@ import { IssueDetailRoot } from "@/components/issues";
|
||||||
import { useAppTheme, useIssueDetail, useProject } from "@/hooks/store";
|
import { useAppTheme, useIssueDetail, useProject } from "@/hooks/store";
|
||||||
// assets
|
// assets
|
||||||
import { useAppRouter } from "@/hooks/use-app-router";
|
import { useAppRouter } from "@/hooks/use-app-router";
|
||||||
|
import { useWorkItemProperties } from "@/plane-web/hooks/use-issue-properties";
|
||||||
import { ProjectAuthWrapper } from "@/plane-web/layouts/project-wrapper";
|
import { ProjectAuthWrapper } from "@/plane-web/layouts/project-wrapper";
|
||||||
import emptyIssueDark from "@/public/empty-state/search/issues-dark.webp";
|
import emptyIssueDark from "@/public/empty-state/search/issues-dark.webp";
|
||||||
import emptyIssueLight from "@/public/empty-state/search/issues-light.webp";
|
import emptyIssueLight from "@/public/empty-state/search/issues-light.webp";
|
||||||
|
|
@ -53,6 +55,13 @@ const IssueDetailsPage = observer(() => {
|
||||||
const issueLoader = !issue || isLoading;
|
const issueLoader = !issue || isLoading;
|
||||||
const pageTitle = project && issue ? `${project?.identifier}-${issue?.sequence_id} ${issue?.name}` : undefined;
|
const pageTitle = project && issue ? `${project?.identifier}-${issue?.sequence_id} ${issue?.name}` : undefined;
|
||||||
|
|
||||||
|
useWorkItemProperties(
|
||||||
|
projectId,
|
||||||
|
workspaceSlug.toString(),
|
||||||
|
issueId,
|
||||||
|
issue?.is_epic ? EIssueServiceType.EPICS : EIssueServiceType.ISSUES
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleToggleIssueDetailSidebar = () => {
|
const handleToggleIssueDetailSidebar = () => {
|
||||||
if (window && window.innerWidth < 768) {
|
if (window && window.innerWidth < 768) {
|
||||||
|
|
|
||||||
10
web/ce/hooks/use-issue-properties.tsx
Normal file
10
web/ce/hooks/use-issue-properties.tsx
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { TIssueServiceType } from "@plane/types";
|
||||||
|
|
||||||
|
export const useWorkItemProperties = (
|
||||||
|
projectId: string | null | undefined,
|
||||||
|
workspaceSlug: string | null | undefined,
|
||||||
|
workItemId: string | null | undefined,
|
||||||
|
issueServiceType: TIssueServiceType
|
||||||
|
) => {
|
||||||
|
if (!projectId || !workspaceSlug || !workItemId) return;
|
||||||
|
};
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
ISSUE_RESTORED,
|
ISSUE_RESTORED,
|
||||||
EUserPermissions,
|
EUserPermissions,
|
||||||
EUserPermissionsLevel,
|
EUserPermissionsLevel,
|
||||||
|
EIssueServiceType,
|
||||||
} from "@plane/constants";
|
} from "@plane/constants";
|
||||||
import { useTranslation } from "@plane/i18n";
|
import { useTranslation } from "@plane/i18n";
|
||||||
import { TIssue, IWorkItemPeekOverview } from "@plane/types";
|
import { TIssue, IWorkItemPeekOverview } from "@plane/types";
|
||||||
|
|
@ -23,6 +24,7 @@ import { IssueView, TIssueOperations } from "@/components/issues";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useIssueDetail, useIssues, useUserPermissions } from "@/hooks/store";
|
import { useEventTracker, useIssueDetail, useIssues, useUserPermissions } from "@/hooks/store";
|
||||||
import { useIssueStoreType } from "@/hooks/use-issue-layout-store";
|
import { useIssueStoreType } from "@/hooks/use-issue-layout-store";
|
||||||
|
import { useWorkItemProperties } from "@/plane-web/hooks/use-issue-properties";
|
||||||
|
|
||||||
|
|
||||||
export const IssuePeekOverview: FC<IWorkItemPeekOverview> = observer((props) => {
|
export const IssuePeekOverview: FC<IWorkItemPeekOverview> = observer((props) => {
|
||||||
|
|
@ -51,6 +53,13 @@ export const IssuePeekOverview: FC<IWorkItemPeekOverview> = observer((props) =>
|
||||||
const storeType = issueStoreFromProps ?? issueStoreType;
|
const storeType = issueStoreFromProps ?? issueStoreType;
|
||||||
const { issues } = useIssues(storeType);
|
const { issues } = useIssues(storeType);
|
||||||
const { captureIssueEvent } = useEventTracker();
|
const { captureIssueEvent } = useEventTracker();
|
||||||
|
|
||||||
|
useWorkItemProperties(
|
||||||
|
peekIssue?.projectId,
|
||||||
|
peekIssue?.workspaceSlug,
|
||||||
|
peekIssue?.issueId,
|
||||||
|
storeType === EIssuesStoreType.EPIC ? EIssueServiceType.EPICS : EIssueServiceType.ISSUES
|
||||||
|
);
|
||||||
// state
|
// state
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const SettingsContentWrapper = observer((props: TProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn("flex flex-col w-full items-center mx-auto py-4 md:py-0", {
|
className={cn("flex flex-col w-full items-center mx-auto py-4 md:py-0", {
|
||||||
"md:p-4 max-w-[800px] 2xl:max-w-[1000px]": size === "md",
|
"md:px-4 max-w-[800px] 2xl:max-w-[1000px]": size === "md",
|
||||||
"md:px-16": size === "lg",
|
"md:px-16": size === "lg",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { TIssueServiceType } from "@plane/types";
|
||||||
// mobx store
|
// mobx store
|
||||||
import { StoreContext } from "@/lib/store-context";
|
import { StoreContext } from "@/lib/store-context";
|
||||||
// types
|
// types
|
||||||
import { IIssueDetail } from "@/store/issue/issue-details/root.store";
|
import { IIssueDetail } from "@/plane-web/store/issue/issue-details/root.store";
|
||||||
|
|
||||||
export const useIssueDetail = (serviceType: TIssueServiceType = EIssueServiceType.ISSUES): IIssueDetail => {
|
export const useIssueDetail = (serviceType: TIssueServiceType = EIssueServiceType.ISSUES): IIssueDetail => {
|
||||||
const context = useContext(StoreContext);
|
const context = useContext(StoreContext);
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ export interface IIssueDetail
|
||||||
relation: IIssueRelationStore;
|
relation: IIssueRelationStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IssueDetail implements IIssueDetail {
|
export abstract class IssueDetail implements IIssueDetail {
|
||||||
// observables
|
// observables
|
||||||
peekIssue: TPeekIssue | undefined = undefined;
|
peekIssue: TPeekIssue | undefined = undefined;
|
||||||
relationKey: TIssueRelationTypes | null = null;
|
relationKey: TIssueRelationTypes | null = null;
|
||||||
|
|
|
||||||
1
web/ee/hooks/use-issue-properties.tsx
Normal file
1
web/ee/hooks/use-issue-properties.tsx
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "ce/hooks/use-issue-properties";
|
||||||
Loading…
Add table
Add a link
Reference in a new issue