Guard againt selected source being deleted

pull/10616/head
Andrew Watkins 2017-10-02 15:23:18 -07:00
parent 18905b1775
commit f60075fdd4
1 changed files with 28 additions and 21 deletions

View File

@ -6,33 +6,36 @@ import {buildQueriesForLayouts} from 'utils/influxql'
import _ from 'lodash'
const getSource = (cell, source, sources) => {
const getSource = (cell, source, sources, defaultSource) => {
const s = _.get(cell, ['queries', '0', 'source'], null)
if (!s) {
return source
}
return sources.find(src => src.links.self === s)
return sources.find(src => src.links.self === s) || defaultSource
}
const Layout = ({
host,
cell,
cell: {h, axes, type},
source,
sources,
onZoom,
templates,
timeRange,
isEditable,
onEditCell,
autoRefresh,
onDeleteCell,
synchronizer,
resizeCoords,
onCancelEditCell,
onSummonOverlayTechnologies,
}) =>
const Layout = (
{
host,
cell,
cell: {h, axes, type},
source,
sources,
onZoom,
templates,
timeRange,
isEditable,
onEditCell,
autoRefresh,
onDeleteCell,
synchronizer,
resizeCoords,
onCancelEditCell,
onSummonOverlayTechnologies,
},
{source: defaultSource}
) =>
<LayoutCell
cell={cell}
sources={sources}
@ -57,7 +60,7 @@ const Layout = ({
resizeCoords={resizeCoords}
queries={buildQueriesForLayouts(
cell,
getSource(cell, source, sources),
getSource(cell, source, sources, defaultSource),
timeRange,
host
)}
@ -66,6 +69,10 @@ const Layout = ({
const {arrayOf, bool, func, number, shape, string} = PropTypes
Layout.contextTypes = {
source: shape(),
}
Layout.propTypes = {
autoRefresh: number.isRequired,
timeRange: shape({