import { useState } from "react"; import { observer } from "mobx-react-lite"; import Link from "next/link"; import { useRouter } from "next/router"; // icons import { Pencil, Trash2 } from "lucide-react"; // ui import { CustomMenu } from "@plane/ui"; // components import { CreateUpdateWorkspaceViewModal, DeleteGlobalViewModal } from "@/components/workspace"; // helpers import { calculateTotalFilters } from "@/helpers/filter.helper"; import { truncateText } from "@/helpers/string.helper"; // store hooks import { useEventTracker, useGlobalView } from "@/hooks/store"; type Props = { viewId: string }; export const GlobalViewListItem: React.FC = observer((props) => { const { viewId } = props; // states const [updateViewModal, setUpdateViewModal] = useState(false); const [deleteViewModal, setDeleteViewModal] = useState(false); // router const router = useRouter(); const { workspaceSlug } = router.query; // store hooks const { getViewDetailsById } = useGlobalView(); const { setTrackElement } = useEventTracker(); // derived data const view = getViewDetailsById(viewId); if (!view) return null; const totalFilters = calculateTotalFilters(view.filters ?? {}); return ( <> setUpdateViewModal(false)} /> setDeleteViewModal(false)} />

{truncateText(view.name, 75)}

{view?.description &&

{view.description}

}

{totalFilters} {totalFilters === 1 ? "filter" : "filters"}

{ e.preventDefault(); e.stopPropagation(); setTrackElement("List view"); setUpdateViewModal(true); }} > Edit View { e.preventDefault(); e.stopPropagation(); setDeleteViewModal(true); }} > Delete View
); });