1
- import DownloadOutlined from "@mui/icons-material/DownloadOutlined" ;
2
- import DuplicateIcon from "@mui/icons-material/FileCopyOutlined" ;
3
- import SettingsIcon from "@mui/icons-material/SettingsOutlined" ;
4
1
import type { Workspace , WorkspaceBuildParameter } from "api/typesGenerated" ;
5
- import { Button } from "components/Button/Button" ;
6
- import {
7
- DropdownMenu ,
8
- DropdownMenuContent ,
9
- DropdownMenuItem ,
10
- DropdownMenuSeparator ,
11
- DropdownMenuTrigger ,
12
- } from "components/DropdownMenu/DropdownMenu" ;
13
2
import { useAuthenticated } from "hooks/useAuthenticated" ;
14
- import { EllipsisVertical } from "lucide-react" ;
15
3
import {
16
4
type ActionType ,
17
5
abilitiesByWorkspaceStatus ,
18
6
} from "modules/workspaces/actions" ;
19
- import { useWorkspaceDuplication } from "pages/CreateWorkspacePage/useWorkspaceDuplication" ;
20
- import { type FC , Fragment , type ReactNode , useState } from "react" ;
7
+ import { type FC , Fragment , type ReactNode } from "react" ;
21
8
import { mustUpdateWorkspace } from "utils/workspace" ;
22
9
import {
23
10
ActivateButton ,
@@ -33,56 +20,57 @@ import {
33
20
} from "./Buttons" ;
34
21
import { DebugButton } from "./DebugButton" ;
35
22
import { RetryButton } from "./RetryButton" ;
23
+ import { WorkspaceMoreActions } from "modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions" ;
24
+ import type { WorkspacePermissions } from "modules/workspaces/permissions" ;
36
25
37
26
export interface WorkspaceActionsProps {
38
27
workspace : Workspace ;
28
+ isUpdating : boolean ;
29
+ isRestarting : boolean ;
30
+ permissions : WorkspacePermissions ;
39
31
handleToggleFavorite : ( ) => void ;
40
32
handleStart : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
41
33
handleStop : ( ) => void ;
42
34
handleRestart : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
43
35
handleUpdate : ( ) => void ;
44
36
handleCancel : ( ) => void ;
45
- handleSettings : ( ) => void ;
46
37
handleRetry : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
47
38
handleDebug : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
48
39
handleDormantActivate : ( ) => void ;
49
- isUpdating : boolean ;
50
- isRestarting : boolean ;
51
- children ?: ReactNode ;
52
- canChangeVersions : boolean ;
53
- canDebug : boolean ;
54
40
}
55
41
56
42
export const WorkspaceActions : FC < WorkspaceActionsProps > = ( {
57
43
workspace,
44
+ isUpdating,
45
+ isRestarting,
46
+ permissions,
58
47
handleToggleFavorite,
59
48
handleStart,
60
49
handleStop,
61
50
handleRestart,
62
51
handleUpdate,
63
52
handleCancel,
64
- handleSettings,
65
53
handleRetry,
66
54
handleDebug,
67
55
handleDormantActivate,
68
- isUpdating,
69
- isRestarting,
70
- canChangeVersions,
71
- canDebug,
72
56
} ) => {
73
- const { duplicateWorkspace, isDuplicationReady } =
74
- useWorkspaceDuplication ( workspace ) ;
75
-
76
57
const { user } = useAuthenticated ( ) ;
77
58
const isOwner =
78
59
user . roles . find ( ( role ) => role . name === "owner" ) !== undefined ;
79
60
const { actions, canCancel, canAcceptJobs } = abilitiesByWorkspaceStatus (
80
61
workspace ,
81
- { canDebug, isOwner } ,
62
+ { canDebug : permissions . deploymentConfig , isOwner } ,
82
63
) ;
83
64
84
- const mustUpdate = mustUpdateWorkspace ( workspace , canChangeVersions ) ;
85
- const tooltipText = getTooltipText ( workspace , mustUpdate , canChangeVersions ) ;
65
+ const mustUpdate = mustUpdateWorkspace (
66
+ workspace ,
67
+ permissions . updateWorkspaceVersion ,
68
+ ) ;
69
+ const tooltipText = getTooltipText (
70
+ workspace ,
71
+ mustUpdate ,
72
+ permissions . updateWorkspaceVersion ,
73
+ ) ;
86
74
87
75
// A mapping of button type to the corresponding React component
88
76
const buttonMapping : Record < ActionType , ReactNode > = {
@@ -170,36 +158,11 @@ export const WorkspaceActions: FC<WorkspaceActionsProps> = ({
170
158
onToggle = { handleToggleFavorite }
171
159
/>
172
160
173
- < DropdownMenu >
174
- < DropdownMenuTrigger asChild >
175
- < Button
176
- size = "icon-lg"
177
- variant = "subtle"
178
- aria-label = "Workspace actions"
179
- data-testid = "workspace-options-button"
180
- aria-controls = "workspace-options"
181
- disabled = { ! canAcceptJobs }
182
- >
183
- < EllipsisVertical aria-hidden = "true" />
184
- < span className = "sr-only" > Workspace actions</ span >
185
- </ Button >
186
- </ DropdownMenuTrigger >
187
-
188
- < DropdownMenuContent id = "workspace-options" align = "end" >
189
- < DropdownMenuItem onClick = { handleSettings } >
190
- < SettingsIcon />
191
- Settings
192
- </ DropdownMenuItem >
193
-
194
- < DropdownMenuItem
195
- onClick = { duplicateWorkspace }
196
- disabled = { ! isDuplicationReady }
197
- >
198
- < DuplicateIcon />
199
- Duplicate…
200
- </ DropdownMenuItem >
201
- </ DropdownMenuContent >
202
- </ DropdownMenu >
161
+ < WorkspaceMoreActions
162
+ workspace = { workspace }
163
+ permissions = { permissions }
164
+ disabled = { ! canAcceptJobs }
165
+ />
203
166
</ div >
204
167
) ;
205
168
} ;
0 commit comments