@@ -5,76 +5,85 @@ import CropSquareIcon from "@mui/icons-material/CropSquare"
5
5
import PlayCircleOutlineIcon from "@mui/icons-material/PlayCircleOutline"
6
6
import ReplayIcon from "@mui/icons-material/Replay"
7
7
import { LoadingButton } from "components/LoadingButton/LoadingButton"
8
- import { FC , PropsWithChildren } from "react"
9
- import { useTranslation } from "react-i18next "
8
+ import { FC } from "react"
9
+ import BlockOutlined from "@mui/icons-material/BlockOutlined "
10
10
11
11
interface WorkspaceAction {
12
+ loading ?: boolean
12
13
handleAction : ( ) => void
13
14
}
14
15
15
- export const UpdateButton : FC < PropsWithChildren < WorkspaceAction > > = ( {
16
+ export const UpdateButton : FC < WorkspaceAction > = ( {
16
17
handleAction,
18
+ loading,
17
19
} ) => {
18
- const { t } = useTranslation ( "workspacePage" )
19
-
20
20
return (
21
- < Button
21
+ < LoadingButton
22
+ loading = { loading }
23
+ loadingIndicator = "Updating..."
24
+ loadingPosition = "start"
22
25
size = "small"
23
26
data-testid = "workspace-update-button"
24
27
startIcon = { < CloudQueueIcon /> }
25
28
onClick = { handleAction }
26
29
>
27
- { t ( "actionButton.update" ) }
28
- </ Button >
30
+ Update
31
+ </ LoadingButton >
29
32
)
30
33
}
31
34
32
- export const StartButton : FC < PropsWithChildren < WorkspaceAction > > = ( {
33
- handleAction,
34
- } ) => {
35
- const { t } = useTranslation ( "workspacePage" )
36
-
35
+ export const StartButton : FC < WorkspaceAction > = ( { handleAction, loading } ) => {
37
36
return (
38
- < Button startIcon = { < PlayCircleOutlineIcon /> } onClick = { handleAction } >
39
- { t ( "actionButton.start" ) }
40
- </ Button >
37
+ < LoadingButton
38
+ size = "small"
39
+ loading = { loading }
40
+ loadingIndicator = "Starting..."
41
+ loadingPosition = "start"
42
+ startIcon = { < PlayCircleOutlineIcon /> }
43
+ onClick = { handleAction }
44
+ >
45
+ Start
46
+ </ LoadingButton >
41
47
)
42
48
}
43
49
44
- export const StopButton : FC < PropsWithChildren < WorkspaceAction > > = ( {
45
- handleAction,
46
- } ) => {
47
- const { t } = useTranslation ( "workspacePage" )
48
-
50
+ export const StopButton : FC < WorkspaceAction > = ( { handleAction, loading } ) => {
49
51
return (
50
- < Button size = "small" startIcon = { < CropSquareIcon /> } onClick = { handleAction } >
51
- { t ( "actionButton.stop" ) }
52
- </ Button >
52
+ < LoadingButton
53
+ size = "small"
54
+ loading = { loading }
55
+ loadingIndicator = "Stopping..."
56
+ loadingPosition = "start"
57
+ startIcon = { < CropSquareIcon /> }
58
+ onClick = { handleAction }
59
+ >
60
+ Stop
61
+ </ LoadingButton >
53
62
)
54
63
}
55
64
56
- export const RestartButton : FC < PropsWithChildren < WorkspaceAction > > = ( {
65
+ export const RestartButton : FC < WorkspaceAction > = ( {
57
66
handleAction,
67
+ loading,
58
68
} ) => {
59
- const { t } = useTranslation ( "workspacePage" )
60
-
61
69
return (
62
- < Button
70
+ < LoadingButton
71
+ loading = { loading }
72
+ loadingIndicator = "Restarting..."
73
+ loadingPosition = "start"
63
74
size = "small"
64
75
startIcon = { < ReplayIcon /> }
65
76
onClick = { handleAction }
66
77
data-testid = "workspace-restart-button"
67
78
>
68
- { t ( "actionButton.restart" ) }
69
- </ Button >
79
+ Restart
80
+ </ LoadingButton >
70
81
)
71
82
}
72
83
73
- export const CancelButton : FC < PropsWithChildren < WorkspaceAction > > = ( {
74
- handleAction,
75
- } ) => {
84
+ export const CancelButton : FC < WorkspaceAction > = ( { handleAction } ) => {
76
85
return (
77
- < Button startIcon = { < BlockIcon /> } onClick = { handleAction } >
86
+ < Button size = "small" startIcon = { < BlockIcon /> } onClick = { handleAction } >
78
87
Cancel
79
88
</ Button >
80
89
)
@@ -84,11 +93,9 @@ interface DisabledProps {
84
93
label : string
85
94
}
86
95
87
- export const DisabledButton : FC < PropsWithChildren < DisabledProps > > = ( {
88
- label,
89
- } ) => {
96
+ export const DisabledButton : FC < DisabledProps > = ( { label } ) => {
90
97
return (
91
- < Button size = "small" disabled >
98
+ < Button size = "small" startIcon = { < BlockOutlined /> } disabled >
92
99
{ label }
93
100
</ Button >
94
101
)
@@ -98,8 +105,15 @@ interface LoadingProps {
98
105
label : string
99
106
}
100
107
101
- export const ActionLoadingButton : FC < PropsWithChildren < LoadingProps > > = ( {
102
- label,
103
- } ) => {
104
- return < LoadingButton loading size = "small" loadingLabel = { label } />
108
+ export const ActionLoadingButton : FC < LoadingProps > = ( { label } ) => {
109
+ return (
110
+ < LoadingButton
111
+ loading
112
+ size = "small"
113
+ loadingPosition = "start"
114
+ loadingIndicator = { label }
115
+ // This icon can be anything
116
+ startIcon = { < ReplayIcon /> }
117
+ />
118
+ )
105
119
}
0 commit comments