Files
weave-scope/client/app/scripts/utils/node-details-utils.js
Filip Barl d3466b5454 Refactored the table component/model and wrote the tests
Backward-compatibility fix
2017-01-16 17:05:36 +01:00

37 lines
1.1 KiB
JavaScript

import { NODE_DETAILS_TABLE_COLUMN_WIDTHS } from '../constants/styles';
export function isGenericTable(table) {
return (table.type || (table.get && table.get('type'))) === 'multicolumn-table';
}
export function isPropertyList(table) {
return (table.type || (table.get && table.get('type'))) === 'property-list';
}
export function isNumber(data) {
return data && data.dataType && data.dataType === 'number';
}
export function isIP(data) {
return data && data.dataType && data.dataType === 'ip';
}
export function genericTableEntryKey(row, column) {
const columnId = column.id || column.get('id');
const rowId = row.id || row.get('id');
return `${rowId}_${columnId}`;
}
export function defaultSortDesc(header) {
return header && isNumber(header);
}
export function getTableColumnsStyles(headers) {
return headers.map(header => ({
// More beauty hacking, ports and counts can only get
// so big, free up WS for other longer fields like IPs!
width: NODE_DETAILS_TABLE_COLUMN_WIDTHS[header.id],
textAlign: isNumber(header) ? 'right' : 'left'
}));
}