From 58922730f54711967c9c707c710cd04249de781e Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Tue, 17 Oct 2017 11:27:16 +0200 Subject: [PATCH] Fixed function-paren-newline. --- .../charts/__tests__/nodes-layout-test.js | 21 ++++--- client/app/scripts/charts/edge-container.js | 11 +++- .../scripts/charts/nodes-chart-elements.js | 4 +- .../components/__tests__/node-details-test.js | 26 ++++----- client/app/scripts/components/app.js | 4 +- .../app/scripts/components/debug-toolbar.js | 4 +- client/app/scripts/components/details.js | 4 +- client/app/scripts/components/dev-tools.js | 14 ++--- .../scripts/components/embedded-terminal.js | 4 +- .../__tests__/node-details-table-test.js | 35 +++++------- .../node-details-generic-table.js | 3 +- .../node-details/node-details-table-row.js | 3 +- .../nodes-resources/node-resources-layer.js | 4 +- client/app/scripts/components/nodes.js | 4 +- client/app/scripts/components/plugins.js | 4 +- client/app/scripts/components/status.js | 4 +- client/app/scripts/components/terminal-app.js | 6 +- client/app/scripts/components/terminal.js | 7 ++- client/app/scripts/components/topologies.js | 5 +- .../scripts/components/topology-options.js | 3 +- .../scripts/components/view-mode-selector.js | 6 +- client/app/scripts/main.dev.js | 14 +++-- client/app/scripts/main.js | 12 ++-- client/app/scripts/reducers/root.js | 42 +++++++++----- .../scripts/selectors/resource-view/layout.js | 4 +- client/app/scripts/terminal-main.js | 12 ++-- .../utils/__tests__/search-utils-test.js | 54 ++++++++++++------ .../utils/__tests__/topology-utils-test.js | 9 ++- client/app/scripts/utils/array-utils.js | 3 +- client/app/scripts/utils/file-utils.js | 3 +- client/app/scripts/utils/search-utils.js | 57 ++++++++++++------- client/app/scripts/utils/web-api-utils.js | 22 ++++--- client/server.js | 6 +- 33 files changed, 230 insertions(+), 184 deletions(-) diff --git a/client/app/scripts/charts/__tests__/nodes-layout-test.js b/client/app/scripts/charts/__tests__/nodes-layout-test.js index ab21cee23..ddf83d182 100644 --- a/client/app/scripts/charts/__tests__/nodes-layout-test.js +++ b/client/app/scripts/charts/__tests__/nodes-layout-test.js @@ -184,7 +184,8 @@ describe('NodesLayout', () => { it('lays out initial nodeset in a rectangle', () => { const result = NodesLayout.doLayout( nodeSets.initial4.nodes, - nodeSets.initial4.edges); + nodeSets.initial4.edges + ); // console.log('initial', result.get('nodes')); nodes = result.nodes.toJS(); @@ -199,7 +200,8 @@ describe('NodesLayout', () => { it('keeps nodes in rectangle after removing one edge', () => { let result = NodesLayout.doLayout( nodeSets.initial4.nodes, - nodeSets.initial4.edges); + nodeSets.initial4.edges + ); options.cachedLayout = result; options.nodeCache = options.nodeCache.merge(result.nodes); @@ -221,7 +223,8 @@ describe('NodesLayout', () => { it('keeps nodes in rectangle after removed edge reappears', () => { let result = NodesLayout.doLayout( nodeSets.initial4.nodes, - nodeSets.initial4.edges); + nodeSets.initial4.edges + ); coords = getNodeCoordinates(result.nodes); options.cachedLayout = result; @@ -252,7 +255,8 @@ describe('NodesLayout', () => { it('keeps nodes in rectangle after node disappears', () => { let result = NodesLayout.doLayout( nodeSets.initial4.nodes, - nodeSets.initial4.edges); + nodeSets.initial4.edges + ); options.cachedLayout = result; options.nodeCache = options.nodeCache.merge(result.nodes); @@ -273,7 +277,8 @@ describe('NodesLayout', () => { it('keeps nodes in rectangle after removed node reappears', () => { let result = NodesLayout.doLayout( nodeSets.initial4.nodes, - nodeSets.initial4.edges); + nodeSets.initial4.edges + ); nodes = result.nodes.toJS(); @@ -313,7 +318,8 @@ describe('NodesLayout', () => { it('renders single nodes in a square', () => { const result = NodesLayout.doLayout( nodeSets.single3.nodes, - nodeSets.single3.edges); + nodeSets.single3.edges + ); nodes = result.nodes.toJS(); @@ -404,7 +410,8 @@ describe('NodesLayout', () => { expect(NodesLayout.hasNewNodesOfExistingRank( nodeSets.rank6.nodes, nodeSets.rank6.edges, - result.nodes)).toBeTruthy(); + result.nodes + )).toBeTruthy(); result = NodesLayout.doLayout( nodeSets.rank6.nodes, diff --git a/client/app/scripts/charts/edge-container.js b/client/app/scripts/charts/edge-container.js index 82f3a7a9f..8c9b5fb50 100644 --- a/client/app/scripts/charts/edge-container.js +++ b/client/app/scripts/charts/edge-container.js @@ -81,9 +81,14 @@ export default class EdgeContainer extends React.PureComponent { // For the Motion interpolation to work, the waypoints need to be in a map format like // { x0: 11, y0: 22, x1: 33, y1: 44 } that we convert to the array format when rendering. - {({ interpolatedThickness, ...interpolatedWaypoints}) => transformedEdge( - forwardedProps, waypointsMapToArray(fromJS(interpolatedWaypoints)), interpolatedThickness - )} + { + ({ interpolatedThickness, ...interpolatedWaypoints}) => + transformedEdge( + forwardedProps, + waypointsMapToArray(fromJS(interpolatedWaypoints)), + interpolatedThickness + ) + } ); } diff --git a/client/app/scripts/charts/nodes-chart-elements.js b/client/app/scripts/charts/nodes-chart-elements.js index 0c4e62280..9e279a833 100644 --- a/client/app/scripts/charts/nodes-chart-elements.js +++ b/client/app/scripts/charts/nodes-chart-elements.js @@ -277,6 +277,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(NodesChartElements); +export default connect(mapStateToProps)(NodesChartElements); diff --git a/client/app/scripts/components/__tests__/node-details-test.js b/client/app/scripts/components/__tests__/node-details-test.js index 66725fb66..ef6c795fb 100644 --- a/client/app/scripts/components/__tests__/node-details-test.js +++ b/client/app/scripts/components/__tests__/node-details-test.js @@ -19,28 +19,26 @@ describe('NodeDetails', () => { }); it('shows n/a when node was not found', () => { - const c = TestUtils.renderIntoDocument( - - - + const c = TestUtils.renderIntoDocument( + + ); + const notFound = TestUtils.findRenderedDOMComponentWithClass( + c, + 'node-details-header-notavailable' ); - const notFound = TestUtils.findRenderedDOMComponentWithClass(c, - 'node-details-header-notavailable'); expect(notFound).toBeDefined(); }); it('show label of node with title', () => { nodes = nodes.set(nodeId, Immutable.fromJS({id: nodeId})); details = {label: 'Node 1'}; - const c = TestUtils.renderIntoDocument( - - + - - ); + ); const title = TestUtils.findRenderedDOMComponentWithClass(c, 'node-details-header-label'); expect(title.title).toBe('Node 1'); diff --git a/client/app/scripts/components/app.js b/client/app/scripts/components/app.js index 8a6ebd167..6f8b6ee05 100644 --- a/client/app/scripts/components/app.js +++ b/client/app/scripts/components/app.js @@ -243,6 +243,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(App); +export default connect(mapStateToProps)(App); diff --git a/client/app/scripts/components/debug-toolbar.js b/client/app/scripts/components/debug-toolbar.js index baa321195..146641177 100644 --- a/client/app/scripts/components/debug-toolbar.js +++ b/client/app/scripts/components/debug-toolbar.js @@ -385,6 +385,4 @@ function mapStateToProps(state) { } -export default connect( - mapStateToProps -)(DebugToolbar); +export default connect(mapStateToProps)(DebugToolbar); diff --git a/client/app/scripts/components/details.js b/client/app/scripts/components/details.js index 553751062..130ffe1bb 100644 --- a/client/app/scripts/components/details.js +++ b/client/app/scripts/components/details.js @@ -27,6 +27,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(Details); +export default connect(mapStateToProps)(Details); diff --git a/client/app/scripts/components/dev-tools.js b/client/app/scripts/components/dev-tools.js index 2722a23a4..068839fd7 100644 --- a/client/app/scripts/components/dev-tools.js +++ b/client/app/scripts/components/dev-tools.js @@ -3,11 +3,9 @@ import { createDevTools } from 'redux-devtools'; import LogMonitor from 'redux-devtools-log-monitor'; import DockMonitor from 'redux-devtools-dock-monitor'; -export default createDevTools( - - - -); +export default createDevTools( + +); diff --git a/client/app/scripts/components/embedded-terminal.js b/client/app/scripts/components/embedded-terminal.js index 149d5998e..1d66a1991 100644 --- a/client/app/scripts/components/embedded-terminal.js +++ b/client/app/scripts/components/embedded-terminal.js @@ -70,6 +70,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(EmeddedTerminal); +export default connect(mapStateToProps)(EmeddedTerminal); diff --git a/client/app/scripts/components/node-details/__tests__/node-details-table-test.js b/client/app/scripts/components/node-details/__tests__/node-details-table-test.js index b024c95a0..1ac23263b 100644 --- a/client/app/scripts/components/node-details/__tests__/node-details-table-test.js +++ b/client/app/scripts/components/node-details/__tests__/node-details-table-test.js @@ -58,8 +58,7 @@ describe('NodeDetailsTable', () => { // form columnIndex + n * columns.length, where n >= 0. Therefore we take only the values // at the index which divided by columns.length gives a reminder columnIndex. const filteredValues = values.filter((element, index) => - index % columns.length === columnIndex - ); + index % columns.length === columnIndex); // Array comparison expect(filteredValues).toEqual(expectedValues); } @@ -72,16 +71,14 @@ describe('NodeDetailsTable', () => { describe('kubernetes_ip', () => { it('sorts by column', () => { - component = TestUtils.renderIntoDocument( - - + - - ); + ); matchColumnValues('kubernetes_ip', [ '10.44.253.255', @@ -108,16 +105,14 @@ describe('NodeDetailsTable', () => { describe('kubernetes_namespace', () => { it('sorts by column', () => { - component = TestUtils.renderIntoDocument( - - + - - ); + ); matchColumnValues('kubernetes_namespace', ['00000', '1111', '12', '5']); clickColumn('Namespace'); diff --git a/client/app/scripts/components/node-details/node-details-generic-table.js b/client/app/scripts/components/node-details/node-details-generic-table.js index 54e295ad8..d81d2d0f1 100644 --- a/client/app/scripts/components/node-details/node-details-generic-table.js +++ b/client/app/scripts/components/node-details/node-details-generic-table.js @@ -63,8 +63,7 @@ export default class NodeDetailsGenericTable extends React.Component { // expanded if any of them match the search query; otherwise hide them. if (this.state.limit > 0 && rows.length > this.state.limit) { const hasHiddenMatch = rows.slice(this.state.limit).some(row => - columns.some(column => matches.has(genericTableEntryKey(row, column))) - ); + columns.some(column => matches.has(genericTableEntryKey(row, column)))); if (!hasHiddenMatch) { notShown = rows.length - NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT; rows = rows.slice(0, this.state.limit); diff --git a/client/app/scripts/components/node-details/node-details-table-row.js b/client/app/scripts/components/node-details/node-details-table-row.js index cd9fca2a0..0e4e748f3 100644 --- a/client/app/scripts/components/node-details/node-details-table-row.js +++ b/client/app/scripts/components/node-details/node-details-table-row.js @@ -71,8 +71,7 @@ function renderValues(node, columns = [], columnStyles = [], timestamp = null, t linkable nodeId={relative.id} {...relative} - /> - ), ' ')} + />), ' ')} ); } diff --git a/client/app/scripts/components/nodes-resources/node-resources-layer.js b/client/app/scripts/components/nodes-resources/node-resources-layer.js index 2a369483e..cb4eacc63 100644 --- a/client/app/scripts/components/nodes-resources/node-resources-layer.js +++ b/client/app/scripts/components/nodes-resources/node-resources-layer.js @@ -50,6 +50,4 @@ function mapStateToProps(state, props) { }; } -export default connect( - mapStateToProps -)(NodesResourcesLayer); +export default connect(mapStateToProps)(NodesResourcesLayer); diff --git a/client/app/scripts/components/nodes.js b/client/app/scripts/components/nodes.js index 78b494534..591829c01 100644 --- a/client/app/scripts/components/nodes.js +++ b/client/app/scripts/components/nodes.js @@ -92,6 +92,4 @@ function mapStateToProps(state) { } -export default connect( - mapStateToProps -)(Nodes); +export default connect(mapStateToProps)(Nodes); diff --git a/client/app/scripts/components/plugins.js b/client/app/scripts/components/plugins.js index e673bc7d2..d5edd3d84 100644 --- a/client/app/scripts/components/plugins.js +++ b/client/app/scripts/components/plugins.js @@ -44,6 +44,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(Plugins); +export default connect(mapStateToProps)(Plugins); diff --git a/client/app/scripts/components/status.js b/client/app/scripts/components/status.js index 43c02b8da..3a0b11288 100644 --- a/client/app/scripts/components/status.js +++ b/client/app/scripts/components/status.js @@ -54,6 +54,4 @@ function mapStateToProps(state) { }; } -export default connect( - mapStateToProps -)(Status); +export default connect(mapStateToProps)(Status); diff --git a/client/app/scripts/components/terminal-app.js b/client/app/scripts/components/terminal-app.js index c3b00122c..f07b86d41 100644 --- a/client/app/scripts/components/terminal-app.js +++ b/client/app/scripts/components/terminal-app.js @@ -13,8 +13,10 @@ class TerminalApp extends React.Component { const paramString = window.location.hash.split('/').pop(); const params = JSON.parse(decodeURIComponent(paramString)); - this.props.receiveControlPipeFromParams(params.pipe.id, params.pipe.raw, - params.pipe.resizeTtyControl); + this.props.receiveControlPipeFromParams( + params.pipe.id, params.pipe.raw, + params.pipe.resizeTtyControl + ); this.state = { title: params.title, diff --git a/client/app/scripts/components/terminal.js b/client/app/scripts/components/terminal.js index 380a9ddb5..4b116652d 100644 --- a/client/app/scripts/components/terminal.js +++ b/client/app/scripts/components/terminal.js @@ -132,7 +132,9 @@ class Terminal extends React.Component { this.createWebsocket(term); } else { this.reconnectTimeout = setTimeout( - this.createWebsocket.bind(this, term), reconnectTimerInterval); + this.createWebsocket.bind(this, term), + reconnectTimerInterval + ); } } }; @@ -379,8 +381,7 @@ class Terminal extends React.Component { function mapStateToProps(state, ownProps) { const controlStatus = state.get('controlPipes').find(pipe => - pipe.get('nodeId') === ownProps.pipe.get('nodeId') - ); + pipe.get('nodeId') === ownProps.pipe.get('nodeId')); return { controlStatus }; } diff --git a/client/app/scripts/components/topologies.js b/client/app/scripts/components/topologies.js index 0d89befda..ad2605a8e 100644 --- a/client/app/scripts/components/topologies.js +++ b/client/app/scripts/components/topologies.js @@ -20,7 +20,6 @@ function basicTopologyInfo(topology, searchMatchCount) { } class Topologies extends React.Component { - constructor(props, context) { super(props, context); this.onTopologyClick = this.onTopologyClick.bind(this); @@ -88,9 +87,7 @@ class Topologies extends React.Component { render() { return (
- {this.props.currentTopology && this.props.topologies.map( - topology => this.renderTopology(topology) - )} + {this.props.currentTopology && this.props.topologies.map(t => this.renderTopology(t))}
); } diff --git a/client/app/scripts/components/topology-options.js b/client/app/scripts/components/topology-options.js index 68fe1549b..046eff2d6 100644 --- a/client/app/scripts/components/topology-options.js +++ b/client/app/scripts/components/topology-options.js @@ -129,8 +129,7 @@ class TopologyOptions extends React.Component { const { options } = this.props; return (
- {options && options.toIndexedSeq().map( - option => this.renderOption(option))} + {options && options.toIndexedSeq().map(option => this.renderOption(option))}
); } diff --git a/client/app/scripts/components/view-mode-selector.js b/client/app/scripts/components/view-mode-selector.js index a4a351afd..cf2e2825d 100644 --- a/client/app/scripts/components/view-mode-selector.js +++ b/client/app/scripts/components/view-mode-selector.js @@ -58,8 +58,10 @@ class ViewModeSelector extends React.Component {
{this.renderItem('fa fa-share-alt', 'Graph', GRAPH_VIEW_MODE, this.props.setGraphView)} {this.renderItem('fa fa-table', 'Table', TABLE_VIEW_MODE, this.props.setTableView)} - {this.renderItem('fa fa-bar-chart', 'Resources', RESOURCE_VIEW_MODE, - this.props.setResourceView, hasResourceView)} + {this.renderItem( +'fa fa-bar-chart', 'Resources', RESOURCE_VIEW_MODE, + this.props.setResourceView, hasResourceView +)}
diff --git a/client/app/scripts/main.dev.js b/client/app/scripts/main.dev.js index 3616126fc..e5debff19 100644 --- a/client/app/scripts/main.dev.js +++ b/client/app/scripts/main.dev.js @@ -15,12 +15,14 @@ const store = configureStore(); function renderApp() { const App = require('./components/app').default; - ReactDOM.render(( - - - - - ), document.getElementById('app')); + ReactDOM.render( + ( + + + + + ), document.getElementById('app') + ); } renderApp(); diff --git a/client/app/scripts/main.js b/client/app/scripts/main.js index 773a44cbb..9b6f32df2 100644 --- a/client/app/scripts/main.js +++ b/client/app/scripts/main.js @@ -11,11 +11,13 @@ const store = configureStore(); function renderApp() { const App = require('./components/app').default; - ReactDOM.render(( - - - - ), document.getElementById('app')); + ReactDOM.render( + ( + + + + ), document.getElementById('app') + ); } renderApp(); diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index fc558d118..6b0804af0 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -119,8 +119,10 @@ function processTopologies(state, nextTopologies) { // set `selectType` field for topology and sub_topologies options (recursive). const topologiesWithSelectType = visibleTopologies.map(calcSelectType); // cache URLs by ID - state = state.set('topologyUrlsById', - setTopologyUrlsById(state.get('topologyUrlsById'), topologiesWithSelectType)); + state = state.set( + 'topologyUrlsById', + setTopologyUrlsById(state.get('topologyUrlsById'), topologiesWithSelectType) + ); const topologiesWithFullnames = addTopologyFullname(topologiesWithSelectType); const immNextTopologies = fromJS(topologiesWithFullnames).sortBy(topologySorter); @@ -144,7 +146,8 @@ function setDefaultTopologyOptions(state, topologyList) { } if (defaultOptions.size) { - state = state.setIn(['topologyOptions', topology.get('id')], + state = state.setIn( + ['topologyOptions', topology.get('id')], defaultOptions ); } @@ -157,8 +160,10 @@ function closeNodeDetails(state, nodeId) { if (nodeDetails.size > 0) { const popNodeId = nodeId || nodeDetails.keySeq().last(); // remove pipe if it belongs to the node being closed - state = state.update('controlPipes', - controlPipes => controlPipes.filter(pipe => pipe.get('nodeId') !== popNodeId)); + state = state.update( + 'controlPipes', + controlPipes => controlPipes.filter(pipe => pipe.get('nodeId') !== popNodeId) + ); state = state.deleteIn(['nodeDetails', popNodeId]); } if (state.get('nodeDetails').size === 0 || state.get('selectedNodeId') === nodeId) { @@ -298,7 +303,8 @@ export function rootReducer(state = initialState, action) { if (prevDetailsStackSize > 1 || prevSelectedNodeId !== action.nodeId) { // dont set origin if a node was already selected, suppresses animation const origin = prevSelectedNodeId === null ? action.origin : null; - state = state.setIn(['nodeDetails', action.nodeId], + state = state.setIn( + ['nodeDetails', action.nodeId], { id: action.nodeId, label: action.label, @@ -318,7 +324,8 @@ export function rootReducer(state = initialState, action) { state = state.deleteIn(['nodeDetails', action.nodeId]); state = state.setIn(['nodeDetails', action.nodeId], details); } else { - state = state.setIn(['nodeDetails', action.nodeId], + state = state.setIn( + ['nodeDetails', action.nodeId], { id: action.nodeId, label: action.label, @@ -331,8 +338,10 @@ export function rootReducer(state = initialState, action) { } case ActionTypes.CLICK_SHOW_TOPOLOGY_FOR_NODE: { - state = state.update('nodeDetails', - nodeDetails => nodeDetails.filter((v, k) => k === action.nodeId)); + state = state.update( + 'nodeDetails', + nodeDetails => nodeDetails.filter((v, k) => k === action.nodeId) + ); state = state.update('controlPipes', controlPipes => controlPipes.clear()); state = state.set('selectedNodeId', action.nodeId); @@ -579,11 +588,13 @@ export function rootReducer(state = initialState, action) { return state; } - log('RECEIVE_NODES_DELTA', + log( + 'RECEIVE_NODES_DELTA', 'remove', size(action.delta.remove), 'update', size(action.delta.update), 'add', size(action.delta.add), - 'reset', action.delta.reset); + 'reset', action.delta.reset + ); if (action.delta.reset) { state = state.set('nodes', makeMap()); @@ -700,8 +711,7 @@ export function rootReducer(state = initialState, action) { state = state.update('controlPipes', controlPipes => controlPipes.clear()); } if (action.state.nodeDetails) { - const actionNodeDetails = makeOrderedMap( - action.state.nodeDetails.map(obj => [obj.id, obj])); + const actionNodeDetails = makeOrderedMap(action.state.nodeDetails.map(h => [h.id, h])); // check if detail IDs have changed if (!isDeepEqual(state.get('nodeDetails').keySeq(), actionNodeDetails.keySeq())) { state = state.set('nodeDetails', actionNodeDetails); @@ -709,8 +719,10 @@ export function rootReducer(state = initialState, action) { } else { state = state.update('nodeDetails', nodeDetails => nodeDetails.clear()); } - state = state.set('topologyOptions', - fromJS(action.state.topologyOptions) || state.get('topologyOptions')); + state = state.set( + 'topologyOptions', + fromJS(action.state.topologyOptions) || state.get('topologyOptions') + ); return state; } diff --git a/client/app/scripts/selectors/resource-view/layout.js b/client/app/scripts/selectors/resource-view/layout.js index 615c2944e..44d41783b 100644 --- a/client/app/scripts/selectors/resource-view/layout.js +++ b/client/app/scripts/selectors/resource-view/layout.js @@ -85,8 +85,8 @@ const decoratedNodesByTopologySelector = createSelector( const isBaseLayer = (index === 0); const nodeParentDecorator = nodeParentDecoratorByTopologyId(parentLayerTopologyId); - const nodeMetricSummaryDecorator = nodeMetricSummaryDecoratorByType( - pinnedMetricType, showCapacity); + const nodeMetricSummaryDecorator = + nodeMetricSummaryDecoratorByType(pinnedMetricType, showCapacity); // Color the node, deduce its anchor point, dimensions and info about its pinned metric. const decoratedTopologyNodes = (topologyNodes || makeMap()) diff --git a/client/app/scripts/terminal-main.js b/client/app/scripts/terminal-main.js index 08a8bcd27..fb8fd64db 100644 --- a/client/app/scripts/terminal-main.js +++ b/client/app/scripts/terminal-main.js @@ -11,11 +11,13 @@ const store = configureStore(); function renderApp() { const TerminalApp = require('./components/terminal-app').default; - ReactDOM.render(( - - - - ), document.getElementById('app')); + ReactDOM.render( + ( + + + + ), document.getElementById('app') + ); } renderApp(); diff --git a/client/app/scripts/utils/__tests__/search-utils-test.js b/client/app/scripts/utils/__tests__/search-utils-test.js index d6745db6d..affaf9cec 100644 --- a/client/app/scripts/utils/__tests__/search-utils-test.js +++ b/client/app/scripts/utils/__tests__/search-utils-test.js @@ -125,15 +125,19 @@ describe('SearchUtils', () => { it('does not add a non-matching field', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 'some value', 'some query', null, 'some label'); + matches = fun( + matches, ['node1', 'field1'], + 'some value', 'some query', null, 'some label' + ); expect(matches.size).toBe(0); }); it('adds a matching field', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 'samevalue', 'samevalue', null, 'some label'); + matches = fun( + matches, ['node1', 'field1'], + 'samevalue', 'samevalue', null, 'some label' + ); expect(matches.size).toBe(1); expect(matches.getIn(['node1', 'field1'])).toBeDefined(); const {text, label, start, length} = matches.getIn(['node1', 'field1']); @@ -145,15 +149,19 @@ describe('SearchUtils', () => { it('does not add a field when the prefix does not match the label', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 'samevalue', 'samevalue', 'some prefix', 'some label'); + matches = fun( + matches, ['node1', 'field1'], + 'samevalue', 'samevalue', 'some prefix', 'some label' + ); expect(matches.size).toBe(0); }); it('adds a field when the prefix matches the label', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 'samevalue', 'samevalue', 'prefix', 'prefixed label'); + matches = fun( + matches, ['node1', 'field1'], + 'samevalue', 'samevalue', 'prefix', 'prefixed label' + ); expect(matches.size).toBe(1); }); }); @@ -163,30 +171,40 @@ describe('SearchUtils', () => { it('does not add a non-matching field', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 1, 'metric1', 'metric2', 'lt', 2); + matches = fun( + matches, ['node1', 'field1'], + 1, 'metric1', 'metric2', 'lt', 2 + ); expect(matches.size).toBe(0); }); it('adds a matching field', () => { let matches = fromJS({}); - matches = fun(matches, ['node1', 'field1'], - 1, 'metric1', 'metric1', 'lt', 2); + matches = fun( + matches, ['node1', 'field1'], + 1, 'metric1', 'metric1', 'lt', 2 + ); expect(matches.size).toBe(1); expect(matches.getIn(['node1', 'field1'])).toBeDefined(); const { metric } = matches.getIn(['node1', 'field1']); expect(metric).toBeTruthy(); - matches = fun(matches, ['node2', 'field1'], - 1, 'metric1', 'metric1', 'gt', 0); + matches = fun( + matches, ['node2', 'field1'], + 1, 'metric1', 'metric1', 'gt', 0 + ); expect(matches.size).toBe(2); - matches = fun(matches, ['node3', 'field1'], - 1, 'metric1', 'metric1', 'eq', 1); + matches = fun( + matches, ['node3', 'field1'], + 1, 'metric1', 'metric1', 'eq', 1 + ); expect(matches.size).toBe(3); - matches = fun(matches, ['node3', 'field1'], - 1, 'metric1', 'metric1', 'other', 1); + matches = fun( + matches, ['node3', 'field1'], + 1, 'metric1', 'metric1', 'other', 1 + ); expect(matches.size).toBe(3); }); }); diff --git a/client/app/scripts/utils/__tests__/topology-utils-test.js b/client/app/scripts/utils/__tests__/topology-utils-test.js index 083c031a3..2e11bb22c 100644 --- a/client/app/scripts/utils/__tests__/topology-utils-test.js +++ b/client/app/scripts/utils/__tests__/topology-utils-test.js @@ -79,7 +79,8 @@ describe('TopologyUtils', () => { it('sets node degrees', () => { nodes = TopologyUtils.updateNodeDegrees( nodeSets.initial4.nodes, - nodeSets.initial4.edges).toJS(); + nodeSets.initial4.edges + ).toJS(); expect(nodes.n1.degree).toEqual(2); expect(nodes.n2.degree).toEqual(1); @@ -88,7 +89,8 @@ describe('TopologyUtils', () => { nodes = TopologyUtils.updateNodeDegrees( nodeSets.removeEdge24.nodes, - nodeSets.removeEdge24.edges).toJS(); + nodeSets.removeEdge24.edges + ).toJS(); expect(nodes.n1.degree).toEqual(2); expect(nodes.n2.degree).toEqual(0); @@ -97,7 +99,8 @@ describe('TopologyUtils', () => { nodes = TopologyUtils.updateNodeDegrees( nodeSets.single3.nodes, - nodeSets.single3.edges).toJS(); + nodeSets.single3.edges + ).toJS(); expect(nodes.n1.degree).toEqual(0); expect(nodes.n2.degree).toEqual(0); diff --git a/client/app/scripts/utils/array-utils.js b/client/app/scripts/utils/array-utils.js index 2ad6218a6..4088b82a3 100644 --- a/client/app/scripts/utils/array-utils.js +++ b/client/app/scripts/utils/array-utils.js @@ -8,8 +8,7 @@ export function uniformSelect(array, size) { } return range(size).map(index => - array[parseInt(index * (array.length / (size - (1 - 1e-9))), 10)] - ); + array[parseInt(index * (array.length / (size - (1 - 1e-9))), 10)]); } export function insertElement(array, index, element) { diff --git a/client/app/scripts/utils/file-utils.js b/client/app/scripts/utils/file-utils.js index d67cfcfc1..545b52f65 100644 --- a/client/app/scripts/utils/file-utils.js +++ b/client/app/scripts/utils/file-utils.js @@ -76,7 +76,8 @@ function download(source, name) { filename = `${window.document.title.replace(/[^a-z0-9]/gi, '-').toLowerCase()}-${(+new Date())}`; } - const url = window.URL.createObjectURL(new Blob(source, + const url = window.URL.createObjectURL(new Blob( + source, { type: 'text/xml' } )); diff --git a/client/app/scripts/utils/search-utils.js b/client/app/scripts/utils/search-utils.js index ee1629d61..9beacf548 100644 --- a/client/app/scripts/utils/search-utils.js +++ b/client/app/scripts/utils/search-utils.js @@ -72,8 +72,10 @@ function findNodeMatch(nodeMatches, keyPath, text, query, prefix, label, truncat if (matches) { const firstMatch = matches[0]; const index = text.search(queryRe); - nodeMatches = nodeMatches.setIn(keyPath, - {text, label, start: index, length: firstMatch.length, truncate}); + nodeMatches = nodeMatches.setIn( + keyPath, + {text, label, start: index, length: firstMatch.length, truncate} + ); } } return nodeMatches; @@ -110,8 +112,10 @@ function findNodeMatchMetric(nodeMatches, keyPath, fieldValue, fieldLabel, metri } } if (matched) { - nodeMatches = nodeMatches.setIn(keyPath, - {fieldLabel, metric: true}); + nodeMatches = nodeMatches.setIn( + keyPath, + {fieldLabel, metric: true} + ); } } return nodeMatches; @@ -125,8 +129,10 @@ export function searchNode(node, { prefix, query, metric, comp, value }) { SEARCH_FIELDS.forEach((field, label) => { const keyPath = [label]; if (node.has(field)) { - nodeMatches = findNodeMatch(nodeMatches, keyPath, node.get(field), - query, prefix, label); + nodeMatches = findNodeMatch( + nodeMatches, keyPath, node.get(field), + query, prefix, label + ); } }); @@ -134,8 +140,10 @@ export function searchNode(node, { prefix, query, metric, comp, value }) { if (node.get('metadata')) { node.get('metadata').forEach((field) => { const keyPath = ['metadata', field.get('id')]; - nodeMatches = findNodeMatch(nodeMatches, keyPath, field.get('value'), - query, prefix, field.get('label'), field.get('truncate')); + nodeMatches = findNodeMatch( + nodeMatches, keyPath, field.get('value'), + query, prefix, field.get('label'), field.get('truncate') + ); }); } @@ -143,8 +151,10 @@ export function searchNode(node, { prefix, query, metric, comp, value }) { if (node.get('parents')) { node.get('parents').forEach((parent) => { const keyPath = ['parents', parent.get('id')]; - nodeMatches = findNodeMatch(nodeMatches, keyPath, parent.get('label'), - query, prefix, parent.get('topologyId')); + nodeMatches = findNodeMatch( + nodeMatches, keyPath, parent.get('label'), + query, prefix, parent.get('topologyId') + ); }); } @@ -153,8 +163,10 @@ export function searchNode(node, { prefix, query, metric, comp, value }) { (propertyList.get('rows') || []).forEach((row) => { const entries = row.get('entries'); const keyPath = ['property-lists', row.get('id')]; - nodeMatches = findNodeMatch(nodeMatches, keyPath, entries.get('value'), - query, prefix, entries.get('label')); + nodeMatches = findNodeMatch( + nodeMatches, keyPath, entries.get('value'), + query, prefix, entries.get('label') + ); }); }); @@ -173,8 +185,10 @@ export function searchNode(node, { prefix, query, metric, comp, value }) { if (metrics) { metrics.forEach((field) => { const keyPath = ['metrics', field.get('id')]; - nodeMatches = findNodeMatchMetric(nodeMatches, keyPath, field.get('value'), - field.get('label'), metric, comp, value); + nodeMatches = findNodeMatchMetric( + nodeMatches, keyPath, field.get('value'), + field.get('label'), metric, comp, value + ); }); } } @@ -259,8 +273,7 @@ export function getSearchableFields(nodes) { // Consider only property lists (and not generic tables). const tableRowLabels = nodes.reduce((labels, node) => ( labels.union(get(node, 'tables').filter(isPropertyList).flatMap(t => (t.get('rows') || makeList) - .map(f => f.getIn(['entries', 'label'])) - )) + .map(f => f.getIn(['entries', 'label'])))) ), makeSet()); const metricLabels = nodes.reduce((labels, node) => ( @@ -282,8 +295,10 @@ export function getSearchableFields(nodes) { */ export function applyPinnedSearches(state) { // clear old filter state - state = state.update('nodes', - nodes => nodes.map(node => node.set('filtered', false))); + state = state.update( + 'nodes', + nodes => nodes.map(node => node.set('filtered', false)) + ); const pinnedSearches = state.get('pinnedSearches'); if (pinnedSearches.size > 0) { @@ -292,10 +307,12 @@ export function applyPinnedSearches(state) { if (parsed) { const nodeMatches = searchTopology(state.get('nodes'), parsed); const filteredNodes = state.get('nodes') - .map(node => node.set('filtered', + .map(node => node.set( + 'filtered', node.get('filtered') // matched by previous pinned search || nodeMatches.size === 0 // no match, filter all nodes - || !nodeMatches.has(node.get('id')))); // filter matches + || !nodeMatches.has(node.get('id')) + )); // filter matches state = state.set('nodes', filteredNodes); } }); diff --git a/client/app/scripts/utils/web-api-utils.js b/client/app/scripts/utils/web-api-utils.js index 1305b5a69..ce16c8861 100644 --- a/client/app/scripts/utils/web-api-utils.js +++ b/client/app/scripts/utils/web-api-utils.js @@ -167,8 +167,10 @@ function createWebsocket(websocketUrl, getState, dispatch) { firstMessageOnWebsocketAt = new Date(); const timeToFirstMessage = firstMessageOnWebsocketAt - createWebsocketAt; if (timeToFirstMessage > FIRST_RENDER_TOO_LONG_THRESHOLD) { - log('Time (ms) to first nodes render after websocket was created', - firstMessageOnWebsocketAt - createWebsocketAt); + log( + 'Time (ms) to first nodes render after websocket was created', + firstMessageOnWebsocketAt - createWebsocketAt + ); } } }; @@ -197,13 +199,15 @@ function getNodesForTopologies(state, dispatch, topologyIds, topologyOptions = m // fetch sequentially state.get('topologyUrlsById') .filter((_, topologyId) => topologyIds.contains(topologyId)) - .reduce((sequence, topologyUrl, topologyId) => sequence - .then(() => { - const optionsQuery = buildUrlQuery(topologyOptions.get(topologyId), state); - return doRequest({ url: `${getApiPath()}${topologyUrl}?${optionsQuery}` }); - }) - .then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId))), - Promise.resolve()); + .reduce( + (sequence, topologyUrl, topologyId) => sequence + .then(() => { + const optionsQuery = buildUrlQuery(topologyOptions.get(topologyId), state); + return doRequest({ url: `${getApiPath()}${topologyUrl}?${optionsQuery}` }); + }) + .then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId))), + Promise.resolve() + ); } function getNodesOnce(getState, dispatch) { diff --git a/client/server.js b/client/server.js index d9557a41e..4855bc1b5 100644 --- a/client/server.js +++ b/client/server.js @@ -100,8 +100,10 @@ const proxyPathServer = http.createServer((req, res) => { return pathProxy.web(req, res, {target}); }).listen(pathProxyPort, 'localhost', () => { const pathProxyHost = proxyPathServer.address().address; - console.log('Scope Proxy Path UI listening at http://%s:%s/scoped/', - pathProxyHost, pathProxyPort); + console.log( + 'Scope Proxy Path UI listening at http://%s:%s/scoped/', + pathProxyHost, pathProxyPort + ); }); proxyPathServer.on('upgrade', (req, socket, head) => {