Skip to content

Commit eb4f88c

Browse files
committed
fix: commit current style update progress
1 parent 5a449b4 commit eb4f88c

File tree

1 file changed

+61
-17
lines changed

1 file changed

+61
-17
lines changed

site/src/pages/WorkspacePage/WorkspaceActions/DownloadLogsDialog.tsx

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { useTheme, type Interpolation, type Theme } from "@emotion/react";
2-
import ErrorIcon from "@mui/icons-material/ErrorOutline";
32
import Skeleton from "@mui/material/Skeleton";
43
import { saveAs } from "file-saver";
54
import JSZip from "jszip";
65
import { type FC, useMemo, useState, useRef, useEffect } from "react";
76
import { useQueries, useQuery } from "react-query";
87
import { agentLogs, buildLogs } from "api/queries/workspaces";
98
import type { Workspace, WorkspaceAgent } from "api/typesGenerated";
10-
import { ErrorAlert } from "components/Alert/ErrorAlert";
9+
import { Alert } from "components/Alert/Alert";
1110
import {
1211
ConfirmDialog,
1312
type ConfirmDialogProps,
@@ -109,12 +108,7 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({
109108
hideCancel={false}
110109
title="Download logs"
111110
confirmLoading={isDownloading}
112-
confirmText={
113-
<>
114-
Download
115-
{!isWorkspaceHealthy && <> {isLoadingFiles ? "partial" : "all"}</>}
116-
</>
117-
}
111+
confirmText="Download"
118112
disabled={
119113
isDownloading ||
120114
// If a workspace isn't healthy, let the user download as many logs as
@@ -152,7 +146,9 @@ export const DownloadLogsDialog: FC<DownloadLogsDialogProps> = ({
152146
</p>
153147

154148
{!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>
156152
)}
157153

158154
<ul css={styles.list}>
@@ -179,6 +175,7 @@ type DownloadingItemProps = Readonly<{
179175
const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
180176
const theme = useTheme();
181177
const [isWaiting, setIsWaiting] = useState(true);
178+
182179
useEffect(() => {
183180
if (giveUpTimeMs === undefined || file.blob !== undefined) {
184181
setIsWaiting(true);
@@ -193,6 +190,8 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
193190
return () => window.clearTimeout(timeoutId);
194191
}, [giveUpTimeMs, file]);
195192

193+
const { baseName, fileExtension } = extractFileNameInfo(file.name);
194+
196195
return (
197196
<li css={styles.listItem}>
198197
<span
@@ -201,7 +200,12 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
201200
!isWaiting && { color: theme.palette.text.disabled },
202201
]}
203202
>
204-
{file.name}
203+
<span css={styles.listItemPrimaryBaseName}>
204+
{/* {baseName} */}
205+
WWWWWWWWWWWWWWWWWWWWWWW
206+
</span>
207+
208+
<span css={styles.listItemPrimaryFileExtension}>.{fileExtension}</span>
205209
</span>
206210

207211
<span css={styles.listItemSecondary}>
@@ -210,13 +214,7 @@ const DownloadingItem: FC<DownloadingItemProps> = ({ file, giveUpTimeMs }) => {
210214
) : isWaiting ? (
211215
<Skeleton variant="text" width={48} height={12} />
212216
) : (
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>
220218
)}
221219
</span>
222220
</li>
@@ -239,6 +237,33 @@ function humanBlobSize(size: number) {
239237
return `${size.toFixed(2)} ${finalUnit}`;
240238
}
241239

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+
242267
const styles = {
243268
list: {
244269
listStyle: "none",
@@ -248,17 +273,36 @@ const styles = {
248273
flexDirection: "column",
249274
gap: 8,
250275
},
276+
251277
listItem: {
278+
width: "100%",
252279
display: "flex",
253280
justifyContent: "space-between",
254281
alignItems: "center",
282+
columnGap: "32px",
255283
},
284+
256285
listItemPrimary: (theme) => ({
257286
fontWeight: 500,
258287
color: theme.palette.text.primary,
288+
display: "flex",
289+
flexFlow: "no nowrap",
259290
}),
291+
292+
listItemPrimaryBaseName: {
293+
minWidth: 0,
294+
flexShrink: 1,
295+
overflow: "hidden",
296+
textOverflow: "ellipsis",
297+
},
298+
299+
listItemPrimaryFileExtension: {
300+
flexShrink: 0,
301+
},
302+
260303
listItemSecondary: {
261304
fontSize: 14,
305+
whiteSpace: "nowrap",
262306
},
263307

264308
notAvailableText: (theme) => ({

0 commit comments

Comments
 (0)