@@ -11,11 +11,7 @@ import {
11
11
UpdateButton ,
12
12
ActivateButton ,
13
13
} from "./Buttons" ;
14
- import {
15
- ButtonMapping ,
16
- ButtonTypesEnum ,
17
- actionsByWorkspaceStatus ,
18
- } from "./constants" ;
14
+ import { ButtonMapping , actionsByWorkspaceStatus } from "./constants" ;
19
15
20
16
import Divider from "@mui/material/Divider" ;
21
17
import DuplicateIcon from "@mui/icons-material/FileCopyOutlined" ;
@@ -76,42 +72,32 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
76
72
const { duplicateWorkspace, isDuplicationReady } =
77
73
useWorkspaceDuplication ( workspace ) ;
78
74
79
- // A mapping of button type to the corresponding React component
75
+ // A mapping of button type to their corresponding React components
80
76
const buttonMapping : ButtonMapping = {
81
- [ ButtonTypesEnum . update ] : < UpdateButton handleAction = { handleUpdate } /> ,
82
- [ ButtonTypesEnum . updating ] : (
83
- < UpdateButton loading handleAction = { handleUpdate } />
84
- ) ,
85
- [ ButtonTypesEnum . start ] : (
86
- < StartButton workspace = { workspace } handleAction = { handleStart } />
87
- ) ,
88
- [ ButtonTypesEnum . starting ] : (
77
+ update : < UpdateButton handleAction = { handleUpdate } /> ,
78
+ updating : < UpdateButton loading handleAction = { handleUpdate } /> ,
79
+ start : < StartButton workspace = { workspace } handleAction = { handleStart } /> ,
80
+ starting : (
89
81
< StartButton loading workspace = { workspace } handleAction = { handleStart } />
90
82
) ,
91
- [ ButtonTypesEnum . stop ] : < StopButton handleAction = { handleStop } /> ,
92
- [ ButtonTypesEnum . stopping ] : (
93
- < StopButton loading handleAction = { handleStop } />
94
- ) ,
95
- [ ButtonTypesEnum . restart ] : (
83
+ stop : < StopButton handleAction = { handleStop } /> ,
84
+ stopping : < StopButton loading handleAction = { handleStop } /> ,
85
+ restart : (
96
86
< RestartButton workspace = { workspace } handleAction = { handleRestart } />
97
87
) ,
98
- [ ButtonTypesEnum . restarting ] : (
88
+ restarting : (
99
89
< RestartButton
100
90
loading
101
91
workspace = { workspace }
102
92
handleAction = { handleRestart }
103
93
/>
104
94
) ,
105
- [ ButtonTypesEnum . deleting ] : < ActionLoadingButton label = "Deleting" /> ,
106
- [ ButtonTypesEnum . canceling ] : < DisabledButton label = "Canceling..." /> ,
107
- [ ButtonTypesEnum . deleted ] : < DisabledButton label = "Deleted" /> ,
108
- [ ButtonTypesEnum . pending ] : < ActionLoadingButton label = "Pending..." /> ,
109
- [ ButtonTypesEnum . activate ] : (
110
- < ActivateButton handleAction = { handleDormantActivate } />
111
- ) ,
112
- [ ButtonTypesEnum . activating ] : (
113
- < ActivateButton loading handleAction = { handleDormantActivate } />
114
- ) ,
95
+ deleting : < ActionLoadingButton label = "Deleting" /> ,
96
+ canceling : < DisabledButton label = "Canceling..." /> ,
97
+ deleted : < DisabledButton label = "Deleted" /> ,
98
+ pending : < ActionLoadingButton label = "Pending..." /> ,
99
+ activate : < ActivateButton handleAction = { handleDormantActivate } /> ,
100
+ activating : < ActivateButton loading handleAction = { handleDormantActivate } /> ,
115
101
} ;
116
102
117
103
return (
@@ -120,18 +106,17 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
120
106
data-testid = "workspace-actions"
121
107
>
122
108
{ canBeUpdated &&
123
- ( isUpdating
124
- ? buttonMapping [ ButtonTypesEnum . updating ]
125
- : buttonMapping [ ButtonTypesEnum . update ] ) }
109
+ ( isUpdating ? buttonMapping . updating : buttonMapping . update ) }
126
110
127
- { isRestarting && buttonMapping [ ButtonTypesEnum . restarting ] }
111
+ { isRestarting && buttonMapping . restarting }
128
112
129
113
{ ! isRestarting &&
130
114
actionsByStatus . map ( ( action ) => (
131
115
< Fragment key = { action } > { buttonMapping [ action ] } </ Fragment >
132
116
) ) }
133
117
134
118
{ canCancel && < CancelButton handleAction = { handleCancel } /> }
119
+
135
120
< MoreMenu >
136
121
< MoreMenuTrigger >
137
122
< ThreeDotsButton
0 commit comments