mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Fix variable labels * Add proper labeling for input * Add ids to PickerRenderer * Fix tests * Update PR feedback * OptionsPicker: Change to id * Inherit aria attributes * Add checkbox role * Fix typo * Add proper label reference * Update role and label * Prevent spreadng non-DOM attributes * Move form layout to other component * Remove haspopup * Add testid to selector * Add HTMLProps extension * Use list * Move styles outside of class * Add cx
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import React, { FunctionComponent, useEffect, useState } from 'react';
|
|
import { VariableHide, VariableModel } from '../../../variables/types';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { PickerRenderer } from '../../../variables/pickers/PickerRenderer';
|
|
|
|
interface Props {
|
|
variables: VariableModel[];
|
|
}
|
|
|
|
export const SubMenuItems: FunctionComponent<Props> = ({ variables }) => {
|
|
const [visibleVariables, setVisibleVariables] = useState<VariableModel[]>([]);
|
|
|
|
useEffect(() => {
|
|
setVisibleVariables(variables.filter((state) => state.hide !== VariableHide.hideVariable));
|
|
}, [variables]);
|
|
|
|
if (visibleVariables.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{visibleVariables.map((variable) => {
|
|
return (
|
|
<div
|
|
key={variable.id}
|
|
className="submenu-item gf-form-inline"
|
|
data-testid={selectors.pages.Dashboard.SubMenu.submenuItem}
|
|
>
|
|
<PickerRenderer variable={variable} />
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
};
|