mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
table-mode: handle nodes w/ no value for sorted column gracefully
- put empty values below those that have a value. +-----+-----+ |3 |5 | |4 |4 | |5 |3 | |null |null | |null |null | +-----+-----+
This commit is contained in:
@@ -87,7 +87,7 @@ function getMetaDataSorters(nodes) {
|
||||
}
|
||||
|
||||
|
||||
function getSortedNodes(nodes, columns, sortBy, sortedDesc) {
|
||||
function sortNodes(nodes, columns, sortBy, sortedDesc) {
|
||||
const sortedNodes = _.sortBy(
|
||||
nodes,
|
||||
getValueForSortBy(sortBy || getDefaultSortBy(columns, nodes)),
|
||||
@@ -101,6 +101,19 @@ function getSortedNodes(nodes, columns, sortBy, sortedDesc) {
|
||||
}
|
||||
|
||||
|
||||
function getSortedNodes(nodes, columns, sortBy, sortedDesc) {
|
||||
const getValue = getValueForSortBy(sortBy || getDefaultSortBy(columns, nodes));
|
||||
const withAndWithoutValues = _.groupBy(nodes, (n) => {
|
||||
const v = getValue(n);
|
||||
return v !== null && v !== undefined;
|
||||
});
|
||||
const withValues = sortNodes(withAndWithoutValues.true, columns, sortBy, sortedDesc);
|
||||
const withoutValues = sortNodes(withAndWithoutValues.false, columns, sortBy, sortedDesc);
|
||||
|
||||
return _.concat(withValues, withoutValues);
|
||||
}
|
||||
|
||||
|
||||
function getColumnsWidths(headers) {
|
||||
return headers.map((h, i) => {
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user