ДИЗАЙН - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: состояние workspace policy в onboarding
This commit is contained in:
parent
e009915e34
commit
8ec762f790
|
|
@ -4,7 +4,7 @@
|
||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
// plane imports
|
// plane imports
|
||||||
import { useTranslation } from "@plane/i18n";
|
import { useTranslation } from "@plane/i18n";
|
||||||
|
|
@ -21,6 +21,9 @@ import { useInstance } from "@/hooks/store/use-instance";
|
||||||
import { useAppRouter } from "@/hooks/use-app-router";
|
import { useAppRouter } from "@/hooks/use-app-router";
|
||||||
// wrappers
|
// wrappers
|
||||||
import { AuthenticationWrapper } from "@/lib/wrappers/authentication-wrapper";
|
import { AuthenticationWrapper } from "@/lib/wrappers/authentication-wrapper";
|
||||||
|
import { WorkspaceService, type NodeDCWorkspacePolicy } from "@/services/workspace.service";
|
||||||
|
|
||||||
|
const workspaceService = new WorkspaceService();
|
||||||
|
|
||||||
const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
@ -36,8 +39,39 @@ const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||||
slug: "",
|
slug: "",
|
||||||
organization_size: "",
|
organization_size: "",
|
||||||
});
|
});
|
||||||
|
const [workspacePolicy, setWorkspacePolicy] = useState<NodeDCWorkspacePolicy | null>(null);
|
||||||
|
const [workspacePolicyLoading, setWorkspacePolicyLoading] = useState(true);
|
||||||
// derived values
|
// derived values
|
||||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||||
|
const isWorkspaceCreationDeniedByNodeDC = Boolean(workspacePolicy?.enabled && !workspacePolicy.can_create_workspace);
|
||||||
|
const shouldBlockWorkspaceCreation = isWorkspaceCreationDisabled || isWorkspaceCreationDeniedByNodeDC;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let mounted = true;
|
||||||
|
|
||||||
|
workspaceService
|
||||||
|
.getNodeDCWorkspacePolicy()
|
||||||
|
.then((policy) => {
|
||||||
|
if (mounted) setWorkspacePolicy(policy);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (mounted) {
|
||||||
|
setWorkspacePolicy({
|
||||||
|
enabled: false,
|
||||||
|
can_create_workspace: true,
|
||||||
|
mode: "unavailable",
|
||||||
|
reason: "NODE.DC workspace policy is unavailable.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (mounted) setWorkspacePolicyLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
mounted = false;
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
const getMailtoHref = () => {
|
const getMailtoHref = () => {
|
||||||
|
|
@ -60,7 +94,17 @@ const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||||
<div className="relative z-10 flex min-h-screen w-screen flex-col overflow-hidden overflow-y-auto bg-canvas px-8 pt-10 pb-12">
|
<div className="relative z-10 flex min-h-screen w-screen flex-col overflow-hidden overflow-y-auto bg-canvas px-8 pt-10 pb-12">
|
||||||
<AuthHeaderBase pageTitle={t("workspace_creation.heading")} />
|
<AuthHeaderBase pageTitle={t("workspace_creation.heading")} />
|
||||||
<main className="grid flex-1 place-items-center py-8">
|
<main className="grid flex-1 place-items-center py-8">
|
||||||
{isWorkspaceCreationDisabled ? (
|
{workspacePolicyLoading ? (
|
||||||
|
<section className="nodedc-auth-shell flex flex-col items-start justify-center gap-4">
|
||||||
|
<div className="space-y-3">
|
||||||
|
<h1 className="m-0 text-30 font-semibold leading-tight text-primary">Работайте во всех измерениях.</h1>
|
||||||
|
<p className="m-0 text-28 font-semibold leading-tight text-secondary">Проверяем доступ к workspace.</p>
|
||||||
|
</div>
|
||||||
|
<p className="m-0 text-14 leading-6 text-secondary">
|
||||||
|
Сверяем платформенную policy NODE.DC перед созданием рабочего пространства.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
) : shouldBlockWorkspaceCreation ? (
|
||||||
<section className="nodedc-auth-shell flex flex-col items-center justify-center gap-4 text-center">
|
<section className="nodedc-auth-shell flex flex-col items-center justify-center gap-4 text-center">
|
||||||
<img
|
<img
|
||||||
src={WorkspaceCreationDisabled}
|
src={WorkspaceCreationDisabled}
|
||||||
|
|
@ -68,10 +112,14 @@ const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||||
alt="Workspace creation disabled"
|
alt="Workspace creation disabled"
|
||||||
/>
|
/>
|
||||||
<h1 className="m-0 text-24 font-semibold text-primary">
|
<h1 className="m-0 text-24 font-semibold text-primary">
|
||||||
{t("workspace_creation.errors.creation_disabled.title")}
|
{isWorkspaceCreationDeniedByNodeDC
|
||||||
|
? "Workspace создаёт администратор."
|
||||||
|
: t("workspace_creation.errors.creation_disabled.title")}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="m-0 text-14 leading-6 text-secondary">
|
<p className="m-0 text-14 leading-6 text-secondary">
|
||||||
{t("workspace_creation.errors.creation_disabled.description")}
|
{isWorkspaceCreationDeniedByNodeDC
|
||||||
|
? workspacePolicy?.reason || "Дождитесь назначения в рабочее пространство администратором NODE.DC."
|
||||||
|
: t("workspace_creation.errors.creation_disabled.description")}
|
||||||
</p>
|
</p>
|
||||||
<div className="mt-6 flex w-full flex-col gap-3">
|
<div className="mt-6 flex w-full flex-col gap-3">
|
||||||
<Button variant="primary" className="nodedc-auth-primary-button" onClick={() => router.back()}>
|
<Button variant="primary" className="nodedc-auth-primary-button" onClick={() => router.back()}>
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,13 @@ import type {
|
||||||
// services
|
// services
|
||||||
import { APIService } from "@/services/api.service";
|
import { APIService } from "@/services/api.service";
|
||||||
|
|
||||||
|
export interface NodeDCWorkspacePolicy {
|
||||||
|
enabled: boolean;
|
||||||
|
can_create_workspace: boolean;
|
||||||
|
mode: string;
|
||||||
|
reason: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class WorkspaceService extends APIService {
|
export class WorkspaceService extends APIService {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(API_BASE_URL);
|
super(API_BASE_URL);
|
||||||
|
|
@ -95,6 +102,14 @@ export class WorkspaceService extends APIService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getNodeDCWorkspacePolicy(): Promise<NodeDCWorkspacePolicy> {
|
||||||
|
return this.get("/api/nodedc/workspace-policy/")
|
||||||
|
.then((response) => response?.data)
|
||||||
|
.catch((error) => {
|
||||||
|
throw error?.response?.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async updateWorkspace(workspaceSlug: string, data: Partial<IWorkspace>): Promise<IWorkspace> {
|
async updateWorkspace(workspaceSlug: string, data: Partial<IWorkspace>): Promise<IWorkspace> {
|
||||||
return this.patch(`/api/workspaces/${workspaceSlug}/`, data)
|
return this.patch(`/api/workspaces/${workspaceSlug}/`, data)
|
||||||
.then((response) => response?.data)
|
.then((response) => response?.data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue