@@ -55,6 +55,7 @@ export interface WorkspaceProps {
5555 isOwner : boolean ;
5656 timings ?: TypesGen . WorkspaceBuildTimings ;
5757 startWorkspaceError ?: unknown ;
58+ updateWorkspaceError ?: unknown ;
5859}
5960
6061/**
@@ -89,6 +90,7 @@ export const Workspace: FC<WorkspaceProps> = ({
8990 isOwner,
9091 timings,
9192 startWorkspaceError,
93+ updateWorkspaceError,
9294} ) => {
9395 const navigate = useNavigate ( ) ;
9496 const theme = useTheme ( ) ;
@@ -125,14 +127,10 @@ export const Workspace: FC<WorkspaceProps> = ({
125127 const { shouldShow : shouldShowWorkspaceReadyDelayAlert } =
126128 useWorkspaceReadyDelayAlert ( timings , workspaceRunning ) ;
127129
128- const isRunningWorkspaceLimitError = Boolean (
129- startWorkspaceError &&
130- isApiError ( startWorkspaceError ) &&
131- startWorkspaceError . response ?. status === 409 &&
132- startWorkspaceError . response ?. data ?. message ?. includes (
133- "Running workspace limit" ,
134- ) ,
135- ) ;
130+ const isStartRunningWorkspaceLimitError =
131+ isRunningWorkspaceLimitError ( startWorkspaceError ) ;
132+ const isUpdateRunningWorkspaceLimitError =
133+ isRunningWorkspaceLimitError ( updateWorkspaceError ) ;
136134
137135 return (
138136 < div
@@ -255,7 +253,7 @@ export const Workspace: FC<WorkspaceProps> = ({
255253 </ Alert >
256254 ) }
257255
258- { isRunningWorkspaceLimitError && (
256+ { isStartRunningWorkspaceLimitError && (
259257 < Alert severity = "warning" >
260258 < AlertTitle > Running workspace limit reached</ AlertTitle >
261259 < AlertDetail >
@@ -267,6 +265,18 @@ export const Workspace: FC<WorkspaceProps> = ({
267265 </ Alert >
268266 ) }
269267
268+ { isUpdateRunningWorkspaceLimitError && (
269+ < Alert severity = "warning" >
270+ < AlertTitle > Running workspace limit reached</ AlertTitle >
271+ < AlertDetail >
272+ { getErrorMessage (
273+ updateWorkspaceError ,
274+ "Running workspace limit reached (max 1 per user). Stop one or more workspaces to update this workspace." ,
275+ ) }
276+ </ AlertDetail >
277+ </ Alert >
278+ ) }
279+
270280 { workspace . latest_build . job . error && (
271281 < Alert severity = "error" >
272282 < AlertTitle > Workspace build failed</ AlertTitle >
@@ -342,6 +352,14 @@ const countAgents = (resource: TypesGen.WorkspaceResource) => {
342352 return resource . agents ? resource . agents . length : 0 ;
343353} ;
344354
355+ const isRunningWorkspaceLimitError = ( error : unknown ) : boolean =>
356+ Boolean (
357+ error &&
358+ isApiError ( error ) &&
359+ error . response ?. status === 409 &&
360+ error . response ?. data ?. message ?. includes ( "Running workspace limit" ) ,
361+ ) ;
362+
345363const styles = {
346364 content : {
347365 padding : 32 ,
0 commit comments