8000 feat(site): add workspace timings by BrunoQuaresma · Pull Request #15068 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

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 54 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
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 Sep 19, 2024
4d509f9
Improve spacing calc
BrunoQuaresma Sep 19, 2024
d48624b
Make bars clickable
BrunoQuaresma Sep 19, 2024
62152ce
Refactor code to allow multiple views
BrunoQuaresma Sep 20, 2024
fd84ed9
Add basic view and breadcrumbs
BrunoQuaresma Sep 23, 2024
f7f09ff
Add resource filtering
BrunoQuaresma Sep 23, 2024
2ffc75a
Find the right tick spacings
BrunoQuaresma Sep 23, 2024
a8372e1
Add colors to the bars
BrunoQuaresma Sep 23, 2024
f7c7488
Do not display Coder resource
BrunoQuaresma Sep 23, 2024
0868185
Add legends
BrunoQuaresma Sep 23, 2024
54d13c8
Handle empty search
BrunoQuaresma Sep 23, 2024
714e37b
Improve coder resource filter and adjust bar hover
BrunoQuaresma Sep 24, 2024
a2dd126
Only scroll the chart
BrunoQuaresma Sep 24, 2024
0b4747e
Add tooltip
BrunoQuaresma Sep 24, 2024
49d3a72
Refactor code and improve legends
BrunoQuaresma Sep 25, 2024
647635d
Adjust columns to fit the space
BrunoQuaresma Sep 25, 2024
6c742aa
Customize scroll
BrunoQuaresma Sep 25, 2024
9a8bb59
Add info tooltip
BrunoQuaresma Sep 25, 2024
4139151
Fix fmt
BrunoQuaresma Sep 25, 2024
bcff9c6
Fix nblock gen
BrunoQuaresma Sep 25, 2024
97b25d9
Fix key
BrunoQuaresma Sep 25, 2024
6d5c344
Debug on chromatic
BrunoQuaresma Sep 25, 2024
c4bd74e
Another debug image
BrunoQuaresma Sep 25, 2024
939ec9a
Try with useEffect
BrunoQuaresma Sep 25, 2024
49c69e0
Fix labels alignment
BrunoQuaresma Sep 26, 2024
61008a3
Increase border radius tooltip
BrunoQuaresma Sep 26, 2024
f969ef2
Add scroll mask
BrunoQuaresma Sep 26, 2024
f55033a
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma Oct 14, 2024
00616d3
Include agent scripts
BrunoQuaresma Oct 14, 2024
8cc7eef
Add failed icon
BrunoQuaresma Oct 14, 2024
6b95860
Use use effect
BrunoQuaresma Oct 14, 2024
5d08ff0
Apply @chifro feedback
BrunoQuaresma Oct 17, 2024
ea3676a
Add legends to script chart
BrunoQuaresma Oct 17, 2024
1c74c96
Fix fmt
BrunoQuaresma Oct 17, 2024
57df89b
Apply Christin suggestions
BrunoQuaresma Oct 18, 2024
48a61d8
Move style constants to css variables
BrunoQuaresma Oct 18, 2024
0726f39
Fix and rename bar blocks
BrunoQuaresma Oct 18, 2024
a4752c3
Remove unecessary cursor
BrunoQuaresma Oct 18, 2024
b481edd
Add tooltip for scripts
BrunoQuaresma Oct 18, 2024
90b54b4
Fix fmt
BrunoQuaresma Oct 18, 2024
266d82d
Add provisioning time collapse
BrunoQuaresma Oct 18, 2024
a4a1ba8
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma Oct 18, 2024
4eb24f7
Add timings to the workspace UI
BrunoQuaresma Oct 18, 2024
79f370c
Fix fmt
BrunoQuaresma Oct 18, 2024
a1ee002
Merge branch 'main' of https://github.com/coder/coder into bq/workspa…
BrunoQuaresma Oct 21, 2024
75ea1e5
Fix code verbiage
BrunoQuaresma Oct 21, 2024
edb885c
Fetch timings from build and not workspace
BrunoQuaresma Oct 21, 2024
f8bb22c
Don't could coder resources for blocks
BrunoQuaresma Oct 21, 2024
1ff245c
Fix timings getting fetched before build getting done
BrunoQuaresma Oct 21, 2024
541ccba
Fix comment spacing
BrunoQuaresma Oct 21, 2024
b3f0351
Revert scales on def
BrunoQuaresma Oct 21, 2024
65ca087
Fix columnd calcl
BrunoQuaresma Oct 21, 2024
f288169
Fix fmt
BrunoQuaresma Oct 22, 2024
08874a3
Add extra tests
BrunoQuaresma Oct 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
Prev Previous commit
Next Next commit
Add failed icon
  • Loading branch information
