import { FC } from "react"; import { observer } from "mobx-react-lite"; import { FileText, Inbox } from "lucide-react"; // ui import { ContrastIcon, DiceIcon, PhotoFilterIcon, ToggleSwitch, setPromiseToast } from "@plane/ui"; // hooks import { useEventTracker, useProject, useUser } from "hooks/store"; // types import { IProject } from "@plane/types"; type Props = { workspaceSlug: string; projectId: string; isAdmin: boolean; }; const PROJECT_FEATURES_LIST = [ { title: "Cycles", description: "Time-box issues and boost momentum, similar to sprints in scrum.", icon: , property: "cycle_view", }, { title: "Modules", description: "Group multiple issues together and track the progress.", icon: , property: "module_view", }, { title: "Views", description: "Apply filters to issues and save them to analyse and investigate work.", icon: , property: "issue_views_view", }, { title: "Pages", description: "Document ideas, feature requirements, discussions within your project.", icon: , property: "page_view", }, { title: "Inbox", description: "Capture external inputs, move valid issues to workflow.", icon: , property: "inbox_view", }, ]; export const ProjectFeaturesList: FC = observer((props) => { const { workspaceSlug, projectId, isAdmin } = props; // store hooks const { captureEvent } = useEventTracker(); const { currentUser } = useUser(); const { getProjectById, updateProject } = useProject(); // derived values const currentProjectDetails = getProjectById(projectId); const handleSubmit = async (formData: Partial) => { if (!workspaceSlug || !projectId || !currentProjectDetails) return; const updateProjectPromise = updateProject(workspaceSlug, projectId, formData); setPromiseToast(updateProjectPromise, { loading: "Updating project feature...", success: { title: "Success!", message: () => "Project feature updated successfully.", }, error: { title: "Error!", message: () => "Something went wrong while updating project feature. Please try again.", }, }); }; if (!currentUser) return <>; return (
{PROJECT_FEATURES_LIST.map((feature) => (
{feature.icon}

{feature.title}

{feature.description}

{ captureEvent(`Toggle ${feature.title.toLowerCase()}`, { enabled: !currentProjectDetails?.[feature.property as keyof IProject], element: "Project settings feature page", }); handleSubmit({ [feature.property]: !currentProjectDetails?.[feature.property as keyof IProject], }); }} disabled={!isAdmin} size="sm" />
))}
); });