mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: rename page store
This commit is contained in:
parent
98a0742d5c
commit
950b7a8f46
@ -9,10 +9,10 @@ import { DeletePageModal } from "@/components/pages";
|
||||
// helpers
|
||||
import { copyUrlToClipboard } from "@/helpers/string.helper";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
pageLink: string;
|
||||
parentRef: React.RefObject<HTMLElement>;
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ import { usePageFilters } from "@/hooks/use-page-filters";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
const fileService = new FileService();
|
||||
|
||||
@ -30,7 +30,7 @@ type Props = {
|
||||
editorRef: React.RefObject<EditorRefApi>;
|
||||
readOnlyEditorRef: React.RefObject<EditorReadOnlyRefApi>;
|
||||
markings: IMarking[];
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
sidePeekVisible: boolean;
|
||||
handleEditorReady: (value: boolean) => void;
|
||||
handleReadOnlyEditorReady: (value: boolean) => void;
|
||||
|
@ -15,12 +15,12 @@ import { renderFormattedDate } from "@/helpers/date-time.helper";
|
||||
// hooks
|
||||
import { useInstance } from "@/hooks/store";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
editorRef: React.RefObject<EditorRefApi>;
|
||||
handleDuplicatePage: () => void;
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
readOnlyEditorRef: React.RefObject<EditorReadOnlyRefApi>;
|
||||
};
|
||||
|
||||
|
@ -4,10 +4,10 @@ import { Calendar, History, Info } from "lucide-react";
|
||||
// helpers
|
||||
import { renderFormattedDate } from "@/helpers/date-time.helper";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
};
|
||||
|
||||
export const PageInfoPopover: React.FC<Props> = (props) => {
|
||||
|
@ -5,14 +5,14 @@ import { PageExtraOptions, PageSummaryPopover, PageToolbar } from "@/components/
|
||||
// hooks
|
||||
import { usePageFilters } from "@/hooks/use-page-filters";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
editorRef: React.RefObject<EditorRefApi>;
|
||||
readOnlyEditorRef: React.RefObject<EditorReadOnlyRefApi>;
|
||||
handleDuplicatePage: () => void;
|
||||
markings: IMarking[];
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
sidePeekVisible: boolean;
|
||||
setSidePeekVisible: (sidePeekState: boolean) => void;
|
||||
editorReady: boolean;
|
||||
|
@ -11,14 +11,13 @@ import { copyTextToClipboard, copyUrlToClipboard } from "@/helpers/string.helper
|
||||
// hooks
|
||||
import { useAppRouter } from "@/hooks/store";
|
||||
import { usePageFilters } from "@/hooks/use-page-filters";
|
||||
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
editorRef: EditorRefApi | EditorReadOnlyRefApi | null;
|
||||
handleDuplicatePage: () => void;
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
};
|
||||
|
||||
export const PageOptionsDropdown: React.FC<Props> = observer((props) => {
|
||||
|
@ -7,14 +7,14 @@ import { cn } from "@/helpers/common.helper";
|
||||
// hooks
|
||||
import { usePageFilters } from "@/hooks/use-page-filters";
|
||||
// store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
type Props = {
|
||||
editorRef: React.RefObject<EditorRefApi>;
|
||||
readOnlyEditorRef: React.RefObject<EditorReadOnlyRefApi>;
|
||||
handleDuplicatePage: () => void;
|
||||
markings: IMarking[];
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
sidePeekVisible: boolean;
|
||||
setSidePeekVisible: (sidePeekState: boolean) => void;
|
||||
editorReady: boolean;
|
||||
|
@ -2,13 +2,13 @@ import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
|
||||
export const usePage = (pageId: string | undefined): IPageStore => {
|
||||
export const usePage = (pageId: string | undefined): IPage => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("usePage must be used within StoreProvider");
|
||||
|
||||
if (!pageId) return {} as IPageStore;
|
||||
if (!pageId) return {} as IPage;
|
||||
|
||||
return context.projectPages.data?.[pageId] ?? {};
|
||||
};
|
||||
|
@ -7,12 +7,12 @@ import { EditorRefApi, generateJSONfromHTML } from "@plane/editor-core";
|
||||
import useReloadConfirmations from "@/hooks/use-reload-confirmation";
|
||||
// services
|
||||
import { ProjectPageService } from "@/services/page";
|
||||
import { IPageStore } from "@/store/pages/page.store";
|
||||
import { IPage } from "@/store/pages/page";
|
||||
const projectPageService = new ProjectPageService();
|
||||
|
||||
type Props = {
|
||||
editorRef: React.RefObject<EditorRefApi>;
|
||||
page: IPageStore;
|
||||
page: IPage;
|
||||
projectId: string | string[] | undefined;
|
||||
workspaceSlug: string | string[] | undefined;
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ import { ProjectPageService } from "@/services/page";
|
||||
|
||||
export type TLoader = "submitting" | "submitted" | "saved";
|
||||
|
||||
export interface IPageStore extends TPage {
|
||||
export interface IPage extends TPage {
|
||||
// observables
|
||||
isSubmitting: TLoader;
|
||||
// computed
|
||||
@ -44,7 +44,7 @@ export interface IPageStore extends TPage {
|
||||
removeFromFavorites: () => Promise<void>;
|
||||
}
|
||||
|
||||
export class PageStore implements IPageStore {
|
||||
export class Page implements IPage {
|
||||
// loaders
|
||||
isSubmitting: TLoader = "saved";
|
||||
// page properties
|
@ -11,7 +11,7 @@ import { RootStore } from "@/plane-web/store/root.store";
|
||||
// services
|
||||
import { ProjectPageService } from "@/services/page";
|
||||
// store
|
||||
import { IPageStore, PageStore } from "@/store/pages/page.store";
|
||||
import { IPage, Page } from "@/store/pages/page";
|
||||
|
||||
type TLoader = "init-loader" | "mutation-loader" | undefined;
|
||||
|
||||
@ -20,7 +20,7 @@ type TError = { title: string; description: string };
|
||||
export interface IProjectPageStore {
|
||||
// observables
|
||||
loader: TLoader;
|
||||
data: Record<string, IPageStore>; // pageId => PageStore
|
||||
data: Record<string, IPage>; // pageId => Page
|
||||
error: TError | undefined;
|
||||
filters: TPageFilters;
|
||||
// computed
|
||||
@ -28,7 +28,7 @@ export interface IProjectPageStore {
|
||||
// helper actions
|
||||
getCurrentProjectPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
||||
getCurrentProjectFilteredPageIds: (pageType: TPageNavigationTabs) => string[] | undefined;
|
||||
pageById: (pageId: string) => IPageStore | undefined;
|
||||
pageById: (pageId: string) => IPage | undefined;
|
||||
updateFilters: <T extends keyof TPageFilters>(filterKey: T, filterValue: TPageFilters[T]) => void;
|
||||
clearAllFilters: () => void;
|
||||
// actions
|
||||
@ -41,7 +41,7 @@ export interface IProjectPageStore {
|
||||
export class ProjectPageStore implements IProjectPageStore {
|
||||
// observables
|
||||
loader: TLoader = "init-loader";
|
||||
data: Record<string, IPageStore> = {}; // pageId => PageStore
|
||||
data: Record<string, IPage> = {}; // pageId => Page
|
||||
error: TError | undefined = undefined;
|
||||
filters: TPageFilters = {
|
||||
searchQuery: "",
|
||||
@ -162,7 +162,7 @@ export class ProjectPageStore implements IProjectPageStore {
|
||||
|
||||
const pages = await this.service.fetchAll(workspaceSlug, projectId);
|
||||
runInAction(() => {
|
||||
for (const page of pages) if (page?.id) set(this.data, [page.id], new PageStore(this.store, page));
|
||||
for (const page of pages) if (page?.id) set(this.data, [page.id], new Page(this.store, page));
|
||||
this.loader = undefined;
|
||||
});
|
||||
|
||||
@ -196,7 +196,7 @@ export class ProjectPageStore implements IProjectPageStore {
|
||||
|
||||
const page = await this.service.fetchById(workspaceSlug, projectId, pageId);
|
||||
runInAction(() => {
|
||||
if (page?.id) set(this.data, [page.id], new PageStore(this.store, page));
|
||||
if (page?.id) set(this.data, [page.id], new Page(this.store, page));
|
||||
this.loader = undefined;
|
||||
});
|
||||
|
||||
@ -229,7 +229,7 @@ export class ProjectPageStore implements IProjectPageStore {
|
||||
|
||||
const page = await this.service.create(workspaceSlug, projectId, pageData);
|
||||
runInAction(() => {
|
||||
if (page?.id) set(this.data, [page.id], new PageStore(this.store, page));
|
||||
if (page?.id) set(this.data, [page.id], new Page(this.store, page));
|
||||
this.loader = undefined;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user