From d7d94d13a0359d0269dbfd323a65acc995a4652e Mon Sep 17 00:00:00 2001 From: Tobias Skarhed <1438972+tskarhed@users.noreply.github.com> Date: Wed, 1 Apr 2020 15:55:23 +0200 Subject: [PATCH] Forms migration: New datasource (#23221) * Add Icon to Button and add newForms to FilterInput * Reset button changes * Update feedback * Update Snapshots --- .../components/FilterInput/FilterInput.tsx | 28 +++++++------- .../__snapshots__/OrgActionBar.test.tsx.snap | 2 +- .../__snapshots__/AlertRuleList.test.tsx.snap | 4 +- .../panel_editor/VizPickerSearch.tsx | 9 +---- .../datasources/NewDataSourcePage.tsx | 37 ++++++------------- .../__snapshots__/TeamList.test.tsx.snap | 6 +-- .../__snapshots__/TeamMembers.test.tsx.snap | 4 +- .../UsersActionBar.test.tsx.snap | 8 ++-- 8 files changed, 39 insertions(+), 59 deletions(-) diff --git a/public/app/core/components/FilterInput/FilterInput.tsx b/public/app/core/components/FilterInput/FilterInput.tsx index 0bf09eb494f..efe66377289 100644 --- a/public/app/core/components/FilterInput/FilterInput.tsx +++ b/public/app/core/components/FilterInput/FilterInput.tsx @@ -1,5 +1,6 @@ -import React, { forwardRef } from 'react'; +import React, { FC } from 'react'; import { escapeStringForRegex, unEscapeStringFromRegex } from '@grafana/data'; +import { Forms, Icon } from '@grafana/ui'; export interface Props { value: string | undefined; @@ -9,16 +10,15 @@ export interface Props { onChange: (value: string) => void; } -export const FilterInput = forwardRef((props, ref) => ( - -)); +export const FilterInput: FC = props => ( + } + type="text" + size="md" + value={props.value ? unEscapeStringFromRegex(props.value) : ''} + onChange={event => props.onChange(escapeStringForRegex(event.currentTarget.value))} + placeholder={props.placeholder ?? ''} + /> +); diff --git a/public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap b/public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap index 81de13f18fe..a8a6a5da651 100644 --- a/public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap +++ b/public/app/core/components/OrgActionBar/__snapshots__/OrgActionBar.test.tsx.snap @@ -7,7 +7,7 @@ exports[`Render should render component 1`] = `
- - - { const { searchQuery, onChange, onClose } = this.props; return ( <> - element && element.focus()} - /> + diff --git a/public/app/features/datasources/NewDataSourcePage.tsx b/public/app/features/datasources/NewDataSourcePage.tsx index 91a930b9679..9d377425a4f 100644 --- a/public/app/features/datasources/NewDataSourcePage.tsx +++ b/public/app/features/datasources/NewDataSourcePage.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import { connect } from 'react-redux'; import { hot } from 'react-hot-loader'; import { DataSourcePluginMeta, NavModel } from '@grafana/data'; -import { List } from '@grafana/ui'; +import { List, LinkButton, Button } from '@grafana/ui'; import { e2e } from '@grafana/e2e'; import Page from 'app/core/components/Page/Page'; @@ -25,11 +25,8 @@ export interface Props { } class NewDataSourcePage extends PureComponent { - searchInput: HTMLElement; - componentDidMount() { this.props.loadDataSourcePlugins(); - this.searchInput.focus(); } onDataSourceTypeClicked = (plugin: DataSourcePluginMeta) => { @@ -76,14 +73,14 @@ class NewDataSourcePage extends PureComponent {
))} ); @@ -96,20 +93,9 @@ class NewDataSourcePage extends PureComponent {
-
- (this.searchInput = elem)} - labelClassName="gf-form--has-input-icon" - inputClassName="gf-form-input width-30" - value={searchQuery} - onChange={this.onSearchQueryChange} - placeholder="Filter by name or type" - /> -
+
- - Cancel - + Cancel
{searchQuery && this.renderPlugins(plugins)} @@ -151,17 +137,18 @@ const DataSourceTypeCard: FC = props => {
{learnMoreLink && ( - - {learnMoreLink.name} - + {learnMoreLink.name} + )} - {!isPhantom && } + {!isPhantom && }
); diff --git a/public/app/features/teams/__snapshots__/TeamList.test.tsx.snap b/public/app/features/teams/__snapshots__/TeamList.test.tsx.snap index e2fa7718142..8dd56c4e75d 100644 --- a/public/app/features/teams/__snapshots__/TeamList.test.tsx.snap +++ b/public/app/features/teams/__snapshots__/TeamList.test.tsx.snap @@ -41,7 +41,7 @@ exports[`Render should render teams table 1`] = `
- - - - - - - - -