[WEB-1436] chore: pages improvement. (#4657)
* add empty state if no pages are available. * set access to private in create page modal when the modal is open form private tab.
This commit is contained in:
parent
608e193c36
commit
a2cdbd52dc
17 changed files with 95 additions and 64 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { FC, useState } from "react";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
// types
|
||||
import { TPage } from "@plane/types";
|
||||
|
|
@ -15,29 +15,34 @@ type Props = {
|
|||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
isModalOpen: boolean;
|
||||
pageAccess?: EPageAccess;
|
||||
handleModalClose: () => void;
|
||||
redirectionEnabled?: boolean;
|
||||
};
|
||||
|
||||
export const CreatePageModal: FC<Props> = (props) => {
|
||||
const { workspaceSlug, projectId, isModalOpen, handleModalClose, redirectionEnabled = false } = props;
|
||||
const { workspaceSlug, projectId, isModalOpen, pageAccess, handleModalClose, redirectionEnabled = false } = props;
|
||||
// states
|
||||
const [pageFormData, setPageFormData] = useState<Partial<TPage>>({
|
||||
id: undefined,
|
||||
name: "",
|
||||
access: EPageAccess.PUBLIC,
|
||||
logo_props: undefined,
|
||||
});
|
||||
// router
|
||||
const router = useRouter();
|
||||
// store hooks
|
||||
const { createPage } = useProjectPages(projectId);
|
||||
const { createPage } = useProjectPages();
|
||||
const { capturePageEvent } = useEventTracker();
|
||||
const handlePageFormData = <T extends keyof TPage>(key: T, value: TPage[T]) =>
|
||||
setPageFormData((prev) => ({ ...prev, [key]: value }));
|
||||
|
||||
// update page access in form data when page access from the store changes
|
||||
useEffect(() => {
|
||||
setPageFormData((prev) => ({ ...prev, access: pageAccess }));
|
||||
}, [pageAccess]);
|
||||
|
||||
const handleStateClear = () => {
|
||||
setPageFormData({ id: undefined, name: "", access: EPageAccess.PUBLIC });
|
||||
setPageFormData({ id: undefined, name: "", access: pageAccess });
|
||||
handleModalClose();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,14 @@ type TConfirmPageDeletionProps = {
|
|||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
pageId: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export const DeletePageModal: React.FC<TConfirmPageDeletionProps> = observer((props) => {
|
||||
const { pageId, projectId, isOpen, onClose } = props;
|
||||
const { pageId, isOpen, onClose } = props;
|
||||
// states
|
||||
const [isDeleting, setIsDeleting] = useState(false);
|
||||
// store hooks
|
||||
const { removePage } = useProjectPages(projectId);
|
||||
const { removePage } = useProjectPages();
|
||||
const { capturePageEvent } = useEventTracker();
|
||||
const page = usePage(pageId);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue