@@ -14,14 +14,10 @@ import {
14
14
UpdateButton ,
15
15
ActivateButton ,
16
16
} from "./Buttons" ;
17
- import {
18
- ButtonMapping ,
19
- ButtonTypesEnum ,
20
- actionsByWorkspaceStatus ,
21
- } from "./constants" ;
22
- import SettingsOutlined from "@mui/icons-material/SettingsOutlined" ;
23
- import HistoryOutlined from "@mui/icons-material/HistoryOutlined" ;
24
- import DeleteOutlined from "@mui/icons-material/DeleteOutlined" ;
17
+ import { ButtonMapping , actionsByWorkspaceStatus } from "./constants" ;
18
+ import SettingsIcon from "@mui/icons-material/SettingsOutlined" ;
19
+ import HistoryIcon from "@mui/icons-material/HistoryOutlined" ;
20
+ import DeleteIcon from "@mui/icons-material/DeleteOutlined" ;
25
21
import IconButton from "@mui/material/IconButton" ;
26
22
27
23
export interface WorkspaceActionsProps {
@@ -68,40 +64,30 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
68
64
69
65
// A mapping of button type to the corresponding React component
70
66
const buttonMapping : ButtonMapping = {
71
- [ ButtonTypesEnum . update ] : < UpdateButton handleAction = { handleUpdate } /> ,
72
- [ ButtonTypesEnum . updating ] : (
73
- < UpdateButton loading handleAction = { handleUpdate } />
74
- ) ,
75
- [ ButtonTypesEnum . start ] : (
76
- < StartButton workspace = { workspace } handleAction = { handleStart } />
77
- ) ,
78
- [ ButtonTypesEnum . starting ] : (
67
+ update : < UpdateButton handleAction = { handleUpdate } /> ,
68
+ updating : < UpdateButton loading handleAction = { handleUpdate } /> ,
69
+ start : < StartButton workspace = { workspace } handleAction = { handleStart } /> ,
70
+ starting : (
79
71
< StartButton loading workspace = { workspace } handleAction = { handleStart } />
80
72
) ,
81
- [ ButtonTypesEnum . stop ] : < StopButton handleAction = { handleStop } /> ,
82
- [ ButtonTypesEnum . stopping ] : (
83
- < StopButton loading handleAction = { handleStop } />
84
- ) ,
85
- [ ButtonTypesEnum . restart ] : (
73
+ stop : < StopButton handleAction = { handleStop } /> ,
74
+ stopping : < StopButton loading handleAction = { handleStop } /> ,
75
+ restart : (
86
76
< RestartButton workspace = { workspace } handleAction = { handleRestart } />
87
77
) ,
88
- [ ButtonTypesEnum . restarting ] : (
78
+ restarting : (
89
79
< RestartButton
90
80
loading
91
81
workspace = { workspace }
92
82
handleAction = { handleRestart }
93
83
/>
94
84
) ,
95
- [ ButtonTypesEnum . deleting ] : < ActionLoadingButton label = "Deleting" /> ,
96
- [ ButtonTypesEnum . canceling ] : < DisabledButton label = "Canceling..." /> ,
97
- [ ButtonTypesEnum . deleted ] : < DisabledButton label = "Deleted" /> ,
98
- [ ButtonTypesEnum . pending ] : < ActionLoadingButton label = "Pending..." /> ,
99
- [ ButtonTypesEnum . activate ] : (
100
- < ActivateButton handleAction = { handleDormantActivate } />
101
- ) ,
102
- [ ButtonTypesEnum . activating ] : (
103
- < ActivateButton loading handleAction = { handleDormantActivate } />
104
- ) ,
85
+ deleting : < ActionLoadingButton label = "Deleting" /> ,
86
+ canceling : < DisabledButton label = "Canceling..." /> ,
87
+ deleted : < DisabledButton label = "Deleted" /> ,
88
+ pending : < ActionLoadingButton label = "Pending..." /> ,
89
+ activate : < ActivateButton handleAction = { handleDormantActivate } /> ,
90
+ activating : < ActivateButton loading handleAction = { handleDormantActivate } /> ,
105
91
} ;
106
92
107
93
// Returns a function that will execute the action and close the menu
@@ -113,10 +99,8 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
113
99
return (
114
100
< div className = { styles . actions } data-testid = "workspace-actions" >
115
101
{ canBeUpdated &&
116
- ( isUpdating
117
- ? buttonMapping [ ButtonTypesEnum . updating ]
118
- : buttonMapping [ ButtonTypesEnum . update ] ) }
119
- { isRestarting && buttonMapping [ ButtonTypesEnum . restarting ] }
102
+ ( isUpdating ? buttonMapping . updating : buttonMapping . update ) }
103
+ { isRestarting && buttonMapping . restarting }
120
104
{ ! isRestarting &&
121
105
actionsByStatus . map ( ( action ) => (
122
106
< Fragment key = { action } > { buttonMapping [ action ] } </ Fragment >
@@ -142,20 +126,20 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
142
126
onClose = { ( ) => setIsMenuOpen ( false ) }
143
127
>
144
128
< MenuItem onClick = { onMenuItemClick ( handleSettings ) } >
145
- < SettingsOutlined />
129
+ < SettingsIcon />
146
130
Settings
147
131
</ MenuItem >
148
132
{ canChangeVersions && (
149
133
< MenuItem onClick = { onMenuItemClick ( handleChangeVersion ) } >
150
- < HistoryOutlined />
134
+ < HistoryIcon />
151
135
Change version…
152
136
</ MenuItem >
153
137
) }
154
138
< MenuItem
155
139
onClick = { onMenuItemClick ( handleDelete ) }
156
140
data-testid = "delete-button"
157
141
>
158
- < DeleteOutlined />
142
+ < DeleteIcon />
159
143
Delete…
160
144
</ MenuItem >
161
145
</ Menu >
0 commit comments