From 8d1644c26c069d2804f5637564c7787852908849 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 9 Sep 2024 16:49:04 +0530 Subject: [PATCH] [WEB-2413] chore: admin application restructuring. --- .../authentication/authentication-modes.tsx | 39 ++++++++++--------- admin/ce/components/common/index.ts | 1 + .../components/common/upgrade-button.tsx | 0 admin/ce/store/root.store.ts | 19 +++++++++ admin/core/components/common/index.ts | 1 - admin/core/layouts/admin-layout.tsx | 1 + admin/core/lib/store-provider.tsx | 4 +- admin/core/store/instance.store.ts | 4 +- admin/core/store/root.store.ts | 2 +- admin/core/store/theme.store.ts | 4 +- admin/core/store/user.store.ts | 4 +- admin/ee/components/common/index.ts | 1 + admin/ee/store/root.store.ts | 1 + 13 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 admin/ce/components/common/index.ts rename admin/{core => ce}/components/common/upgrade-button.tsx (100%) create mode 100644 admin/ce/store/root.store.ts create mode 100644 admin/ee/components/common/index.ts create mode 100644 admin/ee/store/root.store.ts diff --git a/admin/ce/components/authentication/authentication-modes.tsx b/admin/ce/components/authentication/authentication-modes.tsx index e7891e0bcc1..84cde94d44e 100644 --- a/admin/ce/components/authentication/authentication-modes.tsx +++ b/admin/ce/components/authentication/authentication-modes.tsx @@ -10,8 +10,9 @@ import { // components import { AuthenticationMethodCard } from "@/components/authentication"; // helpers -import { UpgradeButton } from "@/components/common/upgrade-button"; import { getBaseAuthenticationModes } from "@/helpers/authentication.helper"; +// plane admin components +import { UpgradeButton } from "@/plane-admin/components/common"; // images import OIDCLogo from "@/public/logos/oidc-logo.svg"; import SAMLLogo from "@/public/logos/saml-logo.svg"; @@ -27,24 +28,24 @@ export const getAuthenticationModes: (props: TGetBaseAuthenticationModeProps) => updateConfig, resolvedTheme, }) => [ - ...getBaseAuthenticationModes({ disabled, updateConfig, resolvedTheme }), - { - key: "oidc", - name: "OIDC", - description: "Authenticate your users via the OpenID Connect protocol.", - icon: OIDC Logo, - config: , - unavailable: true, - }, - { - key: "saml", - name: "SAML", - description: "Authenticate your users via the Security Assertion Markup Language protocol.", - icon: SAML Logo, - config: , - unavailable: true, - }, - ]; + ...getBaseAuthenticationModes({ disabled, updateConfig, resolvedTheme }), + { + key: "oidc", + name: "OIDC", + description: "Authenticate your users via the OpenID Connect protocol.", + icon: OIDC Logo, + config: , + unavailable: true, + }, + { + key: "saml", + name: "SAML", + description: "Authenticate your users via the Security Assertion Markup Language protocol.", + icon: SAML Logo, + config: , + unavailable: true, + }, +]; export const AuthenticationModes: React.FC = observer((props) => { const { disabled, updateConfig } = props; diff --git a/admin/ce/components/common/index.ts b/admin/ce/components/common/index.ts new file mode 100644 index 00000000000..c6a1da8b627 --- /dev/null +++ b/admin/ce/components/common/index.ts @@ -0,0 +1 @@ +export * from "./upgrade-button"; diff --git a/admin/core/components/common/upgrade-button.tsx b/admin/ce/components/common/upgrade-button.tsx similarity index 100% rename from admin/core/components/common/upgrade-button.tsx rename to admin/ce/components/common/upgrade-button.tsx diff --git a/admin/ce/store/root.store.ts b/admin/ce/store/root.store.ts new file mode 100644 index 00000000000..1be816f70a6 --- /dev/null +++ b/admin/ce/store/root.store.ts @@ -0,0 +1,19 @@ +import { enableStaticRendering } from "mobx-react"; +// stores +import { CoreRootStore } from "@/store/root.store"; + +enableStaticRendering(typeof window === "undefined"); + +export class RootStore extends CoreRootStore { + constructor() { + super(); + } + + hydrate(initialData: any) { + super.hydrate(initialData); + } + + resetOnSignOut() { + super.resetOnSignOut(); + } +} diff --git a/admin/core/components/common/index.ts b/admin/core/components/common/index.ts index 2043926acd9..4d664b0a4aa 100644 --- a/admin/core/components/common/index.ts +++ b/admin/core/components/common/index.ts @@ -8,4 +8,3 @@ export * from "./empty-state"; export * from "./logo-spinner"; export * from "./page-header"; export * from "./code-block"; -export * from "./upgrade-button"; diff --git a/admin/core/layouts/admin-layout.tsx b/admin/core/layouts/admin-layout.tsx index 6308aecd172..88f71aa3c4a 100644 --- a/admin/core/layouts/admin-layout.tsx +++ b/admin/core/layouts/admin-layout.tsx @@ -18,6 +18,7 @@ export const AdminLayout: FC = observer((props) => { const { children } = props; // router const router = useRouter(); + // store hooks const { isUserLoggedIn } = useUser(); useEffect(() => { diff --git a/admin/core/lib/store-provider.tsx b/admin/core/lib/store-provider.tsx index 84251386002..7a0d4855911 100644 --- a/admin/core/lib/store-provider.tsx +++ b/admin/core/lib/store-provider.tsx @@ -1,8 +1,8 @@ "use client"; import { ReactNode, createContext } from "react"; -// store -import { RootStore } from "@/store/root.store"; +// plane admin store +import { RootStore } from "@/plane-admin/store/root.store"; let rootStore = new RootStore(); diff --git a/admin/core/store/instance.store.ts b/admin/core/store/instance.store.ts index 7be8deec695..01ab552846f 100644 --- a/admin/core/store/instance.store.ts +++ b/admin/core/store/instance.store.ts @@ -13,7 +13,7 @@ import { EInstanceStatus, TInstanceStatus } from "@/helpers/instance.helper"; // services import { InstanceService } from "@/services/instance.service"; // root store -import { RootStore } from "@/store/root.store"; +import { CoreRootStore } from "@/store/root.store"; export interface IInstanceStore { // issues @@ -46,7 +46,7 @@ export class InstanceStore implements IInstanceStore { // service instanceService; - constructor(private store: RootStore) { + constructor(private store: CoreRootStore) { makeObservable(this, { // observable isLoading: observable.ref, diff --git a/admin/core/store/root.store.ts b/admin/core/store/root.store.ts index 32977422ec2..4b25bcc6868 100644 --- a/admin/core/store/root.store.ts +++ b/admin/core/store/root.store.ts @@ -6,7 +6,7 @@ import { IUserStore, UserStore } from "./user.store"; enableStaticRendering(typeof window === "undefined"); -export class RootStore { +export abstract class CoreRootStore { theme: IThemeStore; instance: IInstanceStore; user: IUserStore; diff --git a/admin/core/store/theme.store.ts b/admin/core/store/theme.store.ts index a3f3b3d5ab5..f47042d6e93 100644 --- a/admin/core/store/theme.store.ts +++ b/admin/core/store/theme.store.ts @@ -1,6 +1,6 @@ import { action, observable, makeObservable } from "mobx"; // root store -import { RootStore } from "@/store/root.store"; +import { CoreRootStore } from "@/store/root.store"; type TTheme = "dark" | "light"; export interface IThemeStore { @@ -21,7 +21,7 @@ export class ThemeStore implements IThemeStore { isSidebarCollapsed: boolean | undefined = undefined; theme: string | undefined = undefined; - constructor(private store: RootStore) { + constructor(private store: CoreRootStore) { makeObservable(this, { // observables isNewUserPopup: observable.ref, diff --git a/admin/core/store/user.store.ts b/admin/core/store/user.store.ts index fd3132169a2..df17c9b0046 100644 --- a/admin/core/store/user.store.ts +++ b/admin/core/store/user.store.ts @@ -6,7 +6,7 @@ import { EUserStatus, TUserStatus } from "@/helpers/user.helper"; import { AuthService } from "@/services/auth.service"; import { UserService } from "@/services/user.service"; // root store -import { RootStore } from "@/store/root.store"; +import { CoreRootStore } from "@/store/root.store"; export interface IUserStore { // observables @@ -31,7 +31,7 @@ export class UserStore implements IUserStore { userService; authService; - constructor(private store: RootStore) { + constructor(private store: CoreRootStore) { makeObservable(this, { // observables isLoading: observable.ref, diff --git a/admin/ee/components/common/index.ts b/admin/ee/components/common/index.ts new file mode 100644 index 00000000000..60441ee25be --- /dev/null +++ b/admin/ee/components/common/index.ts @@ -0,0 +1 @@ +export * from "ce/components/common"; diff --git a/admin/ee/store/root.store.ts b/admin/ee/store/root.store.ts new file mode 100644 index 00000000000..c514c4c25f7 --- /dev/null +++ b/admin/ee/store/root.store.ts @@ -0,0 +1 @@ +export * from "ce/store/root.store";