[WEB-630] refactor: empty state (#3858)
* refactor: empty state global config file added and empty state component refactor * refactor: empty state component refactor * chore: empty state refactor * chore: empty state config file updated * chore: empty state action button permission logic updated * chore: empty state config file updated * chore: cycle and module empty filter state updated * chore: empty state asset updated * chore: empty state config file updated * chore: empty state config file updated * chore: empty state component improvement * chore: empty state action button improvement * fix: merge conflict
This commit is contained in:
parent
4861be2773
commit
a08f401452
32 changed files with 759 additions and 1155 deletions
|
|
@ -1,49 +1,27 @@
|
|||
import size from "lodash/size";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTheme } from "next-themes";
|
||||
// hooks
|
||||
import { EmptyState, getEmptyStateImagePath } from "components/empty-state";
|
||||
import { EMPTY_FILTER_STATE_DETAILS, EMPTY_ISSUE_STATE_DETAILS } from "constants/empty-state";
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EUserProjectRoles } from "constants/project";
|
||||
import { useIssues, useUser } from "hooks/store";
|
||||
import { useIssues } from "hooks/store";
|
||||
// components
|
||||
import { EmptyState } from "components/empty-state";
|
||||
// constants
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EmptyStateType } from "constants/empty-state";
|
||||
// types
|
||||
import { IIssueFilterOptions } from "@plane/types";
|
||||
|
||||
interface EmptyStateProps {
|
||||
title: string;
|
||||
image: string;
|
||||
description?: string;
|
||||
comicBox?: { title: string; description: string };
|
||||
primaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
secondaryButton?: { text: string; onClick: () => void };
|
||||
size?: "lg" | "sm" | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
}
|
||||
|
||||
export const ProjectArchivedEmptyState: React.FC = observer(() => {
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
// theme
|
||||
const { resolvedTheme } = useTheme();
|
||||
// store hooks
|
||||
const {
|
||||
membership: { currentProjectRole },
|
||||
currentUser,
|
||||
} = useUser();
|
||||
const { issuesFilter } = useIssues(EIssuesStoreType.ARCHIVED);
|
||||
|
||||
const userFilters = issuesFilter?.issueFilters?.filters;
|
||||
const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout;
|
||||
|
||||
const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light";
|
||||
const currentLayoutEmptyStateImagePath = getEmptyStateImagePath("empty-filters", activeLayout ?? "list", isLightMode);
|
||||
const EmptyStateImagePath = getEmptyStateImagePath("archived", "empty-issues", isLightMode);
|
||||
|
||||
const issueFilterCount = size(
|
||||
Object.fromEntries(
|
||||
Object.entries(userFilters ?? {}).filter(([, value]) => value && Array.isArray(value) && value.length > 0)
|
||||
|
|
@ -61,33 +39,20 @@ export const ProjectArchivedEmptyState: React.FC = observer(() => {
|
|||
});
|
||||
};
|
||||
|
||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
const emptyStateProps: EmptyStateProps =
|
||||
issueFilterCount > 0
|
||||
? {
|
||||
title: EMPTY_FILTER_STATE_DETAILS["archived"].title,
|
||||
image: currentLayoutEmptyStateImagePath,
|
||||
secondaryButton: {
|
||||
text: EMPTY_FILTER_STATE_DETAILS["archived"].secondaryButton?.text,
|
||||
onClick: handleClearAllFilters,
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: EMPTY_ISSUE_STATE_DETAILS["archived"].title,
|
||||
description: EMPTY_ISSUE_STATE_DETAILS["archived"].description,
|
||||
image: EmptyStateImagePath,
|
||||
primaryButton: {
|
||||
text: EMPTY_ISSUE_STATE_DETAILS["archived"].primaryButton.text,
|
||||
onClick: () => router.push(`/${workspaceSlug}/projects/${projectId}/settings/automations`),
|
||||
},
|
||||
size: "sm",
|
||||
disabled: !isEditingAllowed,
|
||||
};
|
||||
const emptyStateType =
|
||||
issueFilterCount > 0 ? EmptyStateType.PROJECT_ARCHIVED_EMPTY_FILTER : EmptyStateType.PROJECT_ARCHIVED_NO_ISSUES;
|
||||
const additionalPath = issueFilterCount > 0 ? activeLayout ?? "list" : undefined;
|
||||
|
||||
return (
|
||||
<div className="relative h-full w-full overflow-y-auto">
|
||||
<EmptyState {...emptyStateProps} />
|
||||
<EmptyState
|
||||
type={emptyStateType}
|
||||
additionalPath={additionalPath}
|
||||
primaryButtonLink={
|
||||
issueFilterCount > 0 ? undefined : `/${workspaceSlug}/projects/${projectId}/settings/automations`
|
||||
}
|
||||
secondaryButtonOnClick={issueFilterCount > 0 ? handleClearAllFilters : undefined}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
import { useState } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useTheme } from "next-themes";
|
||||
import { PlusIcon } from "lucide-react";
|
||||
// hooks
|
||||
import { useApplication, useEventTracker, useIssues } from "hooks/store";
|
||||
// ui
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
import { ExistingIssuesListModal } from "components/core";
|
||||
// ui
|
||||
// components
|
||||
import { EmptyState, getEmptyStateImagePath } from "components/empty-state";
|
||||
import { CYCLE_EMPTY_STATE_DETAILS, EMPTY_FILTER_STATE_DETAILS } from "constants/empty-state";
|
||||
import { EIssuesStoreType } from "constants/issue";
|
||||
import { EUserProjectRoles } from "constants/project";
|
||||
import { useApplication, useEventTracker, useIssues, useUser } from "hooks/store";
|
||||
// components
|
||||
import { EmptyState } from "components/empty-state";
|
||||
// types
|
||||
import { ISearchIssueResponse, TIssueLayouts } from "@plane/types";
|
||||
// constants
|
||||
import { EIssuesStoreType } from "constants/issue";
|
||||
import { EmptyStateType } from "constants/empty-state";
|
||||
|
||||
type Props = {
|
||||
workspaceSlug: string | undefined;
|
||||
|
|
@ -26,33 +22,16 @@ type Props = {
|
|||
isEmptyFilters?: boolean;
|
||||
};
|
||||
|
||||
interface EmptyStateProps {
|
||||
title: string;
|
||||
image: string;
|
||||
description?: string;
|
||||
comicBox?: { title: string; description: string };
|
||||
primaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
secondaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
size?: "lg" | "sm" | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
}
|
||||
|
||||
export const CycleEmptyState: React.FC<Props> = observer((props) => {
|
||||
const { workspaceSlug, projectId, cycleId, activeLayout, handleClearAllFilters, isEmptyFilters = false } = props;
|
||||
// states
|
||||
const [cycleIssuesListModal, setCycleIssuesListModal] = useState(false);
|
||||
// theme
|
||||
const { resolvedTheme } = useTheme();
|
||||
// store hooks
|
||||
const { issues } = useIssues(EIssuesStoreType.CYCLE);
|
||||
const {
|
||||
commandPalette: { toggleCreateIssueModal },
|
||||
} = useApplication();
|
||||
const { setTrackElement } = useEventTracker();
|
||||
const {
|
||||
membership: { currentProjectRole: userRole },
|
||||
currentUser,
|
||||
} = useUser();
|
||||
|
||||
const handleAddIssuesToCycle = async (data: ISearchIssueResponse[]) => {
|
||||
if (!workspaceSlug || !projectId || !cycleId) return;
|
||||
|
|
@ -77,43 +56,9 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {
|
|||
);
|
||||
};
|
||||
|
||||
const emptyStateDetail = CYCLE_EMPTY_STATE_DETAILS["no-issues"];
|
||||
|
||||
const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light";
|
||||
const currentLayoutEmptyStateImagePath = getEmptyStateImagePath("empty-filters", activeLayout ?? "list", isLightMode);
|
||||
const emptyStateImage = getEmptyStateImagePath("cycle-issues", activeLayout ?? "list", isLightMode);
|
||||
|
||||
const isEditingAllowed = !!userRole && userRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
const emptyStateProps: EmptyStateProps = isEmptyFilters
|
||||
? {
|
||||
title: EMPTY_FILTER_STATE_DETAILS["project"].title,
|
||||
image: currentLayoutEmptyStateImagePath,
|
||||
secondaryButton: {
|
||||
text: EMPTY_FILTER_STATE_DETAILS["project"].secondaryButton.text,
|
||||
onClick: handleClearAllFilters,
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: emptyStateDetail.title,
|
||||
description: emptyStateDetail.description,
|
||||
image: emptyStateImage,
|
||||
primaryButton: {
|
||||
text: emptyStateDetail.primaryButton.text,
|
||||
icon: <PlusIcon className="h-3 w-3" strokeWidth={2} />,
|
||||
onClick: () => {
|
||||
setTrackElement("Cycle issue empty state");
|
||||
toggleCreateIssueModal(true, EIssuesStoreType.CYCLE);
|
||||
},
|
||||
},
|
||||
secondaryButton: {
|
||||
text: emptyStateDetail.secondaryButton.text,
|
||||
icon: <PlusIcon className="h-3 w-3" strokeWidth={2} />,
|
||||
onClick: () => setCycleIssuesListModal(true),
|
||||
},
|
||||
size: "sm",
|
||||
disabled: !isEditingAllowed,
|
||||
};
|
||||
const emptyStateType = isEmptyFilters ? EmptyStateType.PROJECT_EMPTY_FILTER : EmptyStateType.PROJECT_CYCLE_NO_ISSUES;
|
||||
const additionalPath = activeLayout ?? "list";
|
||||
const emptyStateSize = isEmptyFilters ? "lg" : "sm";
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -126,7 +71,20 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {
|
|||
handleOnSubmit={handleAddIssuesToCycle}
|
||||
/>
|
||||
<div className="grid h-full w-full place-items-center">
|
||||
<EmptyState {...emptyStateProps} />
|
||||
<EmptyState
|
||||
type={emptyStateType}
|
||||
additionalPath={additionalPath}
|
||||
size={emptyStateSize}
|
||||
primaryButtonOnClick={
|
||||
isEmptyFilters
|
||||
? undefined
|
||||
: () => {
|
||||
setTrackElement("Cycle issue empty state");
|
||||
toggleCreateIssueModal(true, EIssuesStoreType.CYCLE);
|
||||
}
|
||||
}
|
||||
secondaryButtonOnClick={isEmptyFilters ? handleClearAllFilters : () => setCycleIssuesListModal(true)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,49 +1,26 @@
|
|||
import size from "lodash/size";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTheme } from "next-themes";
|
||||
// hooks
|
||||
import { EmptyState, getEmptyStateImagePath } from "components/empty-state";
|
||||
import { EMPTY_FILTER_STATE_DETAILS, EMPTY_ISSUE_STATE_DETAILS } from "constants/empty-state";
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EUserProjectRoles } from "constants/project";
|
||||
import { useIssues, useUser } from "hooks/store";
|
||||
import { useIssues } from "hooks/store";
|
||||
// components
|
||||
import { EmptyState } from "components/empty-state";
|
||||
// constants
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EmptyStateType } from "constants/empty-state";
|
||||
// types
|
||||
import { IIssueFilterOptions } from "@plane/types";
|
||||
|
||||
interface EmptyStateProps {
|
||||
title: string;
|
||||
image: string;
|
||||
description?: string;
|
||||
comicBox?: { title: string; description: string };
|
||||
primaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
secondaryButton?: { text: string; onClick: () => void };
|
||||
size?: "lg" | "sm" | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
}
|
||||
|
||||
export const ProjectDraftEmptyState: React.FC = observer(() => {
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
// theme
|
||||
const { resolvedTheme } = useTheme();
|
||||
// store hooks
|
||||
const {
|
||||
membership: { currentProjectRole },
|
||||
currentUser,
|
||||
} = useUser();
|
||||
const { issuesFilter } = useIssues(EIssuesStoreType.DRAFT);
|
||||
|
||||
const userFilters = issuesFilter?.issueFilters?.filters;
|
||||
const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout;
|
||||
|
||||
const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light";
|
||||
const currentLayoutEmptyStateImagePath = getEmptyStateImagePath("empty-filters", activeLayout ?? "list", isLightMode);
|
||||
const EmptyStateImagePath = getEmptyStateImagePath("draft", "draft-issues-empty", isLightMode);
|
||||
|
||||
const issueFilterCount = size(
|
||||
Object.fromEntries(
|
||||
Object.entries(userFilters ?? {}).filter(([, value]) => value && Array.isArray(value) && value.length > 0)
|
||||
|
|
@ -61,29 +38,19 @@ export const ProjectDraftEmptyState: React.FC = observer(() => {
|
|||
});
|
||||
};
|
||||
|
||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
const emptyStateProps: EmptyStateProps =
|
||||
issueFilterCount > 0
|
||||
? {
|
||||
title: EMPTY_FILTER_STATE_DETAILS["draft"].title,
|
||||
image: currentLayoutEmptyStateImagePath,
|
||||
secondaryButton: {
|
||||
text: EMPTY_FILTER_STATE_DETAILS["draft"].secondaryButton.text,
|
||||
onClick: handleClearAllFilters,
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: EMPTY_ISSUE_STATE_DETAILS["draft"].title,
|
||||
description: EMPTY_ISSUE_STATE_DETAILS["draft"].description,
|
||||
image: EmptyStateImagePath,
|
||||
size: "sm",
|
||||
disabled: !isEditingAllowed,
|
||||
};
|
||||
const emptyStateType =
|
||||
issueFilterCount > 0 ? EmptyStateType.PROJECT_DRAFT_EMPTY_FILTER : EmptyStateType.PROJECT_DRAFT_NO_ISSUES;
|
||||
const additionalPath = issueFilterCount > 0 ? activeLayout ?? "list" : undefined;
|
||||
const emptyStateSize = issueFilterCount > 0 ? "lg" : "sm";
|
||||
|
||||
return (
|
||||
<div className="relative h-full w-full overflow-y-auto">
|
||||
<EmptyState {...emptyStateProps} />
|
||||
<EmptyState
|
||||
type={emptyStateType}
|
||||
additionalPath={additionalPath}
|
||||
size={emptyStateSize}
|
||||
secondaryButtonOnClick={issueFilterCount > 0 ? handleClearAllFilters : undefined}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
import { useState } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useTheme } from "next-themes";
|
||||
import { PlusIcon } from "lucide-react";
|
||||
// hooks
|
||||
import { useApplication, useEventTracker, useIssues } from "hooks/store";
|
||||
// ui
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
import { ExistingIssuesListModal } from "components/core";
|
||||
import { EmptyState, getEmptyStateImagePath } from "components/empty-state";
|
||||
import { EMPTY_FILTER_STATE_DETAILS, MODULE_EMPTY_STATE_DETAILS } from "constants/empty-state";
|
||||
import { EIssuesStoreType } from "constants/issue";
|
||||
import { EUserProjectRoles } from "constants/project";
|
||||
import { useApplication, useEventTracker, useIssues, useUser } from "hooks/store";
|
||||
// ui
|
||||
// components
|
||||
import { ExistingIssuesListModal } from "components/core";
|
||||
import { EmptyState } from "components/empty-state";
|
||||
// types
|
||||
import { ISearchIssueResponse, TIssueLayouts } from "@plane/types";
|
||||
// constants
|
||||
import { EIssuesStoreType } from "constants/issue";
|
||||
import { EmptyStateType } from "constants/empty-state";
|
||||
|
||||
type Props = {
|
||||
workspaceSlug: string | undefined;
|
||||
|
|
@ -25,33 +23,16 @@ type Props = {
|
|||
isEmptyFilters?: boolean;
|
||||
};
|
||||
|
||||
interface EmptyStateProps {
|
||||
title: string;
|
||||
image: string;
|
||||
description?: string;
|
||||
comicBox?: { title: string; description: string };
|
||||
primaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
secondaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
size?: "lg" | "sm" | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
}
|
||||
|
||||
export const ModuleEmptyState: React.FC<Props> = observer((props) => {
|
||||
const { workspaceSlug, projectId, moduleId, activeLayout, handleClearAllFilters, isEmptyFilters = false } = props;
|
||||
// states
|
||||
const [moduleIssuesListModal, setModuleIssuesListModal] = useState(false);
|
||||
// theme
|
||||
const { resolvedTheme } = useTheme();
|
||||
// store hooks
|
||||
const { issues } = useIssues(EIssuesStoreType.MODULE);
|
||||
const {
|
||||
commandPalette: { toggleCreateIssueModal },
|
||||
} = useApplication();
|
||||
const { setTrackElement } = useEventTracker();
|
||||
const {
|
||||
membership: { currentProjectRole: userRole },
|
||||
currentUser,
|
||||
} = useUser();
|
||||
|
||||
const handleAddIssuesToModule = async (data: ISearchIssueResponse[]) => {
|
||||
if (!workspaceSlug || !projectId || !moduleId) return;
|
||||
|
|
@ -75,42 +56,8 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
|
|||
);
|
||||
};
|
||||
|
||||
const emptyStateDetail = MODULE_EMPTY_STATE_DETAILS["no-issues"];
|
||||
|
||||
const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light";
|
||||
const currentLayoutEmptyStateImagePath = getEmptyStateImagePath("empty-filters", activeLayout ?? "list", isLightMode);
|
||||
const emptyStateImage = getEmptyStateImagePath("module-issues", activeLayout ?? "list", isLightMode);
|
||||
|
||||
const isEditingAllowed = !!userRole && userRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
const emptyStateProps: EmptyStateProps = isEmptyFilters
|
||||
? {
|
||||
title: EMPTY_FILTER_STATE_DETAILS["project"].title,
|
||||
image: currentLayoutEmptyStateImagePath,
|
||||
secondaryButton: {
|
||||
text: EMPTY_FILTER_STATE_DETAILS["project"].secondaryButton.text,
|
||||
onClick: handleClearAllFilters,
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: emptyStateDetail.title,
|
||||
description: emptyStateDetail.description,
|
||||
image: emptyStateImage,
|
||||
primaryButton: {
|
||||
text: emptyStateDetail.primaryButton.text,
|
||||
icon: <PlusIcon className="h-3 w-3" strokeWidth={2} />,
|
||||
onClick: () => {
|
||||
setTrackElement("Module issue empty state");
|
||||
toggleCreateIssueModal(true, EIssuesStoreType.MODULE);
|
||||
},
|
||||
},
|
||||
secondaryButton: {
|
||||
text: emptyStateDetail.secondaryButton.text,
|
||||
icon: <PlusIcon className="h-3 w-3" strokeWidth={2} />,
|
||||
onClick: () => setModuleIssuesListModal(true),
|
||||
},
|
||||
disabled: !isEditingAllowed,
|
||||
};
|
||||
const emptyStateType = isEmptyFilters ? EmptyStateType.PROJECT_EMPTY_FILTER : EmptyStateType.PROJECT_MODULE_ISSUES;
|
||||
const additionalPath = activeLayout ?? "list";
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -123,7 +70,19 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
|
|||
handleOnSubmit={handleAddIssuesToModule}
|
||||
/>
|
||||
<div className="grid h-full w-full place-items-center">
|
||||
<EmptyState {...emptyStateProps} />
|
||||
<EmptyState
|
||||
type={emptyStateType}
|
||||
additionalPath={additionalPath}
|
||||
primaryButtonOnClick={
|
||||
isEmptyFilters
|
||||
? undefined
|
||||
: () => {
|
||||
setTrackElement("Cycle issue empty state");
|
||||
toggleCreateIssueModal(true, EIssuesStoreType.CYCLE);
|
||||
}
|
||||
}
|
||||
secondaryButtonOnClick={isEmptyFilters ? handleClearAllFilters : () => setModuleIssuesListModal(true)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,51 +1,29 @@
|
|||
import size from "lodash/size";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTheme } from "next-themes";
|
||||
// hooks
|
||||
import { EmptyState, getEmptyStateImagePath } from "components/empty-state";
|
||||
import { EMPTY_FILTER_STATE_DETAILS, EMPTY_ISSUE_STATE_DETAILS } from "constants/empty-state";
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EUserProjectRoles } from "constants/project";
|
||||
import { useApplication, useEventTracker, useIssues, useUser } from "hooks/store";
|
||||
import { useApplication, useEventTracker, useIssues } from "hooks/store";
|
||||
// components
|
||||
import { EmptyState } from "components/empty-state";
|
||||
// constants
|
||||
import { EIssueFilterType, EIssuesStoreType } from "constants/issue";
|
||||
import { EmptyStateType } from "constants/empty-state";
|
||||
// types
|
||||
import { IIssueFilterOptions } from "@plane/types";
|
||||
|
||||
interface EmptyStateProps {
|
||||
title: string;
|
||||
image: string;
|
||||
description?: string;
|
||||
comicBox?: { title: string; description: string };
|
||||
primaryButton?: { text: string; icon?: React.ReactNode; onClick: () => void };
|
||||
secondaryButton?: { text: string; onClick: () => void };
|
||||
size?: "lg" | "sm" | undefined;
|
||||
disabled?: boolean | undefined;
|
||||
}
|
||||
|
||||
export const ProjectEmptyState: React.FC = observer(() => {
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
// theme
|
||||
const { resolvedTheme } = useTheme();
|
||||
// store hooks
|
||||
const { commandPalette: commandPaletteStore } = useApplication();
|
||||
const { setTrackElement } = useEventTracker();
|
||||
const {
|
||||
membership: { currentProjectRole },
|
||||
currentUser,
|
||||
} = useUser();
|
||||
|
||||
const { issuesFilter } = useIssues(EIssuesStoreType.PROJECT);
|
||||
|
||||
const userFilters = issuesFilter?.issueFilters?.filters;
|
||||
const activeLayout = issuesFilter?.issueFilters?.displayFilters?.layout;
|
||||
|
||||
const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light";
|
||||
const currentLayoutEmptyStateImagePath = getEmptyStateImagePath("empty-filters", activeLayout ?? "list", isLightMode);
|
||||
const EmptyStateImagePath = getEmptyStateImagePath("onboarding", "issues", isLightMode);
|
||||
|
||||
const issueFilterCount = size(
|
||||
Object.fromEntries(
|
||||
Object.entries(userFilters ?? {}).filter(([, value]) => value && Array.isArray(value) && value.length > 0)
|
||||
|
|
@ -63,40 +41,26 @@ export const ProjectEmptyState: React.FC = observer(() => {
|
|||
});
|
||||
};
|
||||
|
||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||
|
||||
const emptyStateProps: EmptyStateProps =
|
||||
issueFilterCount > 0
|
||||
? {
|
||||
title: EMPTY_FILTER_STATE_DETAILS["project"].title,
|
||||
image: currentLayoutEmptyStateImagePath,
|
||||
secondaryButton: {
|
||||
text: EMPTY_FILTER_STATE_DETAILS["project"].secondaryButton.text,
|
||||
onClick: handleClearAllFilters,
|
||||
},
|
||||
}
|
||||
: {
|
||||
title: EMPTY_ISSUE_STATE_DETAILS["project"].title,
|
||||
description: EMPTY_ISSUE_STATE_DETAILS["project"].description,
|
||||
image: EmptyStateImagePath,
|
||||
comicBox: {
|
||||
title: EMPTY_ISSUE_STATE_DETAILS["project"].comicBox.title,
|
||||
description: EMPTY_ISSUE_STATE_DETAILS["project"].comicBox.description,
|
||||
},
|
||||
primaryButton: {
|
||||
text: EMPTY_ISSUE_STATE_DETAILS["project"].primaryButton.text,
|
||||
onClick: () => {
|
||||
setTrackElement("Project issue empty state");
|
||||
commandPaletteStore.toggleCreateIssueModal(true, EIssuesStoreType.PROJECT);
|
||||
},
|
||||
},
|
||||
size: "lg",
|
||||
disabled: !isEditingAllowed,
|
||||
};
|
||||
const emptyStateType = issueFilterCount > 0 ? EmptyStateType.PROJECT_EMPTY_FILTER : EmptyStateType.PROJECT_NO_ISSUES;
|
||||
const additionalPath = issueFilterCount > 0 ? activeLayout ?? "list" : undefined;
|
||||
const emptyStateSize = issueFilterCount > 0 ? "lg" : "sm";
|
||||
|
||||
return (
|
||||
<div className="relative h-full w-full overflow-y-auto">
|
||||
<EmptyState {...emptyStateProps} />
|
||||
<EmptyState
|
||||
type={emptyStateType}
|
||||
additionalPath={additionalPath}
|
||||
size={emptyStateSize}
|
||||
primaryButtonOnClick={
|
||||
issueFilterCount > 0
|
||||
? undefined
|
||||
: () => {
|
||||
setTrackElement("Project issue empty state");
|
||||
commandPaletteStore.toggleCreateIssueModal(true, EIssuesStoreType.PROJECT);
|
||||
}
|
||||
}
|
||||
secondaryButtonOnClick={issueFilterCount > 0 ? handleClearAllFilters : undefined}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue