mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 19:21:46 +00:00
Extracted table headers common code on the frontend Fixed the search matching and extracted further common code in the UI
37 lines
1.0 KiB
JavaScript
37 lines
1.0 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.dataType && data.dataType === 'number';
|
|
}
|
|
|
|
export function isIP(data) {
|
|
return 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'
|
|
}));
|
|
}
|