import { useState } from "react"; import { observer } from "mobx-react"; import { Lock, RefreshCw, Sparkle } from "lucide-react"; // editor import { EditorReadOnlyRefApi, EditorRefApi } from "@plane/document-editor"; // ui import { ArchiveIcon } from "@plane/ui"; // components import { GptAssistantPopover } from "@/components/core"; import { PageInfoPopover, PageOptionsDropdown } from "@/components/pages"; // helpers import { cn } from "@/helpers/common.helper"; import { renderFormattedDate } from "@/helpers/date-time.helper"; // hooks import { useApplication } from "@/hooks/store"; // store import { IPageStore } from "@/store/pages/page.store"; type Props = { editorRef: React.RefObject; handleDuplicatePage: () => void; pageStore: IPageStore; projectId: string; readOnlyEditorRef: React.RefObject; }; export const PageExtraOptions: React.FC = observer((props) => { const { editorRef, handleDuplicatePage, pageStore, projectId, readOnlyEditorRef } = props; // states const [gptModalOpen, setGptModal] = useState(false); // store hooks const { config: { envConfig }, } = useApplication(); // derived values const { archived_at, isContentEditable, isSubmitting, is_locked } = pageStore; const handleAiAssistance = async (response: string) => { if (!editorRef) return; editorRef.current?.setEditorValueAtCursorPosition(response); }; return (
{isContentEditable && (
{isSubmitting === "submitting" && } {isSubmitting === "submitting" ? "Saving..." : "Saved"}
)} {is_locked && (
Locked
)} {archived_at && (
Archived at {renderFormattedDate(archived_at)}
)} {isContentEditable && envConfig?.has_openai_configured && ( { setGptModal((prevData) => !prevData); // this is done so that the title do not reset after gpt popover closed // reset(getValues()); }} onResponse={handleAiAssistance} placement="top-end" button={ } className="!min-w-[38rem]" /> )}
); });