-
Notifications
You must be signed in to change notification settings - Fork 943
feat: Add workspace build logs page #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5af1e02
display logs
BrunoQuaresma 5d40cf5
Merge branch 'main' of github.com:coder/coder into bq/add-logs-page
BrunoQuaresma 131c04a
Refactor service to be workspace build service
BrunoQuaresma a09c9d8
Add workspace build stats
BrunoQuaresma 7bc03d1
Add handlers
BrunoQuaresma 5536565
Add test to check if the workspace build page is rendered correctly
BrunoQuaresma 1a93770
Add storybook
BrunoQuaresma 6f0ed72
Update site/src/components/Logs/Logs.stories.tsx
BrunoQuaresma 1903f30
Update site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx
BrunoQuaresma 73bc41d
Update site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.tsx
BrunoQuaresma d73fcd2
Update site/src/util/workspace.ts
BrunoQuaresma f3136c3
Update b to build
BrunoQuaresma fe8496f
Remove custom type
BrunoQuaresma 720e9a5
Merge branch 'bq/add-logs-page' of github.com:coder/coder into bq/add…
BrunoQuaresma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Box from "@material-ui/core/Box" | ||
import CircularProgress from "@material-ui/core/CircularProgress" | ||
import React from "react" | ||
|
||
export const Loader: React.FC<{ size?: number }> = ({ size = 26 }) => { | ||
return ( | ||
<Box p={4} width="100%" display="flex" alignItems="center" justifyContent="center"> | ||
<CircularProgress size={size} /> | ||
</Box> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ComponentMeta, Story } from "@storybook/react" | ||
import React from "react" | ||
import { MockWorkspaceBuildLogs } from "../../testHelpers/entities" | ||
import { Logs, LogsProps } from "./Logs" | ||
|
||
export default { | ||
title: "components/Logs", | ||
component: Logs, | ||
} as ComponentMeta<typeof Logs> | ||
|
||
const Template: Story<LogsProps> = (args) => <Logs {...args} /> | ||
|
||
const lines = MockWorkspaceBuildLogs.map((l) => ({ | ||
time: l.created_at, | ||
output: l.output, | ||
})) | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export const Example = Template.bind({}) | ||
Example.args = { | ||
lines, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import dayjs from "dayjs" | ||
import React from "react" | ||
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants" | ||
import { combineClasses } from "../../util/combineClasses" | ||
|
||
interface Line { | ||
time: string | ||
output: string | ||
} | ||
|
||
export interface LogsProps { | ||
lines: Line[] | ||
className?: string | ||
} | ||
|
||
export const Logs: React.FC<LogsProps> = ({ lines, className = "" }) => { | ||
const styles = useStyles() | ||
|
||
return ( | ||
<div className={combineClasses([className, styles.root])}> | ||
{lines.map((line, idx) => ( | ||
<div className={styles.line} key={idx}> | ||
<div className={styles.time}>{dayjs(line.time).format(`HH:mm:ss.SSS`)}</div> | ||
<div>{line.output}</div> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
minHeight: 156, | ||
background: theme.palette.background.default, | ||
color: theme.palette.text.primary, | ||
fontFamily: MONOSPACE_FONT_FAMILY, | ||
fontSize: 13, | ||
wordBreak: "break-all", | ||
padding: theme.spacing(2), | ||
borderRadius: theme.shape.borderRadius, | ||
overflowX: "auto", | ||
}, | ||
line: { | ||
display: "flex", | ||
alignItems: "baseline", | ||
}, | ||
time: { | ||
width: theme.spacing(12.5), | ||
marginRight: theme.spacing(3), | ||
flexShrink: 0, | ||
}, | ||
})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
site/src/components/WorkspaceBuildLogs/WorkspaceBuildLogs.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ComponentMeta, Story } from "@storybook/react" | ||
import React from "react" | ||
import { MockWorkspaceBuildLogs } from "../../testHelpers/entities" | ||
import { WorkspaceBuildLogs, WorkspaceBuildLogsProps } from "./WorkspaceBuildLogs" | ||
|
||
export default { | ||
title: "components/WorkspaceBuildLogs", | ||
component: WorkspaceBuildLogs, | ||
} as ComponentMeta<typeof WorkspaceBuildLogs> | ||
|
||
const Template: Story<WorkspaceBuildLogsProps> = (args) => <WorkspaceBuildLogs {...args} /> | ||
|
||
export const Example = Template.bind({}) | ||
Example.args = { | ||
logs: MockWorkspaceBuildLogs, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.