[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:
Aaryan Khandelwal 2025-06-19 16:00:18 +05:30 committed by GitHub
parent 414010688d
commit eb5ffebcc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 15 deletions

View file

@ -10,7 +10,7 @@ export * from "./issues";
export * from "./module"; export * from "./module";
export * from "./views"; export * from "./views";
export * from "./integration"; export * from "./integration";
export * from "./pages"; export * from "./page";
export * from "./ai"; export * from "./ai";
export * from "./estimate"; export * from "./estimate";
export * from "./importer"; export * from "./importer";

View file

@ -1,9 +1,9 @@
import { TLogoProps } from "./common"; import { TLogoProps } from "../common";
import { EPageAccess } from "./enums"; import { EPageAccess } from "../enums";
import { TPageExtended } from "./extended";
export type TPage = { export type TPage = TPageExtended & {
access: EPageAccess | undefined; access: EPageAccess | undefined;
anchor?: string | null | undefined;
archived_at: string | null | undefined; archived_at: string | null | undefined;
color: string | undefined; color: string | undefined;
created_at: Date | undefined; created_at: Date | undefined;
@ -16,7 +16,6 @@ export type TPage = {
name: string | undefined; name: string | undefined;
owned_by: string | undefined; owned_by: string | undefined;
project_ids?: string[] | undefined; project_ids?: string[] | undefined;
team: string | null | undefined;
updated_at: Date | undefined; updated_at: Date | undefined;
updated_by: string | undefined; updated_by: string | undefined;
workspace: string | undefined; workspace: string | undefined;

1
packages/types/src/page/extended.d.ts vendored Normal file
View file

@ -0,0 +1 @@
export type TPageExtended = {};

2
packages/types/src/page/index.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
export * from "./core";
export * from "./extended";

View file

@ -1,7 +1,7 @@
import { ICycle } from "./cycle"; import { ICycle } from "./cycle";
import { TIssue } from "./issues/issue"; import { TIssue } from "./issues/issue";
import { IModule } from "./module"; import { IModule } from "./module";
import { TPage } from "./pages"; import { TPage } from "./page";
import { IProject } from "./project"; import { IProject } from "./project";
import { IUser } from "./users"; import { IUser } from "./users";
import { IWorkspace } from "./workspace"; import { IWorkspace } from "./workspace";

View 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 {};
}
}

View file

@ -7,6 +7,7 @@ import { TDocumentPayload, TLogoProps, TNameDescriptionLoader, TPage } from "@pl
import { TChangeHandlerProps } from "@plane/ui"; import { TChangeHandlerProps } from "@plane/ui";
import { convertHexEmojiToDecimal } from "@plane/utils"; import { convertHexEmojiToDecimal } from "@plane/utils";
// plane web store // plane web store
import { ExtendedBasePage } from "@/plane-web/store/pages/extended-base-page";
import { RootStore } from "@/plane-web/store/root.store"; import { RootStore } from "@/plane-web/store/root.store";
export type TBasePage = TPage & { export type TBasePage = TPage & {
@ -69,7 +70,7 @@ export type TPageInstance = TBasePage &
getRedirectionLink: () => string; getRedirectionLink: () => string;
}; };
export class BasePage implements TBasePage { export class BasePage extends ExtendedBasePage implements TBasePage {
// loaders // loaders
isSubmitting: TNameDescriptionLoader = "saved"; isSubmitting: TNameDescriptionLoader = "saved";
editorRef: EditorRefApi | null = null; editorRef: EditorRefApi | null = null;
@ -82,13 +83,11 @@ export class BasePage implements TBasePage {
label_ids: string[] | undefined; label_ids: string[] | undefined;
owned_by: string | undefined; owned_by: string | undefined;
access: EPageAccess | undefined; access: EPageAccess | undefined;
anchor?: string | null | undefined;
is_favorite: boolean; is_favorite: boolean;
is_locked: boolean; is_locked: boolean;
archived_at: string | null | undefined; archived_at: string | null | undefined;
workspace: string | undefined; workspace: string | undefined;
project_ids?: string[] | undefined; project_ids?: string[] | undefined;
team: string | null | undefined;
created_by: string | undefined; created_by: string | undefined;
updated_by: string | undefined; updated_by: string | undefined;
created_at: Date | undefined; created_at: Date | undefined;
@ -106,6 +105,8 @@ export class BasePage implements TBasePage {
page: TPage, page: TPage,
services: TBasePageServices services: TBasePageServices
) { ) {
super(store, page, services);
this.id = page?.id || undefined; this.id = page?.id || undefined;
this.name = page?.name; this.name = page?.name;
this.logo_props = page?.logo_props || undefined; this.logo_props = page?.logo_props || undefined;
@ -114,13 +115,11 @@ export class BasePage implements TBasePage {
this.label_ids = page?.label_ids || undefined; this.label_ids = page?.label_ids || undefined;
this.owned_by = page?.owned_by || undefined; this.owned_by = page?.owned_by || undefined;
this.access = page?.access || EPageAccess.PUBLIC; this.access = page?.access || EPageAccess.PUBLIC;
this.anchor = page?.anchor || undefined;
this.is_favorite = page?.is_favorite || false; this.is_favorite = page?.is_favorite || false;
this.is_locked = page?.is_locked || false; this.is_locked = page?.is_locked || false;
this.archived_at = page?.archived_at || undefined; this.archived_at = page?.archived_at || undefined;
this.workspace = page?.workspace || undefined; this.workspace = page?.workspace || undefined;
this.project_ids = page?.project_ids || undefined; this.project_ids = page?.project_ids || undefined;
this.team = page?.team || undefined;
this.created_by = page?.created_by || undefined; this.created_by = page?.created_by || undefined;
this.updated_by = page?.updated_by || undefined; this.updated_by = page?.updated_by || undefined;
this.created_at = page?.created_at || undefined; this.created_at = page?.created_at || undefined;
@ -140,7 +139,6 @@ export class BasePage implements TBasePage {
label_ids: observable, label_ids: observable,
owned_by: observable.ref, owned_by: observable.ref,
access: observable.ref, access: observable.ref,
anchor: observable.ref,
is_favorite: observable.ref, is_favorite: observable.ref,
is_locked: observable.ref, is_locked: observable.ref,
archived_at: observable.ref, archived_at: observable.ref,
@ -212,18 +210,17 @@ export class BasePage implements TBasePage {
label_ids: this.label_ids, label_ids: this.label_ids,
owned_by: this.owned_by, owned_by: this.owned_by,
access: this.access, access: this.access,
anchor: this.anchor,
logo_props: this.logo_props, logo_props: this.logo_props,
is_favorite: this.is_favorite, is_favorite: this.is_favorite,
is_locked: this.is_locked, is_locked: this.is_locked,
archived_at: this.archived_at, archived_at: this.archived_at,
workspace: this.workspace, workspace: this.workspace,
project_ids: this.project_ids, project_ids: this.project_ids,
team: this.team,
created_by: this.created_by, created_by: this.created_by,
updated_by: this.updated_by, updated_by: this.updated_by,
created_at: this.created_at, created_at: this.created_at,
updated_at: this.updated_at, updated_at: this.updated_at,
...this.asJSONExtended,
}; };
} }