Merge pull request #15399 from grafana/15330-vizpicker-red-when-0-hits

Red border color on input when zero hits in vizpicker
This commit is contained in:
Torkel Ödegaard 2019-02-13 15:22:00 +01:00 committed by GitHub
commit c243e78913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 44 additions and 33 deletions

View File

@ -129,14 +129,8 @@
} }
}, },
"lint-staged": { "lint-staged": {
"*.{ts,tsx,json,scss}": [ "*.{ts,tsx,json,scss}": ["prettier --write", "git add"],
"prettier --write", "*pkg/**/*.go": ["gofmt -w -s", "git add"]
"git add"
],
"*pkg/**/*.go": [
"gofmt -w -s",
"git add"
]
}, },
"prettier": { "prettier": {
"trailingComma": "es5", "trailingComma": "es5",
@ -201,12 +195,7 @@
"**/@types/react": "16.7.6" "**/@types/react": "16.7.6"
}, },
"workspaces": { "workspaces": {
"packages": [ "packages": ["packages/*"],
"packages/*" "nohoist": ["**/@types/*", "**/@types/*/**"]
],
"nohoist": [
"**/@types/*",
"**/@types/*/**"
]
} }
} }

View File

@ -0,0 +1,13 @@
import React, { FC } from 'react';
export interface Props {
children: JSX.Element | string;
}
const EmptySearchResult: FC<Props> = ({ children }) => {
return (
<div className="empty-search-result">{children}</div>
);
};
export { EmptySearchResult };

View File

@ -0,0 +1,8 @@
.empty-search-result {
border-left: 3px solid $info-box-border-color;
background-color: $empty-list-cta-bg;
padding: $spacer;
min-width: 350px;
border-radius: $border-radius;
margin-bottom: $spacer*2;
}

View File

@ -7,4 +7,5 @@
@import 'PanelOptionsGrid/PanelOptionsGrid'; @import 'PanelOptionsGrid/PanelOptionsGrid';
@import 'ColorPicker/ColorPicker'; @import 'ColorPicker/ColorPicker';
@import 'ValueMappingsEditor/ValueMappingsEditor'; @import 'ValueMappingsEditor/ValueMappingsEditor';
@import 'EmptySearchResult/EmptySearchResult';
@import 'FormField/FormField'; @import 'FormField/FormField';

View File

@ -23,3 +23,4 @@ export { PanelOptionsGrid } from './PanelOptionsGrid/PanelOptionsGrid';
export { ValueMappingsEditor } from './ValueMappingsEditor/ValueMappingsEditor'; export { ValueMappingsEditor } from './ValueMappingsEditor/ValueMappingsEditor';
export { Gauge } from './Gauge/Gauge'; export { Gauge } from './Gauge/Gauge';
export { Switch } from './Switch/Switch'; export { Switch } from './Switch/Switch';
export { EmptySearchResult } from './EmptySearchResult/EmptySearchResult';

View File

@ -1,9 +1,9 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import _ from 'lodash';
import config from 'app/core/config'; import config from 'app/core/config';
import { PanelPlugin } from 'app/types/plugins'; import { PanelPlugin } from 'app/types/plugins';
import VizTypePickerPlugin from './VizTypePickerPlugin'; import VizTypePickerPlugin from './VizTypePickerPlugin';
import { EmptySearchResult } from '@grafana/ui';
export interface Props { export interface Props {
current: PanelPlugin; current: PanelPlugin;
@ -14,9 +14,9 @@ export interface Props {
export class VizTypePicker extends PureComponent<Props> { export class VizTypePicker extends PureComponent<Props> {
searchInput: HTMLElement; searchInput: HTMLElement;
pluginList = this.getPanelPlugins(''); pluginList = this.getPanelPlugins;
constructor(props) { constructor(props: Props) {
super(props); super(props);
} }
@ -25,14 +25,13 @@ export class VizTypePicker extends PureComponent<Props> {
return filteredPluginList.length - 1; return filteredPluginList.length - 1;
} }
getPanelPlugins(filter): PanelPlugin[] { get getPanelPlugins(): PanelPlugin[] {
const panels = _.chain(config.panels) const allPanels = config.panels;
.filter({ hideFromList: false })
.map(item => item)
.value();
// add sort by sort property return Object.keys(allPanels)
return _.sortBy(panels, 'sort'); .filter(key => allPanels[key]['hideFromList'] === false)
.map(key => allPanels[key])
.sort((a: PanelPlugin, b: PanelPlugin) => a.sort - b.sort);
} }
renderVizPlugin = (plugin: PanelPlugin, index: number) => { renderVizPlugin = (plugin: PanelPlugin, index: number) => {
@ -63,11 +62,15 @@ export class VizTypePicker extends PureComponent<Props> {
render() { render() {
const filteredPluginList = this.getFilteredPluginList(); const filteredPluginList = this.getFilteredPluginList();
const hasResults = filteredPluginList.length > 0;
return ( return (
<div className="viz-picker"> <div className="viz-picker">
<div className="viz-picker-list"> <div className="viz-picker-list">
{filteredPluginList.map((plugin, index) => this.renderVizPlugin(plugin, index))} {hasResults ? (
filteredPluginList.map((plugin, index) => this.renderVizPlugin(plugin, index))
) : (
<EmptySearchResult>Could not find anything matching your query</EmptySearchResult>
)}
</div> </div>
</div> </div>
); );

View File

@ -15,4 +15,3 @@
} }
} }
} }

View File

@ -16,8 +16,8 @@
"large": "img/icn-heatmap-panel.svg" "large": "img/icn-heatmap-panel.svg"
}, },
"links": [ "links": [
{"name": "Brendan Gregg - Heatmaps", "url": "http://www.brendangregg.com/heatmaps.html"}, { "name": "Brendan Gregg - Heatmaps", "url": "http://www.brendangregg.com/heatmaps.html" },
{"name": "Brendan Gregg - Latency Heatmaps", "url": " http://www.brendangregg.com/HeatMaps/latency.html"} { "name": "Brendan Gregg - Latency Heatmaps", "url": " http://www.brendangregg.com/HeatMaps/latency.html" }
], ],
"version": "5.0.0" "version": "5.0.0"
} }

View File

@ -17,4 +17,3 @@
"version": "5.0.0" "version": "5.0.0"
} }
} }

View File

@ -17,4 +17,3 @@
} }
} }
} }

View File

@ -123,7 +123,6 @@
} }
.viz-picker { .viz-picker {
padding: 0px 20px;
position: relative; position: relative;
} }