mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
refactor(site): remove version and last built from workspace header (#10495)
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import { type CSSObject, type Interpolation, type Theme } from "@emotion/react";
|
import { type CSSObject, type Interpolation, type Theme } from "@emotion/react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { type ComponentProps, type FC } from "react";
|
import { ReactNode, type ComponentProps, type FC } from "react";
|
||||||
|
|
||||||
export const Stats: FC<ComponentProps<typeof Box>> = (props) => {
|
export const Stats: FC<ComponentProps<typeof Box>> = (props) => {
|
||||||
return <Box {...props} css={styles.stats} />;
|
return <Box {...props} css={styles.stats} />;
|
||||||
@ -9,7 +9,7 @@ export const Stats: FC<ComponentProps<typeof Box>> = (props) => {
|
|||||||
export const StatsItem: FC<
|
export const StatsItem: FC<
|
||||||
{
|
{
|
||||||
label: string;
|
label: string;
|
||||||
value: string | number | JSX.Element;
|
value: ReactNode;
|
||||||
} & ComponentProps<typeof Box>
|
} & ComponentProps<typeof Box>
|
||||||
> = ({ label, value, ...divProps }) => {
|
> = ({ label, value, ...divProps }) => {
|
||||||
return (
|
return (
|
||||||
|
@ -20,7 +20,7 @@ export const Language = {
|
|||||||
outdatedLabel: "Outdated",
|
outdatedLabel: "Outdated",
|
||||||
versionTooltipText:
|
versionTooltipText:
|
||||||
"This workspace version is outdated and a newer version is available.",
|
"This workspace version is outdated and a newer version is available.",
|
||||||
updateVersionLabel: "Update version",
|
updateVersionLabel: "Update",
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TooltipProps {
|
interface TooltipProps {
|
||||||
|
@ -58,7 +58,11 @@ export const BuildRow: React.FC<BuildRowProps> = ({ build }) => {
|
|||||||
</span>
|
</span>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Stack direction="row" spacing={1}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={1}
|
||||||
|
css={{ "& strong": { fontWeight: 600 } }}
|
||||||
|
>
|
||||||
<span css={styles.buildInfo}>
|
<span css={styles.buildInfo}>
|
||||||
Reason: <strong>{build.reason}</strong>
|
Reason: <strong>{build.reason}</strong>
|
||||||
</span>
|
</span>
|
||||||
@ -94,6 +98,9 @@ const styles = {
|
|||||||
buildSummary: (theme) => ({
|
buildSummary: (theme) => ({
|
||||||
...(theme.typography.body1 as CSSObject),
|
...(theme.typography.body1 as CSSObject),
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
|
"& strong": {
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
buildInfo: (theme) => ({
|
buildInfo: (theme) => ({
|
||||||
|
@ -4,9 +4,7 @@ import Link from "@mui/material/Link";
|
|||||||
import { WorkspaceOutdatedTooltip } from "components/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
|
import { WorkspaceOutdatedTooltip } from "components/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
|
||||||
import { type FC } from "react";
|
import { type FC } from "react";
|
||||||
import { Link as RouterLink } from "react-router-dom";
|
import { Link as RouterLink } from "react-router-dom";
|
||||||
import { createDayString } from "utils/createDayString";
|
|
||||||
import {
|
import {
|
||||||
getDisplayWorkspaceBuildInitiatedBy,
|
|
||||||
getDisplayWorkspaceTemplateName,
|
getDisplayWorkspaceTemplateName,
|
||||||
isWorkspaceOn,
|
isWorkspaceOn,
|
||||||
workspaceUpdatePolicy,
|
workspaceUpdatePolicy,
|
||||||
@ -38,12 +36,6 @@ import { Stack } from "components/Stack/Stack";
|
|||||||
const Language = {
|
const Language = {
|
||||||
workspaceDetails: "Workspace Details",
|
workspaceDetails: "Workspace Details",
|
||||||
templateLabel: "Template",
|
templateLabel: "Template",
|
||||||
statusLabel: "Workspace Status",
|
|
||||||
versionLabel: "Version",
|
|
||||||
lastBuiltLabel: "Last built",
|
|
||||||
outdated: "Outdated",
|
|
||||||
upToDate: "Up to date",
|
|
||||||
byLabel: "Last built by",
|
|
||||||
costLabel: "Daily cost",
|
costLabel: "Daily cost",
|
||||||
updatePolicy: "Update policy",
|
updatePolicy: "Update policy",
|
||||||
};
|
};
|
||||||
@ -72,9 +64,6 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
|
|||||||
onDeadlinePlus,
|
onDeadlinePlus,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const initiatedBy = getDisplayWorkspaceBuildInitiatedBy(
|
|
||||||
workspace.latest_build,
|
|
||||||
);
|
|
||||||
const displayTemplateName = getDisplayWorkspaceTemplateName(workspace);
|
const displayTemplateName = getDisplayWorkspaceTemplateName(workspace);
|
||||||
const deadlinePlusEnabled = maxDeadlineIncrease >= 1;
|
const deadlinePlusEnabled = maxDeadlineIncrease >= 1;
|
||||||
const deadlineMinusEnabled = maxDeadlineDecrease >= 1;
|
const deadlineMinusEnabled = maxDeadlineDecrease >= 1;
|
||||||
@ -103,24 +92,12 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
|
|||||||
css={styles.statsItem}
|
css={styles.statsItem}
|
||||||
label={Language.templateLabel}
|
label={Language.templateLabel}
|
||||||
value={
|
value={
|
||||||
<Link
|
<div css={{ display: "flex", alignItems: "center", gap: 2 }}>
|
||||||
component={RouterLink}
|
|
||||||
to={`/templates/${workspace.template_name}`}
|
|
||||||
>
|
|
||||||
{displayTemplateName}
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<StatsItem
|
|
||||||
css={styles.statsItem}
|
|
||||||
label={Language.versionLabel}
|
|
||||||
value={
|
|
||||||
<>
|
|
||||||
<Link
|
<Link
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
to={`/templates/${workspace.template_name}/versions/${workspace.latest_build.template_version_name}`}
|
to={`/templates/${workspace.template_name}`}
|
||||||
>
|
>
|
||||||
{workspace.latest_build.template_version_name}
|
{displayTemplateName}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
{workspace.outdated && (
|
{workspace.outdated && (
|
||||||
@ -131,19 +108,10 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
|
|||||||
ariaLabel="update version"
|
ariaLabel="update version"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
}
|
|
||||||
/>
|
|
||||||
<StatsItem
|
|
||||||
css={styles.statsItem}
|
|
||||||
label={Language.lastBuiltLabel}
|
|
||||||
value={
|
|
||||||
<>
|
|
||||||
{upperFirst(createDayString(workspace.latest_build.created_at))}{" "}
|
|
||||||
by {initiatedBy}
|
|
||||||
</>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{shouldDisplayScheduleLabel(workspace) && (
|
{shouldDisplayScheduleLabel(workspace) && (
|
||||||
<StatsItem
|
<StatsItem
|
||||||
css={styles.statsItem}
|
css={styles.statsItem}
|
||||||
|
Reference in New Issue
Block a user