2023-12-04 06:41:36 +00:00
import React , { FC } from "react" ;
import { observer } from "mobx-react-lite" ;
import { Plus } from "lucide-react" ;
// mobx store
import { useMobxStore } from "lib/mobx/store-provider" ;
2023-03-27 17:49:05 +00:00
// components
2023-12-04 06:41:36 +00:00
import { PagesListView } from "components/pages/pages-list" ;
import { NewEmptyState } from "components/common/new-empty-state" ;
2023-03-27 17:49:05 +00:00
// ui
2023-12-04 06:41:36 +00:00
import { Loader } from "@plane/ui" ;
// assets
import emptyPage from "public/empty-state/empty_page.webp" ;
2023-03-27 17:49:05 +00:00
// helpers
import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper" ;
2023-12-04 06:41:36 +00:00
export const RecentPagesList : FC = observer ( ( ) = > {
// store
const {
commandPalette : commandPaletteStore ,
page : { recentProjectPages } ,
} = useMobxStore ( ) ;
2023-03-27 17:49:05 +00:00
2023-12-04 06:41:36 +00:00
const isEmpty = recentProjectPages && Object . values ( recentProjectPages ) . every ( ( value ) = > value . length === 0 ) ;
2023-03-27 17:49:05 +00:00
2023-12-04 06:41:36 +00:00
if ( ! recentProjectPages ) {
return (
< Loader className = "space-y-4" >
< Loader.Item height = "40px" / >
< Loader.Item height = "40px" / >
< Loader.Item height = "40px" / >
< / Loader >
) ;
}
2023-03-30 21:21:39 +00:00
2023-03-27 17:49:05 +00:00
return (
< >
2023-12-04 06:41:36 +00:00
{ Object . keys ( recentProjectPages ) . length > 0 && ! isEmpty ? (
< >
{ Object . keys ( recentProjectPages ) . map ( ( key ) = > {
if ( recentProjectPages [ key ] ? . length === 0 ) return null ;
2023-03-27 17:49:05 +00:00
2023-05-29 09:46:49 +00:00
return (
2023-12-04 06:41:36 +00:00
< div key = { key } >
< h2 className = "sticky top-0 bg-custom-background-100 z-[1] text-xl font-semibold capitalize mb-2" >
2023-05-29 09:46:49 +00:00
{ replaceUnderscoreIfSnakeCase ( key ) }
< / h2 >
2023-12-04 06:41:36 +00:00
< PagesListView pages = { recentProjectPages [ key ] } / >
2023-05-29 09:46:49 +00:00
< / div >
) ;
2023-12-04 06:41:36 +00:00
} ) }
< / >
) : (
< >
< NewEmptyState
title = "Write a note, a doc, or a full knowledge base. Get Galileo, Plane’ s AI assistant, to help you get started."
description = "Pages are thoughtspotting space in Plane. Take down meeting notes, format them easily, embed issues, lay them out using a library of components, and keep them all in your project’ s context. To make short work of any doc, invoke Galileo, Plane’ s AI, with a shortcut or the click of a button."
2023-07-12 06:15:45 +00:00
image = { emptyPage }
2023-12-04 06:41:36 +00:00
comicBox = { {
title : "A page can be a doc or a doc of docs." ,
description :
"We wrote Parth and Meera’ s love story. You could write your project’ s mission, goals, and eventual vision." ,
direction : "right" ,
} }
2023-08-01 08:28:58 +00:00
primaryButton = { {
2023-12-04 06:41:36 +00:00
icon : < Plus className = "h-4 w-4" / > ,
text : "Create your first page" ,
onClick : ( ) = > commandPaletteStore . toggleCreatePageModal ( true ) ,
2023-07-12 06:15:45 +00:00
} }
2023-05-29 09:46:49 +00:00
/ >
2023-12-04 06:41:36 +00:00
< / >
2023-03-27 17:49:05 +00:00
) }
< / >
) ;
2023-12-04 06:41:36 +00:00
} ) ;