import { useState } from "react"; import { observer } from "mobx-react-lite"; import { useTheme } from "next-themes"; import { Search } from "lucide-react"; // hooks // components import { Input } from "@plane/ui"; import { EmptyState, getEmptyStateImagePath } from "components/empty-state"; // ui import { ViewListLoader } from "components/ui"; import { ProjectViewListItem } from "components/views"; // constants import { VIEW_EMPTY_STATE_DETAILS } from "constants/empty-state"; import { EUserProjectRoles } from "constants/project"; import { useApplication, useProjectView, useUser } from "hooks/store"; export const ProjectViewsList = observer(() => { // states const [query, setQuery] = useState(""); // theme const { resolvedTheme } = useTheme(); // store hooks const { commandPalette: { toggleCreateViewModal }, } = useApplication(); const { membership: { currentProjectRole }, currentUser, } = useUser(); const { projectViewIds, getViewById, loader } = useProjectView(); if (loader || !projectViewIds) return ; const viewsList = projectViewIds.map((viewId) => getViewById(viewId)); const isLightMode = resolvedTheme ? resolvedTheme === "light" : currentUser?.theme.theme === "light"; const EmptyStateImagePath = getEmptyStateImagePath("onboarding", "views", isLightMode); const filteredViewsList = viewsList.filter((v) => v?.name.toLowerCase().includes(query.toLowerCase())); const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER; return ( <> {viewsList.length > 0 ? (
setQuery(e.target.value)} placeholder="Search" mode="true-transparent" />
{filteredViewsList.length > 0 ? ( filteredViewsList.map((view) => ) ) : (

No results found

)}
) : ( toggleCreateViewModal(true), }} size="lg" disabled={!isEditingAllowed} /> )} ); });