diff --git a/app/components/Table.tsx b/app/components/Table.tsx index cb1a2d5800..7900ef2d89 100644 --- a/app/components/Table.tsx +++ b/app/components/Table.tsx @@ -63,6 +63,8 @@ export type Column = { id: string; component: (data: TData) => React.ReactNode; width: string; + /** Whether the column is hidden on narrow viewports (defaults to false). */ + hideOnMobile?: boolean; } & (DataColumn | ActionColumn); /** The minimum shape of a row, rows are identified by the model identifier. */ @@ -163,13 +165,12 @@ function TableViewInner({ const visibleColumns = React.useMemo( () => - id - ? columns.filter( - (column) => - column.type !== "data" || !hiddenColumns.includes(column.id) - ) - : columns, - [id, columns, hiddenColumns] + columns.filter( + (column) => + (!isMobile || !column.hideOnMobile) && + (!id || column.type !== "data" || !hiddenColumns.includes(column.id)) + ), + [id, columns, hiddenColumns, isMobile] ); const allColumns = React.useMemo(() => { diff --git a/app/models/User.ts b/app/models/User.ts index f046b6c8d9..c32c76842e 100644 --- a/app/models/User.ts +++ b/app/models/User.ts @@ -19,6 +19,7 @@ import type Group from "./Group"; import type UserMembership from "./UserMembership"; import ParanoidModel from "./base/ParanoidModel"; import Field from "./decorators/Field"; +import Relation from "./decorators/Relation"; import type { Searchable } from "./interfaces/Searchable"; class User extends ParanoidModel implements Searchable { @@ -80,6 +81,13 @@ class User extends ParanoidModel implements Searchable { @observable isSuspended: boolean; + @observable + invitedById: string | undefined; + + /** The user that invited this user, if they were invited. */ + @Relation(() => User) + invitedBy: User | undefined; + @computed get searchContent(): string[] { return [this.name, this.email, this.initials].filter(Boolean); diff --git a/app/scenes/Settings/components/UsersTable.tsx b/app/scenes/Settings/components/UsersTable.tsx index 0401a2208f..1eeedf92c0 100644 --- a/app/scenes/Settings/components/UsersTable.tsx +++ b/app/scenes/Settings/components/UsersTable.tsx @@ -16,6 +16,7 @@ import { ContextMenu } from "~/components/Menu/ContextMenu"; import { ActionContextProvider } from "~/hooks/useActionContext"; import { useUserMenuActions } from "~/hooks/useUserMenuActions"; import Time from "~/components/Time"; +import { UserHoverCard } from "~/components/UserHoverCard"; import useCurrentUser from "~/hooks/useCurrentUser"; import useMobile from "~/hooks/useMobile"; import UserMenu from "~/menus/UserMenu"; @@ -101,7 +102,7 @@ export function UsersTable({ canManage, ...rest }: Props) { ), width: "4fr", }, - canManage && !isMobile + canManage ? { type: "data", id: "email", @@ -109,21 +110,52 @@ export function UsersTable({ canManage, ...rest }: Props) { accessor: (user) => user.email, component: (user) => <>{user.email}, width: "4fr", + hideOnMobile: true, } : undefined, - isMobile - ? undefined - : { + { + type: "data", + id: "lastActiveAt", + header: t("Last active"), + accessor: (user) => user.lastActiveAt, + component: (user) => + user.lastActiveAt ? ( +