From 712339a6381d4690fccd03346617aff4b8e3a6d3 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Fri, 29 Nov 2024 14:53:30 +0530 Subject: [PATCH 1/2] minor improvements for workspace management (#6099) * minor improvements for workspace management * typo fix --- admin/core/components/workspace/list-item.tsx | 2 +- admin/core/services/workspace.service.ts | 3 ++- admin/core/store/workspace.store.ts | 6 +++--- apiserver/plane/license/api/serializers/workspace.py | 3 +++ apiserver/plane/license/api/views/workspace.py | 2 +- packages/ui/src/icons/workspace-icon.tsx | 9 ++++++++- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/admin/core/components/workspace/list-item.tsx b/admin/core/components/workspace/list-item.tsx index 9289140f7..691e9dbb6 100644 --- a/admin/core/components/workspace/list-item.tsx +++ b/admin/core/components/workspace/list-item.tsx @@ -22,7 +22,7 @@ export const WorkspaceListItem = observer(({ workspaceId }: TWorkspaceListItemPr return ( diff --git a/admin/core/services/workspace.service.ts b/admin/core/services/workspace.service.ts index 1de24fd9b..81ba36a6f 100644 --- a/admin/core/services/workspace.service.ts +++ b/admin/core/services/workspace.service.ts @@ -30,7 +30,8 @@ export class WorkspaceService extends APIService { * @returns Promise */ async workspaceSlugCheck(slug: string): Promise { - return this.get(`/api/instances/workspace-slug-check/?slug=${slug}`) + const params = new URLSearchParams({ slug }); + return this.get(`/api/instances/workspace-slug-check/?${params.toString()}`) .then((response) => response?.data) .catch((error) => { throw error?.response?.data; diff --git a/admin/core/store/workspace.store.ts b/admin/core/store/workspace.store.ts index dafe96760..f892e14f0 100644 --- a/admin/core/store/workspace.store.ts +++ b/admin/core/store/workspace.store.ts @@ -14,7 +14,7 @@ export interface IWorkspaceStore { // computed workspaceIds: string[]; // helper actions - hydrate: (data: any) => void; + hydrate: (data: Record) => void; getWorkspaceById: (workspaceId: string) => IWorkspace | undefined; // fetch actions fetchWorkspaces: () => Promise; @@ -59,9 +59,9 @@ export class WorkspaceStore implements IWorkspaceStore { // helper actions /** * @description Hydrates the workspaces - * @param data - any + * @param data - Record */ - hydrate = (data: any) => { + hydrate = (data: Record) => { if (data) this.workspaces = data; }; diff --git a/apiserver/plane/license/api/serializers/workspace.py b/apiserver/plane/license/api/serializers/workspace.py index 1d3bfa890..75dd938e4 100644 --- a/apiserver/plane/license/api/serializers/workspace.py +++ b/apiserver/plane/license/api/serializers/workspace.py @@ -18,6 +18,9 @@ class WorkspaceSerializer(BaseSerializer): # Check if the slug is restricted if value in RESTRICTED_WORKSPACE_SLUGS: raise serializers.ValidationError("Slug is not valid") + # Check uniqueness case-insensitively + if Workspace.objects.filter(slug__iexact=value).exists(): + raise serializers.ValidationError("Slug is already in use") return value class Meta: diff --git a/apiserver/plane/license/api/views/workspace.py b/apiserver/plane/license/api/views/workspace.py index af9e8773a..14118d85b 100644 --- a/apiserver/plane/license/api/views/workspace.py +++ b/apiserver/plane/license/api/views/workspace.py @@ -25,7 +25,7 @@ class InstanceWorkSpaceAvailabilityCheckEndpoint(BaseAPIView): ) workspace = ( - Workspace.objects.filter(slug=slug).exists() + Workspace.objects.filter(slug__iexact=slug).exists() or slug in RESTRICTED_WORKSPACE_SLUGS ) return Response({"status": not workspace}, status=status.HTTP_200_OK) diff --git a/packages/ui/src/icons/workspace-icon.tsx b/packages/ui/src/icons/workspace-icon.tsx index 07872b264..e15d33f30 100644 --- a/packages/ui/src/icons/workspace-icon.tsx +++ b/packages/ui/src/icons/workspace-icon.tsx @@ -3,7 +3,14 @@ import * as React from "react"; import { ISvgIcons } from "./type"; export const WorkspaceIcon: React.FC = ({ className }) => ( - + Date: Fri, 29 Nov 2024 14:55:39 +0530 Subject: [PATCH 2/2] chore: enable no load by default (#5968) * enable no load by default * remove help section brackets * fallback to server with mentions --- web/ce/constants/issues.ts | 3 -- .../workspace/sidebar/help-section.tsx | 38 +++++++++---------- web/core/store/user/index.ts | 3 +- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/web/ce/constants/issues.ts b/web/ce/constants/issues.ts index d30ec492e..dc6ffbcb8 100644 --- a/web/ce/constants/issues.ts +++ b/web/ce/constants/issues.ts @@ -31,7 +31,4 @@ export const filterActivityOnSelectedFilters = ( ): TIssueActivityComment[] => activity.filter((activity) => filter.includes(activity.activity_type as TActivityFilters)); -// boolean to decide if the local db cache is enabled -export const ENABLE_LOCAL_DB_CACHE = false; - export const ENABLE_ISSUE_DEPENDENCIES = false; diff --git a/web/core/components/workspace/sidebar/help-section.tsx b/web/core/components/workspace/sidebar/help-section.tsx index 5570b5727..54df5909e 100644 --- a/web/core/components/workspace/sidebar/help-section.tsx +++ b/web/core/components/workspace/sidebar/help-section.tsx @@ -16,7 +16,6 @@ import { usePlatformOS } from "@/hooks/use-platform-os"; // plane web components import { PlaneVersionNumber } from "@/plane-web/components/global"; import { WorkspaceEditionBadge } from "@/plane-web/components/workspace"; -import { ENABLE_LOCAL_DB_CACHE } from "@/plane-web/constants/issues"; export interface WorkspaceHelpSectionProps { setSidebarActive?: React.Dispatch>; @@ -111,23 +110,21 @@ export const SidebarHelpSection: React.FC = observer(
- {ENABLE_LOCAL_DB_CACHE && ( - -
{ - e.preventDefault(); - e.stopPropagation(); - }} - className="flex w-full items-center justify-between text-xs hover:bg-custom-background-80" - > - Local Cache - toggleLocalDB(workspaceSlug?.toString(), projectId?.toString())} - /> -
-
- )} + +
{ + e.preventDefault(); + e.stopPropagation(); + }} + className="flex w-full items-center justify-between text-xs hover:bg-custom-background-80" + > + Local Cache + toggleLocalDB(workspaceSlug?.toString(), projectId?.toString())} + /> +
+