remove width attr from DataColumn, move styles to data-explorer
[arvados-workbench2.git] / src / components / data-table / data-table.tsx
index 5a6f9e5a5b5337abce7b07d738206cbd84d56c78..1d208d7590536f93412fbb564fcb27cd62e939d9 100644 (file)
@@ -20,7 +20,7 @@ export interface DataTableDataProps<T> {
     extractKey?: (item: T) => React.Key;
 }
 
-type CssRules = "tableBody" | "tableContainer" | "noItemsInfo";
+type CssRules = "tableBody" | "tableContainer" | "noItemsInfo" | 'tableCell';
 
 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
     tableContainer: {
@@ -33,6 +33,9 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
     noItemsInfo: {
         textAlign: "center",
         padding: theme.spacing.unit
+    },
+    tableCell: {
+        wordWrap: 'break-word'
     }
 });
 
@@ -60,7 +63,7 @@ export const DataTable = withStyles(styles)(
         renderHeadCell = (column: DataColumn<T>, index: number) => {
             const { name, key, renderHeader, filters, sortDirection } = column;
             const { onSortToggle, onFiltersChange } = this.props;
-            return <TableCell key={key || index} style={{ width: column.width, minWidth: column.width }}>
+            return <TableCell key={key || index}>
                 {renderHeader ?
                     renderHeader() :
                     filters.length > 0
@@ -88,7 +91,7 @@ export const DataTable = withStyles(styles)(
         }
 
         renderBodyRow = (item: T, index: number) => {
-            const { onRowClick, onRowDoubleClick, extractKey } = this.props;
+            const { onRowClick, onRowDoubleClick, extractKey, classes } = this.props;
             return <TableRow
                 hover
                 key={extractKey ? extractKey(item) : index}
@@ -96,7 +99,7 @@ export const DataTable = withStyles(styles)(
                 onContextMenu={this.handleRowContextMenu(item)}
                 onDoubleClick={event => onRowDoubleClick && onRowDoubleClick(event, item) }>
                 {this.mapVisibleColumns((column, index) => (
-                    <TableCell key={column.key || index}>
+                    <TableCell key={column.key || index} className={classes.tableCell}>
                         {column.render(item)}
                     </TableCell>
                 ))}