@@ -19,10 +19,14 @@ import {
19
19
ButtonTypesEnum ,
20
20
actionsByWorkspaceStatus ,
21
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" ;
22
+
25
23
import IconButton from "@mui/material/IconButton" ;
24
+ import DuplicateIcon from "@mui/icons-material/FileCopyOutlined" ;
25
+ import SettingsIcon from "@mui/icons-material/SettingsOutlined" ;
26
+ import HistoryIcon from "@mui/icons-material/HistoryOutlined" ;
27
+ import DeleteIcon from "@mui/icons-material/DeleteOutlined" ;
28
+
29
+ import { useWorkspaceDuplication } from "pages/CreateWorkspacePage/useWorkspaceDuplication" ;
26
30
27
31
export interface WorkspaceActionsProps {
28
32
workspace : Workspace ;
@@ -69,6 +73,8 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
69
73
const canBeUpdated = workspace . outdated && canAcceptJobs ;
70
74
const menuTriggerRef = useRef < HTMLButtonElement > ( null ) ;
71
75
const [ isMenuOpen , setIsMenuOpen ] = useState ( false ) ;
76
+ const { duplicateWorkspace, duplicationReady } =
77
+ useWorkspaceDuplication ( workspace ) ;
72
78
73
79
// A mapping of button type to the corresponding React component
74
80
const buttonMapping : ButtonMapping = {
@@ -120,12 +126,16 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
120
126
( isUpdating
121
127
? buttonMapping [ ButtonTypesEnum . updating ]
122
128
: buttonMapping [ ButtonTypesEnum . update ] ) }
129
+
123
130
{ isRestarting && buttonMapping [ ButtonTypesEnum . restarting ] }
131
+
124
132
{ ! isRestarting &&
125
133
actionsByStatus . map ( ( action ) => (
126
134
< Fragment key = { action } > { buttonMapping [ action ] } </ Fragment >
127
135
) ) }
136
+
128
137
{ canCancel && < CancelButton handleAction = { handleCancel } /> }
138
+
129
139
< div >
130
140
< IconButton
131
141
title = "More options"
@@ -139,27 +149,38 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
139
149
>
140
150
< MoreVertOutlined />
141
151
</ IconButton >
152
+
142
153
< Menu
143
154
id = "workspace-options"
144
155
anchorEl = { menuTriggerRef . current }
145
156
open = { isMenuOpen }
146
157
onClose = { ( ) => setIsMenuOpen ( false ) }
147
158
>
148
159
< MenuItem onClick = { onMenuItemClick ( handleSettings ) } >
149
- < SettingsOutlined />
160
+ < SettingsIcon />
150
161
Settings
151
162
</ MenuItem >
163
+
152
164
{ canChangeVersions && (
153
165
< MenuItem onClick = { onMenuItemClick ( handleChangeVersion ) } >
154
- < HistoryOutlined />
166
+ < HistoryIcon />
155
167
Change version…
156
168
</ MenuItem >
157
169
) }
170
+
171
+ < MenuItem
172
+ onClick = { onMenuItemClick ( duplicateWorkspace ) }
173
+ disabled = { ! duplicationReady }
174
+ >
175
+ < DuplicateIcon />
176
+ Duplicate…
177
+ </ MenuItem >
178
+
158
179
< MenuItem
159
180
onClick = { onMenuItemClick ( handleDelete ) }
160
181
data-testid = "delete-button"
161
182
>
162
- < DeleteOutlined />
183
+ < DeleteIcon />
163
184
Delete…
164
185
</ MenuItem >
165
186
</ Menu >
0 commit comments