[WEB-1236] chore: add Create page button to public/ private page empty state. (#4401)

This commit is contained in:
Prateek Shourya 2024-05-08 13:43:08 +05:30 committed by GitHub
parent 6efa135e9e
commit 10efd8d1d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import { PageLoader } from "@/components/pages";
// constants // constants
import { EmptyStateType } from "@/constants/empty-state"; import { EmptyStateType } from "@/constants/empty-state";
// hooks // hooks
import { useProjectPages } from "@/hooks/store"; import { useApplication, useProjectPages } from "@/hooks/store";
// assets // assets
import AllFiltersImage from "public/empty-state/pages/all-filters.svg"; import AllFiltersImage from "public/empty-state/pages/all-filters.svg";
import NameFilterImage from "public/empty-state/pages/name-filter.svg"; import NameFilterImage from "public/empty-state/pages/name-filter.svg";
@ -23,6 +23,7 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
const { children, pageType, projectId } = props; const { children, pageType, projectId } = props;
// store hooks // store hooks
const { loader, getCurrentProjectFilteredPageIds, getCurrentProjectPageIds, filters } = useProjectPages(projectId); const { loader, getCurrentProjectFilteredPageIds, getCurrentProjectPageIds, filters } = useProjectPages(projectId);
const { commandPalette: commandPaletteStore } = useApplication();
// derived values // derived values
const pageIds = getCurrentProjectPageIds(pageType); const pageIds = getCurrentProjectPageIds(pageType);
const filteredPageIds = getCurrentProjectFilteredPageIds(pageType); const filteredPageIds = getCurrentProjectFilteredPageIds(pageType);
@ -30,8 +31,24 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
if (loader === "init-loader") return <PageLoader />; if (loader === "init-loader") return <PageLoader />;
// if no pages exist in the active page type // if no pages exist in the active page type
if (pageIds?.length === 0) { if (pageIds?.length === 0) {
if (pageType === "public") return <EmptyState type={EmptyStateType.PROJECT_PAGE_PUBLIC} />; if (pageType === "public")
if (pageType === "private") return <EmptyState type={EmptyStateType.PROJECT_PAGE_PRIVATE} />; return (
<EmptyState
type={EmptyStateType.PROJECT_PAGE_PUBLIC}
primaryButtonOnClick={() => {
commandPaletteStore.toggleCreatePageModal(true);
}}
/>
);
if (pageType === "private")
return (
<EmptyState
type={EmptyStateType.PROJECT_PAGE_PRIVATE}
primaryButtonOnClick={() => {
commandPaletteStore.toggleCreatePageModal(true);
}}
/>
);
if (pageType === "archived") return <EmptyState type={EmptyStateType.PROJECT_PAGE_ARCHIVED} />; if (pageType === "archived") return <EmptyState type={EmptyStateType.PROJECT_PAGE_ARCHIVED} />;
} }
// if no pages match the filter criteria // if no pages match the filter criteria

View File

@ -500,12 +500,22 @@ const emptyStateDetails = {
title: "No private pages yet", title: "No private pages yet",
description: "Keep your private thoughts here. When you're ready to share, the team's just a click away.", description: "Keep your private thoughts here. When you're ready to share, the team's just a click away.",
path: "/empty-state/pages/private", path: "/empty-state/pages/private",
primaryButton: {
text: "Create your first page",
},
accessType: "project",
access: EUserProjectRoles.MEMBER,
}, },
[EmptyStateType.PROJECT_PAGE_PUBLIC]: { [EmptyStateType.PROJECT_PAGE_PUBLIC]: {
key: EmptyStateType.PROJECT_PAGE_PUBLIC, key: EmptyStateType.PROJECT_PAGE_PUBLIC,
title: "No public pages yet", title: "No public pages yet",
description: "See pages shared with everyone in your project right here.", description: "See pages shared with everyone in your project right here.",
path: "/empty-state/pages/public", path: "/empty-state/pages/public",
primaryButton: {
text: "Create your first page",
},
accessType: "project",
access: EUserProjectRoles.MEMBER,
}, },
[EmptyStateType.PROJECT_PAGE_ARCHIVED]: { [EmptyStateType.PROJECT_PAGE_ARCHIVED]: {
key: EmptyStateType.PROJECT_PAGE_ARCHIVED, key: EmptyStateType.PROJECT_PAGE_ARCHIVED,