[WIKI-458] refactor: base page instance for additional properties (#7228)
* refactor: create a super class for base page * fix: path --------- Co-authored-by: Palanikannan M <akashmalinimurugu@gmail.com>
This commit is contained in:
parent
414010688d
commit
eb5ffebcc6
7 changed files with 30 additions and 15 deletions
16
web/ce/store/pages/extended-base-page.ts
Normal file
16
web/ce/store/pages/extended-base-page.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { TPage, TPageExtended } from "@plane/types";
|
||||
import { RootStore } from "@/plane-web/store/root.store";
|
||||
import { TBasePageServices } from "@/store/pages/base-page";
|
||||
|
||||
export type TExtendedPageInstance = TPageExtended & {
|
||||
asJSONExtended: TPageExtended;
|
||||
};
|
||||
|
||||
export class ExtendedBasePage implements TExtendedPageInstance {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
constructor(store: RootStore, page: TPage, services: TBasePageServices) {}
|
||||
|
||||
get asJSONExtended(): TExtendedPageInstance["asJSONExtended"] {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import { TDocumentPayload, TLogoProps, TNameDescriptionLoader, TPage } from "@pl
|
|||
import { TChangeHandlerProps } from "@plane/ui";
|
||||
import { convertHexEmojiToDecimal } from "@plane/utils";
|
||||
// plane web store
|
||||
import { ExtendedBasePage } from "@/plane-web/store/pages/extended-base-page";
|
||||
import { RootStore } from "@/plane-web/store/root.store";
|
||||
|
||||
export type TBasePage = TPage & {
|
||||
|
|
@ -69,7 +70,7 @@ export type TPageInstance = TBasePage &
|
|||
getRedirectionLink: () => string;
|
||||
};
|
||||
|
||||
export class BasePage implements TBasePage {
|
||||
export class BasePage extends ExtendedBasePage implements TBasePage {
|
||||
// loaders
|
||||
isSubmitting: TNameDescriptionLoader = "saved";
|
||||
editorRef: EditorRefApi | null = null;
|
||||
|
|
@ -82,13 +83,11 @@ export class BasePage implements TBasePage {
|
|||
label_ids: string[] | undefined;
|
||||
owned_by: string | undefined;
|
||||
access: EPageAccess | undefined;
|
||||
anchor?: string | null | undefined;
|
||||
is_favorite: boolean;
|
||||
is_locked: boolean;
|
||||
archived_at: string | null | undefined;
|
||||
workspace: string | undefined;
|
||||
project_ids?: string[] | undefined;
|
||||
team: string | null | undefined;
|
||||
created_by: string | undefined;
|
||||
updated_by: string | undefined;
|
||||
created_at: Date | undefined;
|
||||
|
|
@ -106,6 +105,8 @@ export class BasePage implements TBasePage {
|
|||
page: TPage,
|
||||
services: TBasePageServices
|
||||
) {
|
||||
super(store, page, services);
|
||||
|
||||
this.id = page?.id || undefined;
|
||||
this.name = page?.name;
|
||||
this.logo_props = page?.logo_props || undefined;
|
||||
|
|
@ -114,13 +115,11 @@ export class BasePage implements TBasePage {
|
|||
this.label_ids = page?.label_ids || undefined;
|
||||
this.owned_by = page?.owned_by || undefined;
|
||||
this.access = page?.access || EPageAccess.PUBLIC;
|
||||
this.anchor = page?.anchor || undefined;
|
||||
this.is_favorite = page?.is_favorite || false;
|
||||
this.is_locked = page?.is_locked || false;
|
||||
this.archived_at = page?.archived_at || undefined;
|
||||
this.workspace = page?.workspace || undefined;
|
||||
this.project_ids = page?.project_ids || undefined;
|
||||
this.team = page?.team || undefined;
|
||||
this.created_by = page?.created_by || undefined;
|
||||
this.updated_by = page?.updated_by || undefined;
|
||||
this.created_at = page?.created_at || undefined;
|
||||
|
|
@ -140,7 +139,6 @@ export class BasePage implements TBasePage {
|
|||
label_ids: observable,
|
||||
owned_by: observable.ref,
|
||||
access: observable.ref,
|
||||
anchor: observable.ref,
|
||||
is_favorite: observable.ref,
|
||||
is_locked: observable.ref,
|
||||
archived_at: observable.ref,
|
||||
|
|
@ -212,18 +210,17 @@ export class BasePage implements TBasePage {
|
|||
label_ids: this.label_ids,
|
||||
owned_by: this.owned_by,
|
||||
access: this.access,
|
||||
anchor: this.anchor,
|
||||
logo_props: this.logo_props,
|
||||
is_favorite: this.is_favorite,
|
||||
is_locked: this.is_locked,
|
||||
archived_at: this.archived_at,
|
||||
workspace: this.workspace,
|
||||
project_ids: this.project_ids,
|
||||
team: this.team,
|
||||
created_by: this.created_by,
|
||||
updated_by: this.updated_by,
|
||||
created_at: this.created_at,
|
||||
updated_at: this.updated_at,
|
||||
...this.asJSONExtended,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue