File tree Expand file tree Collapse file tree 3 files changed +22
-12
lines changed
src/views/settings/components Expand file tree Collapse file tree 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 11import { zodResolver } from "@hookform/resolvers/zod" ;
2+ import { env } from "next-runtime-env" ;
23import { useForm } from "react-hook-form" ;
34import { HiCheck , HiMiniStar } from "react-icons/hi2" ;
45import { z } from "zod" ;
@@ -92,7 +93,9 @@ const UpdateWorkspaceUrlForm = ({
9293 const isWorkspaceSlugAvailable = checkWorkspaceSlugAvailability . data ;
9394
9495 const onSubmit = ( data : FormValues ) => {
95- if ( isWorkspaceSlugAvailable ?. isAvailable && workspacePlan !== "pro" )
96+ if ( ! isWorkspaceSlugAvailable ?. isAvailable ) return ;
97+
98+ if ( workspacePlan !== "pro" && env ( "NEXT_PUBLIC_KAN_ENV" ) === "cloud" )
9699 return openModal ( "UPDATE_WORKSPACE_URL" , data . slug ) ;
97100
98101 updateWorkspaceSlug . mutate ( {
@@ -118,7 +121,11 @@ const UpdateWorkspaceUrlForm = ({
118121 ? "This workspace username has already been taken"
119122 : undefined )
120123 }
121- prefix = "kan.bn/"
124+ prefix = {
125+ env ( "NEXT_PUBLIC_KAN_ENV" ) === "cloud"
126+ ? "kan.bn/"
127+ : `${ env ( "NEXT_PUBLIC_BASE_URL" ) } /`
128+ }
122129 iconRight = {
123130 isWorkspaceSlugAvailable ?. isAvailable ||
124131 ( workspacePlan === "pro" && slug === workspaceUrl ) ? (
Original file line number Diff line number Diff line change 11import { TRPCError } from "@trpc/server" ;
2+ import { env } from "next-runtime-env" ;
23import { z } from "zod" ;
34
45import * as workspaceRepo from "@kan/db/repository/workspace.repo" ;
@@ -224,10 +225,19 @@ export const workspaceRouter = createTRPCRouter({
224225 const isWorkspaceSlugAvailable =
225226 await workspaceRepo . isWorkspaceSlugAvailable ( ctx . db , input . slug ) ;
226227
228+ if (
229+ env ( "NEXT_PUBLIC_KAN_ENV" ) === "cloud" &&
230+ workspace . plan !== "pro" &&
231+ input . slug !== workspace . publicId
232+ ) {
233+ throw new TRPCError ( {
234+ message : `Workspace slug cannot be changed in cloud without upgrading to a paid plan` ,
235+ code : "FORBIDDEN" ,
236+ } ) ;
237+ }
238+
227239 if (
228240 reservedOrPremiumWorkspaceSlug ?. type === "reserved" ||
229- ( workspace . plan !== "pro" &&
230- reservedOrPremiumWorkspaceSlug ?. type === "premium" ) ||
231241 ! isWorkspaceSlugAvailable
232242 ) {
233243 throw new TRPCError ( {
You can’t perform that action at this time.
0 commit comments