Skip to content

Add Users Last Seen At #4192

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 5 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Complete frontend
  • Loading branch information
ammario committed Sep 24, 2022
commit bf7f5ab8de8892dc2a20083eb8ed51e5377ac9e7
1 change: 1 addition & 0 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ export interface User {
readonly username: string
readonly email: string
readonly created_at: string
readonly last_seen_at: string
readonly status: UserStatus
readonly organization_ids: string[]
readonly roles: Role[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { colors } from "theme/colors"

dayjs.extend(relativeTime)

interface WorkspaceLastUsedProps {
interface LastUsedProps {
lastUsedAt: string
}

export const WorkspaceLastUsed: FC<WorkspaceLastUsedProps> = ({ lastUsedAt }) => {
export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
const theme: Theme = useTheme()
const styles = useStyles()

Expand Down
2 changes: 2 additions & 0 deletions site/src/components/UsersTable/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Language = {
usernameLabel: "User",
rolesLabel: "Roles",
statusLabel: "Status",
lastSeenLabel: "Last Seen",
}

export interface UsersTableProps {
Expand Down Expand Up @@ -50,6 +51,7 @@ export const UsersTable: FC<React.PropsWithChildren<UsersTableProps>> = ({
<TableRow>
<TableCell width="50%">{Language.usernameLabel}</TableCell>
<TableCell width="25%">{Language.statusLabel}</TableCell>
<TableCell width="50%">{Language.lastSeenLabel}</TableCell>
<TableCell width="25%">
<Stack direction="row" spacing={1} alignItems="center">
<span>{Language.rolesLabel}</span>
Expand Down
4 changes: 4 additions & 0 deletions site/src/components/UsersTable/UsersTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Box from "@material-ui/core/Box"
import { makeStyles } from "@material-ui/core/styles"
import TableCell from "@material-ui/core/TableCell"
import TableRow from "@material-ui/core/TableRow"
import { LastUsed } from "components/LastUsed/LastUsed"
import { FC } from "react"
import * as TypesGen from "../../api/typesGenerated"
import { combineClasses } from "../../util/combineClasses"
Expand Down Expand Up @@ -101,6 +102,9 @@ export const UsersTableBody: FC<React.PropsWithChildren<UsersTableBodyProps>> =
>
{user.status}
</TableCell>
<TableCell>
<LastUsed lastUsedAt={user.last_seen_at} />
</TableCell>
<TableCell>
{canEditUsers ? (
<RoleSelect
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/WorkspacesTable/WorkspacesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { WorkspaceStatusBadge } from "components/WorkspaceStatusBadge/WorkspaceS
import { FC } from "react"
import { useNavigate } from "react-router-dom"
import { WorkspaceItemMachineRef } from "../../xServices/workspaces/workspacesXService"
import { LastUsed } from "../LastUsed/LastUsed"
import { TableCellData, TableCellDataPrimary } from "../TableCellData/TableCellData"
import { TableCellLink } from "../TableCellLink/TableCellLink"
import { OutdatedHelpTooltip } from "../Tooltips"
import { WorkspaceLastUsed } from "./WorkspaceLastUsed"

const Language = {
upToDateLabel: "Up to date",
Expand Down Expand Up @@ -61,7 +61,7 @@ export const WorkspacesRow: FC<
</TableCellLink>
<TableCellLink to={workspacePageLink}>
<TableCellData>
<WorkspaceLastUsed lastUsedAt={workspace.last_used_at} />
<LastUsed lastUsedAt={workspace.last_used_at} />
</TableCellData>
</TableCellLink>

Expand Down
4 changes: 4 additions & 0 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const MockUser: TypesGen.User = {
organization_ids: ["fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0"],
roles: [MockOwnerRole],
avatar_url: "https://github.com/coder.png",
last_seen_at: "",
}

export const MockUserAdmin: TypesGen.User = {
Expand All @@ -82,6 +83,7 @@ export const MockUserAdmin: TypesGen.User = {
organization_ids: ["fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0"],
roles: [MockUserAdminRole],
avatar_url: "",
last_seen_at: "",
}

export const MockUser2: TypesGen.User = {
Expand All @@ -93,6 +95,7 @@ export const MockUser2: TypesGen.User = {
organization_ids: ["fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0"],
roles: [],
avatar_url: "",
last_seen_at: "2022-09-14T19:12:21Z",
}

export const SuspendedMockUser: TypesGen.User = {
Expand All @@ -104,6 +107,7 @@ export const SuspendedMockUser: TypesGen.User = {
organization_ids: ["fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0"],
roles: [],
avatar_url: "",
last_seen_at: "",
}

export const MockOrganization: TypesGen.Organization = {
Expand Down