Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 54 commits intomainfrombq/workspace-timings-ui
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
54 commits
Select commitHold shift + click to select a range
5268b1e
Add base components for the chart
BrunoQuaresmaSep 19, 2024
4d509f9
Improve spacing calc
BrunoQuaresmaSep 19, 2024
d48624b
Make bars clickable
BrunoQuaresmaSep 19, 2024
62152ce
Refactor code to allow multiple views
BrunoQuaresmaSep 20, 2024
fd84ed9
Add basic view and breadcrumbs
BrunoQuaresmaSep 23, 2024
f7f09ff
Add resource filtering
BrunoQuaresmaSep 23, 2024
2ffc75a
Find the right tick spacings
BrunoQuaresmaSep 23, 2024
a8372e1
Add colors to the bars
BrunoQuaresmaSep 23, 2024
f7c7488
Do not display Coder resource
BrunoQuaresmaSep 23, 2024
0868185
Add legends
BrunoQuaresmaSep 23, 2024
54d13c8
Handle empty search
BrunoQuaresmaSep 23, 2024
714e37b
Improve coder resource filter and adjust bar hover
BrunoQuaresmaSep 24, 2024
a2dd126
Only scroll the chart
BrunoQuaresmaSep 24, 2024
0b4747e
Add tooltip
BrunoQuaresmaSep 24, 2024
49d3a72
Refactor code and improve legends
BrunoQuaresmaSep 25, 2024
647635d
Adjust columns to fit the space
BrunoQuaresmaSep 25, 2024
6c742aa
Customize scroll
BrunoQuaresmaSep 25, 2024
9a8bb59
Add info tooltip
BrunoQuaresmaSep 25, 2024
4139151
Fix fmt
BrunoQuaresmaSep 25, 2024
bcff9c6
Fix nblock gen
BrunoQuaresmaSep 25, 2024
97b25d9
Fix key
BrunoQuaresmaSep 25, 2024
6d5c344
Debug on chromatic
BrunoQuaresmaSep 25, 2024
c4bd74e
Another debug image
BrunoQuaresmaSep 25, 2024
939ec9a
Try with useEffect
BrunoQuaresmaSep 25, 2024
49c69e0
Fix labels alignment
BrunoQuaresmaSep 26, 2024
61008a3
Increase border radius tooltip
BrunoQuaresmaSep 26, 2024
f969ef2
Add scroll mask
BrunoQuaresmaSep 26, 2024
f55033a
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresmaOct 14, 2024
00616d3
Include agent scripts
BrunoQuaresmaOct 14, 2024
8cc7eef
Add failed icon
BrunoQuaresmaOct 14, 2024
6b95860
Use use effect
BrunoQuaresmaOct 14, 2024
5d08ff0
Apply @chifro feedback
BrunoQuaresmaOct 17, 2024
ea3676a
Add legends to script chart
BrunoQuaresmaOct 17, 2024
1c74c96
Fix fmt
BrunoQuaresmaOct 17, 2024
57df89b
Apply Christin suggestions
BrunoQuaresmaOct 18, 2024
48a61d8
Move style constants to css variables
BrunoQuaresmaOct 18, 2024
0726f39
Fix and rename bar blocks
BrunoQuaresmaOct 18, 2024
a4752c3
Remove unecessary cursor
BrunoQuaresmaOct 18, 2024
b481edd
Add tooltip for scripts
BrunoQuaresmaOct 18, 2024
90b54b4
Fix fmt
BrunoQuaresmaOct 18, 2024
266d82d
Add provisioning time collapse
BrunoQuaresmaOct 18, 2024
a4a1ba8
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresmaOct 18, 2024
4eb24f7
Add timings to the workspace UI
BrunoQuaresmaOct 18, 2024
79f370c
Fix fmt
BrunoQuaresmaOct 18, 2024
a1ee002
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresmaOct 21, 2024
75ea1e5
Fix code verbiage
BrunoQuaresmaOct 21, 2024
edb885c
Fetch timings from build and not workspace
BrunoQuaresmaOct 21, 2024
f8bb22c
Don't could coder resources for blocks
BrunoQuaresmaOct 21, 2024
1ff245c
Fix timings getting fetched before build getting done
BrunoQuaresmaOct 21, 2024
541ccba
Fix comment spacing
BrunoQuaresmaOct 21, 2024
b3f0351
Revert scales on def
BrunoQuaresmaOct 21, 2024
65ca087
Fix columnd calcl
BrunoQuaresmaOct 21, 2024
f288169
Fix fmt
BrunoQuaresmaOct 22, 2024
08874a3
Add extra tests
BrunoQuaresmaOct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Add tooltip
  • Loading branch information
@BrunoQuaresma
BrunoQuaresma committedSep 24, 2024
commit0b4747eb86796c946e8575e2da650abd1fa3bfcb
44 changes: 38 additions & 6 deletionssite/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
import type { Interpolation, Theme } from "@emotion/react";
import { css } from "@emotion/css";
import { useTheme, type Interpolation, type Theme } from "@emotion/react";
import Tooltip from "@mui/material/Tooltip";
import { forwardRef, type HTMLProps, type ReactNode } from "react";

