diff --git a/client/app/scripts/utils/__tests__/search-utils-test.js b/client/app/scripts/utils/__tests__/search-utils-test.js index 1596e3d626..278cff1b73 100644 --- a/client/app/scripts/utils/__tests__/search-utils-test.js +++ b/client/app/scripts/utils/__tests__/search-utils-test.js @@ -29,17 +29,50 @@ describe('SearchUtils', () => { }], tables: [{ id: 'metric1', + type: 'property-list', rows: [{ + id: 'label1', entries: { - id: 'row1', - label: 'Row 1', - value: 'Row Value 1' + label: 'Label 1', + value: 'Label Value 1' } }, { + id: 'label2', entries: { - id: 'row2', - label: 'Row 2', - value: 'Row Value 2' + label: 'Label 2', + value: 'Label Value 2' + } + }] + }, { + id: 'metric2', + type: 'multicolumn-table', + columns: [{ + id: 'a', + label: 'A' + }, { + id: 'c', + label: 'C' + }], + rows: [{ + id: 'row1', + entries: { + a: 'xxxa', + b: 'yyya', + c: 'zzz1' + } + }, { + id: 'row2', + entries: { + a: 'yyyb', + b: 'xxxb', + c: 'zzz2' + } + }, { + id: 'row3', + entries: { + a: 'Value 1', + b: 'Value 2', + c: 'Value 3' } }] }], @@ -80,7 +113,7 @@ describe('SearchUtils', () => { it('should filter nodes that do not match a pinned searches', () => { let nextState = fromJS({ nodes: nodeSets.someNodes, - pinnedSearches: ['row'] + pinnedSearches: ['Label Value 1'] }); nextState = fun(nextState); expect(nextState.get('nodes').filter(node => node.get('filtered')).size).toEqual(1); @@ -244,11 +277,31 @@ describe('SearchUtils', () => { expect(matches.getIn(['n1', 'metrics', 'metric1']).metric).toBeTruthy(); }); - it('should match on a tables field', () => { + it('should match on a property list value', () => { const nodes = nodeSets.someNodes; - const matches = fun(nodes, {query: 'Row Value 1'}); - expect(matches.size).toEqual(1); - expect(matches.getIn(['n2', 'tables', 'row1']).text).toBe('Row Value 1'); + const matches = fun(nodes, {query: 'Value 1'}); + expect(matches.size).toEqual(2); + expect(matches.getIn(['n2', 'labels']).size).toEqual(1); + expect(matches.getIn(['n2', 'labels', 'label1']).text).toBe('Label Value 1'); + }); + + it('should match on a generic table values', () => { + const nodes = nodeSets.someNodes; + const matches1 = fun(nodes, {query: 'xx'}).getIn(['n2', 'tables']); + const matches2 = fun(nodes, {query: 'yy'}).getIn(['n2', 'tables']); + const matches3 = fun(nodes, {query: 'zz'}).getIn(['n2', 'tables']); + const matches4 = fun(nodes, {query: 'a'}).getIn(['n2', 'tables']); + expect(matches1.size).toEqual(1); + expect(matches2.size).toEqual(1); + expect(matches3.size).toEqual(2); + expect(matches4.size).toEqual(3); + expect(matches1.get('row1_a').text).toBe('xxxa'); + expect(matches2.get('row2_a').text).toBe('yyyb'); + expect(matches3.get('row1_c').text).toBe('zzz1'); + expect(matches3.get('row2_c').text).toBe('zzz2'); + expect(matches4.get('row1_a').text).toBe('xxxa'); + expect(matches4.get('row3_a').text).toBe('Value 1'); + expect(matches4.get('row3_c').text).toBe('Value 3'); }); }); diff --git a/probe/overlay/weave.go b/probe/overlay/weave.go index fde8ccf869..fa404b7a8b 100644 --- a/probe/overlay/weave.go +++ b/probe/overlay/weave.go @@ -127,15 +127,15 @@ var ( Type: report.MulticolumnTableType, Prefix: WeaveConnectionsMulticolumnTablePrefix, Columns: []report.Column{ - report.Column{ + { ID: WeaveConnectionsConnection, Label: "Connections", }, - report.Column{ + { ID: WeaveConnectionsState, Label: "State", }, - report.Column{ + { ID: WeaveConnectionsInfo, Label: "Info", }, diff --git a/report/table.go b/report/table.go index e8e0f8297e..487c39c03b 100644 --- a/report/table.go +++ b/report/table.go @@ -117,12 +117,14 @@ func (node Node) ExtractTable(template TableTemplate) (rows []Row, truncationCou return rows, truncationCount } +// Column is the type for multi-column tables in the UI. type Column struct { ID string `json:"id"` Label string `json:"label"` DataType string `json:"dataType"` } +// Row is the type that holds the table data for the UI. type Row struct { ID string `json:"id"` Entries map[string]string `json:"entries"`