File tree 4 files changed +21
-10
lines changed
4 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ fatal() {
136
136
trap ' fatal "Script encountered an error"' ERR
137
137
138
138
cdroot
139
- start_cmd API " " " ${CODER_DEV_SHIM} " server --http-address 0.0.0.0:3000 --swagger-enable --access-url " ${CODER_DEV_ACCESS_URL} " --experiments= " template_update_policies " -- dangerous-allow-cors-requests=true " $@ "
139
+ start_cmd API " " " ${CODER_DEV_SHIM} " server --http-address 0.0.0.0:3000 --swagger-enable --access-url " ${CODER_DEV_ACCESS_URL} " --dangerous-allow-cors-requests=true " $@ "
140
140
141
141
echo ' == Waiting for Coder to become ready'
142
142
# Start the timeout in the background so interrupting this script
Original file line number Diff line number Diff line change 1
1
import { Workspace , WorkspaceStatus } from "api/typesGenerated" ;
2
2
import { ReactNode } from "react" ;
3
+ import { workspaceUpdatePolicy } from "utils/workspace" ;
3
4
4
5
// the button types we have
5
6
export enum ButtonTypesEnum {
@@ -44,8 +45,8 @@ export const actionsByWorkspaceStatus = (
44
45
}
45
46
if (
46
47
workspace . outdated &&
47
- ( ( workspace . template_require_active_version && ! canChangeVersions ) ||
48
- workspace . automatic_updates === "always" )
48
+ workspace . template_require_active_version &&
49
+ ! canChangeVersions
49
50
) {
50
51
if ( status === "running" ) {
51
52
return {
Original file line number Diff line number Diff line change 7
7
getDisplayWorkspaceBuildInitiatedBy ,
8
8
getDisplayWorkspaceTemplateName ,
9
9
isWorkspaceOn ,
10
+ workspaceUpdatePolicy ,
10
11
} from "utils/workspace" ;
11
12
import { Workspace } from "api/typesGenerated" ;
12
13
import { Stats , StatsItem } from "components/Stats/Stats" ;
@@ -77,12 +78,6 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
77
78
const deadlinePlusEnabled = maxDeadlineIncrease >= 1 ;
78
79
const deadlineMinusEnabled = maxDeadlineDecrease >= 1 ;
79
80
const templatePoliciesEnabled = useTemplatePoliciesEnabled ( ) ;
80
- const workspaceUpdatePolicy = ( ) : string => {
81
- if ( workspace . template_require_active_version && ! canChangeVersions ) {
82
- return "Always" ;
83
- }
84
- return upperFirst ( workspace . automatic_updates ) ;
85
- } ;
86
81
87
82
return (
88
83
< >
@@ -219,7 +214,9 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
219
214
< StatsItem
220
215
className = { styles . statsItem }
221
216
label = { Language . updatePolicy }
222
- value = { workspaceUpdatePolicy ( ) }
217
+ value = { upperFirst (
218
+ workspaceUpdatePolicy ( workspace , canChangeVersions ) ,
219
+ ) }
223
220
/>
224
221
{ workspace . automatic_updates === "never" &&
225
222
workspace . template_require_active_version &&
Original file line number Diff line number Diff line change @@ -303,3 +303,16 @@ export const getMatchingAgentOrFirst = (
303
303
} )
304
304
. filter ( ( a ) => a ) [ 0 ] ;
305
305
} ;
306
+
307
+ export const workspaceUpdatePolicy = (
308
+ workspace : TypesGen . Workspace ,
309
+ canChangeVersions : boolean ,
310
+ ) : TypesGen . AutomaticUpdates => {
311
+ // If a template requires the active version and you cannot change versions
312
+ // (restricted to template admins), then your policy must be "Always".
313
+ if ( workspace . template_require_active_version && ! canChangeVersions ) {
314
+ return "always" ;
315
+ }
316
+ // Else prefer the workspace-level setting.
317
+ return workspace . automatic_updates ;
318
+ } ;
You can’t perform that action at this time.
0 commit comments