From 32c0e6f1cf10ff42ae89cad975913631bafeaf83 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Fri, 29 Sep 2017 15:18:22 -0700 Subject: [PATCH] Handle rebase --- ui/src/shared/components/Layout.js | 20 ++++++++- ui/src/shared/components/LayoutRenderer.js | 49 ++++++++++++---------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/ui/src/shared/components/Layout.js b/ui/src/shared/components/Layout.js index 174964885d..bb42972fe8 100644 --- a/ui/src/shared/components/Layout.js +++ b/ui/src/shared/components/Layout.js @@ -4,11 +4,23 @@ import LayoutCell from 'shared/components/LayoutCell' import RefreshingGraph from 'shared/components/RefreshingGraph' import {buildQueriesForLayouts} from 'utils/influxql' +import _ from 'lodash' + +const getSource = (cell, source, sources) => { + const s = _.get(cell, ['queries', '0', 'source'], null) + if (!s) { + return source + } + + return sources.find(src => src.links.self === s) +} + const Layout = ({ host, cell, cell: {h, axes, type}, source, + sources, onZoom, templates, timeRange, @@ -41,7 +53,12 @@ const Layout = ({ autoRefresh={autoRefresh} synchronizer={synchronizer} resizeCoords={resizeCoords} - queries={buildQueriesForLayouts(cell, source, timeRange, host)} + queries={buildQueriesForLayouts( + cell, + getSource(cell, source, sources), + timeRange, + host + )} />} @@ -87,6 +104,7 @@ Layout.propTypes = { onCancelEditCell: func, resizeCoords: shape(), onZoom: func, + sources: arrayOf(shape()), } export default Layout diff --git a/ui/src/shared/components/LayoutRenderer.js b/ui/src/shared/components/LayoutRenderer.js index 7c5b27b0f5..0d7ec560be 100644 --- a/ui/src/shared/components/LayoutRenderer.js +++ b/ui/src/shared/components/LayoutRenderer.js @@ -1,6 +1,7 @@ import React, {Component, PropTypes} from 'react' import ReactGridLayout, {WidthProvider} from 'react-grid-layout' import Resizeable from 'react-component-resizable' + import _ from 'lodash' import Layout from 'src/shared/components/Layout' @@ -67,6 +68,7 @@ class LayoutRenderer extends Component { host, cells, source, + sources, onZoom, templates, timeRange, @@ -83,7 +85,7 @@ class LayoutRenderer extends Component { const isDashboard = !!this.props.onPositionChange return ( - + - {cells.map(cell => -
- -
- )} + {cells.map(cell => { + return ( +
+ +
+ ) + })}
)