1
1
import { useTheme , type Interpolation , type Theme } from "@emotion/react" ;
2
- import ErrorIcon from "@mui/icons-material/ErrorOutline" ;
3
2
import Skeleton from "@mui/material/Skeleton" ;
4
3
import { saveAs } from "file-saver" ;
5
4
import JSZip from "jszip" ;
6
5
import { type FC , useMemo , useState , useRef , useEffect } from "react" ;
7
6
import { useQueries , useQuery } from "react-query" ;
8
7
import { agentLogs , buildLogs } from "api/queries/workspaces" ;
9
8
import type { Workspace , WorkspaceAgent } from "api/typesGenerated" ;
10
- import { ErrorAlert } from "components/Alert/ErrorAlert " ;
9
+ import { Alert } from "components/Alert/Alert " ;
11
10
import {
12
11
ConfirmDialog ,
13
12
type ConfirmDialogProps ,
@@ -109,12 +108,7 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({
109
108
hideCancel = { false }
110
109
title = "Download logs"
111
110
confirmLoading = { isDownloading }
112
- confirmText = {
113
- < >
114
- Download
115
- { ! isWorkspaceHealthy && < > { isLoadingFiles ? "partial" : "all" } </ > }
116
- </ >
117
- }
111
+ confirmText = "Download"
118
112
disabled = {
119
113
isDownloading ||
120
114
// If a workspace isn't healthy, let the user download as many logs as
@@ -152,7 +146,9 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({
152
146
</ p >
153
147
154
148
{ ! isWorkspaceHealthy && isLoadingFiles && (
155
- < ErrorAlert error = "Your workspace is not healthy. Some logs may be unavailable." />
149
+ < Alert severity = "warning" >
150
+ Your workspace is unhealthy. Some logs may be unavailable.
151
+ </ Alert >
156
152
) }
157
153
158
154
< ul css = { styles . list } >
@@ -179,6 +175,7 @@ type DownloadingItemProps = Readonly<{
179
175
const DownloadingItem : FC < DownloadingItemProps > = ( { file, giveUpTimeMs } ) => {
180
176
const theme = useTheme ( ) ;
181
177
const [ isWaiting , setIsWaiting ] = useState ( true ) ;
178
+
182
179
useEffect ( ( ) => {
183
180
if ( giveUpTimeMs === undefined || file . blob !== undefined ) {
184
181
setIsWaiting ( true ) ;
@@ -193,6 +190,8 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
193
190
return ( ) => window . clearTimeout ( timeoutId ) ;
194
191
} , [ giveUpTimeMs , file ] ) ;
195
192
193
+ const { baseName, fileExtension } = extractFileNameInfo ( file . name ) ;
194
+
196
195
return (
197
196
< li css = { styles . listItem } >
198
197
< span
@@ -201,7 +200,12 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
201
200
! isWaiting && { color : theme . palette . text . disabled } ,
202
201
] }
203
202
>
204
- { file . name }
203
+ < span css = { styles . listItemPrimaryBaseName } >
204
+ { /* {baseName} */ }
205
+ WWWWWWWWWWWWWWWWWWWWWWW
206
+ </ span >
207
+
208
+ < span css = { styles . listItemPrimaryFileExtension } > .{ fileExtension } </ span >
205
209
</ span >
206
210
207
211
< span css = { styles . listItemSecondary } >
@@ -210,13 +214,7 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
210
214
) : isWaiting ? (
211
215
< Skeleton variant = "text" width = { 48 } height = { 12 } />
212
216
) : (
213
- < div css = { styles . notAvailableText } >
214
- < span aria-hidden >
215
- < ErrorIcon fontSize = "inherit" />
216
- </ span >
217
-
218
- < p > N/A</ p >
219
- </ div >
217
+ < p css = { styles . notAvailableText } > Not available</ p >
220
218
) }
221
219
</ span >
222
220
</ li >
@@ -239,6 +237,33 @@ function humanBlobSize(size: number) {
239
237
return `${ size . toFixed ( 2 ) } ${ finalUnit } ` ;
240
238
}
241
239
240
+ type FileNameInfo = Readonly < {
241
+ baseName : string ;
242
+ fileExtension : string | undefined ;
243
+ } > ;
244
+
245
+ function extractFileNameInfo ( filename : string ) : FileNameInfo {
246
+ if ( filename . length === 0 ) {
247
+ return {
248
+ baseName : "" ,
249
+ fileExtension : undefined ,
250
+ } ;
251
+ }
252
+
253
+ const periodIndex = filename . lastIndexOf ( "." ) ;
254
+ if ( periodIndex === - 1 ) {
255
+ return {
256
+ baseName : filename ,
257
+ fileExtension : undefined ,
258
+ } ;
259
+ }
260
+
261
+ return {
262
+ baseName : filename . slice ( 0 , periodIndex ) ,
263
+ fileExtension : filename . slice ( periodIndex + 1 ) ,
264
+ } ;
265
+ }
266
+
242
267
const styles = {
243
268
list : {
244
269
listStyle : "none" ,
@@ -248,17 +273,36 @@ const styles = {
248
273
flexDirection : "column" ,
249
274
gap : 8 ,
250
275
} ,
276
+
251
277
listItem : {
278
+ width : "100%" ,
252
279
display : "flex" ,
253
280
justifyContent : "space-between" ,
254
281
alignItems : "center" ,
282
+ columnGap : "32px" ,
255
283
} ,
284
+
256
285
listItemPrimary : ( theme ) => ( {
257
286
fontWeight : 500 ,
258
287
color : theme . palette . text . primary ,
288
+ display : "flex" ,
289
+ flexFlow : "no nowrap" ,
259
290
} ) ,
291
+
292
+ listItemPrimaryBaseName : {
293
+ minWidth : 0 ,
294
+ flexShrink : 1 ,
295
+ overflow : "hidden" ,
296
+ textOverflow : "ellipsis" ,
297
+ } ,
298
+
299
+ listItemPrimaryFileExtension : {
300
+ flexShrink : 0 ,
301
+ } ,
302
+
260
303
listItemSecondary : {
261
304
fontSize : 14 ,
305
+ whiteSpace : "nowrap" ,
262
306
} ,
263
307
264
308
notAvailableText : ( theme ) => ( {
0 commit comments