Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor improvements for workspace management #6099

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/core/components/workspace/list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`}
sriramveeraghanta marked this conversation as resolved.
Show resolved Hide resolved
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"
>
Expand Down
3 changes: 2 additions & 1 deletion admin/core/services/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions admin/core/store/workspace.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]>;
Expand Down Expand Up @@ -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;
};

Expand Down
3 changes: 3 additions & 0 deletions apiserver/plane/license/api/serializers/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def validate_slug(self, value):
# 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:
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/license/api/views/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get(self, request):
)

workspace = (
Workspace.objects.filter(slug=slug).exists()
Workspace.objects.filter(slug__iexact=slug).exists()
sriramveeraghanta marked this conversation as resolved.
Show resolved Hide resolved
or slug in RESTRICTED_WORKSPACE_SLUGS
)
return Response({"status": not workspace}, status=status.HTTP_200_OK)
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/src/icons/workspace-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading