From b1aa84804b03e1d487cd3d2016ad92294397d830 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Tue, 12 Feb 2019 16:14:48 +0100 Subject: [PATCH 1/5] feat: Add css-support for invalid form input elements --- public/sass/components/_gf-form.scss | 6 +++++- public/sass/mixins/_forms.scss | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/public/sass/components/_gf-form.scss b/public/sass/components/_gf-form.scss index 90ef1da30dc..e2c5eebecd4 100644 --- a/public/sass/components/_gf-form.scss +++ b/public/sass/components/_gf-form.scss @@ -203,7 +203,7 @@ $input-border: 1px solid $input-border-color; } // Customize the `:focus` state to imitate native WebKit styles. - @include form-control-focus(); + @include form-control-focus(false); // Placeholder &::placeholder { @@ -251,6 +251,10 @@ $input-border: 1px solid $input-border-color; &--plaintext { white-space: unset; } + + &--invalid { + @include form-control-focus(true); + } } .gf-form-hint { diff --git a/public/sass/mixins/_forms.scss b/public/sass/mixins/_forms.scss index 5d2a4421353..b67a303438b 100644 --- a/public/sass/mixins/_forms.scss +++ b/public/sass/mixins/_forms.scss @@ -30,12 +30,19 @@ } } -@mixin form-control-focus() { +@mixin form-control-focus($error) { &:focus { + $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), + 0 0 5px $input-box-shadow-focus; border-color: $input-border-focus; outline: none; - $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), - 0 0 5px $input-box-shadow-focus; + + @if $error == true { + border-color: $brand-warning; + $shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), + 0 0 5px $brand-warning; + } + @include box-shadow($shadow); } } From 11db48e76e569b6e247511f2d312a8d83930c573 Mon Sep 17 00:00:00 2001 From: Johannes Schill Date: Tue, 12 Feb 2019 16:19:23 +0100 Subject: [PATCH 2/5] feat: Highlight vizpicker input when there are no panels matching the search query --- .../dashboard/panel_editor/EditorTabBody.tsx | 2 +- .../panel_editor/VisualizationTab.tsx | 21 +++++++++++++++---- .../dashboard/panel_editor/VizTypePicker.tsx | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/public/app/features/dashboard/panel_editor/EditorTabBody.tsx b/public/app/features/dashboard/panel_editor/EditorTabBody.tsx index 0413cae8a7b..3183f7a7b24 100644 --- a/public/app/features/dashboard/panel_editor/EditorTabBody.tsx +++ b/public/app/features/dashboard/panel_editor/EditorTabBody.tsx @@ -36,7 +36,7 @@ export class EditorTabBody extends PureComponent { toolbarItems: [], }; - constructor(props) { + constructor(props: Props) { super(props); this.state = { diff --git a/public/app/features/dashboard/panel_editor/VisualizationTab.tsx b/public/app/features/dashboard/panel_editor/VisualizationTab.tsx index 37f109250a7..efb1caf0cf7 100644 --- a/public/app/features/dashboard/panel_editor/VisualizationTab.tsx +++ b/public/app/features/dashboard/panel_editor/VisualizationTab.tsx @@ -1,5 +1,5 @@ // Libraries -import React, { PureComponent } from 'react'; +import React, { PureComponent, ChangeEvent } from 'react'; // Utils & Services import { AngularComponent, getAngularLoader } from 'app/core/services/AngularLoader'; @@ -31,6 +31,7 @@ interface Props { interface State { isVizPickerOpen: boolean; searchQuery: string; + searchResults: PanelPlugin[]; scrollTop: number; } @@ -39,12 +40,13 @@ export class VisualizationTab extends PureComponent { angularOptions: AngularComponent; searchInput: HTMLElement; - constructor(props) { + constructor(props: Props) { super(props); this.state = { isVizPickerOpen: this.props.urlOpenVizPicker, searchQuery: '', + searchResults: [], scrollTop: 0, }; } @@ -170,7 +172,7 @@ export class VisualizationTab extends PureComponent { this.setState({ isVizPickerOpen: false }); }; - onSearchQueryChange = evt => { + onSearchQueryChange = (evt: ChangeEvent) => { const value = evt.target.value; this.setState({ searchQuery: value, @@ -187,7 +189,7 @@ export class VisualizationTab extends PureComponent {