File tree 4 files changed +20
-7
lines changed
WorkspacePage/WorkspaceActions
4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { type FC , type ReactNode , Fragment } from "react" ;
2
2
import { Workspace , WorkspaceBuildParameter } from "api/typesGenerated" ;
3
3
import { useWorkspaceDuplication } from "pages/CreateWorkspacePage/useWorkspaceDuplication" ;
4
- import { workspaceUpdatePolicy } from "utils/workspace" ;
4
+ import { mustUpdateWorkspace } from "utils/workspace" ;
5
5
import { type ActionType , abilitiesByWorkspaceStatus } from "./constants" ;
6
6
import {
7
7
CancelButton ,
@@ -79,10 +79,7 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
79
79
canCancel &&
80
80
( workspace . template_allow_user_cancel_workspace_jobs || isOwner ) ;
81
81
82
- const mustUpdate =
83
- workspaceUpdatePolicy ( workspace , canChangeVersions ) === "always" &&
84
- workspace . outdated ;
85
-
82
+ const mustUpdate = mustUpdateWorkspace ( workspace , canChangeVersions ) ;
86
83
const tooltipText = getTooltipText ( workspace , mustUpdate , canChangeVersions ) ;
87
84
const canBeUpdated = workspace . outdated && canAcceptJobs ;
88
85
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ const WorkspacesPage: FC = () => {
85
85
86
86
< WorkspacesPageView
87
87
canCreateTemplate = { permissions . createTemplates }
88
+ canChangeVersions = { permissions . updateTemplates }
88
89
checkedWorkspaces = { checkedWorkspaces }
89
90
onCheckChange = { setCheckedWorkspaces }
90
91
canCheckWorkspaces = { canCheckWorkspaces }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import KeyboardArrowDownOutlined from "@mui/icons-material/KeyboardArrowDownOutl
26
26
import Divider from "@mui/material/Divider" ;
27
27
import LoadingButton from "@mui/lab/LoadingButton" ;
28
28
import { PaginationHeader } from "components/PaginationWidget/PaginationHeader" ;
29
+ import { mustUpdateWorkspace } from "utils/workspace" ;
29
30
30
31
export const Language = {
31
32
pageTitle : "Workspaces" ,
@@ -59,6 +60,7 @@ export interface WorkspacesPageViewProps {
59
60
templatesFetchStatus : TemplateQuery [ "status" ] ;
60
61
templates : TemplateQuery [ "data" ] ;
61
62
canCreateTemplate : boolean ;
63
+ canChangeVersions : boolean ;
62
64
}
63
65
64
66
export const WorkspacesPageView = ( {
@@ -81,6 +83,7 @@ export const WorkspacesPageView = ({
81
83
templates,
82
84
templatesFetchStatus,
83
85
canCreateTemplate,
86
+ canChangeVersions,
84
87
} : WorkspacesPageViewProps ) => {
85
88
return (
86
89
< Margins >
@@ -136,7 +139,9 @@ export const WorkspacesPageView = ({
136
139
onClick = { onStartAll }
137
140
disabled = {
138
141
! checkedWorkspaces ?. every (
139
- ( w ) => w . latest_build . status === "stopped" ,
142
+ ( w ) =>
143
+ w . latest_build . status === "stopped" &&
144
+ ! mustUpdateWorkspace ( w , canChangeVersions ) ,
140
145
)
141
146
}
142
147
>
Original file line number Diff line number Diff line change @@ -274,7 +274,17 @@ export const getMatchingAgentOrFirst = (
274
274
. filter ( ( a ) => a ) [ 0 ] ;
275
275
} ;
276
276
277
- export const workspaceUpdatePolicy = (
277
+ export const mustUpdateWorkspace = (
278
+ workspace : TypesGen . Workspace ,
279
+ canChangeVersions : boolean ,
280
+ ) : boolean => {
281
+ return (
282
+ workspaceUpdatePolicy ( workspace , canChangeVersions ) === "always" &&
283
+ workspace . outdated
284
+ ) ;
285
+ } ;
286
+
287
+ const workspaceUpdatePolicy = (
278
288
workspace : TypesGen . Workspace ,
279
289
canChangeVersions : boolean ,
280
290
) : TypesGen . AutomaticUpdates => {
You can’t perform that action at this time.
0 commit comments