Skip to content

Commit

Permalink
Let user of DataTable control if table is responsive (Graylog2#4633)
Browse files Browse the repository at this point in the history
Responsive tables may clip dropdowns or other elements that overflow the
container vertically, so this may not be something we want to use
everywhere. The `useResponsiveTable` prop let us disable the responsive
styles if we display dropdowns inside the table.

More information on `table-responsive`:
https://getbootstrap.com/docs/3.3/css/#tables-responsive
  • Loading branch information
edmundoa authored and Marius Sturm committed Mar 2, 2018
1 parent d400729 commit 8d19af2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions graylog2-web-interface/src/components/common/DataTable.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import DataTableElement from './DataTableElement';
import { TypeAheadDataFilter } from 'components/common';
import DataTableElement from './DataTableElement';

/**
* Component that renders a data table, letting consumers of the component to
Expand Down Expand Up @@ -46,13 +46,21 @@ const DataTable = React.createClass({
rows: PropTypes.array.isRequired,
/** Object key to use to sort data table. */
sortByKey: PropTypes.string,
/**
* Indicates whether the table should use a bootstrap responsive table or not:
* https://getbootstrap.com/docs/3.3/css/#tables-responsive
*
* The main reason to disable this is if the table is clipping a dropdown menu or another component in a table edge.
*/
useResponsiveTable: PropTypes.bool,
},
getDefaultProps() {
return {
filterSuggestions: [],
displayKey: 'value',
noDataText: 'No data available.',
rowClassName: '',
useResponsiveTable: true,
};
},
getInitialState() {
Expand Down Expand Up @@ -143,7 +151,7 @@ const DataTable = React.createClass({
{filter}
<div className={`row ${this.props.rowClassName}`}>
<div className="col-md-12">
<div id={this.props.id} className="data-table table-responsive">
<div id={this.props.id} className={`data-table ${this.props.useResponsiveTable ? 'table-responsive' : ''}`}>
{data}
</div>
</div>
Expand Down

0 comments on commit 8d19af2

Please sign in to comment.