Skip to content

Commit a823ce7

Browse files
refactor(site): add sticky option to the build logs (#8565)
1 parent 0bf1b01 commit a823ce7

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ProvisionerJobLog } from "../../api/typesGenerated"
55
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
66
import { Logs } from "../Logs/Logs"
77
import Box from "@mui/material/Box"
8+
import { combineClasses } from "utils/combineClasses"
89

910
const Language = {
1011
seconds: "seconds",
@@ -40,11 +41,13 @@ const getStageDurationInSeconds = (logs: ProvisionerJobLog[]) => {
4041

4142
export type WorkspaceBuildLogsProps = {
4243
logs: ProvisionerJobLog[]
44+
sticky?: boolean
4345
hideTimestamps?: boolean
4446
} & ComponentProps<typeof Box>
4547

4648
export const WorkspaceBuildLogs: FC<WorkspaceBuildLogsProps> = ({
4749
hideTimestamps,
50+
sticky,
4851
logs,
4952
...boxProps
5053
}) => {
@@ -75,7 +78,12 @@ export const WorkspaceBuildLogs: FC<WorkspaceBuildLogsProps> = ({
7578

7679
return (
7780
<Fragment key={stage}>
78-
<div className={styles.header}>
81+
<div
82+
className={combineClasses([
83+
styles.header,
84+
sticky ? styles.sticky : "",
85+
])}
86+
>
7987
<div>{stage}</div>
8088
{shouldDisplayDuration && (
8189
<div className={styles.duration}>
@@ -100,8 +108,6 @@ const useStyles = makeStyles((theme) => ({
100108
alignItems: "center",
101109
fontFamily: "Inter",
102110
borderBottom: `1px solid ${theme.palette.divider}`,
103-
position: "sticky",
104-
top: 0,
105111
background: theme.palette.background.default,
106112

107113
"&:last-child": {
@@ -114,6 +120,11 @@ const useStyles = makeStyles((theme) => ({
114120
},
115121
},
116122

123+
sticky: {
124+
position: "sticky",
125+
top: 0,
126+
},
127+
117128
duration: {
118129
marginLeft: "auto",
119130
color: theme.palette.text.secondary,

site/src/pages/WorkspacePage/WorkspaceBuildLogsSection.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ export const WorkspaceBuildLogsSection = ({
4747
})}
4848
>
4949
{logs ? (
50-
<WorkspaceBuildLogs logs={logs} sx={{ border: 0, borderRadius: 0 }} />
50+
<WorkspaceBuildLogs
51+
sticky
52+
logs={logs}
53+
sx={{ border: 0, borderRadius: 0 }}
54+
/>
5155
) : (
5256
<Box
5357
sx={{

0 commit comments

Comments
 (0)