1
1
import { type Workspace , type WorkspaceStatus } from "api/typesGenerated" ;
2
2
3
3
/**
4
- * An iterable of all button types supported by the workspace actions UI
4
+ * An iterable of all action types supported by the workspace UI
5
5
*/
6
- export const buttonTypes = [
6
+ export const actionTypes = [
7
7
"start" ,
8
8
"starting" ,
9
9
"stop" ,
@@ -28,18 +28,15 @@ export const buttonTypes = [
28
28
"pending" ,
29
29
] as const ;
30
30
31
- /**
32
- * A button type supported by the workspace actions UI
33
- */
34
- export type ButtonType = ( typeof buttonTypes ) [ number ] ;
31
+ export type ActionType = ( typeof actionTypes ) [ number ] ;
35
32
36
33
type WorkspaceAbilities = {
37
- actions : readonly ButtonType [ ] ;
34
+ actions : readonly ActionType [ ] ;
38
35
canCancel : boolean ;
39
36
canAcceptJobs : boolean ;
40
37
} ;
41
38
42
- export const actionsByWorkspaceStatus = (
39
+ export const abilitiesByWorkspaceStatus = (
43
40
workspace : Workspace ,
44
41
canRetryDebug : boolean ,
45
42
) : WorkspaceAbilities => {
@@ -54,15 +51,15 @@ export const actionsByWorkspaceStatus = (
54
51
const status = workspace . latest_build . status ;
55
52
if ( status === "failed" && canRetryDebug ) {
56
53
return {
57
- ...statusToActions . failed ,
54
+ ...statusToAbility . failed ,
58
55
actions : [ "retry" , "retryDebug" ] ,
59
56
} ;
60
57
}
61
58
62
- return statusToActions [ status ] ;
59
+ return statusToAbility [ status ] ;
63
60
} ;
64
61
65
- const statusToActions : Record < WorkspaceStatus , WorkspaceAbilities > = {
62
+ const statusToAbility : Record < WorkspaceStatus , WorkspaceAbilities > = {
66
63
starting : {
67
64
actions : [ "starting" ] ,
68
65
canCancel : true ,
0 commit comments