@@ -11,10 +11,13 @@ import { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
11
11
import { BuildParametersPopover } from "./BuildParametersPopover" ;
12
12
import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew" ;
13
13
import LoadingButton from "@mui/lab/LoadingButton" ;
14
+ import Tooltip from "@mui/material/Tooltip" ;
14
15
15
16
interface WorkspaceAction {
16
17
loading ?: boolean ;
17
18
handleAction : ( ) => void ;
19
+ disabled ?: boolean ;
20
+ tooltipText ?: string ;
18
21
}
19
22
20
23
export const UpdateButton : FC < WorkspaceAction > = ( {
@@ -55,8 +58,8 @@ export const StartButton: FC<
55
58
workspace : Workspace ;
56
59
handleAction : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
57
60
}
58
- > = ( { handleAction, workspace, loading } ) => {
59
- return (
61
+ > = ( { handleAction, workspace, loading, disabled , tooltipText } ) => {
62
+ const buttonContent = (
60
63
< ButtonGroup
61
64
variant = "outlined"
62
65
sx = { {
@@ -65,12 +68,14 @@ export const StartButton: FC<
65
68
borderLeft : "1px solid #FFF" ,
66
69
} ,
67
70
} }
71
+ disabled = { disabled }
68
72
>
69
73
< LoadingButton
70
74
loading = { loading }
71
75
loadingPosition = "start"
72
76
startIcon = { < PlayCircleOutlineIcon /> }
73
77
onClick = { ( ) => handleAction ( ) }
78
+ disabled = { disabled }
74
79
>
75
80
{ loading ? < > Starting…</ > : "Start" }
76
81
</ LoadingButton >
@@ -81,6 +86,12 @@ export const StartButton: FC<
81
86
/>
82
87
</ ButtonGroup >
83
88
) ;
89
+
90
+ return tooltipText ? (
91
+ < Tooltip title = { tooltipText } > { buttonContent } </ Tooltip >
92
+ ) : (
93
+ buttonContent
94
+ ) ;
84
95
} ;
85
96
86
97
export const StopButton : FC < WorkspaceAction > = ( { handleAction, loading } ) => {
@@ -102,8 +113,8 @@ export const RestartButton: FC<
102
113
workspace : Workspace ;
103
114
handleAction : ( buildParameters ?: WorkspaceBuildParameter [ ] ) => void ;
104
115
}
105
- > = ( { handleAction, loading, workspace } ) => {
106
- return (
116
+ > = ( { handleAction, loading, workspace, disabled , tooltipText } ) => {
117
+ const buttonContent = (
107
118
< ButtonGroup
108
119
variant = "outlined"
109
120
sx = { {
@@ -112,13 +123,15 @@ export const RestartButton: FC<
112
123
borderLeft : "1px solid #FFF" ,
113
124
} ,
114
125
} }
126
+ disabled = { disabled }
115
127
>
116
128
< LoadingButton
117
129
loading = { loading }
118
130
loadingPosition = "start"
119
131
startIcon = { < ReplayIcon /> }
120
132
onClick = { ( ) => handleAction ( ) }
121
133
data-testid = "workspace-restart-button"
134
+ disabled = { disabled }
122
135
>
123
136
{ loading ? < > Restarting…</ > : < > Restart…</ > }
124
137
</ LoadingButton >
@@ -129,6 +142,12 @@ export const RestartButton: FC<
129
142
/>
130
143
</ ButtonGroup >
131
144
) ;
145
+
146
+ return tooltipText ? (
147
+ < Tooltip title = { tooltipText } > { buttonContent } </ Tooltip >
148
+ ) : (
149
+ buttonContent
150
+ ) ;
132
151
} ;
133
152
134
153
export const CancelButton : FC < WorkspaceAction > = ( { handleAction } ) => {
0 commit comments