X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1cc633c7a6ad9609424580973da06c92839489e2..1a9eb2261e6030ba78078e2a206bad27653f2475:/src/components/data-table/data-table.tsx

diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index ec260e96..43efdd0a 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -3,12 +3,14 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Table, TableBody, TableRow, TableCell, TableHead, StyleRulesCallback, Theme, WithStyles, withStyles, Typography } from '@material-ui/core';
+import { Table, TableBody, TableRow, TableCell, TableHead, TableSortLabel, StyleRulesCallback, Theme, WithStyles, withStyles, Typography } from '@material-ui/core';
 import { DataColumn } from './data-column';
 
+export type DataColumns<T> = Array<DataColumn<T>>;
+
 export interface DataTableProps<T> {
     items: T[];
-    columns: Array<DataColumn<T>>;
+    columns: DataColumns<T>;
     onRowClick?: (event: React.MouseEvent<HTMLTableRowElement>, item: T) => void;
     onRowContextMenu?: (event: React.MouseEvent<HTMLTableRowElement>, item: T) => void;
 }
@@ -23,9 +25,16 @@ class DataTable<T> extends React.Component<DataTableProps<T> & WithStyles<CssRul
                         <TableRow>
                             {columns
                                 .filter(column => column.selected)
-                                .map(({ name, renderHeader, key }, index) =>
+                                .map(({ name, renderHeader, key, sortDirection, onSortToggle }, index) =>
                                     <TableCell key={key || index}>
-                                        {renderHeader ? renderHeader() : name}
+                                        {renderHeader ?
+                                            renderHeader() :
+                                            <TableSortLabel
+                                                active={!!sortDirection}
+                                                direction={sortDirection}
+                                                onClick={() => onSortToggle && onSortToggle()}>
+                                                {name}
+                                            </TableSortLabel>}
                                     </TableCell>
                                 )}
                         </TableRow>
@@ -48,7 +57,7 @@ class DataTable<T> extends React.Component<DataTableProps<T> & WithStyles<CssRul
                                 </TableRow>
                             )}
                     </TableBody>
-                </Table> : <Typography 
+                </Table> : <Typography
                     className={classes.noItemsInfo}
                     variant="body2"
                     gutterBottom>