BrunoQuaresma committed Oct 14, 2024
commit 8cc7eef74fea73280a0d2bd60338f9ab1b24d3bc
2 changes: 1 addition & 1 deletion site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const styles = {
// The bar should fill the row height.
height: "inherit",
display: "flex",
padding: 0,
padding: 7,
minWidth: 8,
}),
clickable: {
Expand Down
25 changes: 9 additions & 16 deletions site/src/modules/workspaces/WorkspaceTiming/Chart/BarBlocks.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Interpolation, Theme } from "@emotion/react";
import MoreHorizOutlined from "@mui/icons-material/MoreHorizOutlined";
import { type FC, useEffect, useRef, useState } from "react";
import { type FC, useLayoutEffect, useRef, useState } from "react";

const sidePadding = 8;
const spaceBetweenBlocks = 4;
const moreIconSize = 18;
const blockSize = 20;
Expand All @@ -12,26 +11,21 @@ type BarBlocksProps = {
};

export const BarBlocks: FC<BarBlocksProps> = ({ count }) => {
const [parentWidth, setParentWidth] = useState<number>();
const [availableWidth, setAvailableWidth] = useState<number>(0);
const blocksRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (!blocksRef.current || parentWidth) {
useLayoutEffect(() => {
if (availableWidth || !blocksRef.current) {
return;
}
const parentEl = blocksRef.current.parentElement;
if (!parentEl) {
throw new Error("BarBlocks must be a child of a Bar");
}
setParentWidth(parentEl.clientWidth);
}, [parentWidth]);
setAvailableWidth(blocksRef.current.clientWidth);
}, [availableWidth]);

const totalSpaceBetweenBlocks = (count - 1) * spaceBetweenBlocks;
const freeSize = parentWidth ? parentWidth - sidePadding * 2 : 0;
const necessarySize = blockSize * count + totalSpaceBetweenBlocks;
const hasSpacing = necessarySize <= freeSize;
const hasSpacing = necessarySize <= availableWidth;
const nOfPossibleBlocks = Math.floor(
(freeSize - moreIconSize) / (blockSize + spaceBetweenBlocks),
(availableWidth - moreIconSize) / (blockSize + spaceBetweenBlocks),
);
const nOfBlocks = hasSpacing ? count : nOfPossibleBlocks;

Expand All @@ -54,13 +48,12 @@ const styles = {
display: "flex",
width: "100%",
height: "100%",
padding: sidePadding,
gap: spaceBetweenBlocks,
alignItems: "center",
},
block: {
borderRadius: 4,
height: 16,
height: 18,
backgroundColor: "#082F49",
border: "1px solid #38BDF8",
flexShrink: 0,
Expand Down
15 changes: 15 additions & 0 deletions site/src/modules/workspaces/WorkspaceTiming/StagesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
mergeTimeRanges,
type TimeRange,
} from "./Chart/utils";
import { ErrorSharp } from "@mui/icons-material";

export type StageCategory = {
name: string;
Expand Down Expand Up @@ -111,6 +112,11 @@ type StageTiming = {
* be undefined if a stage has no timing data.
*/
range: TimeRange | undefined;
/**
* Display an error icon within the bar to indicate when a stage has failed.
* This is used in the agent scripts stage.
*/
error?: boolean;
};

export type StagesChartProps = {
Expand Down Expand Up @@ -196,6 +202,15 @@ export const StagesChart: FC<StagesChartProps> = ({
onSelectStage(t, category);
}}
>
{t.error && (
<ErrorSharp
css={{
fontSize: 18,
color: "#F87171",
marginRight: 4,
}}
/>
)}
<BarBlocks count={t.resources} />
</ClickableBar>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ export default meta;
type Story = StoryObj<typeof WorkspaceTimings>;

export const Default: Story = {};

const [first, ...others] = WorkspaceTimingsResponse.agent_script_timings;
export const FailedScript: Story = {
args: {
agentScriptTimings: [{ ...first, status: "exit_failure" }, ...others],
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const WorkspaceTimings: FC<WorkspaceTimingsProps> = ({
name: s.name,
categoryID: s.categoryID,
resources: stageTimings.length,
error: stageTimings.some(
(t) => "status" in t && t.status === "exit_failure",
),
};
})}
onSelectStage={(t, category) => {
Expand Down
Loading
0