@@ -2,84 +2,15 @@ import PersonOutlinedIcon from "@mui/icons-material/PersonOutlined";
2
2
import ScheduleIcon from "@mui/icons-material/Schedule" ;
3
3
import { visuallyHidden } from "@mui/utils" ;
4
4
import dayjs from "dayjs" ;
5
- import "dayjs/plugin/relativeTime" ;
6
- import { type Interpolation , type Theme } from "@emotion/react" ;
5
+ import relativeTime from "dayjs/plugin/relativeTime" ;
6
+ import { useTheme , type Interpolation , type Theme } from "@emotion/react" ;
7
7
import { type FC , type ReactNode , useState } from "react" ;
8
- import { useMutation } from "react-query" ;
9
- import {
10
- deleteWorkspace ,
11
- startWorkspace ,
12
- stopWorkspace ,
13
- updateWorkspace ,
14
- } from "api/api" ;
15
8
import type { Workspace } from "api/typesGenerated" ;
16
9
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog" ;
17
- import { displayError } from "components/GlobalSnackbar/utils" ;
18
- import { getResourceIconPath } from "utils/workspace" ;
19
10
import { Stack } from "components/Stack/Stack" ;
11
+ import { getResourceIconPath } from "utils/workspace" ;
20
12
21
- interface UseBatchActionsProps {
22
- onSuccess : ( ) => Promise < void > ;
23
- }
24
-
25
- export function useBatchActions ( options : UseBatchActionsProps ) {
26
- const { onSuccess } = options ;
27
-
28
- const startAllMutation = useMutation ( {
29
- mutationFn : async ( workspaces : Workspace [ ] ) => {
30
- return Promise . all (
31
- workspaces . map ( ( w ) =>
32
- startWorkspace ( w . id , w . latest_build . template_version_id ) ,
33
- ) ,
34
- ) ;
35
- } ,
36
- onSuccess,
37
- onError : ( ) => {
38
- displayError ( "Failed to start workspaces" ) ;
39
- } ,
40
- } ) ;
41
-
42
- const stopAllMutation = useMutation ( {
43
- mutationFn : async ( workspaces : Workspace [ ] ) => {
44
- return Promise . all ( workspaces . map ( ( w ) => stopWorkspace ( w . id ) ) ) ;
45
- } ,
46
- onSuccess,
47
- onError : ( ) => {
48
- displayError ( "Failed to stop workspaces" ) ;
49
- } ,
50
- } ) ;
51
-
52
- const deleteAllMutation = useMutation ( {
53
- mutationFn : async ( workspaces : Workspace [ ] ) => {
54
- return Promise . all ( workspaces . map ( ( w ) => deleteWorkspace ( w . id ) ) ) ;
55
- } ,
56
- onSuccess,
57
- onError : ( ) => {
58
- displayError ( "Failed to delete some workspaces" ) ;
59
- } ,
60
- } ) ;
61
-
62
- const updateAllMutation = useMutation ( {
63
- mutationFn : async ( workspaces : Workspace [ ] ) => {
64
- return Promise . all ( workspaces . map ( ( w ) => updateWorkspace ( w ) ) ) ;
65
- } ,
66
- onSuccess,
67
- onError : ( ) => {
68
- displayError ( "Failed to update some workspaces" ) ;
69
- } ,
70
- } ) ;
71
-
72
- return {
73
- startAll : startAllMutation . mutateAsync ,
74
- stopAll : stopAllMutation . mutateAsync ,
75
- deleteAll : deleteAllMutation . mutateAsync ,
76
- updateAll : updateAllMutation . mutateAsync ,
77
- isLoading :
78
- startAllMutation . isLoading ||
79
- stopAllMutation . isLoading ||
80
- deleteAllMutation . isLoading ,
81
- } ;
82
- }
13
+ dayjs . extend ( relativeTime ) ;
83
14
84
15
type BatchDeleteConfirmationProps = {
85
16
checkedWorkspaces : Workspace [ ] ;
@@ -198,6 +129,8 @@ const Consequences: FC = () => {
198
129
} ;
199
130
200
131
const Workspaces : FC < StageProps > = ( { workspaces } ) => {
132
+ const theme = useTheme ( ) ;
133
+
201
134
const mostRecent = workspaces . reduce (
202
135
( latestSoFar , against ) => {
203
136
if ( ! latestSoFar ) {
@@ -225,7 +158,9 @@ const Workspaces: FC<StageProps> = ({ workspaces }) => {
225
158
alignItems = "center"
226
159
justifyContent = "space-between"
227
160
>
228
- < span css = { { fontWeight : 500 , color : "#fff" } } >
161
+ < span
162
+ css = { { fontWeight : 500 , color : theme . experimental . l1 . text } }
163
+ >
229
164
{ workspace . name }
230
165
</ span >
231
166
< Stack css = { { gap : 0 , fontSize : 14 , width : 128 } } >
@@ -250,7 +185,12 @@ const Workspaces: FC<StageProps> = ({ workspaces }) => {
250
185
</ li >
251
186
) ) }
252
187
</ ul >
253
- < Stack justifyContent = "center" direction = "row" css = { { fontSize : 14 } } >
188
+ < Stack
189
+ justifyContent = "center"
190
+ direction = "row"
191
+ wrap = "wrap"
192
+ css = { { gap : "6px 20px" , fontSize : 14 } }
193
+ >
254
194
< Stack direction = "row" alignItems = "center" spacing = { 1 } >
255
195
< PersonIcon />
256
196
< span > { ownersCount } </ span >
0 commit comments