mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
e975abff21
* fix: removed parameters `workspace`, `project` & `id` from the patch calls * feat: modified components to work with new pages hooks * feat: modified stores * feat: modified initial component * feat: component implementation changes * feat: store implementation * refactor pages store * feat: updated page store to perform async operations faster * fix: added types for archive and restore pages * feat: implemented archive and restore pages * fix: page creating twice when form submit * feat: updated create-page-modal * feat: updated page form and delete page modal * fix: create page modal not updating isSubmitted prop * feat: list items and list view refactored for pages * feat: refactored project-page-store for inserting computed pagesids * chore: renamed project pages hook * feat: added favourite pages implementation * fix: implemented store for archived pages * fix: project page store for recent pages * fix: issue suggestions breaking pages * fix: issue embeds and suggestions breaking * feat: implemented page store and project page store in page editor * chore: lock file changes * fix: modified page details header to catch mobx updates instead of swr calls * fix: modified usePage hook to fetch page details when reloaded directly on page * fix: fixed deleting pages * fix: removed render on props changed * feat: implemented page store inside page details * fix: role change in pages archives * fix: rerending of pages on tab change * fix: reimplementation of peek overview inside pages * chore: typo fixes * fix: issue suggestion widget selecting wrong issues on click * feat: added labels in pages * fix: deepsource errors fixed * fix: build errors * fix: review comments * fix: removed swr hooks from the `usePage` store hook and refactored `issueEmbed` hook * fix: resolved reviewed comments --------- Co-authored-by: Rahul R <rahulr@Rahuls-MacBook-Pro.local>
93 lines
3.1 KiB
TypeScript
93 lines
3.1 KiB
TypeScript
import React, { FC } from "react";
|
|
import { useRouter } from "next/router";
|
|
import { Dialog, Transition } from "@headlessui/react";
|
|
// hooks
|
|
import { useApplication } from "hooks/store";
|
|
// components
|
|
import { PageForm } from "./page-form";
|
|
// types
|
|
import { IPage } from "@plane/types";
|
|
import { useProjectPages } from "hooks/store/use-project-page";
|
|
import { IPageStore } from "store/page.store";
|
|
|
|
type Props = {
|
|
// data?: IPage | null;
|
|
pageStore?: IPageStore;
|
|
handleClose: () => void;
|
|
isOpen: boolean;
|
|
projectId: string;
|
|
};
|
|
|
|
export const CreateUpdatePageModal: FC<Props> = (props) => {
|
|
const { isOpen, handleClose, projectId, pageStore } = props;
|
|
// router
|
|
const router = useRouter();
|
|
const { workspaceSlug } = router.query;
|
|
|
|
const { createPage } = useProjectPages();
|
|
// store hooks
|
|
const {
|
|
eventTracker: { postHogEventTracker },
|
|
} = useApplication();
|
|
|
|
const createProjectPage = async (payload: IPage) => {
|
|
if (!workspaceSlug) return;
|
|
await createPage(workspaceSlug.toString(), projectId, payload);
|
|
};
|
|
|
|
const handleFormSubmit = async (formData: IPage) => {
|
|
if (!workspaceSlug || !projectId) return;
|
|
try {
|
|
if (pageStore) {
|
|
if (pageStore.name !== formData.name) {
|
|
await pageStore.updateName(formData.name);
|
|
}
|
|
if (pageStore.access !== formData.access) {
|
|
formData.access === 1 ? await pageStore.makePrivate() : await pageStore.makePublic();
|
|
}
|
|
} else {
|
|
await createProjectPage(formData);
|
|
}
|
|
handleClose();
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Transition.Root show={isOpen} as={React.Fragment}>
|
|
<Dialog as="div" className="relative z-20" onClose={handleClose}>
|
|
<Transition.Child
|
|
as={React.Fragment}
|
|
enter="ease-out duration-300"
|
|
enterFrom="opacity-0"
|
|
enterTo="opacity-100"
|
|
leave="ease-in duration-200"
|
|
leaveFrom="opacity-100"
|
|
leaveTo="opacity-0"
|
|
>
|
|
<div className="fixed inset-0 bg-custom-backdrop transition-opacity" />
|
|
</Transition.Child>
|
|
|
|
<div className="fixed inset-0 z-20 overflow-y-auto">
|
|
<div className="my-10 flex justify-center p-4 text-center sm:p-0 md:my-20">
|
|
<Transition.Child
|
|
as={React.Fragment}
|
|
enter="ease-out duration-300"
|
|
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
enterTo="opacity-100 translate-y-0 sm:scale-100"
|
|
leave="ease-in duration-200"
|
|
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
|
|
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
|
>
|
|
<Dialog.Panel className="relative transform rounded-lg bg-custom-background-100 p-5 px-4 text-left shadow-custom-shadow-md transition-all sm:w-full sm:max-w-2xl">
|
|
<PageForm handleFormSubmit={handleFormSubmit} handleClose={handleClose} pageStore={pageStore} />
|
|
</Dialog.Panel>
|
|
</Transition.Child>
|
|
</div>
|
|
</div>
|
|
</Dialog>
|
|
</Transition.Root>
|
|
);
|
|
};
|