Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ const styles = {
left: -8,
},
}),
clickable: {
clickable: (theme) => ({
cursor: "pointer",
// We need to make the bar width at least 34px to allow the "..." icons to be displayed.
// The calculation is border * 1 + side paddings * 2 + icon width (which is 18px)
minWidth: 34,

"&:focus, &:hover, &:active": {
outline: "none",
borderColor: "#38BDF8",
borderColor: theme.roles.active.outline,
},
},
}),
} satisfies Record<string, Interpolation<Theme>>;
14 changes: 7 additions & 7 deletions site/src/modules/workspaces/WorkspaceTiming/Chart/Blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ const styles = {
gap: spaceBetweenBlocks,
alignItems: "center",
},
block: {
block: (theme) => ({
borderRadius: 4,
height: 18,
backgroundColor: "#082F49",
border: "1px solid #38BDF8",
backgroundColor: theme.roles.active.background,
border: `1px solid ${theme.roles.active.outline}`,
flexShrink: 0,
flex: 1,
},
more: {
color: "#38BDF8",
}),
more: (theme) => ({
color: theme.roles.active.outline,
lineHeight: 0,
flexShrink: 0,
flex: 1,

"& svg": {
fontSize: moreIconSize,
},
},
}),
} satisfies Record<string, Interpolation<Theme>>;
58 changes: 31 additions & 27 deletions site/src/modules/workspaces/WorkspaceTiming/ResourcesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,6 @@ import {
} from "./Chart/utils";
import type { StageCategory } from "./StagesChart";

const legendsByAction: Record<string, ChartLegend> = {
"state refresh": {
label: "state refresh",
},
create: {
label: "create",
colors: {
fill: "#022C22",
stroke: "#BBF7D0",
},
},
delete: {
label: "delete",
colors: {
fill: "#422006",
stroke: "#FDBA74",
},
},
read: {
label: "read",
colors: {
fill: "#082F49",
stroke: "#38BDF8",
},
},
};

type ResourceTiming = {
name: string;
source: string;
Expand Down Expand Up @@ -86,6 +59,8 @@ export const ResourcesChart: FC<ResourcesChartProps> = ({
const visibleTimings = timings.filter(
(t) => !isCoderResource(t.name) && t.name.includes(filter),
);
const theme = useTheme();
const legendsByAction = getLegendsByAction(theme);
const visibleLegends = [...new Set(visibleTimings.map((t) => t.action))].map(
(a) => legendsByAction[a],
);
Expand Down Expand Up @@ -168,3 +143,32 @@ export const isCoderResource = (resource: string) => {
resource.startsWith("coder_")
);
};

function getLegendsByAction(theme: Theme): Record<string, ChartLegend> {
return {
"state refresh": {
label: "state refresh",
},
create: {
label: "create",
colors: {
fill: theme.roles.success.background,
stroke: theme.roles.success.outline,
},
},
delete: {
label: "delete",
colors: {
fill: theme.roles.warning.background,
stroke: theme.roles.warning.outline,
},
},
read: {
label: "read",
colors: {
fill: theme.roles.active.background,
stroke: theme.roles.active.outline,
},
},
};
}
53 changes: 29 additions & 24 deletions site/src/modules/workspaces/WorkspaceTiming/ScriptsChart.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type Theme, useTheme } from "@emotion/react";
import { type FC, useState } from "react";
import { Bar } from "./Chart/Bar";
import {
Expand Down Expand Up @@ -28,30 +29,6 @@ import {
} from "./Chart/utils";
import type { StageCategory } from "./StagesChart";

const legendsByStatus: Record<string, ChartLegend> = {
ok: {
label: "success",
colors: {
fill: "#022C22",
stroke: "#BBF7D0",
},
},
exit_failure: {
label: "failure",
colors: {
fill: "#450A0A",
stroke: "#F87171",
},
},
timeout: {
label: "timed out",
colors: {
fill: "#422006",
stroke: "#FDBA74",
},
},
};

type ScriptTiming = {
name: string;
status: string;
Expand All @@ -77,6 +54,8 @@ export const ScriptsChart: FC<ScriptsChartProps> = ({
const [ticks, scale] = makeTicks(totalTime);
const [filter, setFilter] = useState("");
const visibleTimings = timings.filter((t) => t.name.includes(filter));
const theme = useTheme();
const legendsByStatus = getLegendsByStatus(theme);
const visibleLegends = [...new Set(visibleTimings.map((t) => t.status))].map(
(s) => legendsByStatus[s],
);
Expand Down Expand Up @@ -151,3 +130,29 @@ export const ScriptsChart: FC<ScriptsChartProps> = ({
</Chart>
);
};

function getLegendsByStatus(theme: Theme): Record<string, ChartLegend> {
return {
ok: {
label: "success",
colors: {
fill: theme.roles.success.background,
stroke: theme.roles.success.outline,
},
},
exit_failure: {
label: "failure",
colors: {
fill: theme.roles.error.background,
stroke: theme.roles.error.outline,
},
},
timeout: {
label: "timed out",
colors: {
fill: theme.roles.warning.background,
stroke: theme.roles.warning.outline,
},
},
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import { expect, userEvent, waitFor, within } from "@storybook/test";
import { chromatic } from "testHelpers/chromatic";
import { WorkspaceTimings } from "./WorkspaceTimings";
import { WorkspaceTimingsResponse } from "./storybookData";

Expand All @@ -11,6 +12,9 @@ const meta: Meta<typeof WorkspaceTimings> = {
provisionerTimings: WorkspaceTimingsResponse.provisioner_timings,
agentScriptTimings: WorkspaceTimingsResponse.agent_script_timings,
},
parameters: {
chromatic,
},
};

export default meta;
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy