import React, { FC } from "react"; import { observer } from "mobx-react-lite"; import { Plus } from "lucide-react"; // hooks import { useApplication, usePage, useUser } from "hooks/store"; // components import { PagesListView } from "components/pages/pages-list"; import { NewEmptyState } from "components/common/new-empty-state"; // ui import { Loader } from "@plane/ui"; // assets import emptyPage from "public/empty-state/empty_page.png"; // helpers import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper"; // constants import { EUserProjectRoles } from "constants/project"; export const RecentPagesList: FC = observer(() => { // store hooks const { commandPalette: commandPaletteStore } = useApplication(); const { membership: { currentProjectRole }, } = useUser(); const { recentProjectPages } = usePage(); // FIXME: replace any with proper type const isEmpty = recentProjectPages && Object.values(recentProjectPages).every((value: any) => value.length === 0); const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; if (!recentProjectPages) { return ( ); } return ( <> {Object.keys(recentProjectPages).length > 0 && !isEmpty ? ( <> {Object.keys(recentProjectPages).map((key) => { if (recentProjectPages[key]?.length === 0) return null; return (

{replaceUnderscoreIfSnakeCase(key)}

); })} ) : ( <> , text: "Create your first page", onClick: () => commandPaletteStore.toggleCreatePageModal(true), }} disabled={!isEditingAllowed} /> )} ); });