Be more defensive where we split text from responses

Closes #5139
Closes #5155
pull/5185/head
Brandon Farmer 2019-05-20 10:04:34 -07:00
parent 36c17f1952
commit 4df76c444f
5 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import _ from 'lodash'
import React, {PureComponent, MouseEvent} from 'react'
import {Controlled as ReactCodeMirror, IInstance} from 'react-codemirror2'
import {EditorChange, LineWidget, Position} from 'codemirror'
@ -192,11 +193,12 @@ class FluxScriptEditor extends PureComponent<Props, State> {
private get statusLine(): Gutter[] {
const {status} = this.props
const messages = status.text.split('\n')
const messages = _.get(status, 'text', '').split('\n')
const lineNumbers = messages
.map(text => {
const [numbers] = text.split(' ')
const [lineNumber] = numbers.split(':')
return {line: Number(lineNumber), text}
})
.filter(d => !isNaN(d.line))

View File

@ -29,7 +29,9 @@ class Form extends Component<Props> {
]
public static ValidChildNames: string = _.map(Form.ValidChildTypes, valid => {
const name = valid.displayName.split('Form').pop()
const name = _.get(valid, 'displayName', '')
.split('Form')
.pop()
return `<Form.${name}>`
}).join(', ')

View File

@ -39,7 +39,9 @@ class Panel extends Component<Props> {
public static ValidChildNames: string = _.map(
Panel.ValidChildTypes,
child => {
const name = child.displayName.split('Panel').pop()
const name = _.get(child, 'displayName', '')
.split('Panel')
.pop()
return `<Panel.${name}>`
}

View File

@ -171,7 +171,9 @@ export default class LayoutCell extends Component<Props> {
private async downloadInfluxQLCSV() {
const {cellData, cell} = this.props
const name = `${cell.name.split(' ').join('_')}.csv`
const name = `${_.get(cell, 'name', '')
.split(' ')
.join('_')}.csv`
let csv: string
@ -190,7 +192,9 @@ export default class LayoutCell extends Component<Props> {
private downloadFluxCSV() {
const {cellFluxData, cell} = this.props
const joinedName = cell.name.split(' ').join('_')
const joinedName = _.get(cell, 'name', '')
.split(' ')
.join('_')
downloadCSV(cellFluxData, joinedName)
}

View File

@ -38,7 +38,7 @@ export function diskBytesFromShardForDatabase(response) {
}
const shardData = results.series.reduce((data, series) => {
const pathParts = series.tags.path.split('/')
const pathParts = _.get(series, 'tags.path', '').split('/')
const shardID = pathParts[pathParts.length - 1]
const diskUsage = series.values[0][series.columns.indexOf('last')]
const nodeID = series.tags.nodeID