Skip to content

feat: tweak timeline design #5144

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 2 commits into from
Nov 22, 2022
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
44 changes: 5 additions & 39 deletions site/src/components/AuditLogRow/AuditLogRow.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
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,
OpenDropdown,
} 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 => {
Expand Down Expand Up @@ -68,19 +67,16 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
}

return (
<TableRow
<TimelineEntry
key={auditLog.id}
data-testid={`audit-log-row-${auditLog.id}`}
className={styles.auditLogRow}
clickable={shouldDisplayDiff}
>
<TableCell className={styles.auditLogCell}>
<Stack
direction="row"
alignItems="center"
className={combineClasses({
[styles.auditLogHeader]: true,
[styles.clickable]: shouldDisplayDiff,
})}
className={styles.auditLogHeader}
tabIndex={0}
onClick={toggle}
onKeyDown={(event) => {
Expand Down Expand Up @@ -164,7 +160,7 @@ export const AuditLogRow: React.FC<AuditLogRowProps> = ({
</Collapse>
)}
</TableCell>
</TableRow>
</TimelineEntry>
)
}

Expand All @@ -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,
},
Expand Down
33 changes: 3 additions & 30 deletions site/src/components/BuildsTable/BuildRow.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -27,12 +27,7 @@ export const BuildRow: React.FC<BuildRowProps> = ({ build }) => {
)

return (
<TableRow
hover
data-testid={`build-${build.id}`}
className={styles.buildRow}
{...clickableProps}
>
<TimelineEntry hover data-testid={`build-${build.id}`} {...clickableProps}>
<TableCell className={styles.buildCell}>
<Stack
direction="row"
Expand Down Expand Up @@ -76,33 +71,11 @@ export const BuildRow: React.FC<BuildRowProps> = ({ build }) => {
</Stack>
</Stack>
</TableCell>
</TableRow>
</TimelineEntry>
)
}

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),
},
Expand Down
56 changes: 56 additions & 0 deletions site/src/components/Timeline/TimelineEntry.tsx
Original file line number Diff line number Diff line change
@@ -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<TimelineEntryProps & TableRowProps>): JSX.Element => {
const styles = useStyles()
return (
<TableRow
className={combineClasses({
[styles.timelineEntry]: true,
[styles.clickable]: clickable,
})}
{...props}
>
{children}
</TableRow>
)
}

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,
},
},
}))
29 changes: 3 additions & 26 deletions site/src/components/VersionsTable/VersionRow.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -21,11 +21,7 @@ export const VersionRow: React.FC<VersionRowProps> = ({ version }) => {
})

return (
<TableRow
className={styles.versionRow}
data-testid={`version-${version.id}`}
{...clickableProps}
>
<TimelineEntry data-testid={`version-${version.id}`} {...clickableProps}>
<TableCell className={styles.versionCell}>
<Stack
direction="row"
Expand Down Expand Up @@ -55,30 +51,11 @@ export const VersionRow: React.FC<VersionRowProps> = ({ version }) => {
</Stack>
</Stack>
</TableCell>
</TableRow>
</TimelineEntry>
)
}

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),
},
Expand Down