Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show table overflow only if limit exceeded by 2+ #2683

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class NodeDetailsTable extends React.Component {
super(props, context);

this.state = {
limit: props.limit || NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT,
limit: props.limit,
sortedDesc: this.props.sortedDesc,
sortedBy: this.props.sortedBy
};
Expand All @@ -155,7 +155,7 @@ class NodeDetailsTable extends React.Component {
}

handleLimitClick() {
const limit = this.state.limit ? 0 : NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT;
const limit = this.state.limit ? 0 : this.props.limit;
this.setState({ limit });
}

Expand Down Expand Up @@ -226,11 +226,16 @@ class NodeDetailsTable extends React.Component {
}
}

const limited = nodes && this.state.limit > 0 && nodes.length > this.state.limit;
const expanded = this.state.limit === 0;
const notShown = nodes.length - this.state.limit;
// If we are 1 over the limit, we still show the row. We never display
// "+1" but only "+2" and up.
const limit = this.state.limit > 0 && nodes.length === this.state.limit + 1
? nodes.length
: this.state.limit;
const limited = nodes && limit > 0 && nodes.length > limit;
const expanded = limit === 0;
const notShown = nodes.length - limit;
if (nodes && limited) {
nodes = nodes.slice(0, this.state.limit);
nodes = nodes.slice(0, limit);
}

const className = classNames('node-details-table-wrapper-wrapper', this.props.className);
Expand Down Expand Up @@ -287,6 +292,7 @@ class NodeDetailsTable extends React.Component {

NodeDetailsTable.defaultProps = {
nodeIdKey: 'id', // key to identify a node in a row (used for topology links)
limit: NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT,
onSortChange: () => {},
sortedDesc: null,
sortedBy: null,
Expand Down