minor improvements for workspace management (#6099)
* minor improvements for workspace management * typo fix
This commit is contained in:
parent
1c9162e1f1
commit
712339a638
6 changed files with 18 additions and 7 deletions
|
|
@ -22,7 +22,7 @@ export const WorkspaceListItem = observer(({ workspaceId }: TWorkspaceListItemPr
|
|||
return (
|
||||
<Link
|
||||
key={workspaceId}
|
||||
href={encodeURI(WEB_BASE_URL + "/" + workspace.slug)}
|
||||
href={`${WEB_BASE_URL}/${encodeURIComponent(workspace.slug)}`}
|
||||
target="_blank"
|
||||
className="group flex items-center justify-between p-4 gap-2.5 truncate border border-custom-border-200/70 hover:border-custom-border-200 hover:bg-custom-background-90 rounded-md"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ export class WorkspaceService extends APIService {
|
|||
* @returns Promise<any>
|
||||
*/
|
||||
async workspaceSlugCheck(slug: string): Promise<any> {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export interface IWorkspaceStore {
|
|||
// computed
|
||||
workspaceIds: string[];
|
||||
// helper actions
|
||||
hydrate: (data: any) => void;
|
||||
hydrate: (data: Record<string, IWorkspace>) => void;
|
||||
getWorkspaceById: (workspaceId: string) => IWorkspace | undefined;
|
||||
// fetch actions
|
||||
fetchWorkspaces: () => Promise<IWorkspace[]>;
|
||||
|
|
@ -59,9 +59,9 @@ export class WorkspaceStore implements IWorkspaceStore {
|
|||
// helper actions
|
||||
/**
|
||||
* @description Hydrates the workspaces
|
||||
* @param data - any
|
||||
* @param data - Record<string, IWorkspace>
|
||||
*/
|
||||
hydrate = (data: any) => {
|
||||
hydrate = (data: Record<string, IWorkspace>) => {
|
||||
if (data) this.workspaces = data;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,14 @@ import * as React from "react";
|
|||
import { ISvgIcons } from "./type";
|
||||
|
||||
export const WorkspaceIcon: React.FC<ISvgIcons> = ({ className }) => (
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={className}
|
||||
role="img"
|
||||
aria-label="Workspace icon"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue