File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed
apps/web/app/routes/ws/settings Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,20 @@ export default function GeneralSettingsPage() {
3030 slug ?: string ;
3131 } > ( { } ) ;
3232
33- const utils = trpc . useUtils ( ) ;
33+ const saveWorkspace = trpc . workspace . save . useMutation ( {
34+ onSuccess : ( ) => {
35+ toast . success ( "Workspace saved sucessfully" ) ;
36+ } ,
37+ onError : ( error : unknown ) => {
38+ const message =
39+ error instanceof Error ? error . message : "Failed to update workspace" ;
40+ toast . error ( message ) ;
41+ } ,
42+ } ) ;
43+
3444 const updateWorkspace = trpc . workspace . update . useMutation ( {
3545 onSuccess : ( ) => {
3646 toast . success ( "Workspace updated successfully" ) ;
37- // Invalidate the user session to refetch the updated workspace info
38- void utils . user . session . invalidate ( ) ;
3947 } ,
4048 onError : ( error : unknown ) => {
4149 const message =
@@ -167,6 +175,22 @@ export default function GeneralSettingsPage() {
167175 </ form >
168176 </ CardContent >
169177 </ Card >
178+
179+ < Card >
180+ < CardHeader >
181+ < CardTitle > Workspace Information</ CardTitle >
182+ < CardDescription >
183+ Update your workspace name and URL slug
184+ </ CardDescription >
185+ </ CardHeader >
186+ < CardContent >
187+ < Button
188+ onClick = { ( ) => saveWorkspace . mutate ( { workspaceId : workspace . id } ) }
189+ >
190+ Force Save Workspace
191+ </ Button >
192+ </ CardContent >
193+ </ Card >
170194 </ div >
171195 ) ;
172196}
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import type * as schema from "@ctrlplane/db/schema";
22import type { WorkspaceEngine } from "@ctrlplane/workspace-engine-sdk" ;
33
44export enum Event {
5+ WorkspaceSave = "workspace.save" ,
6+
57 SystemCreated = "system.created" ,
68 SystemUpdated = "system.updated" ,
79 SystemDeleted = "system.deleted" ,
@@ -159,6 +161,7 @@ export type EventPayload = {
159161} ;
160162
161163export type GoEventPayload = {
164+ [ Event . WorkspaceSave ] : object ;
162165 [ Event . SystemCreated ] : WorkspaceEngine [ "schemas" ] [ "System" ] ;
163166 [ Event . SystemUpdated ] : WorkspaceEngine [ "schemas" ] [ "System" ] ;
164167 [ Event . SystemDeleted ] : WorkspaceEngine [ "schemas" ] [ "System" ] ;
Original file line number Diff line number Diff line change @@ -3,11 +3,24 @@ import { z } from "zod";
33
44import { eq , takeFirst , takeFirstOrNull } from "@ctrlplane/db" ;
55import * as schema from "@ctrlplane/db/schema" ;
6+ import { Event , sendGoEvent } from "@ctrlplane/events" ;
67import { Permission } from "@ctrlplane/validators/auth" ;
78
89import { protectedProcedure , router } from "../trpc.js" ;
910
1011export const workspaceRouter = router ( {
12+ save : protectedProcedure
13+ . input ( z . object ( { workspaceId : z . uuid ( ) } ) )
14+ . mutation ( async ( { input } ) => {
15+ await sendGoEvent ( {
16+ workspaceId : input . workspaceId ,
17+ eventType : Event . WorkspaceSave ,
18+ timestamp : Date . now ( ) ,
19+ data : { } ,
20+ } ) ;
21+ return true ;
22+ } ) ,
23+
1124 get : protectedProcedure
1225 . meta ( {
1326 authorizationCheck : ( { canUser, input } ) =>
You can’t perform that action at this time.
0 commit comments