diff --git a/public/app/features/dashboard/components/SubMenu/SubMenuItems.tsx b/public/app/features/dashboard/components/SubMenu/SubMenuItems.tsx index 5ddf27df9191..81cd18320311 100644 --- a/public/app/features/dashboard/components/SubMenu/SubMenuItems.tsx +++ b/public/app/features/dashboard/components/SubMenu/SubMenuItems.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react'; import { selectors } from '@grafana/e2e-selectors'; +import { useSelector } from 'app/types'; import { PickerRenderer } from '../../../variables/pickers/PickerRenderer'; import { VariableHide, VariableModel } from '../../../variables/types'; @@ -13,6 +14,8 @@ interface Props { export const SubMenuItems = ({ variables, readOnly }: Props) => { const [visibleVariables, setVisibleVariables] = useState([]); + const hiddenVariables = useSelector((state) => state.fnGlobalState.hiddenVariables); + useEffect(() => { setVisibleVariables(variables.filter((state) => state.hide !== VariableHide.hideVariable)); }, [variables]); @@ -24,6 +27,10 @@ export const SubMenuItems = ({ variables, readOnly }: Props) => { return ( <> {visibleVariables.map((variable) => { + if (hiddenVariables?.includes(variable.id)) { + return null; + } + return (
{ +const renderWrapperStyle = css` + & button, + & span, + & label, + & input { + height: 24px; + font-size: 12px; + line-height: 24px; + } +`; + +export const PickerRenderer: FunctionComponent = (props) => { const PickerToRender = useMemo(() => variableAdapters.get(props.variable.type).picker, [props.variable]); if (!props.variable) { @@ -23,41 +38,70 @@ export const PickerRenderer = (props: Props) => {
{props.variable.hide !== VariableHide.hideVariable && PickerToRender && ( - +
+ +
)}
); }; +const COMMON_PICKER_LABEL_STYLE: CSSProperties = { + borderRadius: '2px', + border: 'none', + fontWeight: 400, + fontSize: '12px', + padding: '3px 6px', + letterSpacing: '0.15px', + height: '24px', + marginTop: '2px', +}; + function PickerLabel({ variable }: PropsWithChildren): ReactElement | null { const labelOrName = useMemo(() => variable.label || variable.name, [variable]); + const { FNDashboard, mode } = useSelector(({ fnGlobalState }) => fnGlobalState); + + const fnLabelStyle = useMemo( + () => ({ + ...COMMON_PICKER_LABEL_STYLE, + ...(FNDashboard + ? { + color: mode === 'light' ? '#2D333E' : '#DBD9D7', + backgroundColor: mode === 'light' ? '#E0E0E0' : '#56524D', + } + : {}), + }), + [mode, FNDashboard] + ); if (variable.hide !== VariableHide.dontHide) { return null; } + const fnLabelOrName = FNDashboard ? labelOrName.replace('druid_adhoc_filters', 'ad-hoc') : labelOrName; - const elementId = VARIABLE_PREFIX + variable.id; + const elementId = `var-${variable.id}`; if (variable.description) { return ( ); } - return ( ); }