-
Notifications
You must be signed in to change notification settings - Fork 944
feat(site): add workspace timings #15068
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 1 commit
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
5268b1e
Add base components for the chart
BrunoQuaresma 4d509f9
Improve spacing calc
BrunoQuaresma d48624b
Make bars clickable
BrunoQuaresma 62152ce
Refactor code to allow multiple views
BrunoQuaresma fd84ed9
Add basic view and breadcrumbs
BrunoQuaresma f7f09ff
Add resource filtering
BrunoQuaresma 2ffc75a
Find the right tick spacings
BrunoQuaresma a8372e1
Add colors to the bars
BrunoQuaresma f7c7488
Do not display Coder resource
BrunoQuaresma 0868185
Add legends
BrunoQuaresma 54d13c8
Handle empty search
BrunoQuaresma 714e37b
Improve coder resource filter and adjust bar hover
BrunoQuaresma a2dd126
Only scroll the chart
BrunoQuaresma 0b4747e
Add tooltip
BrunoQuaresma 49d3a72
Refactor code and improve legends
BrunoQuaresma 647635d
Adjust columns to fit the space
BrunoQuaresma 6c742aa
Customize scroll
BrunoQuaresma 9a8bb59
Add info tooltip
BrunoQuaresma 4139151
Fix fmt
BrunoQuaresma bcff9c6
Fix nblock gen
BrunoQuaresma 97b25d9
Fix key
BrunoQuaresma 6d5c344
Debug on chromatic
BrunoQuaresma c4bd74e
Another debug image
BrunoQuaresma 939ec9a
Try with useEffect
BrunoQuaresma 49c69e0
Fix labels alignment
BrunoQuaresma 61008a3
Increase border radius tooltip
BrunoQuaresma f969ef2
Add scroll mask
BrunoQuaresma f55033a
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma 00616d3
Include agent scripts
BrunoQuaresma 8cc7eef
Add failed icon
BrunoQuaresma 6b95860
Use use effect
BrunoQuaresma 5d08ff0
Apply @chifro feedback
BrunoQuaresma ea3676a
Add legends to script chart
BrunoQuaresma 1c74c96
Fix fmt
BrunoQuaresma 57df89b
Apply Christin suggestions
BrunoQuaresma 48a61d8
Move style constants to css variables
BrunoQuaresma 0726f39
Fix and rename bar blocks
BrunoQuaresma a4752c3
Remove unecessary cursor
BrunoQuaresma b481edd
Add tooltip for scripts
BrunoQuaresma 90b54b4
Fix fmt
BrunoQuaresma 266d82d
Add provisioning time collapse
BrunoQuaresma a4a1ba8
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma 4eb24f7
Add timings to the workspace UI
BrunoQuaresma 79f370c
Fix fmt
BrunoQuaresma a1ee002
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma 75ea1e5
Fix code verbiage
BrunoQuaresma edb885c
Fetch timings from build and not workspace
BrunoQuaresma f8bb22c
Don't could coder resources for blocks
BrunoQuaresma 1ff245c
Fix timings getting fetched before build getting done
BrunoQuaresma 541ccba
Fix comment spacing
BrunoQuaresma b3f0351
Revert scales on def
BrunoQuaresma 65ca087
Fix columnd calcl
BrunoQuaresma f288169
Fix fmt
BrunoQuaresma 08874a3
Add extra tests
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
Adjust columns to fit the space
- Loading branch information
commit 647635d7c0aa257eba4951e63005cb60358b0990
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import type { FC, HTMLProps } from "react"; | ||
import { | ||
useLayoutEffect, | ||
useRef, | ||
useState, | ||
type FC, | ||
type HTMLProps, | ||
} from "react"; | ||
import type { Interpolation, Theme } from "@emotion/react"; | ||
import { YAxisCaptionHeight } from "./YAxis"; | ||
import { formatTime } from "./utils"; | ||
import { XAxisLabelsHeight, XAxisRowsGap } from "./constants"; | ||
import { CSSVars, XAxisLabelsHeight, XAxisRowsGap } from "./constants"; | ||
|
||
export const XAxisWidth = 130; | ||
export const XAxisMinWidth = 130; | ||
export const XAxisSidePadding = 16; | ||
|
||
type XAxisProps = HTMLProps<HTMLDivElement> & { | ||
|
@@ -13,13 +19,28 @@ type XAxisProps = HTMLProps<HTMLDivElement> & { | |
}; | ||
|
||
export const XAxis: FC<XAxisProps> = ({ ticks, scale, ...htmlProps }) => { | ||
const rootRef = useRef<HTMLDivElement>(null); | ||
|
||
// The X axis should occupy all available space. If there is extra space, | ||
// increase the column width accordingly. Use a CSS variable to propagate the | ||
// value to the child components. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not important, but this comment has a bunch of space at the beginning 😄 |
||
useLayoutEffect(() => { | ||
const rootEl = rootRef.current; | ||
if (!rootEl) { | ||
return; | ||
} | ||
// We always add one extra column to the grid to ensure that the last column | ||
// is fully visible. | ||
const avgWidth = rootEl.clientWidth / (ticks.length + 1); | ||
avgWidth > XAxisMinWidth ? avgWidth : XAxisMinWidth; | ||
rootEl.style.setProperty(CSSVars.xAxisWidth, `${avgWidth}px`); | ||
}, [ticks]); | ||
|
||
return ( | ||
<div css={styles.root} {...htmlProps}> | ||
<div css={styles.root} {...htmlProps} ref={rootRef}> | ||
<XAxisLabels> | ||
{ticks.map((tick) => ( | ||
<XAxisLabel key={tick} width={XAxisWidth}> | ||
{formatTime(tick, scale)} | ||
</XAxisLabel> | ||
<XAxisLabel key={tick}>{formatTime(tick, scale)}</XAxisLabel> | ||
))} | ||
</XAxisLabels> | ||
{htmlProps.children} | ||
|
@@ -32,11 +53,7 @@ export const XAxisLabels: FC<HTMLProps<HTMLUListElement>> = (props) => { | |
return <ul css={styles.labels} {...props} />; | ||
}; | ||
|
||
type XAxisLabelProps = HTMLProps<HTMLLIElement> & { | ||
width: number; | ||
}; | ||
|
||
export const XAxisLabel: FC<XAxisLabelProps> = ({ width, ...htmlProps }) => { | ||
export const XAxisLabel: FC<HTMLProps<HTMLLIElement>> = (props) => { | ||
return ( | ||
<li | ||
css={[ | ||
|
@@ -47,13 +64,13 @@ export const XAxisLabel: FC<XAxisLabelProps> = ({ width, ...htmlProps }) => { | |
// 2. Shift the label to the left by half of the column width. | ||
// Note: This adjustment is not applied to the first element, | ||
// as the 0 label/value is not displayed in the chart. | ||
width: width * 2, | ||
width: `calc(var(${CSSVars.xAxisWidth}) * 2)`, | ||
"&:not(:first-child)": { | ||
marginLeft: -width, | ||
marginLeft: `calc(-1 * var(${CSSVars.xAxisWidth}))`, | ||
}, | ||
}, | ||
]} | ||
{...htmlProps} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
@@ -108,7 +125,10 @@ export const XGrid: FC<XGridProps> = ({ columns, ...htmlProps }) => { | |
return ( | ||
<div css={styles.grid} role="presentation" {...htmlProps}> | ||
{[...Array(columns).keys()].map((key) => ( | ||
<div key={key} css={[styles.column, { width: XAxisWidth }]} /> | ||
<div | ||
key={key} | ||
css={[styles.column, { width: `var(${CSSVars.xAxisWidth})` }]} | ||
/> | ||
))} | ||
</div> | ||
); | ||
|
@@ -138,7 +158,7 @@ const styles = { | |
alignItems: "center", | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
height: XAxisLabelsHeight, | ||
padding: `0px ${XAxisSidePadding}px`, | ||
padding: 0, | ||
minWidth: "100%", | ||
flexShrink: 0, | ||
position: "sticky", | ||
|
3 changes: 3 additions & 0 deletions
3
site/src/modules/workspaces/WorkspaceTiming/Chart/constants.ts
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Constants that are used across the Chart components | ||
export const XAxisLabelsHeight = 40; | ||
export const XAxisRowsGap = 20; | ||
export const CSSVars = { | ||
xAxisWidth: "--x-axis-width", | ||
}; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this component is related, but I found that if I:
Then the timings run off edge of the component and I am not able to see them. It seems to fix itself if I navigate away and come back again. Weirdly, the same issue does not appear to happen if I start a stopped workspace then navigate away and back again, it only happens when I stop my workspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing is if I resize my screen then the timings and legend get cut off, idk if it is worth adding resizing logic but maybe we can just throw in a horizontal scrollbar.