diff --git a/site/src/components/AuditLogRow/AuditLogRow.tsx b/site/src/components/AuditLogRow/AuditLogRow.tsx index c00d1564d5c95..1da44dbfd229c 100644 --- a/site/src/components/AuditLogRow/AuditLogRow.tsx +++ b/site/src/components/AuditLogRow/AuditLogRow.tsx @@ -1,7 +1,6 @@ import Collapse from "@material-ui/core/Collapse" import { makeStyles } from "@material-ui/core/styles" import TableCell from "@material-ui/core/TableCell" -import TableRow from "@material-ui/core/TableRow" import { AuditLog } from "api/typesGenerated" import { CloseDropdown, @@ -9,11 +8,11 @@ import { } from "components/DropdownArrows/DropdownArrows" import { Pill } from "components/Pill/Pill" import { Stack } from "components/Stack/Stack" +import { TimelineEntry } from "components/Timeline/TimelineEntry" import { UserAvatar } from "components/UserAvatar/UserAvatar" import { useState } from "react" import { PaletteIndex } from "theme/palettes" import userAgentParser from "ua-parser-js" -import { combineClasses } from "util/combineClasses" import { AuditLogDiff } from "./AuditLogDiff" export const readableActionMessage = (auditLog: AuditLog): string => { @@ -68,19 +67,16 @@ export const AuditLogRow: React.FC = ({ } return ( - { @@ -164,7 +160,7 @@ export const AuditLogRow: React.FC = ({ )} - + ) } @@ -174,40 +170,10 @@ const useStyles = makeStyles((theme) => ({ border: 0, }, - auditLogRow: { - position: "relative", - - "&:focus": { - outlineStyle: "solid", - outlineOffset: -1, - outlineWidth: 2, - outlineColor: theme.palette.secondary.dark, - }, - - "&:not(:last-child) td:before": { - position: "absolute", - top: 20, - left: 50, - display: "block", - content: "''", - height: "100%", - width: 2, - background: theme.palette.divider, - }, - }, - auditLogHeader: { padding: theme.spacing(2, 4), }, - clickable: { - cursor: "pointer", - - "&:hover": { - backgroundColor: theme.palette.action.hover, - }, - }, - auditLogHeaderInfo: { flex: 1, }, diff --git a/site/src/components/BuildsTable/BuildRow.tsx b/site/src/components/BuildsTable/BuildRow.tsx index 2fe032472c3d2..1e349f68371c2 100644 --- a/site/src/components/BuildsTable/BuildRow.tsx +++ b/site/src/components/BuildsTable/BuildRow.tsx @@ -1,8 +1,8 @@ import { makeStyles } from "@material-ui/core/styles" import TableCell from "@material-ui/core/TableCell" -import TableRow from "@material-ui/core/TableRow" import { WorkspaceBuild } from "api/typesGenerated" import { Stack } from "components/Stack/Stack" +import { TimelineEntry } from "components/Timeline/TimelineEntry" import { useClickable } from "hooks/useClickable" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" @@ -27,12 +27,7 @@ export const BuildRow: React.FC = ({ build }) => { ) return ( - + = ({ build }) => { - + ) } const useStyles = makeStyles((theme) => ({ - buildRow: { - cursor: "pointer", - - "&:focus": { - outlineStyle: "solid", - outlineOffset: -1, - outlineWidth: 2, - outlineColor: theme.palette.secondary.dark, - }, - - "&:not(:last-child) td:before": { - position: "absolute", - top: 20, - left: 50, - display: "block", - content: "''", - height: "100%", - width: 2, - background: theme.palette.divider, - }, - }, - buildWrapper: { padding: theme.spacing(2, 4), }, diff --git a/site/src/components/Timeline/TimelineEntry.tsx b/site/src/components/Timeline/TimelineEntry.tsx new file mode 100644 index 0000000000000..df4348e903d87 --- /dev/null +++ b/site/src/components/Timeline/TimelineEntry.tsx @@ -0,0 +1,56 @@ +import { makeStyles } from "@material-ui/core/styles" +import TableRow, { TableRowProps } from "@material-ui/core/TableRow" +import { PropsWithChildren } from "react" +import { combineClasses } from "util/combineClasses" + +interface TimelineEntryProps { + clickable?: boolean +} + +export const TimelineEntry = ({ + children, + clickable = true, + ...props +}: PropsWithChildren): JSX.Element => { + const styles = useStyles() + return ( + + {children} + + ) +} + +const useStyles = makeStyles((theme) => ({ + clickable: { + cursor: "pointer", + + "&:hover": { + backgroundColor: theme.palette.action.hover, + }, + }, + + timelineEntry: { + position: "relative", + "&:focus": { + outlineStyle: "solid", + outlineOffset: -1, + outlineWidth: 2, + outlineColor: theme.palette.secondary.dark, + }, + "& td:before": { + position: "absolute", + left: 50, + display: "block", + content: "''", + height: "100%", + width: 2, + background: theme.palette.divider, + }, + }, +})) diff --git a/site/src/components/VersionsTable/VersionRow.tsx b/site/src/components/VersionsTable/VersionRow.tsx index 583f9ba093b09..e1cb777f7f979 100644 --- a/site/src/components/VersionsTable/VersionRow.tsx +++ b/site/src/components/VersionsTable/VersionRow.tsx @@ -1,8 +1,8 @@ import { makeStyles } from "@material-ui/core/styles" import TableCell from "@material-ui/core/TableCell" -import TableRow from "@material-ui/core/TableRow" import { TemplateVersion } from "api/typesGenerated" import { Stack } from "components/Stack/Stack" +import { TimelineEntry } from "components/Timeline/TimelineEntry" import { UserAvatar } from "components/UserAvatar/UserAvatar" import { useClickable } from "hooks/useClickable" import { useTranslation } from "react-i18next" @@ -21,11 +21,7 @@ export const VersionRow: React.FC = ({ version }) => { }) return ( - + = ({ version }) => { - + ) } const useStyles = makeStyles((theme) => ({ - versionRow: { - cursor: "pointer", - - "&:hover": { - backgroundColor: theme.palette.action.hover, - }, - - "&:not(:last-child) td:before": { - position: "absolute", - top: 20, - left: 50, - display: "block", - content: "''", - height: "100%", - width: 2, - background: theme.palette.divider, - }, - }, - versionWrapper: { padding: theme.spacing(2, 4), },