From 6c7b46ed1d46ef55594d06957e49d8e24a797a92 Mon Sep 17 00:00:00 2001 From: Joao Silva <100691367+JoaoSilvaGrafana@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:37:42 +0100 Subject: [PATCH] DashList: Add tooltip for star dashboard icon (#73490) --- .../app/plugins/panel/dashlist/DashList.tsx | 92 ++----------------- public/app/plugins/panel/dashlist/styles.ts | 14 +-- 2 files changed, 8 insertions(+), 98 deletions(-) diff --git a/public/app/plugins/panel/dashlist/DashList.tsx b/public/app/plugins/panel/dashlist/DashList.tsx index 75912315190..84dcd3d8cd8 100644 --- a/public/app/plugins/panel/dashlist/DashList.tsx +++ b/public/app/plugins/panel/dashlist/DashList.tsx @@ -1,19 +1,8 @@ -import { css, cx } from '@emotion/css'; import { take } from 'lodash'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; -import { - DateTime, - GrafanaTheme2, - InterpolateFunction, - PanelProps, - textUtil, - UrlQueryValue, - urlUtil, -} from '@grafana/data'; -import { CustomScrollbar, stylesFactory, useStyles2 } from '@grafana/ui'; -import { Icon, IconProps } from '@grafana/ui/src/components/Icon/Icon'; -import { getFocusStyles } from '@grafana/ui/src/themes/mixins'; +import { DateTime, InterpolateFunction, PanelProps, textUtil, UrlQueryValue, urlUtil } from '@grafana/data'; +import { CustomScrollbar, useStyles2, IconButton } from '@grafana/ui'; import { getConfig } from 'app/core/config'; import { setStarred } from 'app/core/reducers/navBarTree'; import { getBackendSrv } from 'app/core/services/backend_srv'; @@ -182,12 +171,10 @@ export function DashList(props: PanelProps) { {dash.folderTitle &&
{dash.folderTitle}
} - toggleDashboardStar(e, dash)} /> @@ -211,68 +198,3 @@ export function DashList(props: PanelProps) { ); } - -interface IconToggleProps extends Partial { - enabled: IconProps; - disabled: IconProps; - checked: boolean; -} - -function IconToggle({ - enabled, - disabled, - checked, - onClick, - className, - 'aria-label': ariaLabel, - ...otherProps -}: IconToggleProps) { - const toggleCheckbox = useCallback( - (e: React.MouseEvent) => { - e.preventDefault(); - e.stopPropagation(); - - onClick?.(e); - }, - [onClick] - ); - - const iconPropsOverride = checked ? enabled : disabled; - const iconProps = { ...otherProps, ...iconPropsOverride }; - const styles = useStyles2(getCheckboxStyles); - return ( - - ); -} - -export const getCheckboxStyles = stylesFactory((theme: GrafanaTheme2) => { - return { - wrapper: css({ - display: 'flex', - alignSelf: 'center', - cursor: 'pointer', - zIndex: 1, - }), - checkBox: css({ - appearance: 'none', - '&:focus-visible + *': { - ...getFocusStyles(theme), - borderRadius: theme.shape.radius.default, - }, - }), - icon: css({ - marginBottom: 0, - verticalAlign: 'baseline', - display: 'flex', - }), - }; -}); diff --git a/public/app/plugins/panel/dashlist/styles.ts b/public/app/plugins/panel/dashlist/styles.ts index 22fcbf0e177..9dab97be66d 100644 --- a/public/app/plugins/panel/dashlist/styles.ts +++ b/public/app/plugins/panel/dashlist/styles.ts @@ -17,6 +17,7 @@ export const getStyles = (theme: GrafanaTheme2) => ({ border-bottom: 1px solid ${theme.colors.border.weak}; margin-right: ${theme.spacing(1)}; padding: ${theme.spacing(1)}; + align-items: center; &:hover { a { @@ -25,12 +26,6 @@ export const getStyles = (theme: GrafanaTheme2) => ({ } } `, - dashlistStar: css` - align-self: center; - margin-right: 0px; - color: ${theme.colors.secondary.text}; - z-index: 1; - `, dashlistFolder: css` color: ${theme.colors.text.secondary}; font-size: ${theme.typography.bodySmall.fontSize}; @@ -55,11 +50,4 @@ export const getStyles = (theme: GrafanaTheme2) => ({ position: relative; list-style: none; `, - gridContainer: css` - display: grid; - gap: ${theme.spacing(1)}; - grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); - list-style: none; - margin-bottom: ${theme.spacing(1)}; - `, });