The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
fix(collections): show a skeleton while collection items load (#84322)
Anna Tomka78b9f19a5482
diff --git a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsxindex 2a99ac6212a..19bc86f677a 100644--- a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx+++ b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx@@ -32,6 +32,7 @@ import { isRootTrashCollection } from "metabase/common/collections/utils";import { EmptyState } from "metabase/common/components/EmptyState";import { ItemsTable } from "metabase/common/components/ItemsTable";import { getVisibleColumnsMap } from "metabase/common/components/ItemsTable/utils";+import { DelayedLoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper/DelayedLoadingAndErrorWrapper";import { PaginationControls } from "metabase/common/components/PaginationControls";import { useDebouncedValue } from "metabase/common/hooks/use-debounced-value";import { usePagination } from "metabase/common/hooks/use-pagination";@@ -341,7 +342,8 @@ const CollectionItemsTableContent = ({onSelectedFiltersChange,onItemsSortingChange,}: CollectionItemsTableContentProps) => {- const { data, isFetching } = useListCollectionItemsQuery(itemsQuery);+ const { data, isFetching, isLoading, error } =+ useListCollectionItemsQuery(itemsQuery);const items = data?.data ?? [];const totalMatchingItems = data?.total;@@ -368,14 +370,22 @@ const CollectionItemsTableContent = ({const hasSearchText = searchText.trim().length > 0 || hasSearchQuery;const hasActiveFilters = hasSearchText || selectedFilters != null;const isSearching = isFetching && hasSearchQuery;- const isEmpty = !isFetching && items.length === 0 && !hasActiveFilters;+ const hasNoItems = !isFetching && !error && items.length === 0;+ const isEmpty = hasNoItems && !hasActiveFilters;if (isEmpty) {return <EmptyContentComponent collection={collection} />;}- const showNoResults = !isFetching && hasActiveFilters && items.length === 0;+ const showNoResults = hasNoItems && hasActiveFilters;const showTable = !showNoResults;+ // Shared by the skeleton and the loaded table, so both render the same header and columns.+ const sharedTableProps = {+ collection,+ sortingOptions: itemsSorting,+ onToggleSelected: toggleItem,+ visibleColumnsMap,+ };return (<>@@ -392,27 +402,32 @@ const CollectionItemsTableContent = ({{showNoResults && <CollectionNoResults hasSearchText={hasSearchText} />}{showTable && (<Box data-testid="collection-table">- <ItemsTable- databases={databases}- bookmarks={bookmarks}- createBookmark={createBookmark}- deleteBookmark={deleteBookmark}- items={items}- collection={collection}- sortingOptions={itemsSorting}- onSortingOptionsChange={onItemsSortingChange}- selectedItems={selected}- hasUnselected={hasUnselected}- getIsSelected={getIsSelected}- onToggleSelected={toggleItem}- onDrop={clear}- onMove={handleMove}- onCopy={handleCopy}- onSelectAll={handleSelectAll}- onSelectNone={clear}- onClick={onClick}- visibleColumnsMap={visibleColumnsMap}- />+ <DelayedLoadingAndErrorWrapper+ error={error}+ loading={isLoading}+ loader={+ <ItemsTable withSkeleton items={[]} {...sharedTableProps} />+ }+ >+ <ItemsTable+ {...sharedTableProps}+ databases={databases}+ bookmarks={bookmarks}+ createBookmark={createBookmark}+ deleteBookmark={deleteBookmark}+ items={items}+ onSortingOptionsChange={onItemsSortingChange}+ selectedItems={selected}+ hasUnselected={hasUnselected}+ getIsSelected={getIsSelected}+ onDrop={clear}+ onMove={handleMove}+ onCopy={handleCopy}+ onSelectAll={handleSelectAll}+ onSelectNone={clear}+ onClick={onClick}+ />+ </DelayedLoadingAndErrorWrapper><divclassName={cx(CS.flex,diff --git a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsxindex c45604c1d35..cb9c4f95b41 100644--- a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx+++ b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.unit.spec.tsx@@ -14,10 +14,12 @@ import * as Analytics from "metabase/analytics";import { Api } from "metabase/api";import { Route } from "metabase/router";import { SEARCH_DEBOUNCE_DURATION } from "metabase/utils/constants";+import { defer } from "metabase/utils/promise";import type {Collection,CollectionId,CollectionItem,+ ListCollectionItemsResponse,} from "metabase-types/api";import {createMockCollection,@@ -73,8 +75,33 @@ type SetupOpts = {collectionItems?: CollectionItem[];pageSize?: number;showFilterBar?: boolean;+ /** Holds the items response until the returned `releaseItems` is called */+ holdItems?: boolean;+ /** Makes the items request fail with this message */+ itemsError?: string;};+function holdItemsResponse(+ collectionId: CollectionId,+ items: CollectionItem[],+) {+ const gate = defer<void>();+ const response: ListCollectionItemsResponse = {+ data: items,+ total: items.length,+ models: [],+ limit: 25,+ offset: 0,+ };+ fetchMock.modifyRoute(`collection-${collectionId}-items`, {+ response: async () => {+ await gate.promise;+ return response;+ },+ });+ return gate;+}+function getTable({collection: currentCollection = collection,pageSize,@@ -100,19 +127,31 @@ function setup({collectionItems: items = collectionItems,pageSize,showFilterBar = true,+ holdItems = false,+ itemsError,}: SetupOpts = {}) {setupCollectionItemsEndpoint({collection: currentCollection,collectionItems: items,});+ const itemsGate = holdItems+ ? holdItemsResponse(currentCollection.id, items)+ : undefined;+ if (itemsError != null) {+ fetchMock.modifyRoute(`collection-${currentCollection.id}-items`, {+ response: { status: 500, body: { message: itemsError } },+ });+ }- return renderWithProviders(+ const view = renderWithProviders(getTable({ collection: currentCollection, pageSize, showFilterBar }),{withRouter: true,withDND: true,},);++ return { ...view, releaseItems: () => itemsGate?.resolve() };}function getItemsCalls(collectionId: CollectionId = collection.id) {@@ -1075,4 +1114,54 @@ describe("CollectionItemsTable", () => {expect(screen.queryByText("Revenue overview")).not.toBeInTheDocument();});});++ it("shows placeholder rows while the first items load", async () => {+ const { releaseItems } = setup({ holdItems: true });++ expect(+ await screen.findByTestId("items-table-skeleton"),+ ).toBeInTheDocument();+ expect(screen.queryByText("Revenue overview")).not.toBeInTheDocument();+ expect(+ screen.queryByTestId("collection-empty-state"),+ ).not.toBeInTheDocument();++ await act(async () => {+ releaseItems();+ await fetchMock.callHistory.flush();+ });++ expect(await screen.findByText("Revenue overview")).toBeInTheDocument();+ expect(+ screen.queryByTestId("items-table-skeleton"),+ ).not.toBeInTheDocument();+ });++ it("announces that the items are loading", async () => {+ const { releaseItems } = setup({ holdItems: true });++ expect(await screen.findByRole("status")).toHaveTextContent("Loading…");++ await act(async () => {+ releaseItems();+ await fetchMock.callHistory.flush();+ });++ expect(await screen.findByText("Revenue overview")).toBeInTheDocument();+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ });++ it("shows the error, not the empty state, when the items fail to load", async () => {+ setup({ itemsError: "Could not load the items" });++ expect(+ await screen.findByText("Could not load the items"),+ ).toBeInTheDocument();+ expect(+ screen.queryByTestId("collection-empty-state"),+ ).not.toBeInTheDocument();+ expect(+ screen.queryByTestId("items-table-skeleton"),+ ).not.toBeInTheDocument();+ });});diff --git a/frontend/src/metabase/common/components/ItemsTable/BaseItemTableRow.tsx b/frontend/src/metabase/common/components/ItemsTable/BaseItemTableRow.tsxindex 7ac39b596b6..3c2f4e87b7e 100644--- a/frontend/src/metabase/common/components/ItemsTable/BaseItemTableRow.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/BaseItemTableRow.tsx@@ -13,6 +13,8 @@ import type { CollectionItem } from "metabase-types/api";import S from "./BaseItemTableRow.module.css";+export const ITEM_ROW_HEIGHT = 48;+export type ItemTableRowDndState =| "idle"| "dragged"@@ -117,7 +119,7 @@ export const TableRow = ({<trkey={itemKey}data-testid={testIdPrefix}- style={{ height: 48 }}+ style={{ height: ITEM_ROW_HEIGHT }}onClickCapture={getRowShiftSelectHandler({item,collection,@@ -171,7 +173,7 @@ export const ItemDragSourceTableRow = ({<trdata-dnd-state={dndState}data-testid={testIdPrefix}- style={{ height: 48 }}+ style={{ height: ITEM_ROW_HEIGHT }}className={cx({[S.draggedRow]: dndState === "dragged",[S.disabledRow]: dndState === "disabled",diff --git a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.tsx b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.tsxindex 358c98b894f..3b5b16b88aa 100644--- a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.tsx@@ -12,6 +12,7 @@ import type {} from "metabase/common/collections/types";import { isTrashedCollection } from "metabase/common/collections/utils";import { BaseItemsTableBody } from "metabase/common/components/ItemsTable/BaseItemsTableBody/BaseItemsTableBody";+import { SkeletonItemsTableBody } from "metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody";import type { ItemRendererProps } from "metabase/common/components/ItemsTable/DefaultItemRenderer";import { DefaultItemRenderer } from "metabase/common/components/ItemsTable/DefaultItemRenderer";import { canSelectItems } from "metabase/common/components/ItemsTable/utils";@@ -126,6 +127,7 @@ export type BaseItemsTableProps = {ItemComponent?: (props: ItemRendererProps) => JSX.Element;onClick?: (item: CollectionItem) => void;visibleColumnsMap: CollectionContentTableColumnsMap;+ withSkeleton?: boolean;} & Partial<Omit<HTMLAttributes<HTMLTableElement>, "onCopy" | "onClick">>;export const BaseItemsTable = ({@@ -150,6 +152,7 @@ export const BaseItemsTable = ({ItemComponent = DefaultItemRenderer,visibleColumnsMap,onClick,+ withSkeleton = false,...props}: BaseItemsTableProps) => {const canSelect = canSelectItems(collection, onToggleSelected);@@ -172,14 +175,17 @@ export const BaseItemsTable = ({data-testid={isPinned ? "pinned-items-table-head" : "items-table-head"}><tr>- {canSelect && (- <Columns.Select.Header- selectedItems={selectedItems}- hasUnselected={hasUnselected}- onSelectAll={onSelectAll}- onSelectNone={onSelectNone}- />- )}+ {canSelect &&+ (withSkeleton ? (+ <ColumnHeader />+ ) : (+ <Columns.Select.Header+ selectedItems={selectedItems}+ hasUnselected={hasUnselected}+ onSelectAll={onSelectAll}+ onSelectNone={onSelectNone}+ />+ ))}{visibleColumnsMap["type"] && (<Columns.Type.HeadersortingOptions={sortingOptions}@@ -217,24 +223,31 @@ export const BaseItemsTable = ({<Columns.RightEdge.Header /></tr></thead>- <BaseItemsTableBody- items={items}- getIsSelected={getIsSelected}- isPinned={isPinned}- collection={collection}- selectedItems={selectedItems}- onDrop={onDrop}- ItemComponent={ItemComponent}- databases={databases}- bookmarks={bookmarks}- createBookmark={createBookmark}- deleteBookmark={deleteBookmark}- onCopy={onCopy}- onMove={onMove}- onToggleSelected={onToggleSelected}- onClick={onClick}- visibleColumnsMap={visibleColumnsMap}- />+ {withSkeleton ? (+ <SkeletonItemsTableBody+ canSelect={canSelect}+ visibleColumnsMap={visibleColumnsMap}+ />+ ) : (+ <BaseItemsTableBody+ items={items}+ getIsSelected={getIsSelected}+ isPinned={isPinned}+ collection={collection}+ selectedItems={selectedItems}+ onDrop={onDrop}+ ItemComponent={ItemComponent}+ databases={databases}+ bookmarks={bookmarks}+ createBookmark={createBookmark}+ deleteBookmark={deleteBookmark}+ onCopy={onCopy}+ onMove={onMove}+ onToggleSelected={onToggleSelected}+ onClick={onClick}+ visibleColumnsMap={visibleColumnsMap}+ />+ )}</Table>);};diff --git a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.unit.spec.tsx b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.unit.spec.tsxindex c41d19db48f..19bd53c51df 100644--- a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.unit.spec.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTable/BaseItemsTable.unit.spec.tsx@@ -2,8 +2,12 @@ import userEvent from "@testing-library/user-event";import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";import { mockSettings } from "__support__/settings";-import { getIcon, renderWithProviders, screen } from "__support__/ui";-import { DEFAULT_VISIBLE_COLUMNS_LIST } from "metabase/common/collections/columns";+import { getIcon, renderWithProviders, screen, within } from "__support__/ui";+import {+ COLLECTION_CONTENT_COLUMNS,+ type CollectionContentTableColumn,+ DEFAULT_VISIBLE_COLUMNS_LIST,+} from "metabase/common/collections/columns";import { getVisibleColumnsMap } from "metabase/common/components/ItemsTable/utils";import type { ItemWithLastEditInfo } from "metabase/common/components/LastEditInfoLabel/LastEditInfoLabel";import { dayjs } from "metabase/dayjs";@@ -194,4 +198,73 @@ describe("BaseItemsTable", () => {expect(tooltip).toHaveTextContent("important text");});});++ it("renders the header in the order of COLLECTION_CONTENT_COLUMNS, which the skeleton rows follow", () => {+ const HEADER_LABELS: Record<CollectionContentTableColumn, string> = {+ type: "Type",+ name: "Name",+ description: "Description",+ lastEditedBy: "Last edited by",+ lastEditedAt: "Last edited at",+ actionMenu: "",+ archive: "",+ };+ setup({+ items: [],+ visibleColumnsMap: getVisibleColumnsMap([...COLLECTION_CONTENT_COLUMNS]),+ });++ const headerCells = within(+ screen.getByTestId("items-table-head"),+ ).getAllByRole("columnheader");+ // The last header cell is the table's right edge, not a column.+ const columnLabels = headerCells+ .slice(0, -1)+ .map((cell) => cell.textContent);++ expect(columnLabels).toEqual(+ COLLECTION_CONTENT_COLUMNS.map((column) => HEADER_LABELS[column]),+ );+ });++ describe("skeleton", () => {+ const selectableProps: Partial<BaseItemsTableProps> = {+ collection: createMockCollection({ can_write: true }),+ onToggleSelected: jest.fn<void, [CollectionItem]>(),+ };++ it.each([+ { description: "when items can be selected", props: selectableProps },+ { description: "when items can't be selected", props: {} },+ ])(+ "renders one placeholder cell per header cell $description",+ ({ props }) => {+ setup({ withSkeleton: true, items: [], ...props });++ const headerCells = within(+ screen.getByTestId("items-table-head"),+ ).getAllByRole("columnheader");+ // The placeholder rows are hidden from assistive technology.+ const rows = within(+ screen.getByTestId("items-table-skeleton"),+ ).getAllByRole("row", { hidden: true });++ expect(rows.length).toBeGreaterThan(0);+ rows.forEach((row) => {+ expect(+ within(row).getAllByRole("cell", { hidden: true }),+ ).toHaveLength(headerCells.length);+ });+ },+ );++ it("does not render the select all checkbox", () => {+ setup({ withSkeleton: true, items: [], ...selectableProps });++ expect(screen.getByTestId("items-table-skeleton")).toBeInTheDocument();+ expect(+ screen.queryByLabelText("Select all items"),+ ).not.toBeInTheDocument();+ });+ });});diff --git a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.module.css b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.module.cssnew file mode 100644index 00000000000..a45637d69da--- /dev/null+++ b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.module.css@@ -0,0 +1,9 @@+/* Placeholder rows aren't interactive, so they drop the hover styles the real rows get */+tr.row:hover td {+ background-color: var(--mb-color-background_page-primary);+}++tr.row:hover td,+tr.row:hover td * {+ cursor: default;+}diff --git a/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.tsx b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.tsxnew file mode 100644index 00000000000..f7feab3cda6--- /dev/null+++ b/frontend/src/metabase/common/components/ItemsTable/BaseItemsTableBody/SkeletonItemsTableBody.tsx@@ -0,0 +1,87 @@+import {+ COLLECTION_CONTENT_COLUMNS,+ type CollectionContentTableColumn,+} from "metabase/common/collections/columns";+import type { BaseItemsTableProps } from "metabase/common/components/ItemsTable/BaseItemsTable";+import { Box, Repeat, Skeleton } from "metabase/ui";++import { ITEM_ROW_HEIGHT } from "../BaseItemTableRow";+import { Columns } from "../Columns";+import { EntityIconCheckBoxSkeleton } from "../EntityIconCheckBox";+import { ItemCell, ItemNameCell, TBody } from "../TableElements";+import { COLUMN_RESPONSIVE_PROPS } from "../column-layout";++import S from "./SkeletonItemsTableBody.module.css";++const SKELETON_ROW_COUNT = 7;++const SkeletonText = () => <Skeleton natural h="1rem" />;++const SkeletonIconCell = () => (+ <ItemCell>+ <EntityIconCheckBoxSkeleton />+ </ItemCell>+);++const SKELETON_CELLS = {+ type: SkeletonIconCell,+ name: () => (+ <ItemNameCell>+ <Box>+ <SkeletonText />+ </Box>+ </ItemNameCell>+ ),+ description: () => (+ <ItemCell {...COLUMN_RESPONSIVE_PROPS.description}>+ <SkeletonText />+ </ItemCell>+ ),+ lastEditedBy: () => (+ <ItemCell {...COLUMN_RESPONSIVE_PROPS.lastEditedBy}>+ <SkeletonText />+ </ItemCell>+ ),+ lastEditedAt: () => (+ <ItemCell {...COLUMN_RESPONSIVE_PROPS.lastEditedAt}>+ <SkeletonText />+ </ItemCell>+ ),+ actionMenu: () => <ItemCell />,+ archive: () => <ItemCell />,+} satisfies Record<CollectionContentTableColumn, () => JSX.Element>;++type SkeletonItemsTableBodyProps = Pick<+ BaseItemsTableProps,+ "visibleColumnsMap"+> & {+ canSelect: boolean;+};++/**+ * Placeholder rows shown while the items are loading. The cells follow the+ * order of `COLLECTION_CONTENT_COLUMNS`, which has to match the table header.+ */+export const SkeletonItemsTableBody = ({+ canSelect,+ visibleColumnsMap,+}: SkeletonItemsTableBodyProps) => {+ const visibleColumns = COLLECTION_CONTENT_COLUMNS.filter(+ (column) => visibleColumnsMap[column],+ );++ return (+ <TBody aria-hidden data-testid="items-table-skeleton">+ <Repeat times={SKELETON_ROW_COUNT}>+ <tr className={S.row} style={{ height: ITEM_ROW_HEIGHT }}>+ {canSelect && <SkeletonIconCell />}+ {visibleColumns.map((column) => {+ const SkeletonCell = SKELETON_CELLS[column];+ return <SkeletonCell key={column} />;+ })}+ <Columns.RightEdge.Cell />+ </tr>+ </Repeat>+ </TBody>+ );+};diff --git a/frontend/src/metabase/common/components/ItemsTable/Columns.tsx b/frontend/src/metabase/common/components/ItemsTable/Columns.tsxindex 5207c18a30e..7b22ba966f3 100644--- a/frontend/src/metabase/common/components/ItemsTable/Columns.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/Columns.tsx@@ -41,6 +41,7 @@ import {ItemNameCell,TableColumn,} from "./TableElements";+import { COLUMN_RESPONSIVE_PROPS } from "./column-layout";type HeaderProps = Omit<SortableColumnHeaderProps<ListCollectionItemsSortColumn>,@@ -229,12 +230,12 @@ export const Columns = {},},Description: {- Col: () => <TableColumn hideAtContainerBreakpoint="sm" />,+ Col: () => <TableColumn {...COLUMN_RESPONSIVE_PROPS.description} />,Header: ({ sortingOptions, onSortingOptionsChange }: HeaderProps) => (<SortableColumnHeadername="description"sortingOptions={sortingOptions}- hideAtContainerBreakpoint="sm"+ {...COLUMN_RESPONSIVE_PROPS.description}onSortingOptionsChange={onSortingOptionsChange}>{t`Description`}@@ -251,7 +252,10 @@ export const Columns = {const tc = useTranslateContent();return (- <ItemCell data-testid={`${testIdPrefix}-description`}>+ <ItemCell+ data-testid={`${testIdPrefix}-description`}+ {...COLUMN_RESPONSIVE_PROPS.description}+ ><Ellipsified>{tc(item.description) ?? ""}</Ellipsified></ItemCell>);@@ -259,7 +263,10 @@ export const Columns = {},LastEditedBy: {Col: () => (- <TableColumn style={{ width: "140px" }} hideAtContainerBreakpoint="sm" />+ <TableColumn+ style={{ width: "140px" }}+ {...COLUMN_RESPONSIVE_PROPS.lastEditedBy}+ />),Header: ({sortingOptions,@@ -272,7 +279,7 @@ export const Columns = {name="last_edited_by"sortingOptions={sortingOptions}onSortingOptionsChange={onSortingOptionsChange}- hideAtContainerBreakpoint="sm"+ {...COLUMN_RESPONSIVE_PROPS.lastEditedBy}>{isTrashed? c("Precedes the name of a user").t`Deleted by`@@ -292,7 +299,7 @@ export const Columns = {return (<ItemCelldata-testid={`${testIdPrefix}-last-edited-by`}- hideAtContainerBreakpoint="sm"+ {...COLUMN_RESPONSIVE_PROPS.lastEditedBy}><Ellipsified>{lastEditedBy}</Ellipsified></ItemCell>@@ -301,7 +308,10 @@ export const Columns = {},LastEditedAt: {Col: () => (- <TableColumn style={{ width: "140px" }} hideAtContainerBreakpoint="md" />+ <TableColumn+ style={{ width: "140px" }}+ {...COLUMN_RESPONSIVE_PROPS.lastEditedAt}+ />),Header: ({sortingOptions,@@ -314,7 +324,7 @@ export const Columns = {name="last_edited_at"sortingOptions={sortingOptions}onSortingOptionsChange={onSortingOptionsChange}- hideAtContainerBreakpoint="md"+ {...COLUMN_RESPONSIVE_PROPS.lastEditedAt}>{isTrashed? c("Time which the item was deleted").t`Deleted at`@@ -333,7 +343,7 @@ export const Columns = {<ItemCelldata-testid={`${testIdPrefix}-last-edited-at`}data-server-date- hideAtContainerBreakpoint="md"+ {...COLUMN_RESPONSIVE_PROPS.lastEditedAt}>{lastEditInfo && (<Tooltip label={<DateTime value={lastEditInfo.timestamp} />}>diff --git a/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.module.css b/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.module.cssindex da58b4b5d8b..ea59c28446f 100644--- a/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.module.css+++ b/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.module.css@@ -1,10 +1,13 @@-.iconWrapper {+.iconSlot {padding: 0.75rem;+ width: 3em;+ height: 3em;+}++.iconWrapper {background-color: transparent;cursor: pointer;color: var(--mb-color-core-brand);- width: 3em;- height: 3em;&.pinned {color: var(--mb-color-accent4);diff --git a/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.tsx b/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.tsxindex 3c6bae0aca7..218530ff528 100644--- a/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/EntityIconCheckBox.tsx@@ -5,10 +5,12 @@ import { IconButtonWrapper } from "metabase/common/components/IconButtonWrapper"import { Swapper } from "metabase/common/components/Swapper";import type { IconData } from "metabase/common/utils/icon";import CS from "metabase/css/core/index.css";-import { Checkbox, type IconProps } from "metabase/ui";+import { Center, Checkbox, type IconProps, Skeleton } from "metabase/ui";import S from "./EntityIconCheckBox.module.css";+const LIST_ICON_SIZE = 16;+type EntityIconCheckBoxProps = {variant?: "list" | "small";icon: IconProps | IconData;@@ -30,7 +32,7 @@ export const EntityIconCheckBox = ({onToggleSelected,}: EntityIconCheckBoxProps) => {const isSmall = variant === "small";- const iconSize = isSmall ? 12 : 16;+ const iconSize = isSmall ? 12 : LIST_ICON_SIZE;const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {e.preventDefault();onToggleSelected?.();@@ -40,7 +42,7 @@ export const EntityIconCheckBox = ({return (<IconButtonWrapper- className={cx(S.iconWrapper, {+ className={cx(S.iconSlot, S.iconWrapper, {[S.pinned]: pinned,[S.disabled]: disabled,})}@@ -71,3 +73,9 @@ export const EntityIconCheckBox = ({</IconButtonWrapper>);};++export const EntityIconCheckBoxSkeleton = () => (+ <Center className={S.iconSlot}>+ <Skeleton h={LIST_ICON_SIZE} w={LIST_ICON_SIZE} />+ </Center>+);diff --git a/frontend/src/metabase/common/components/ItemsTable/ItemsTable.tsx b/frontend/src/metabase/common/components/ItemsTable/ItemsTable.tsxindex 41875c84983..5b84503f26e 100644--- a/frontend/src/metabase/common/components/ItemsTable/ItemsTable.tsx+++ b/frontend/src/metabase/common/components/ItemsTable/ItemsTable.tsx@@ -1,8 +1,10 @@import cx from "classnames";+import { t } from "ttag";import PinDropZone from "metabase/common/collections/components/PinDropZone";import type { ItemRendererProps } from "metabase/common/components/ItemsTable/DefaultItemRenderer";import CS from "metabase/css/core/index.css";+import visuallyHidden from "metabase/css/core/visually-hidden.module.css";import { Flex } from "metabase/ui";import type { CollectionItem } from "metabase-types/api";@@ -28,12 +30,13 @@ const Item = ({export const ItemsTable = ({items,ItemComponent = Item,+ withSkeleton = false,...props}: {items: CollectionItem[];ItemComponent?: (props: ItemRendererProps) => JSX.Element;} & BaseItemsTableProps) => {- if (items.length === 0) {+ if (items.length === 0 && !withSkeleton) {return (<Flex pos="relative" justify="center" align="center" m="lg" p="4rem"><PinDropZone variant="unpin" />@@ -42,9 +45,22 @@ export const ItemsTable = ({}return (- <div className={cx(CS.relative, S.container)}>+ <div+ className={cx(CS.relative, S.container)}+ aria-busy={withSkeleton || undefined}+ >+ {withSkeleton && (+ <span role="status" className={visuallyHidden.visuallyHidden}>+ {t`Loading…`}+ </span>+ )}<PinDropZone variant="unpin" />- <BaseItemsTable items={items} {...props} ItemComponent={ItemComponent} />+ <BaseItemsTable+ items={items}+ withSkeleton={withSkeleton}+ {...props}+ ItemComponent={ItemComponent}+ /></div>);};diff --git a/frontend/src/metabase/common/components/ItemsTable/column-layout.ts b/frontend/src/metabase/common/components/ItemsTable/column-layout.tsnew file mode 100644index 00000000000..7f5ae5ebc17--- /dev/null+++ b/frontend/src/metabase/common/components/ItemsTable/column-layout.ts@@ -0,0 +1,13 @@+import type { CollectionContentTableColumn } from "metabase/common/collections/columns";++import type { ResponsiveProps } from "./utils";++export const COLUMN_RESPONSIVE_PROPS = {+ type: {},+ name: {},+ description: { hideAtContainerBreakpoint: "sm" },+ lastEditedBy: { hideAtContainerBreakpoint: "sm" },+ lastEditedAt: { hideAtContainerBreakpoint: "md" },+ actionMenu: {},+ archive: {},+} satisfies Record<CollectionContentTableColumn, ResponsiveProps>;