mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[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
@ -71,7 +71,7 @@ export const CommandPaletteProjectActions: React.FC<Props> = (props) => {
|
|||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
closePalette();
|
closePalette();
|
||||||
setTrackElement("Command palette");
|
setTrackElement("Command palette");
|
||||||
toggleCreatePageModal(true);
|
toggleCreatePageModal({ isOpen: true });
|
||||||
}}
|
}}
|
||||||
className="focus:outline-none"
|
className="focus:outline-none"
|
||||||
>
|
>
|
||||||
|
@ -50,7 +50,7 @@ export const CommandPalette: FC = observer(() => {
|
|||||||
toggleCreateIssueModal,
|
toggleCreateIssueModal,
|
||||||
isCreateCycleModalOpen,
|
isCreateCycleModalOpen,
|
||||||
toggleCreateCycleModal,
|
toggleCreateCycleModal,
|
||||||
isCreatePageModalOpen,
|
createPageModal,
|
||||||
toggleCreatePageModal,
|
toggleCreatePageModal,
|
||||||
isCreateProjectModalOpen,
|
isCreateProjectModalOpen,
|
||||||
toggleCreateProjectModal,
|
toggleCreateProjectModal,
|
||||||
@ -150,7 +150,7 @@ export const CommandPalette: FC = observer(() => {
|
|||||||
d: {
|
d: {
|
||||||
title: "Create a new page",
|
title: "Create a new page",
|
||||||
description: "Create a new page in the current project",
|
description: "Create a new page in the current project",
|
||||||
action: () => toggleCreatePageModal(true),
|
action: () => toggleCreatePageModal({ isOpen: true }),
|
||||||
},
|
},
|
||||||
m: {
|
m: {
|
||||||
title: "Create a new module",
|
title: "Create a new module",
|
||||||
@ -297,8 +297,9 @@ export const CommandPalette: FC = observer(() => {
|
|||||||
<CreatePageModal
|
<CreatePageModal
|
||||||
workspaceSlug={workspaceSlug.toString()}
|
workspaceSlug={workspaceSlug.toString()}
|
||||||
projectId={projectId.toString()}
|
projectId={projectId.toString()}
|
||||||
isModalOpen={isCreatePageModalOpen}
|
isModalOpen={createPageModal.isOpen}
|
||||||
handleModalClose={() => toggleCreatePageModal(false)}
|
pageAccess={createPageModal.pageAccess}
|
||||||
|
handleModalClose={() => toggleCreatePageModal({ isOpen: false })}
|
||||||
redirectionEnabled
|
redirectionEnabled
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { FileText } from "lucide-react";
|
import { FileText } from "lucide-react";
|
||||||
// hooks
|
|
||||||
// ui
|
// ui
|
||||||
import { Breadcrumbs, Button } from "@plane/ui";
|
import { Breadcrumbs, Button } from "@plane/ui";
|
||||||
// helpers
|
// helpers
|
||||||
import { BreadcrumbLink, Logo } from "@/components/common";
|
import { BreadcrumbLink, Logo } from "@/components/common";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
|
||||||
// constants
|
// constants
|
||||||
// components
|
import { EPageAccess } from "@/constants/page";
|
||||||
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
|
// hooks
|
||||||
import { useCommandPalette, useEventTracker, useProject, useUser } from "@/hooks/store";
|
import { useCommandPalette, useEventTracker, useProject, useUser } from "@/hooks/store";
|
||||||
|
|
||||||
export const PagesHeader = observer(() => {
|
export const PagesHeader = observer(() => {
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug } = router.query;
|
const { workspaceSlug, type: pageType } = router.query;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { toggleCreatePageModal } = useCommandPalette();
|
const { toggleCreatePageModal } = useCommandPalette();
|
||||||
const {
|
const {
|
||||||
@ -61,7 +61,10 @@ export const PagesHeader = observer(() => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTrackElement("Project pages page");
|
setTrackElement("Project pages page");
|
||||||
toggleCreatePageModal(true);
|
toggleCreatePageModal({
|
||||||
|
isOpen: true,
|
||||||
|
pageAccess: pageType === "private" ? EPageAccess.PRIVATE : EPageAccess.PUBLIC,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add Page
|
Add Page
|
||||||
|
@ -85,12 +85,7 @@ export const PageQuickActions: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DeletePageModal
|
<DeletePageModal isOpen={deletePageModal} onClose={() => setDeletePageModal(false)} pageId={pageId} />
|
||||||
isOpen={deletePageModal}
|
|
||||||
onClose={() => setDeletePageModal(false)}
|
|
||||||
pageId={pageId}
|
|
||||||
projectId={projectId}
|
|
||||||
/>
|
|
||||||
<ContextMenu parentRef={parentRef} items={MENU_ITEMS} />
|
<ContextMenu parentRef={parentRef} items={MENU_ITEMS} />
|
||||||
<CustomMenu placement="bottom-end" ellipsis closeOnSelect>
|
<CustomMenu placement="bottom-end" ellipsis closeOnSelect>
|
||||||
{MENU_ITEMS.map((item) => {
|
{MENU_ITEMS.map((item) => {
|
||||||
|
@ -25,7 +25,7 @@ type Props = {
|
|||||||
export const PagesListHeaderRoot: React.FC<Props> = observer((props) => {
|
export const PagesListHeaderRoot: React.FC<Props> = observer((props) => {
|
||||||
const { pageType, projectId, workspaceSlug } = props;
|
const { pageType, projectId, workspaceSlug } = props;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { filters, updateFilters, clearAllFilters } = useProjectPages(projectId);
|
const { filters, updateFilters, clearAllFilters } = useProjectPages();
|
||||||
const {
|
const {
|
||||||
workspace: { workspaceMemberIds },
|
workspace: { workspaceMemberIds },
|
||||||
} = useMember();
|
} = useMember();
|
||||||
@ -52,7 +52,7 @@ export const PagesListHeaderRoot: React.FC<Props> = observer((props) => {
|
|||||||
<div className="flex-shrink-0 h-[50px] w-full border-b border-custom-border-200 px-6 relative flex items-center gap-4 justify-between">
|
<div className="flex-shrink-0 h-[50px] w-full border-b border-custom-border-200 px-6 relative flex items-center gap-4 justify-between">
|
||||||
<PageTabNavigation workspaceSlug={workspaceSlug} projectId={projectId} pageType={pageType} />
|
<PageTabNavigation workspaceSlug={workspaceSlug} projectId={projectId} pageType={pageType} />
|
||||||
<div className="h-full flex items-center gap-2 self-end">
|
<div className="h-full flex items-center gap-2 self-end">
|
||||||
<PageSearchInput projectId={projectId} />
|
<PageSearchInput />
|
||||||
<PageOrderByDropdown
|
<PageOrderByDropdown
|
||||||
sortBy={filters.sortBy}
|
sortBy={filters.sortBy}
|
||||||
sortKey={filters.sortKey}
|
sortKey={filters.sortKey}
|
||||||
|
@ -18,7 +18,7 @@ type TPagesListRoot = {
|
|||||||
export const PagesListRoot: FC<TPagesListRoot> = observer((props) => {
|
export const PagesListRoot: FC<TPagesListRoot> = observer((props) => {
|
||||||
const { pageType, projectId, workspaceSlug } = props;
|
const { pageType, projectId, workspaceSlug } = props;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { getCurrentProjectFilteredPageIds } = useProjectPages(projectId);
|
const { getCurrentProjectFilteredPageIds } = useProjectPages();
|
||||||
// derived values
|
// derived values
|
||||||
const filteredPageIds = getCurrentProjectFilteredPageIds(pageType);
|
const filteredPageIds = getCurrentProjectFilteredPageIds(pageType);
|
||||||
|
|
||||||
|
@ -5,15 +5,12 @@ import { cn } from "@/helpers/common.helper";
|
|||||||
import { useProjectPages } from "@/hooks/store";
|
import { useProjectPages } from "@/hooks/store";
|
||||||
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
||||||
|
|
||||||
export type TPageSearchInput = { projectId: string };
|
export const PageSearchInput: FC = observer(() => {
|
||||||
|
|
||||||
export const PageSearchInput: FC<TPageSearchInput> = observer((props) => {
|
|
||||||
const { projectId } = props;
|
|
||||||
// hooks
|
// hooks
|
||||||
const {
|
const {
|
||||||
filters: { searchQuery },
|
filters: { searchQuery },
|
||||||
updateFilters,
|
updateFilters,
|
||||||
} = useProjectPages(projectId);
|
} = useProjectPages();
|
||||||
// states
|
// states
|
||||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||||
// refs
|
// refs
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FC, useState } from "react";
|
import { FC, useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
// types
|
// types
|
||||||
import { TPage } from "@plane/types";
|
import { TPage } from "@plane/types";
|
||||||
@ -15,29 +15,34 @@ type Props = {
|
|||||||
workspaceSlug: string;
|
workspaceSlug: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
isModalOpen: boolean;
|
isModalOpen: boolean;
|
||||||
|
pageAccess?: EPageAccess;
|
||||||
handleModalClose: () => void;
|
handleModalClose: () => void;
|
||||||
redirectionEnabled?: boolean;
|
redirectionEnabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CreatePageModal: FC<Props> = (props) => {
|
export const CreatePageModal: FC<Props> = (props) => {
|
||||||
const { workspaceSlug, projectId, isModalOpen, handleModalClose, redirectionEnabled = false } = props;
|
const { workspaceSlug, projectId, isModalOpen, pageAccess, handleModalClose, redirectionEnabled = false } = props;
|
||||||
// states
|
// states
|
||||||
const [pageFormData, setPageFormData] = useState<Partial<TPage>>({
|
const [pageFormData, setPageFormData] = useState<Partial<TPage>>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: "",
|
name: "",
|
||||||
access: EPageAccess.PUBLIC,
|
|
||||||
logo_props: undefined,
|
logo_props: undefined,
|
||||||
});
|
});
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
// store hooks
|
// store hooks
|
||||||
const { createPage } = useProjectPages(projectId);
|
const { createPage } = useProjectPages();
|
||||||
const { capturePageEvent } = useEventTracker();
|
const { capturePageEvent } = useEventTracker();
|
||||||
const handlePageFormData = <T extends keyof TPage>(key: T, value: TPage[T]) =>
|
const handlePageFormData = <T extends keyof TPage>(key: T, value: TPage[T]) =>
|
||||||
setPageFormData((prev) => ({ ...prev, [key]: value }));
|
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 = () => {
|
const handleStateClear = () => {
|
||||||
setPageFormData({ id: undefined, name: "", access: EPageAccess.PUBLIC });
|
setPageFormData({ id: undefined, name: "", access: pageAccess });
|
||||||
handleModalClose();
|
handleModalClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,15 +13,14 @@ type TConfirmPageDeletionProps = {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
pageId: string;
|
pageId: string;
|
||||||
projectId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DeletePageModal: React.FC<TConfirmPageDeletionProps> = observer((props) => {
|
export const DeletePageModal: React.FC<TConfirmPageDeletionProps> = observer((props) => {
|
||||||
const { pageId, projectId, isOpen, onClose } = props;
|
const { pageId, isOpen, onClose } = props;
|
||||||
// states
|
// states
|
||||||
const [isDeleting, setIsDeleting] = useState(false);
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
// store hooks
|
// store hooks
|
||||||
const { removePage } = useProjectPages(projectId);
|
const { removePage } = useProjectPages();
|
||||||
const { capturePageEvent } = useEventTracker();
|
const { capturePageEvent } = useEventTracker();
|
||||||
const page = usePage(pageId);
|
const page = usePage(pageId);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import { PageLoader } from "@/components/pages";
|
|||||||
// constants
|
// constants
|
||||||
import { EmptyStateType } from "@/constants/empty-state";
|
import { EmptyStateType } from "@/constants/empty-state";
|
||||||
// hooks
|
// hooks
|
||||||
|
import { EPageAccess } from "@/constants/page";
|
||||||
import { useCommandPalette, useProjectPages } from "@/hooks/store";
|
import { useCommandPalette, useProjectPages } from "@/hooks/store";
|
||||||
// assets
|
// assets
|
||||||
import AllFiltersImage from "public/empty-state/pages/all-filters.svg";
|
import AllFiltersImage from "public/empty-state/pages/all-filters.svg";
|
||||||
@ -16,13 +17,13 @@ import NameFilterImage from "public/empty-state/pages/name-filter.svg";
|
|||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
pageType: TPageNavigationTabs;
|
pageType: TPageNavigationTabs;
|
||||||
projectId: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PagesListMainContent: React.FC<Props> = observer((props) => {
|
export const PagesListMainContent: React.FC<Props> = observer((props) => {
|
||||||
const { children, pageType, projectId } = props;
|
const { children, pageType } = props;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { loader, getCurrentProjectFilteredPageIds, getCurrentProjectPageIds, filters } = useProjectPages(projectId);
|
const { loader, isAnyPageAvailable, getCurrentProjectFilteredPageIds, getCurrentProjectPageIds, filters } =
|
||||||
|
useProjectPages();
|
||||||
const { toggleCreatePageModal } = useCommandPalette();
|
const { toggleCreatePageModal } = useCommandPalette();
|
||||||
// derived values
|
// derived values
|
||||||
const pageIds = getCurrentProjectPageIds(pageType);
|
const pageIds = getCurrentProjectPageIds(pageType);
|
||||||
@ -30,13 +31,23 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
if (loader === "init-loader") return <PageLoader />;
|
if (loader === "init-loader") return <PageLoader />;
|
||||||
// if no pages exist in the active page type
|
// if no pages exist in the active page type
|
||||||
if (pageIds?.length === 0) {
|
if (!isAnyPageAvailable || pageIds?.length === 0) {
|
||||||
|
if (!isAnyPageAvailable) {
|
||||||
|
return (
|
||||||
|
<EmptyState
|
||||||
|
type={EmptyStateType.PROJECT_PAGE}
|
||||||
|
primaryButtonOnClick={() => {
|
||||||
|
toggleCreatePageModal({ isOpen: true });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (pageType === "public")
|
if (pageType === "public")
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
type={EmptyStateType.PROJECT_PAGE_PUBLIC}
|
type={EmptyStateType.PROJECT_PAGE_PUBLIC}
|
||||||
primaryButtonOnClick={() => {
|
primaryButtonOnClick={() => {
|
||||||
toggleCreatePageModal(true);
|
toggleCreatePageModal({ isOpen: true, pageAccess: EPageAccess.PUBLIC });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -45,7 +56,7 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
|
|||||||
<EmptyState
|
<EmptyState
|
||||||
type={EmptyStateType.PROJECT_PAGE_PRIVATE}
|
type={EmptyStateType.PROJECT_PAGE_PRIVATE}
|
||||||
primaryButtonOnClick={() => {
|
primaryButtonOnClick={() => {
|
||||||
toggleCreatePageModal(true);
|
toggleCreatePageModal({ isOpen: true, pageAccess: EPageAccess.PRIVATE });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -16,7 +16,7 @@ type TPageView = {
|
|||||||
export const PagesListView: React.FC<TPageView> = observer((props) => {
|
export const PagesListView: React.FC<TPageView> = observer((props) => {
|
||||||
const { workspaceSlug, projectId, pageType, children } = props;
|
const { workspaceSlug, projectId, pageType, children } = props;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { getAllPages } = useProjectPages(projectId);
|
const { isAnyPageAvailable, getAllPages } = useProjectPages();
|
||||||
// fetching pages list
|
// fetching pages list
|
||||||
useSWR(projectId ? `PROJECT_PAGES_${projectId}` : null, projectId ? () => getAllPages(pageType) : null);
|
useSWR(projectId ? `PROJECT_PAGES_${projectId}` : null, projectId ? () => getAllPages(pageType) : null);
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ export const PagesListView: React.FC<TPageView> = observer((props) => {
|
|||||||
return (
|
return (
|
||||||
<div className="relative w-full h-full overflow-hidden flex flex-col">
|
<div className="relative w-full h-full overflow-hidden flex flex-col">
|
||||||
{/* tab header */}
|
{/* tab header */}
|
||||||
<PagesListHeaderRoot pageType={pageType} projectId={projectId} workspaceSlug={workspaceSlug} />
|
{isAnyPageAvailable && (
|
||||||
<PagesListMainContent pageType={pageType} projectId={projectId}>
|
<PagesListHeaderRoot pageType={pageType} projectId={projectId} workspaceSlug={workspaceSlug} />
|
||||||
{children}
|
)}
|
||||||
</PagesListMainContent>
|
<PagesListMainContent pageType={pageType}>{children}</PagesListMainContent>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -486,11 +486,6 @@ const emptyStateDetails = {
|
|||||||
path: "/empty-state/onboarding/pages",
|
path: "/empty-state/onboarding/pages",
|
||||||
primaryButton: {
|
primaryButton: {
|
||||||
text: "Create your first page",
|
text: "Create your first page",
|
||||||
comicBox: {
|
|
||||||
title: "A page can be a doc or a doc of docs.",
|
|
||||||
description:
|
|
||||||
"We wrote Nikhil and Meera’s love story. You could write your project’s mission, goals, and eventual vision.",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
accessType: "project",
|
accessType: "project",
|
||||||
access: EUserProjectRoles.MEMBER,
|
access: EUserProjectRoles.MEMBER,
|
||||||
|
@ -32,3 +32,13 @@ export const PAGE_SORT_BY_OPTIONS: {
|
|||||||
{ key: "asc", label: "Ascending" },
|
{ key: "asc", label: "Ascending" },
|
||||||
{ key: "desc", label: "Descending" },
|
{ key: "desc", label: "Descending" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export type TCreatePageModal = {
|
||||||
|
isOpen: boolean;
|
||||||
|
pageAccess?: EPageAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_CREATE_PAGE_MODAL_DATA: TCreatePageModal = {
|
||||||
|
isOpen: false,
|
||||||
|
pageAccess: EPageAccess.PUBLIC,
|
||||||
|
};
|
||||||
|
@ -4,11 +4,8 @@ import { StoreContext } from "@/lib/store-context";
|
|||||||
// mobx store
|
// mobx store
|
||||||
import { IProjectPageStore } from "@/store/pages/project-page.store";
|
import { IProjectPageStore } from "@/store/pages/project-page.store";
|
||||||
|
|
||||||
export const useProjectPages = (projectId: string | undefined): IProjectPageStore => {
|
export const useProjectPages = (): IProjectPageStore => {
|
||||||
const context = useContext(StoreContext);
|
const context = useContext(StoreContext);
|
||||||
if (context === undefined) throw new Error("useProjectPage must be used within StoreProvider");
|
if (context === undefined) throw new Error("useProjectPage must be used within StoreProvider");
|
||||||
|
|
||||||
if (!projectId) throw new Error("projectId must be passed as a property");
|
|
||||||
|
|
||||||
return context.projectPages;
|
return context.projectPages;
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId, pageId } = router.query;
|
const { workspaceSlug, projectId, pageId } = router.query;
|
||||||
// store hooks
|
// store hooks
|
||||||
const { createPage, getPageById } = useProjectPages(projectId?.toString() ?? "");
|
const { createPage, getPageById } = useProjectPages();
|
||||||
const page = usePage(pageId?.toString() ?? "");
|
const page = usePage(pageId?.toString() ?? "");
|
||||||
const { access, description_html, id, name } = page;
|
const { access, description_html, id, name } = page;
|
||||||
// editor markings hook
|
// editor markings hook
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { observable, action, makeObservable, computed } from "mobx";
|
import { observable, action, makeObservable, computed } from "mobx";
|
||||||
// services
|
// services
|
||||||
import { EIssuesStoreType, TCreateModalStoreTypes } from "@/constants/issue";
|
import { EIssuesStoreType, TCreateModalStoreTypes } from "@/constants/issue";
|
||||||
|
// types / constants
|
||||||
|
import { DEFAULT_CREATE_PAGE_MODAL_DATA, EPageAccess, TCreatePageModal } from "@/constants/page";
|
||||||
|
|
||||||
export interface ModalData {
|
export interface ModalData {
|
||||||
store: EIssuesStoreType;
|
store: EIssuesStoreType;
|
||||||
@ -16,7 +18,7 @@ export interface ICommandPaletteStore {
|
|||||||
isCreateCycleModalOpen: boolean;
|
isCreateCycleModalOpen: boolean;
|
||||||
isCreateModuleModalOpen: boolean;
|
isCreateModuleModalOpen: boolean;
|
||||||
isCreateViewModalOpen: boolean;
|
isCreateViewModalOpen: boolean;
|
||||||
isCreatePageModalOpen: boolean;
|
createPageModal: TCreatePageModal;
|
||||||
isCreateIssueModalOpen: boolean;
|
isCreateIssueModalOpen: boolean;
|
||||||
isDeleteIssueModalOpen: boolean;
|
isDeleteIssueModalOpen: boolean;
|
||||||
isBulkDeleteIssueModalOpen: boolean;
|
isBulkDeleteIssueModalOpen: boolean;
|
||||||
@ -28,7 +30,7 @@ export interface ICommandPaletteStore {
|
|||||||
toggleCreateProjectModal: (value?: boolean) => void;
|
toggleCreateProjectModal: (value?: boolean) => void;
|
||||||
toggleCreateCycleModal: (value?: boolean) => void;
|
toggleCreateCycleModal: (value?: boolean) => void;
|
||||||
toggleCreateViewModal: (value?: boolean) => void;
|
toggleCreateViewModal: (value?: boolean) => void;
|
||||||
toggleCreatePageModal: (value?: boolean) => void;
|
toggleCreatePageModal: (value?: TCreatePageModal) => void;
|
||||||
toggleCreateIssueModal: (value?: boolean, storeType?: TCreateModalStoreTypes) => void;
|
toggleCreateIssueModal: (value?: boolean, storeType?: TCreateModalStoreTypes) => void;
|
||||||
toggleCreateModuleModal: (value?: boolean) => void;
|
toggleCreateModuleModal: (value?: boolean) => void;
|
||||||
toggleDeleteIssueModal: (value?: boolean) => void;
|
toggleDeleteIssueModal: (value?: boolean) => void;
|
||||||
@ -45,10 +47,10 @@ export class CommandPaletteStore implements ICommandPaletteStore {
|
|||||||
isCreateCycleModalOpen: boolean = false;
|
isCreateCycleModalOpen: boolean = false;
|
||||||
isCreateModuleModalOpen: boolean = false;
|
isCreateModuleModalOpen: boolean = false;
|
||||||
isCreateViewModalOpen: boolean = false;
|
isCreateViewModalOpen: boolean = false;
|
||||||
isCreatePageModalOpen: boolean = false;
|
|
||||||
isCreateIssueModalOpen: boolean = false;
|
isCreateIssueModalOpen: boolean = false;
|
||||||
isDeleteIssueModalOpen: boolean = false;
|
isDeleteIssueModalOpen: boolean = false;
|
||||||
isBulkDeleteIssueModalOpen: boolean = false;
|
isBulkDeleteIssueModalOpen: boolean = false;
|
||||||
|
createPageModal: TCreatePageModal = DEFAULT_CREATE_PAGE_MODAL_DATA;
|
||||||
|
|
||||||
createIssueStoreType: TCreateModalStoreTypes = EIssuesStoreType.PROJECT;
|
createIssueStoreType: TCreateModalStoreTypes = EIssuesStoreType.PROJECT;
|
||||||
|
|
||||||
@ -61,10 +63,10 @@ export class CommandPaletteStore implements ICommandPaletteStore {
|
|||||||
isCreateCycleModalOpen: observable.ref,
|
isCreateCycleModalOpen: observable.ref,
|
||||||
isCreateModuleModalOpen: observable.ref,
|
isCreateModuleModalOpen: observable.ref,
|
||||||
isCreateViewModalOpen: observable.ref,
|
isCreateViewModalOpen: observable.ref,
|
||||||
isCreatePageModalOpen: observable.ref,
|
|
||||||
isCreateIssueModalOpen: observable.ref,
|
isCreateIssueModalOpen: observable.ref,
|
||||||
isDeleteIssueModalOpen: observable.ref,
|
isDeleteIssueModalOpen: observable.ref,
|
||||||
isBulkDeleteIssueModalOpen: observable.ref,
|
isBulkDeleteIssueModalOpen: observable.ref,
|
||||||
|
createPageModal: observable,
|
||||||
// computed
|
// computed
|
||||||
isAnyModalOpen: computed,
|
isAnyModalOpen: computed,
|
||||||
// projectPages: computed,
|
// projectPages: computed,
|
||||||
@ -90,13 +92,13 @@ export class CommandPaletteStore implements ICommandPaletteStore {
|
|||||||
return Boolean(
|
return Boolean(
|
||||||
this.isCreateIssueModalOpen ||
|
this.isCreateIssueModalOpen ||
|
||||||
this.isCreateCycleModalOpen ||
|
this.isCreateCycleModalOpen ||
|
||||||
this.isCreatePageModalOpen ||
|
|
||||||
this.isCreateProjectModalOpen ||
|
this.isCreateProjectModalOpen ||
|
||||||
this.isCreateModuleModalOpen ||
|
this.isCreateModuleModalOpen ||
|
||||||
this.isCreateViewModalOpen ||
|
this.isCreateViewModalOpen ||
|
||||||
this.isShortcutModalOpen ||
|
this.isShortcutModalOpen ||
|
||||||
this.isBulkDeleteIssueModalOpen ||
|
this.isBulkDeleteIssueModalOpen ||
|
||||||
this.isDeleteIssueModalOpen
|
this.isDeleteIssueModalOpen ||
|
||||||
|
this.createPageModal.isOpen
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,15 +168,21 @@ export class CommandPaletteStore implements ICommandPaletteStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the create page modal
|
* Toggles the create page modal along with the page access
|
||||||
* @param value
|
* @param value
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
toggleCreatePageModal = (value?: boolean) => {
|
toggleCreatePageModal = (value?: TCreatePageModal) => {
|
||||||
if (value !== undefined) {
|
if (value) {
|
||||||
this.isCreatePageModalOpen = value;
|
this.createPageModal = {
|
||||||
|
isOpen: value.isOpen,
|
||||||
|
pageAccess: value.pageAccess || EPageAccess.PUBLIC,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
this.isCreatePageModalOpen = !this.isCreatePageModalOpen;
|
this.createPageModal = {
|
||||||
|
isOpen: !this.createPageModal.isOpen,
|
||||||
|
pageAccess: EPageAccess.PUBLIC,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ export interface IProjectPageStore {
|
|||||||
data: Record<string, IPageStore>; // pageId => PageStore
|
data: Record<string, IPageStore>; // pageId => PageStore
|
||||||
error: TError | undefined;
|
error: TError | undefined;
|
||||||
filters: TPageFilters;
|
filters: TPageFilters;
|
||||||
|
// computed
|
||||||
|
isAnyPageAvailable: boolean;
|
||||||
// helper actions
|
// helper actions
|
||||||
getCurrentProjectPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
getCurrentProjectPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
||||||
getCurrentProjectFilteredPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
getCurrentProjectFilteredPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
||||||
@ -76,6 +78,14 @@ export class ProjectPageStore implements IProjectPageStore {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description check if any page is available
|
||||||
|
*/
|
||||||
|
get isAnyPageAvailable() {
|
||||||
|
if (this.loader) return true;
|
||||||
|
return Object.keys(this.data).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get the current project page ids based on the pageType
|
* @description get the current project page ids based on the pageType
|
||||||
* @param {TPageNavigationTabs} pageType
|
* @param {TPageNavigationTabs} pageType
|
||||||
|
Loading…
Reference in New Issue
Block a user