export type BarColor = {
Expand All@@ -22,21 +24,30 @@ type BarProps = Omit<HTMLProps<HTMLDivElement>, "size" | "color"> & {
* The X position of the bar component.
*/
x?: number;
/**
* The tooltip content for the bar.
*/
tooltip?: ReactNode;
};

export const Bar = forwardRef<HTMLDivElement, BarProps>(
({ color, width, afterLabel, children, x, ...htmlProps }, ref) => {
return (
({ color, width, afterLabel, children, x, tooltip, ...htmlProps }, ref) => {
const theme = useTheme();
const row = (
<div
ref={ref}
css={[styles.root, { transform: `translateX(${x}px)` }]}
css={[styles.row, { transform: `translateX(${x}px)` }]}
{...htmlProps}
>
<button
type="button"
css={[
styles.bar,
{ width, backgroundColor: color?.fill, borderColor: color?.border },
{
width,
backgroundColor: color?.fill,
borderColor: color?.border,
},
]}
disabled={htmlProps.disabled}
aria-labelledby={htmlProps["aria-labelledby"]}
Expand All@@ -46,16 +57,37 @@ export const Bar = forwardRef<HTMLDivElement, BarProps>(
{afterLabel}
</div>
);

if (tooltip) {
return (
<Tooltip
placement="top-start"
classes={{
tooltip: css({
backgroundColor: theme.palette.background.default,
border: `1px solid ${theme.palette.divider}`,
width: 220,
}),
}}
title={tooltip}
>
{row}
</Tooltip>
);
}

return row;
},
);

const styles = {
root: {
row: {
// Stack children horizontally for adjacent labels
display: "flex",
alignItems: "center",
width: "fit-content",
gap: 8,
cursor: "pointer",
},
bar: (theme) => ({
border: "1px solid",
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import type { Interpolation, Theme } from "@emotion/react";
import { XGrid } from "./XGrid";
import { XAxis } from "./XAxis";
import type { FC } from "react";
import type { FC, ReactNode } from "react";
import { TimingBlocks } from "./TimingBlocks";
import {
YAxis,
Expand DownExpand Up@@ -40,6 +40,7 @@ export type Timing = Duration & {
*/
visible?: boolean;
color?: BarColor;
tooltip?: ReactNode;
};

// Extracts the 'startedAt' and 'endedAt' date fields from the main Timing type.
Expand DownExpand Up@@ -128,6 +129,7 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
const size = calcSize(durationTime(t));
return (
<Bar
tooltip={t.tooltip}
color={t.color}
key={t.label}
x={calcSize(offset)}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,8 @@ import type { Interpolation, Theme } from "@emotion/react";
import ChevronRight from "@mui/icons-material/ChevronRight";
import { YAxisSidePadding, YAxisWidth } from "./Chart/YAxis";
import { SearchField } from "components/SearchField/SearchField";
import { Link } from "react-router-dom";
import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined";

// TODO: Export provisioning stages from the BE to the generated types.
const provisioningStages = ["init", "plan", "graph", "apply"];
Expand DownExpand Up@@ -194,6 +196,7 @@ export const selectChartData = (
visible: !isCoderResource,
// Resource timings don't have inner timings
childrenCount: 0,
tooltip: <ProvisionerTooltip timing={t} />,
...extractDuration(t),
} as Timing;
});
Expand All@@ -208,6 +211,19 @@ export const selectChartData = (
}
};

const ProvisionerTooltip: FC<{ timing: ProvisionerTiming }> = ({ timing }) => {
return (
<div css={styles.tooltip}>
<span>{timing.source}</span>
<span css={styles.tooltipResource}>{timing.resource}</span>
<Link to="" css={styles.tooltipLink}>
<OpenInNewOutlined />
view template
</Link>
</div>
);
};

const styles = {
panelBody: {
display: "flex",
Expand DownExpand Up@@ -305,4 +321,38 @@ const styles = {
border: `1px solid ${theme.palette.divider}`,
backgroundColor: theme.palette.background.default,
}),
tooltip: (theme) => ({
display: "flex",
flexDirection: "column",
fontWeight: 500,
fontSize: 12,
color: theme.palette.text.secondary,
}),
tooltipResource: (theme) => ({
color: theme.palette.text.primary,
fontWeight: 600,
marginTop: 4,
display: "block",
maxWidth: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
}),
tooltipLink: (theme) => ({
color: "inherit",
textDecoration: "none",
display: "flex",
alignItems: "center",
gap: 4,
marginTop: 8,

"&:hover": {
color: theme.palette.text.primary,
},

"& svg": {
width: 12,
height: 12,
},
}),
} satisfies Record<string, Interpolation<Theme>>;

[8]ページ先頭

©2009-2025 Movatter.jp