1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export interface DataColumn<T> {
8 configurable?: boolean;
10 sortDirection?: SortDirection;
11 onSortToggle?: () => void;
12 render: (item: T) => React.ReactElement<void>;
13 renderHeader?: () => React.ReactElement<void> | null;
16 export type SortDirection = "asc" | "desc";
18 export const isColumnConfigurable = <T>(column: DataColumn<T>) => {
19 return column.configurable === undefined || column.configurable;
22 export const toggleSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
23 const sortDirection = column.sortDirection === undefined || column.sortDirection === "desc" ? "asc" : "desc";
24 return { ...column, sortDirection };
27 export const resetSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
28 return { ...column, sortDirection: undefined };