From c4da96be2ef31e5c73f5ca3e20b8596ca785d273 Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 3 Dec 2024 12:15:34 +0530 Subject: [PATCH 1/5] fix: refactoring --- space/app/issues/[anchor]/layout.tsx | 19 ++-------------- space/app/layout.tsx | 24 ++++++++------------- space/app/provider.tsx | 23 ++++++++++++++++++++ space/core/components/common/index.ts | 1 + space/core/components/common/powered-by.tsx | 19 ++++++++++++++++ space/core/components/views/auth.tsx | 8 +++---- space/core/lib/instance-provider.tsx | 12 +++++------ space/helpers/common.helper.ts | 4 ---- space/next.config.js | 6 ++---- 9 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 space/app/provider.tsx create mode 100644 space/core/components/common/powered-by.tsx diff --git a/space/app/issues/[anchor]/layout.tsx b/space/app/issues/[anchor]/layout.tsx index ac5dba43078..70ed5b746fd 100644 --- a/space/app/issues/[anchor]/layout.tsx +++ b/space/app/issues/[anchor]/layout.tsx @@ -1,16 +1,13 @@ "use client"; import { observer } from "mobx-react"; -import Image from "next/image"; import useSWR from "swr"; // components -import { LogoSpinner } from "@/components/common"; +import { LogoSpinner, PoweredBy } from "@/components/common"; import { IssuesNavbarRoot } from "@/components/issues"; import { SomethingWentWrongError } from "@/components/issues/issue-layouts/error"; // hooks import { useIssueFilter, usePublish, usePublishList } from "@/hooks/store"; -// assets -import planeLogo from "@/public/plane-logo.svg"; type Props = { children: React.ReactNode; @@ -56,19 +53,7 @@ const IssuesLayout = observer((props: Props) => {
{children}
- -
- Plane logo -
-
- Powered by Plane Publish -
-
+ ); }); diff --git a/space/app/layout.tsx b/space/app/layout.tsx index ca6d11ea167..e457ae5d1d1 100644 --- a/space/app/layout.tsx +++ b/space/app/layout.tsx @@ -1,12 +1,10 @@ import { Metadata } from "next"; // helpers -import { ASSET_PREFIX } from "@/helpers/common.helper"; -// components -import { InstanceProvider } from "@/lib/instance-provider"; -import { StoreProvider } from "@/lib/store-provider"; +import { SPACE_BASE_PATH } from "@plane/constants"; // styles import "@/styles/globals.css"; -import { ToastProvider } from "@/lib/toast-provider"; +// components +import { AppProvider } from "./provider"; export const metadata: Metadata = { title: "Plane Publish | Make your Plane boards public with one-click", @@ -27,18 +25,14 @@ export default function RootLayout({ children }: { children: React.ReactNode }) return ( - - - - - + + + + + - - - {children} - - + {children} ); diff --git a/space/app/provider.tsx b/space/app/provider.tsx new file mode 100644 index 00000000000..c3ab6673f5a --- /dev/null +++ b/space/app/provider.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { FC, ReactNode } from "react"; +// components +import { InstanceProvider } from "@/lib/instance-provider"; +import { StoreProvider } from "@/lib/store-provider"; +import { ToastProvider } from "@/lib/toast-provider"; + +interface IAppProvider { + children: ReactNode; +} + +export const AppProvider: FC = (props) => { + const { children } = props; + + return ( + + + {children} + + + ); +}; diff --git a/space/core/components/common/index.ts b/space/core/components/common/index.ts index 1949c069bef..0a63ca1ac8b 100644 --- a/space/core/components/common/index.ts +++ b/space/core/components/common/index.ts @@ -1,2 +1,3 @@ export * from "./project-logo"; export * from "./logo-spinner"; +export * from "./powered-by"; diff --git a/space/core/components/common/powered-by.tsx b/space/core/components/common/powered-by.tsx new file mode 100644 index 00000000000..931eb434080 --- /dev/null +++ b/space/core/components/common/powered-by.tsx @@ -0,0 +1,19 @@ +import Image from "next/image"; +// assets +import planeLogo from "@/public/plane-logo.svg"; + +export const PoweredBy = () => ( + +
+ Plane logo +
+
+ Powered by Plane Publish +
+
+); diff --git a/space/core/components/views/auth.tsx b/space/core/components/views/auth.tsx index 2c5a8a2f4de..4a924ed03f7 100644 --- a/space/core/components/views/auth.tsx +++ b/space/core/components/views/auth.tsx @@ -4,15 +4,15 @@ import { observer } from "mobx-react"; import Image from "next/image"; import Link from "next/link"; import { useTheme } from "next-themes"; +// plane constants +import { SPACE_BASE_PATH } from "@plane/constants"; // components import { AuthRoot } from "@/components/account"; -// helpers -import { SPACE_BASE_PATH } from "@/helpers/common.helper"; // images import PlaneBackgroundPatternDark from "@/public/auth/background-pattern-dark.svg"; import PlaneBackgroundPattern from "@/public/auth/background-pattern.svg"; -import BlackHorizontalLogo from "public/plane-logos/black-horizontal-with-blue-logo.png"; -import WhiteHorizontalLogo from "public/plane-logos/white-horizontal-with-blue-logo.png"; +import BlackHorizontalLogo from "@/public/plane-logos/black-horizontal-with-blue-logo.png"; +import WhiteHorizontalLogo from "@/public/plane-logos/white-horizontal-with-blue-logo.png"; export const AuthView = observer(() => { // hooks diff --git a/space/core/lib/instance-provider.tsx b/space/core/lib/instance-provider.tsx index 4f28dbcf9b5..7753bbf11cf 100644 --- a/space/core/lib/instance-provider.tsx +++ b/space/core/lib/instance-provider.tsx @@ -6,18 +6,18 @@ import Image from "next/image"; import Link from "next/link"; import { useTheme } from "next-themes"; import useSWR from "swr"; +// plane constants +import { SPACE_BASE_PATH } from "@plane/constants"; // components import { LogoSpinner } from "@/components/common"; import { InstanceFailureView } from "@/components/instance"; -// helpers -import { SPACE_BASE_PATH } from "@/helpers/common.helper"; // hooks import { useInstance, useUser } from "@/hooks/store"; // assets -import PlaneBackgroundPatternDark from "public/auth/background-pattern-dark.svg"; -import PlaneBackgroundPattern from "public/auth/background-pattern.svg"; -import BlackHorizontalLogo from "public/plane-logos/black-horizontal-with-blue-logo.png"; -import WhiteHorizontalLogo from "public/plane-logos/white-horizontal-with-blue-logo.png"; +import PlaneBackgroundPatternDark from "@/public/auth/background-pattern-dark.svg"; +import PlaneBackgroundPattern from "@/public/auth/background-pattern.svg"; +import BlackHorizontalLogo from "@/public/plane-logos/black-horizontal-with-blue-logo.png"; +import WhiteHorizontalLogo from "@/public/plane-logos/white-horizontal-with-blue-logo.png"; export const InstanceProvider = observer(({ children }: { children: ReactNode }) => { const { fetchInstanceInfo, instance, error } = useInstance(); diff --git a/space/helpers/common.helper.ts b/space/helpers/common.helper.ts index 6db73a4a100..7b18c0e660d 100644 --- a/space/helpers/common.helper.ts +++ b/space/helpers/common.helper.ts @@ -6,16 +6,12 @@ export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || ""; export const ADMIN_BASE_URL = process.env.NEXT_PUBLIC_ADMIN_BASE_URL || ""; export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || ""; -export const SPACE_BASE_PATH = process.env.NEXT_PUBLIC_SPACE_BASE_PATH || ""; - export const SUPPORT_EMAIL = process.env.NEXT_PUBLIC_SUPPORT_EMAIL || ""; export const WEB_BASE_URL = process.env.NEXT_PUBLIC_WEB_BASE_URL || ""; export const GOD_MODE_URL = encodeURI(`${ADMIN_BASE_URL}${ADMIN_BASE_PATH}`); -export const ASSET_PREFIX = SPACE_BASE_PATH; - export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs)); export const resolveGeneralTheme = (resolvedTheme: string | undefined) => diff --git a/space/next.config.js b/space/next.config.js index d18ce805f4d..58b6cfa0be8 100644 --- a/space/next.config.js +++ b/space/next.config.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires /* eslint-disable @typescript-eslint/no-var-requires */ /** @type {import('next').NextConfig} */ require("dotenv").config({ path: ".env" }); @@ -28,7 +29,6 @@ const nextConfig = { }, }; - const sentryConfig = { // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options @@ -62,12 +62,10 @@ const sentryConfig = { // https://docs.sentry.io/product/crons/ // https://vercel.com/docs/cron-jobs automaticVercelMonitors: true, -} - +}; if (parseInt(process.env.SENTRY_MONITORING_ENABLED || "0", 10)) { module.exports = withSentryConfig(nextConfig, sentryConfig); } else { module.exports = nextConfig; } - From fcd085d02b12be5e7d39069db83214c31b163d75 Mon Sep 17 00:00:00 2001 From: sriram veeraghanta Date: Tue, 3 Dec 2024 15:38:16 +0530 Subject: [PATCH 2/5] fix: site ssr implementation --- apiserver/plane/space/urls/project.py | 6 ++ apiserver/plane/space/views/__init__.py | 2 + apiserver/plane/space/views/meta.py | 26 ++++++++ space/app/issues/[anchor]/client-layout.tsx | 55 +++++++++++++++++ space/app/issues/[anchor]/layout.tsx | 67 ++++++--------------- space/core/lib/store-provider.tsx | 15 ++--- 6 files changed, 115 insertions(+), 56 deletions(-) create mode 100644 apiserver/plane/space/views/meta.py create mode 100644 space/app/issues/[anchor]/client-layout.tsx diff --git a/apiserver/plane/space/urls/project.py b/apiserver/plane/space/urls/project.py index 7676c959924..068b8c5c17f 100644 --- a/apiserver/plane/space/urls/project.py +++ b/apiserver/plane/space/urls/project.py @@ -10,9 +10,15 @@ ProjectStatesEndpoint, ProjectLabelsEndpoint, ProjectMembersEndpoint, + ProjectMetaDataEndpoint, ) urlpatterns = [ + path( + "anchor//meta/", + ProjectMetaDataEndpoint.as_view(), + name="project-meta", + ), path( "anchor//settings/", ProjectDeployBoardPublicSettingsEndpoint.as_view(), diff --git a/apiserver/plane/space/views/__init__.py b/apiserver/plane/space/views/__init__.py index afdc1d33741..22acfd15bd2 100644 --- a/apiserver/plane/space/views/__init__.py +++ b/apiserver/plane/space/views/__init__.py @@ -25,3 +25,5 @@ from .label import ProjectLabelsEndpoint from .asset import EntityAssetEndpoint, AssetRestoreEndpoint, EntityBulkAssetEndpoint + +from .meta import ProjectMetaDataEndpoint diff --git a/apiserver/plane/space/views/meta.py b/apiserver/plane/space/views/meta.py new file mode 100644 index 00000000000..12e873b5a14 --- /dev/null +++ b/apiserver/plane/space/views/meta.py @@ -0,0 +1,26 @@ +# third party +from rest_framework.permissions import AllowAny +from rest_framework import status +from rest_framework.response import Response + +from plane.db.models import DeployBoard, Project + +from .base import BaseAPIView +from plane.space.serializer.project import ProjectLiteSerializer + + +class ProjectMetaDataEndpoint(BaseAPIView): + permission_classes = [AllowAny] + + def get(self, request, anchor): + deploy_board = DeployBoard.objects.filter( + anchor=anchor, entity_name="project" + ).first() + if not deploy_board: + return Response( + {"error": "Project is not published"}, status=status.HTTP_404_NOT_FOUND + ) + + project_id = deploy_board.entity_identifier + serializer = ProjectLiteSerializer(Project.objects.get(id=project_id)) + return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/space/app/issues/[anchor]/client-layout.tsx b/space/app/issues/[anchor]/client-layout.tsx new file mode 100644 index 00000000000..03ddcf7d1f9 --- /dev/null +++ b/space/app/issues/[anchor]/client-layout.tsx @@ -0,0 +1,55 @@ +"use client"; + +import { observer } from "mobx-react"; +import useSWR from "swr"; +// components +import { LogoSpinner, PoweredBy } from "@/components/common"; +import { IssuesNavbarRoot } from "@/components/issues"; +import { SomethingWentWrongError } from "@/components/issues/issue-layouts/error"; +// hooks +import { useIssueFilter, usePublish, usePublishList } from "@/hooks/store"; + +type Props = { + children: React.ReactNode; + anchor: string; +}; + +export const IssuesClientLayout = observer((props: Props) => { + const { children, anchor } = props; + // store hooks + const { fetchPublishSettings } = usePublishList(); + const publishSettings = usePublish(anchor); + const { updateLayoutOptions } = useIssueFilter(); + // fetch publish settings + const { error } = useSWR( + anchor ? `PUBLISH_SETTINGS_${anchor}` : null, + anchor + ? async () => { + const response = await fetchPublishSettings(anchor); + if (response.view_props) { + updateLayoutOptions({ + list: !!response.view_props.list, + kanban: !!response.view_props.kanban, + calendar: !!response.view_props.calendar, + gantt: !!response.view_props.gantt, + spreadsheet: !!response.view_props.spreadsheet, + }); + } + } + : null + ); + + if (!publishSettings && !error) return ; + + if (error) return ; + + return ( +
+
+ +
+
{children}
+ +
+ ); +}); diff --git a/space/app/issues/[anchor]/layout.tsx b/space/app/issues/[anchor]/layout.tsx index 70ed5b746fd..f4502a127fd 100644 --- a/space/app/issues/[anchor]/layout.tsx +++ b/space/app/issues/[anchor]/layout.tsx @@ -1,13 +1,6 @@ -"use client"; +"use server"; -import { observer } from "mobx-react"; -import useSWR from "swr"; -// components -import { LogoSpinner, PoweredBy } from "@/components/common"; -import { IssuesNavbarRoot } from "@/components/issues"; -import { SomethingWentWrongError } from "@/components/issues/issue-layouts/error"; -// hooks -import { useIssueFilter, usePublish, usePublishList } from "@/hooks/store"; +import { IssuesClientLayout } from "./client-layout"; type Props = { children: React.ReactNode; @@ -16,46 +9,22 @@ type Props = { }; }; -const IssuesLayout = observer((props: Props) => { - const { children, params } = props; - // params +export async function generateMetadata({ params }: Props) { const { anchor } = params; - // store hooks - const { fetchPublishSettings } = usePublishList(); - const publishSettings = usePublish(anchor); - const { updateLayoutOptions } = useIssueFilter(); - // fetch publish settings - const { error } = useSWR( - anchor ? `PUBLISH_SETTINGS_${anchor}` : null, - anchor - ? async () => { - const response = await fetchPublishSettings(anchor); - if (response.view_props) { - updateLayoutOptions({ - list: !!response.view_props.list, - kanban: !!response.view_props.kanban, - calendar: !!response.view_props.calendar, - gantt: !!response.view_props.gantt, - spreadsheet: !!response.view_props.spreadsheet, - }); - } - } - : null - ); - - if (!publishSettings && !error) return ; - - if (error) return ; + const DEFAULT_TITLE = "Plane"; + const DEFAULT_DESCRIPTION = "Made with Plane, an AI-powered work management platform with publishing capabilities."; + try { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/public/anchor/${anchor}/meta/`); + const data = await response.json(); + return { title: data?.name || DEFAULT_TITLE, description: data?.description || DEFAULT_DESCRIPTION }; + } catch { + return { title: DEFAULT_TITLE, description: DEFAULT_DESCRIPTION }; + } +} - return ( -
-
- -
-
{children}
- -
- ); -}); +export default async function IssuesLayout(props: Props) { + const { children, params } = props; + const { anchor } = params; -export default IssuesLayout; + return {children}; +} diff --git a/space/core/lib/store-provider.tsx b/space/core/lib/store-provider.tsx index c1256ddc29b..dcec7786739 100644 --- a/space/core/lib/store-provider.tsx +++ b/space/core/lib/store-provider.tsx @@ -9,13 +9,8 @@ let rootStore = new RootStore(); export const StoreContext = createContext(rootStore); -function initializeStore(initialData = {}) { +function initializeStore() { const singletonRootStore = rootStore ?? new RootStore(); - // If your page has Next.js data fetching methods that use a Mobx store, it will - // get hydrated here, check `pages/ssg.js` and `pages/ssr.js` for more details - if (initialData) { - singletonRootStore.hydrate(initialData); - } // For SSG and SSR always create a new store if (typeof window === "undefined") return singletonRootStore; // Create the store once in the client @@ -30,7 +25,13 @@ export type StoreProviderProps = { }; export const StoreProvider = ({ children, initialState = {} }: StoreProviderProps) => { - const store = initializeStore(initialState); + const store = initializeStore(); + // If your page has Next.js data fetching methods that use a Mobx store, it will + // get hydrated here, check `pages/ssg.js` and `pages/ssr.js` for more details + if (initialState) { + store.hydrate(initialState); + } + return ( {children} From 6a7fe3bfea7222eaa56be07c7d1c5e08fbf9234a Mon Sep 17 00:00:00 2001 From: gurusainath Date: Tue, 3 Dec 2024 17:30:56 +0530 Subject: [PATCH 3/5] chore: fixed auto reload on file change in sites --- space/core/lib/store-provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/space/core/lib/store-provider.tsx b/space/core/lib/store-provider.tsx index dcec7786739..b810c10562f 100644 --- a/space/core/lib/store-provider.tsx +++ b/space/core/lib/store-provider.tsx @@ -24,7 +24,7 @@ export type StoreProviderProps = { initialState?: any; }; -export const StoreProvider = ({ children, initialState = {} }: StoreProviderProps) => { +export const StoreProvider = ({ children, initialState = undefined }: StoreProviderProps) => { const store = initializeStore(); // If your page has Next.js data fetching methods that use a Mobx store, it will // get hydrated here, check `pages/ssg.js` and `pages/ssr.js` for more details From 777698f80eb8956c0f6979d27a8ef2a27ba78b36 Mon Sep 17 00:00:00 2001 From: gurusainath Date: Tue, 3 Dec 2024 18:56:24 +0530 Subject: [PATCH 4/5] chore: updated constant imports and globalised powerBy component --- space/app/issues/[anchor]/client-layout.tsx | 3 +- space/app/views/[anchor]/layout.tsx | 13 ------ .../account/auth-forms/password.tsx | 2 +- .../account/auth-forms/unique-code.tsx | 3 +- .../account/oauth/github-button.tsx | 3 +- .../account/oauth/gitlab-button.tsx | 3 +- .../account/oauth/google-button.tsx | 3 +- space/core/components/common/powered-by.tsx | 43 ++++++++++++------- .../components/issues/navbar/user-avatar.tsx | 2 +- space/core/lib/instance-provider.tsx | 9 +++- space/core/services/auth.service.ts | 3 +- space/core/services/cycle.service.ts | 4 +- space/core/services/file.service.ts | 3 +- space/core/services/instance.service.ts | 4 +- space/core/services/issue.service.ts | 2 +- space/core/services/label.service.ts | 3 +- space/core/services/member.service.ts | 4 +- space/core/services/module.service.ts | 4 +- space/core/services/project-member.service.ts | 3 +- space/core/services/publish.service.ts | 4 +- space/core/services/state.service.ts | 3 +- space/core/services/user.service.ts | 4 +- space/helpers/common.helper.ts | 9 ---- space/helpers/file.helper.ts | 4 +- 24 files changed, 63 insertions(+), 75 deletions(-) diff --git a/space/app/issues/[anchor]/client-layout.tsx b/space/app/issues/[anchor]/client-layout.tsx index 03ddcf7d1f9..b100e57c6f5 100644 --- a/space/app/issues/[anchor]/client-layout.tsx +++ b/space/app/issues/[anchor]/client-layout.tsx @@ -3,7 +3,7 @@ import { observer } from "mobx-react"; import useSWR from "swr"; // components -import { LogoSpinner, PoweredBy } from "@/components/common"; +import { LogoSpinner } from "@/components/common"; import { IssuesNavbarRoot } from "@/components/issues"; import { SomethingWentWrongError } from "@/components/issues/issue-layouts/error"; // hooks @@ -49,7 +49,6 @@ export const IssuesClientLayout = observer((props: Props) => {
{children}
- ); }); diff --git a/space/app/views/[anchor]/layout.tsx b/space/app/views/[anchor]/layout.tsx index cf7643bb607..e795c64df68 100644 --- a/space/app/views/[anchor]/layout.tsx +++ b/space/app/views/[anchor]/layout.tsx @@ -53,19 +53,6 @@ const IssuesLayout = observer((props: Props) => {
{children}
- -
- Plane logo -
-
- Powered by Plane Publish -
-
); }); diff --git a/space/core/components/account/auth-forms/password.tsx b/space/core/components/account/auth-forms/password.tsx index 3d87cded59c..c0a9945adc4 100644 --- a/space/core/components/account/auth-forms/password.tsx +++ b/space/core/components/account/auth-forms/password.tsx @@ -4,10 +4,10 @@ import React, { useEffect, useMemo, useRef, useState } from "react"; import { observer } from "mobx-react"; import { Eye, EyeOff, XCircle } from "lucide-react"; import { Button, Input, Spinner } from "@plane/ui"; +import { API_BASE_URL } from "@plane/constants"; // components import { PasswordStrengthMeter } from "@/components/account"; // helpers -import { API_BASE_URL } from "@/helpers/common.helper"; import { E_PASSWORD_STRENGTH, getPasswordStrength } from "@/helpers/password.helper"; // services import { AuthService } from "@/services/auth.service"; diff --git a/space/core/components/account/auth-forms/unique-code.tsx b/space/core/components/account/auth-forms/unique-code.tsx index 10c7b4f00a1..9cfe2f512b6 100644 --- a/space/core/components/account/auth-forms/unique-code.tsx +++ b/space/core/components/account/auth-forms/unique-code.tsx @@ -3,8 +3,7 @@ import React, { useEffect, useState } from "react"; import { CircleCheck, XCircle } from "lucide-react"; import { Button, Input, Spinner } from "@plane/ui"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // hooks import useTimer from "@/hooks/use-timer"; // services diff --git a/space/core/components/account/oauth/github-button.tsx b/space/core/components/account/oauth/github-button.tsx index ba65f38c4d0..eaa83ebbbd4 100644 --- a/space/core/components/account/oauth/github-button.tsx +++ b/space/core/components/account/oauth/github-button.tsx @@ -2,8 +2,7 @@ import { FC } from "react"; import { useSearchParams } from "next/navigation"; import Image from "next/image"; import { useTheme } from "next-themes"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // images import githubLightModeImage from "/public/logos/github-black.png"; import githubDarkModeImage from "/public/logos/github-dark.svg"; diff --git a/space/core/components/account/oauth/gitlab-button.tsx b/space/core/components/account/oauth/gitlab-button.tsx index 072a2f628cd..ba1880ae97f 100644 --- a/space/core/components/account/oauth/gitlab-button.tsx +++ b/space/core/components/account/oauth/gitlab-button.tsx @@ -2,8 +2,7 @@ import { FC } from "react"; import { useSearchParams } from "next/navigation"; import Image from "next/image"; import { useTheme } from "next-themes"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // images import GitlabLogo from "/public/logos/gitlab-logo.svg"; diff --git a/space/core/components/account/oauth/google-button.tsx b/space/core/components/account/oauth/google-button.tsx index 179b1c35ad1..dc28bdae489 100644 --- a/space/core/components/account/oauth/google-button.tsx +++ b/space/core/components/account/oauth/google-button.tsx @@ -2,8 +2,7 @@ import { FC } from "react"; import { useSearchParams } from "next/navigation"; import Image from "next/image"; import { useTheme } from "next-themes"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // images import GoogleLogo from "/public/logos/google-logo.svg"; diff --git a/space/core/components/common/powered-by.tsx b/space/core/components/common/powered-by.tsx index 931eb434080..347338f16d9 100644 --- a/space/core/components/common/powered-by.tsx +++ b/space/core/components/common/powered-by.tsx @@ -1,19 +1,32 @@ +"use client"; + +import { FC } from "react"; import Image from "next/image"; // assets import planeLogo from "@/public/plane-logo.svg"; -export const PoweredBy = () => ( - -
- Plane logo -
-
- Powered by Plane Publish -
-
-); +type TPoweredBy = { + disabled?: boolean; +}; + +export const PoweredBy: FC = (props) => { + // props + const { disabled = false } = props; + + if (disabled) return null; + return ( + +
+ Plane logo +
+
+ Powered by Plane Publish +
+
+ ); +}; diff --git a/space/core/components/issues/navbar/user-avatar.tsx b/space/core/components/issues/navbar/user-avatar.tsx index 40339bb5c04..220bd016a1f 100644 --- a/space/core/components/issues/navbar/user-avatar.tsx +++ b/space/core/components/issues/navbar/user-avatar.tsx @@ -8,8 +8,8 @@ import { usePopper } from "react-popper"; import { LogOut } from "lucide-react"; import { Popover, Transition } from "@headlessui/react"; import { Avatar, Button } from "@plane/ui"; +import { API_BASE_URL } from "@plane/constants"; // helpers -import { API_BASE_URL } from "@/helpers/common.helper"; import { getFileURL } from "@/helpers/file.helper"; import { queryParamGenerator } from "@/helpers/query-param-generator"; // hooks diff --git a/space/core/lib/instance-provider.tsx b/space/core/lib/instance-provider.tsx index 7753bbf11cf..b2f69fcfa81 100644 --- a/space/core/lib/instance-provider.tsx +++ b/space/core/lib/instance-provider.tsx @@ -9,7 +9,7 @@ import useSWR from "swr"; // plane constants import { SPACE_BASE_PATH } from "@plane/constants"; // components -import { LogoSpinner } from "@/components/common"; +import { LogoSpinner, PoweredBy } from "@/components/common"; import { InstanceFailureView } from "@/components/instance"; // hooks import { useInstance, useUser } from "@/hooks/store"; @@ -69,5 +69,10 @@ export const InstanceProvider = observer(({ children }: { children: ReactNode }) ); } - return <>{children}; + return ( + <> + {children} + + + ); }); diff --git a/space/core/services/auth.service.ts b/space/core/services/auth.service.ts index 060da53f4a0..3bbfd149e62 100644 --- a/space/core/services/auth.service.ts +++ b/space/core/services/auth.service.ts @@ -1,5 +1,4 @@ -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; // types diff --git a/space/core/services/cycle.service.ts b/space/core/services/cycle.service.ts index 6df75ebde12..7d4ff9a10fd 100644 --- a/space/core/services/cycle.service.ts +++ b/space/core/services/cycle.service.ts @@ -1,5 +1,7 @@ -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; +// services import { APIService } from "@/services/api.service"; +// types import { TPublicCycle } from "@/types/cycle"; export class CycleService extends APIService { diff --git a/space/core/services/file.service.ts b/space/core/services/file.service.ts index 168738804e2..01986a1b4be 100644 --- a/space/core/services/file.service.ts +++ b/space/core/services/file.service.ts @@ -1,7 +1,6 @@ -// plane types import { TFileEntityInfo, TFileSignedURLResponse } from "@plane/types"; +import { API_BASE_URL } from "@plane/constants"; // helpers -import { API_BASE_URL } from "@/helpers/common.helper"; import { generateFileUploadPayload, getAssetIdFromUrl, getFileMetaDataForUpload } from "@/helpers/file.helper"; // services import { APIService } from "@/services/api.service"; diff --git a/space/core/services/instance.service.ts b/space/core/services/instance.service.ts index a11599b0c73..03cb1a73e80 100644 --- a/space/core/services/instance.service.ts +++ b/space/core/services/instance.service.ts @@ -1,7 +1,5 @@ -// types import type { IInstanceInfo } from "@plane/types"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; diff --git a/space/core/services/issue.service.ts b/space/core/services/issue.service.ts index b5ecb807782..8ec67ee45f9 100644 --- a/space/core/services/issue.service.ts +++ b/space/core/services/issue.service.ts @@ -1,4 +1,4 @@ -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; // types diff --git a/space/core/services/label.service.ts b/space/core/services/label.service.ts index 2a2ee5ad979..c2343160527 100644 --- a/space/core/services/label.service.ts +++ b/space/core/services/label.service.ts @@ -1,5 +1,6 @@ import { IIssueLabel } from "@plane/types"; -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; +// services import { APIService } from "./api.service"; export class LabelService extends APIService { diff --git a/space/core/services/member.service.ts b/space/core/services/member.service.ts index 02cd1f77620..9de19455b16 100644 --- a/space/core/services/member.service.ts +++ b/space/core/services/member.service.ts @@ -1,5 +1,7 @@ -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; +// services import { APIService } from "@/services/api.service"; +// types import { TPublicMember } from "@/types/member"; export class MemberService extends APIService { diff --git a/space/core/services/module.service.ts b/space/core/services/module.service.ts index f89202b6b6c..30d6ebecf17 100644 --- a/space/core/services/module.service.ts +++ b/space/core/services/module.service.ts @@ -1,5 +1,7 @@ -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; +// services import { APIService } from "@/services/api.service"; +// types import { TPublicModule } from "@/types/modules"; export class ModuleService extends APIService { diff --git a/space/core/services/project-member.service.ts b/space/core/services/project-member.service.ts index 722380efafe..9bbdb3ad2d4 100644 --- a/space/core/services/project-member.service.ts +++ b/space/core/services/project-member.service.ts @@ -1,6 +1,5 @@ -// types import type { IProjectMember, IProjectMembership } from "@plane/types"; -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; diff --git a/space/core/services/publish.service.ts b/space/core/services/publish.service.ts index 896f36ee991..fd8e8e78698 100644 --- a/space/core/services/publish.service.ts +++ b/space/core/services/publish.service.ts @@ -1,7 +1,5 @@ -// types import { TProjectPublishSettings } from "@plane/types"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; diff --git a/space/core/services/state.service.ts b/space/core/services/state.service.ts index 153f965280d..7278f1a8dc4 100644 --- a/space/core/services/state.service.ts +++ b/space/core/services/state.service.ts @@ -1,5 +1,6 @@ import { IState } from "@plane/types"; -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; +// services import { APIService } from "./api.service"; export class StateService extends APIService { diff --git a/space/core/services/user.service.ts b/space/core/services/user.service.ts index 1aeb134668a..a97a8f24b2b 100644 --- a/space/core/services/user.service.ts +++ b/space/core/services/user.service.ts @@ -1,7 +1,5 @@ -// types import { IUser, TUserProfile } from "@plane/types"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; // services import { APIService } from "@/services/api.service"; diff --git a/space/helpers/common.helper.ts b/space/helpers/common.helper.ts index 7b18c0e660d..3ffc59573c5 100644 --- a/space/helpers/common.helper.ts +++ b/space/helpers/common.helper.ts @@ -1,17 +1,8 @@ import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; -export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || ""; - -export const ADMIN_BASE_URL = process.env.NEXT_PUBLIC_ADMIN_BASE_URL || ""; -export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || ""; - export const SUPPORT_EMAIL = process.env.NEXT_PUBLIC_SUPPORT_EMAIL || ""; -export const WEB_BASE_URL = process.env.NEXT_PUBLIC_WEB_BASE_URL || ""; - -export const GOD_MODE_URL = encodeURI(`${ADMIN_BASE_URL}${ADMIN_BASE_PATH}`); - export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs)); export const resolveGeneralTheme = (resolvedTheme: string | undefined) => diff --git a/space/helpers/file.helper.ts b/space/helpers/file.helper.ts index b149ebc7cf0..452bfd6f4eb 100644 --- a/space/helpers/file.helper.ts +++ b/space/helpers/file.helper.ts @@ -1,7 +1,5 @@ -// plane types import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types"; -// helpers -import { API_BASE_URL } from "@/helpers/common.helper"; +import { API_BASE_URL } from "@plane/constants"; /** * @description from the provided signed URL response, generate a payload to be used to upload the file From e6ea55d51f039e94d63ba4ae8473e4ca4d2f27c1 Mon Sep 17 00:00:00 2001 From: gurusainath Date: Tue, 3 Dec 2024 19:19:57 +0530 Subject: [PATCH 5/5] chore: resolved lint and updated the env --- apiserver/plane/space/views/meta.py | 20 +++++++++++++------ packages/constants/src/endpoints.ts | 3 +++ space/app/views/[anchor]/layout.tsx | 3 --- .../account/auth-forms/password.tsx | 2 +- .../account/auth-forms/unique-code.tsx | 2 +- space/core/components/common/powered-by.tsx | 6 ++++-- .../components/issues/navbar/user-avatar.tsx | 2 +- space/core/components/views/auth.tsx | 1 - space/core/lib/instance-provider.tsx | 1 - 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/apiserver/plane/space/views/meta.py b/apiserver/plane/space/views/meta.py index 12e873b5a14..fa441359964 100644 --- a/apiserver/plane/space/views/meta.py +++ b/apiserver/plane/space/views/meta.py @@ -13,14 +13,22 @@ class ProjectMetaDataEndpoint(BaseAPIView): permission_classes = [AllowAny] def get(self, request, anchor): - deploy_board = DeployBoard.objects.filter( - anchor=anchor, entity_name="project" - ).first() - if not deploy_board: + try: + deploy_board = DeployBoard.objects.filter( + anchor=anchor, entity_name="project" + ).first() + except DeployBoard.DoesNotExist: return Response( {"error": "Project is not published"}, status=status.HTTP_404_NOT_FOUND ) - project_id = deploy_board.entity_identifier - serializer = ProjectLiteSerializer(Project.objects.get(id=project_id)) + try: + project_id = deploy_board.entity_identifier + project = Project.objects.get(id=project_id) + except Project.DoesNotExist: + return Response( + {"error": "Project is not published"}, status=status.HTTP_404_NOT_FOUND + ) + + serializer = ProjectLiteSerializer(project) return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/packages/constants/src/endpoints.ts b/packages/constants/src/endpoints.ts index 751ee20dd3d..fa6db6ec73c 100644 --- a/packages/constants/src/endpoints.ts +++ b/packages/constants/src/endpoints.ts @@ -13,3 +13,6 @@ export const SITES_URL = encodeURI(`${SPACE_BASE_URL}${SPACE_BASE_PATH}/`); export const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || ""; export const LIVE_BASE_PATH = process.env.NEXT_PUBLIC_LIVE_BASE_PATH || ""; export const LIVE_URL = encodeURI(`${LIVE_BASE_URL}${LIVE_BASE_PATH}/`); +// plane website url +export const WEBSITE_URL = + process.env.NEXT_PUBLIC_WEBSITE_URL || "https://plane.so"; diff --git a/space/app/views/[anchor]/layout.tsx b/space/app/views/[anchor]/layout.tsx index e795c64df68..6f286efe2e8 100644 --- a/space/app/views/[anchor]/layout.tsx +++ b/space/app/views/[anchor]/layout.tsx @@ -1,7 +1,6 @@ "use client"; import { observer } from "mobx-react"; -import Image from "next/image"; import useSWR from "swr"; // components import { LogoSpinner } from "@/components/common"; @@ -11,8 +10,6 @@ import { usePublish, usePublishList } from "@/hooks/store"; // Plane web import { ViewNavbarRoot } from "@/plane-web/components/navbar"; import { useView } from "@/plane-web/hooks/store"; -// assets -import planeLogo from "@/public/plane-logo.svg"; type Props = { children: React.ReactNode; diff --git a/space/core/components/account/auth-forms/password.tsx b/space/core/components/account/auth-forms/password.tsx index c0a9945adc4..5f0384f9bbc 100644 --- a/space/core/components/account/auth-forms/password.tsx +++ b/space/core/components/account/auth-forms/password.tsx @@ -3,8 +3,8 @@ import React, { useEffect, useMemo, useRef, useState } from "react"; import { observer } from "mobx-react"; import { Eye, EyeOff, XCircle } from "lucide-react"; -import { Button, Input, Spinner } from "@plane/ui"; import { API_BASE_URL } from "@plane/constants"; +import { Button, Input, Spinner } from "@plane/ui"; // components import { PasswordStrengthMeter } from "@/components/account"; // helpers diff --git a/space/core/components/account/auth-forms/unique-code.tsx b/space/core/components/account/auth-forms/unique-code.tsx index 9cfe2f512b6..f16796d0589 100644 --- a/space/core/components/account/auth-forms/unique-code.tsx +++ b/space/core/components/account/auth-forms/unique-code.tsx @@ -2,8 +2,8 @@ import React, { useEffect, useState } from "react"; import { CircleCheck, XCircle } from "lucide-react"; -import { Button, Input, Spinner } from "@plane/ui"; import { API_BASE_URL } from "@plane/constants"; +import { Button, Input, Spinner } from "@plane/ui"; // hooks import useTimer from "@/hooks/use-timer"; // services diff --git a/space/core/components/common/powered-by.tsx b/space/core/components/common/powered-by.tsx index 347338f16d9..654089c55c3 100644 --- a/space/core/components/common/powered-by.tsx +++ b/space/core/components/common/powered-by.tsx @@ -2,6 +2,7 @@ import { FC } from "react"; import Image from "next/image"; +import { WEBSITE_URL } from "@plane/constants"; // assets import planeLogo from "@/public/plane-logo.svg"; @@ -13,10 +14,11 @@ export const PoweredBy: FC = (props) => { // props const { disabled = false } = props; - if (disabled) return null; + if (disabled || !WEBSITE_URL) return null; + return (