forked from linkerd/linkerd2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove toggle sorting functionality from TableComponent (linkerd#630)
remove toggle sorting functionality from TableComponent: - tables displaying metrics allowed to toggle between being sorted and unsorted when clicking the same button. This was confusing behavior for the user. - this PR removes the toggle functionality and introduces a BaseTable Component that extends antd's component without the capability to toggle - Fixes: linkerd#566 Signed-off-by: Franziska von der Goltz <franziska@vdgoltz.eu>
- Loading branch information
1 parent
c688cf6
commit 67fac9d
Showing
2 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Table } from 'antd'; | ||
|
||
// BaseTable extends ant-design's table, but overwrites the `toggleSortOrder` | ||
// method, in order to remove the default behavior of unsorting a column when | ||
// the same sorting arrow is pressed twice: | ||
// https://github.com/ant-design/ant-design/blob/master/components/table/Table.tsx#L348 | ||
export default class BaseTable extends Table { | ||
constructor(props) { | ||
super(props); | ||
Table.prototype.toggleSortOrder = this.toggleSortOrder; | ||
} | ||
|
||
toggleSortOrder(order, column) { | ||
const newState = { | ||
sortOrder: order, | ||
sortColumn: column, | ||
}; | ||
|
||
if (this.getSortOrderColumns().length === 0) { | ||
this.setState(newState); | ||
} | ||
|
||
const onChange = this.props.onChange; | ||
if (onChange) { | ||
onChange.apply(null, this.prepareParamsArguments({ | ||
...this.state, | ||
...newState, | ||
})); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters