From 19d27351e9233a814bc6a512c0a98cc0f47e61d8 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Wed, 1 Jul 2020 11:40:37 +0200 Subject: [PATCH] Fix few null checks to make master green (#25965) --- .../plugins/datasource/graphite/configuration/ConfigEditor.tsx | 2 +- .../app/plugins/datasource/loki/configuration/DebugSection.tsx | 3 ++- public/app/plugins/datasource/loki/datasource.ts | 2 +- public/app/plugins/panel/singlestat/module.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx b/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx index b973514d27e..8e22d7bce0b 100644 --- a/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx +++ b/public/app/plugins/datasource/graphite/configuration/ConfigEditor.tsx @@ -86,7 +86,7 @@ export class ConfigEditor extends PureComponent { label="Rollup indicator" labelClass={'width-10'} tooltip="Shows up as an info icon in panel headers when data is aggregated" - checked={options.jsonData.rollupIndicatorEnabled} + checked={!!options.jsonData.rollupIndicatorEnabled} onChange={onUpdateDatasourceJsonDataOptionChecked(this.props, 'rollupIndicatorEnabled')} /> diff --git a/public/app/plugins/datasource/loki/configuration/DebugSection.tsx b/public/app/plugins/datasource/loki/configuration/DebugSection.tsx index 64d878e9252..82f3a717c8e 100644 --- a/public/app/plugins/datasource/loki/configuration/DebugSection.tsx +++ b/public/app/plugins/datasource/loki/configuration/DebugSection.tsx @@ -84,6 +84,7 @@ type DebugField = { value?: string; href?: string; }; + function makeDebugFields(derivedFields: DerivedFieldConfig[], debugText: string): DebugField[] { return derivedFields .filter(field => field.name && field.matcherRegex) @@ -91,7 +92,7 @@ function makeDebugFields(derivedFields: DerivedFieldConfig[], debugText: string) try { const testMatch = debugText.match(field.matcherRegex); const value = testMatch && testMatch[1]; - let link: LinkModel; + let link: LinkModel = null; if (field.url && value) { link = getFieldLinksForExplore( diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 9823453ed98..b81830e752c 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -518,7 +518,7 @@ export class LokiDatasource extends DataSourceApi { } showContextToggle = (row?: LogRowModel) => { - return row.searchWords && row.searchWords.length > 0; + return row && row.searchWords && row.searchWords.length > 0; }; throwUnless = (err: any, condition: boolean, target: LokiQuery) => { diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts index 82259845aee..ad58bb95cd7 100644 --- a/public/app/plugins/panel/singlestat/module.ts +++ b/public/app/plugins/panel/singlestat/module.ts @@ -502,7 +502,7 @@ class SingleStatCtrl extends MetricsPanelCtrl { function addSparkline() { const data: ShowData = ctrl.data; const width = elem.width(); - if (width < 30) { + if (width && width < 30) { // element has not gotten it's width yet // delay sparkline render setTimeout(addSparkline, 30);