From e505babbf4d7a9d20ad5a8597bf71a698388f222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 25 Apr 2020 13:08:23 +0200 Subject: [PATCH] ManageDashboards: Fixes and improvements (#23879) * ManageDashboards: Fixes and improvements * Fixed tests * Fixed issue with item height and margin --- .../src/components/Forms/Checkbox.tsx | 6 +- .../IconButton/IconButton.story.tsx | 11 ++- .../src/components/IconButton/IconButton.tsx | 4 +- .../core/components/BackButton/BackButton.tsx | 2 +- .../dashboard/components/DashNav/DashNav.tsx | 2 +- .../DashboardSettings/DashboardSettings.tsx | 2 +- .../features/search/components/ActionRow.tsx | 24 +----- .../components/DashboardSearch.test.tsx | 6 +- .../search/components/ManageDashboards.tsx | 83 ++++--------------- .../search/components/SearchResults.tsx | 15 +++- .../components/SearchResultsFilter.test.tsx | 16 ++-- .../search/components/SearchResultsFilter.tsx | 1 - .../features/search/hooks/useSearchQuery.ts | 21 +---- 13 files changed, 62 insertions(+), 131 deletions(-) diff --git a/packages/grafana-ui/src/components/Forms/Checkbox.tsx b/packages/grafana-ui/src/components/Forms/Checkbox.tsx index e648ae01c4f..67d5ebc9292 100644 --- a/packages/grafana-ui/src/components/Forms/Checkbox.tsx +++ b/packages/grafana-ui/src/components/Forms/Checkbox.tsx @@ -19,6 +19,7 @@ export const getCheckboxStyles = stylesFactory((theme: GrafanaTheme) => { labelStyles.label, css` padding-left: ${theme.spacing.formSpacingBase}px; + white-space: nowrap; ` ), description: cx( @@ -50,11 +51,13 @@ export const getCheckboxStyles = stylesFactory((theme: GrafanaTheme) => { * */ &:checked + span { background: blue; - background: ${theme.colors.formInputBg}; + background: ${theme.colors.formCheckboxBgChecked}; border: none; + &:hover { background: ${theme.colors.formCheckboxBgCheckedHover}; } + &:after { content: ''; position: absolute; @@ -79,6 +82,7 @@ export const getCheckboxStyles = stylesFactory((theme: GrafanaTheme) => { position: absolute; top: 1px; left: 0; + &:hover { cursor: pointer; border-color: ${theme.colors.formInputBorderHover}; diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx index 0b5d28e6ce9..ab7ab8f1088 100644 --- a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx +++ b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx @@ -20,7 +20,12 @@ export const simple = () => { return (
- {renderScenario('body', theme, ['sm', 'md', 'lg', 'xl', 'xxl'], ['search', 'trash-alt', 'arrow-left', 'times'])} + {renderScenario( + 'dashboard', + theme, + ['sm', 'md', 'lg', 'xl', 'xxl'], + ['search', 'trash-alt', 'arrow-left', 'times'] + )} {renderScenario('panel', theme, ['sm', 'md', 'lg', 'xl', 'xxl'], ['search', 'trash-alt', 'arrow-left', 'times'])} {renderScenario('header', theme, ['sm', 'md', 'lg', 'xl', 'xxl'], ['search', 'trash-alt', 'arrow-left', 'times'])}
@@ -31,8 +36,8 @@ function renderScenario(surface: string, theme: GrafanaTheme, sizes: IconSize[], let bg: string = 'red'; switch (surface) { - case 'body': - bg = theme.colors.bodyBg; + case 'dashboard': + bg = theme.colors.dashboardBg; break; case 'panel': bg = theme.colors.bodyBg; diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.tsx index 1b9340a0f05..532957b01f9 100644 --- a/packages/grafana-ui/src/components/IconButton/IconButton.tsx +++ b/packages/grafana-ui/src/components/IconButton/IconButton.tsx @@ -18,7 +18,7 @@ export interface Props extends React.ButtonHTMLAttributes { tooltipPlacement?: TooltipPlacement; } -type SurfaceType = 'body' | 'panel' | 'header'; +type SurfaceType = 'dashboard' | 'panel' | 'header'; export const IconButton = React.forwardRef( ({ name, size = 'md', surface = 'panel', iconType, tooltip, tooltipPlacement, className, ...restProps }, ref) => { @@ -47,7 +47,7 @@ IconButton.displayName = 'IconButton'; function getHoverColor(theme: GrafanaTheme, surface: SurfaceType): string { switch (surface) { - case 'body': + case 'dashboard': return theme.isLight ? theme.palette.gray95 : theme.palette.gray15; case 'panel': return theme.isLight ? theme.palette.gray6 : theme.palette.gray15; diff --git a/public/app/core/components/BackButton/BackButton.tsx b/public/app/core/components/BackButton/BackButton.tsx index c951da4fd75..5ad54ed2701 100644 --- a/public/app/core/components/BackButton/BackButton.tsx +++ b/public/app/core/components/BackButton/BackButton.tsx @@ -3,7 +3,7 @@ import { IconButton } from '@grafana/ui'; import { e2e } from '@grafana/e2e'; export interface Props extends ButtonHTMLAttributes { - surface: 'body' | 'panel'; + surface: 'dashboard' | 'panel' | 'header'; } export const BackButton: React.FC = ({ surface, onClick }) => { diff --git a/public/app/features/dashboard/components/DashNav/DashNav.tsx b/public/app/features/dashboard/components/DashNav/DashNav.tsx index 0d7c686ba8b..d0a0c395132 100644 --- a/public/app/features/dashboard/components/DashNav/DashNav.tsx +++ b/public/app/features/dashboard/components/DashNav/DashNav.tsx @@ -143,7 +143,7 @@ class DashNav extends PureComponent { renderBackButton() { return (
- +
); } diff --git a/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.tsx b/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.tsx index e3f09cab87d..0d663c39b6b 100644 --- a/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/DashboardSettings.tsx @@ -50,7 +50,7 @@ export class DashboardSettings extends PureComponent {
- +
{haveFolder &&
{folderTitle} /
} diff --git a/public/app/features/search/components/ActionRow.tsx b/public/app/features/search/components/ActionRow.tsx index 568cc237883..62f313dbcae 100644 --- a/public/app/features/search/components/ActionRow.tsx +++ b/public/app/features/search/components/ActionRow.tsx @@ -1,6 +1,6 @@ import React, { Dispatch, FC, SetStateAction } from 'react'; import { css } from 'emotion'; -import { HorizontalGroup, RadioButtonGroup, Select, stylesFactory, useTheme } from '@grafana/ui'; +import { HorizontalGroup, RadioButtonGroup, stylesFactory, useTheme, Checkbox } from '@grafana/ui'; import { GrafanaTheme, SelectableValue } from '@grafana/data'; import { SortPicker } from 'app/core/components/Select/SortPicker'; import { TagFilter } from 'app/core/components/TagFilter/TagFilter'; @@ -8,11 +8,6 @@ import { SearchSrv } from 'app/core/services/search_srv'; import { layoutOptions } from '../hooks/useSearchLayout'; import { DashboardQuery } from '../types'; -const starredFilterOptions = [ - { label: 'Yes', value: true }, - { label: 'No', value: false }, -]; - const searchSrv = new SearchSrv(); type onSelectChange = (value: SelectableValue) => void; @@ -24,7 +19,6 @@ interface Props { onTagFilterChange: onSelectChange; query: DashboardQuery; showStarredFilter?: boolean; - hideSelectedTags?: boolean; hideLayout?: boolean; } @@ -36,7 +30,6 @@ export const ActionRow: FC = ({ onTagFilterChange, query, showStarredFilter, - hideSelectedTags, hideLayout, }) => { const theme = useTheme(); @@ -48,24 +41,13 @@ export const ActionRow: FC = ({ {!hideLayout ? : null} - - {showStarredFilter && ( -