From 67105588bc74a28a8f13a510993a1e951a6ff309 Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 19 Apr 2018 16:23:29 -0700 Subject: [PATCH 1/7] Fix dropdown size calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Can’t pass an object into calculateSize --- ui/src/dashboards/constants/templateControlBar.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/dashboards/constants/templateControlBar.js b/ui/src/dashboards/constants/templateControlBar.js index fd013d0eb..7ab849f3f 100644 --- a/ui/src/dashboards/constants/templateControlBar.js +++ b/ui/src/dashboards/constants/templateControlBar.js @@ -8,9 +8,10 @@ export const dropdownPadding = 30 const valueLength = a => _.size(a.value) export const calculateDropdownWidth = (values = []) => { - const longestValue = _.maxBy(values, valueLength) + const longest = _.maxBy(values, valueLength) + const longestValuePixels = - calculateSize(longestValue, { + calculateSize(longest.value, { font: 'Monospace', fontSize: '12px', }).width + dropdownPadding From 8e6bd2c490062d592f088fd93378a85c04daa59a Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 19 Apr 2018 16:23:48 -0700 Subject: [PATCH 2/7] Expand min and max sizes for tempvar dropdowns --- ui/src/dashboards/constants/templateControlBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/dashboards/constants/templateControlBar.js b/ui/src/dashboards/constants/templateControlBar.js index 7ab849f3f..11b6d3c11 100644 --- a/ui/src/dashboards/constants/templateControlBar.js +++ b/ui/src/dashboards/constants/templateControlBar.js @@ -1,8 +1,8 @@ import _ from 'lodash' import calculateSize from 'calculate-size' -export const minDropdownWidth = 146 -export const maxDropdownWidth = 300 +export const minDropdownWidth = 120 +export const maxDropdownWidth = 330 export const dropdownPadding = 30 const valueLength = a => _.size(a.value) From bbf2f491aa9a4aa08205e44b8a6ea22f7b7bf6db Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 20 Apr 2018 10:15:34 -0700 Subject: [PATCH 3/7] Guard against empty values array --- ui/src/dashboards/constants/templateControlBar.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/src/dashboards/constants/templateControlBar.js b/ui/src/dashboards/constants/templateControlBar.js index 11b6d3c11..5a8f3eea8 100644 --- a/ui/src/dashboards/constants/templateControlBar.js +++ b/ui/src/dashboards/constants/templateControlBar.js @@ -7,7 +7,11 @@ export const dropdownPadding = 30 const valueLength = a => _.size(a.value) -export const calculateDropdownWidth = (values = []) => { +export const calculateDropdownWidth = values => { + if (!values || !values.length) { + return minDropdownWidth + } + const longest = _.maxBy(values, valueLength) const longestValuePixels = From bf547f6b6cf41a2246fd9bb3ecb6d9ee1ce78f99 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Fri, 20 Apr 2018 11:10:34 -0700 Subject: [PATCH 4/7] Extendable error handling --- ui/src/shared/decorators/errors.tsx | 77 +++++++++++++++++------------ 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/ui/src/shared/decorators/errors.tsx b/ui/src/shared/decorators/errors.tsx index 5d1d384d1..f3c7c14c0 100644 --- a/ui/src/shared/decorators/errors.tsx +++ b/ui/src/shared/decorators/errors.tsx @@ -1,38 +1,53 @@ -/* tslint:disable no-console */ -import React from 'react' +/* +tslint:disable no-console +tslint:disable max-classes-per-file +*/ -export function ErrorHandling< - P, - S, - T extends {new (...args: any[]): React.Component} ->(constructor: T) { - class Wrapped extends constructor { - public static get displayName(): string { - return constructor.name - } +import React, {ComponentClass, PureComponent, Component} from 'react' - private error: boolean = false +class DefaultError extends PureComponent { + public render() { + return ( +

+ A Chronograf error has occurred. Please report the issue  + here. +

+ ) + } +} - public componentDidCatch(error, info) { - console.error(error) - console.warn(info) - this.error = true - this.forceUpdate() - } - - public render() { - if (this.error) { - return ( -

- A Chronograf error has occurred. Please report the issue  - here. -

- ) +export function ErrorHandlingWith( + Error: ComponentClass, + alwaysDisplay = false +) { + return }>( + constructor: T + ) => { + class Wrapped extends constructor { + public static get displayName(): string { + return constructor.name } - return super.render() - } - } + private error: boolean = false - return Wrapped + public componentDidCatch(err, info) { + console.error(err) + console.warn(info) + this.error = true + this.forceUpdate() + } + + public render() { + if (this.error || alwaysDisplay) { + return + } + + return super.render() + } + } + + return Wrapped + } } + +export const ErrorHandling = ErrorHandlingWith(DefaultError) From e8329018b581b7b0e4204d979a225893766fca94 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Fri, 20 Apr 2018 11:54:02 -0700 Subject: [PATCH 5/7] Swap default error to be a Component instead of PureComponent --- ui/src/shared/decorators/errors.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/shared/decorators/errors.tsx b/ui/src/shared/decorators/errors.tsx index f3c7c14c0..2f6ddff72 100644 --- a/ui/src/shared/decorators/errors.tsx +++ b/ui/src/shared/decorators/errors.tsx @@ -3,9 +3,9 @@ tslint:disable no-console tslint:disable max-classes-per-file */ -import React, {ComponentClass, PureComponent, Component} from 'react' +import React, {ComponentClass, Component} from 'react' -class DefaultError extends PureComponent { +class DefaultError extends Component { public render() { return (

@@ -17,7 +17,7 @@ class DefaultError extends PureComponent { } export function ErrorHandlingWith( - Error: ComponentClass, + Error: ComponentClass, // Must be a class based component and not an SFC alwaysDisplay = false ) { return }>( From c341ca559e352d5bb2bdd8ca323c7e01b52c3999 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Fri, 20 Apr 2018 14:34:45 -0700 Subject: [PATCH 6/7] Fix base path for kapacitor logs --- ui/src/kapacitor/apis/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/src/kapacitor/apis/index.js b/ui/src/kapacitor/apis/index.js index 01155b43d..984e714e4 100644 --- a/ui/src/kapacitor/apis/index.js +++ b/ui/src/kapacitor/apis/index.js @@ -107,21 +107,22 @@ const kapacitorLogHeaders = { } export const getLogStream = kapacitor => - fetch(`${kapacitor.links.proxy}?path=/kapacitor/v1preview/logs`, { + AJAX({ + url: `${kapacitor.links.proxy}?path=/kapacitor/v1preview/logs`, method: 'GET', headers: kapacitorLogHeaders, credentials: 'include', }) export const getLogStreamByRuleID = (kapacitor, ruleID) => - fetch( - `${kapacitor.links.proxy}?path=/kapacitor/v1preview/logs?task=${ruleID}`, - { - method: 'GET', - headers: kapacitorLogHeaders, - credentials: 'include', - } - ) + AJAX({ + url: `${ + kapacitor.links.proxy + }?path=/kapacitor/v1preview/logs?task=${ruleID}`, + method: 'GET', + headers: kapacitorLogHeaders, + credentials: 'include', + }) export const pingKapacitorVersion = async kapacitor => { try { From 50f14dffd54f4343d68c3ffb01b1cd926e663b46 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Fri, 20 Apr 2018 14:37:22 -0700 Subject: [PATCH 7/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 429fab90f..0d151c455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bug Fixes 1. [#3252](https://github.com/influxdata/chronograf/pull/3252): Allows users to select tickscript editor with mouse +1. [#3281](https://github.com/influxdata/chronograf/pull/3281): Fix base path for kapacitor logs ## v1.4.4.1 [2018-04-16]