Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/scenes/src/locales/en-US/grafana-scenes.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"collapse": "Collapse",
"collapse-filters": "Collapse filters",
"expand-filters": "Expand filters",
"filters-label": "Filters:",
"group-by-label": "Group by:",
"restore-default-group-by": "Restore groupby set by this dashboard.",
"show-more-filters_one": "Show {{count}} more filters",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ interface Props {
}

export const AdHocFiltersComboboxRenderer = memo(function AdHocFiltersComboboxRenderer({ controller }: Props) {
const { originFilters, filters, readOnly, collapsible, valueRecommendations, enableGroupBy, groupByRestorable } =
controller.useState();
const {
originFilters,
filters,
readOnly,
collapsible,
valueRecommendations,
enableGroupBy,
hideLabel,
variableLabel,
groupByRestorable,
} = controller.useState();
const styles = useStyles2(getStyles);
const theme = useTheme2();
const [collapsed, setCollapsed] = useState(true);
Expand Down Expand Up @@ -93,12 +102,20 @@ export const AdHocFiltersComboboxRenderer = memo(function AdHocFiltersComboboxRe
>
{!readOnly && valueRecommendations && <valueRecommendations.Component model={valueRecommendations} />}

{enableGroupBy && hideLabel && (
<span id={`${variableControlId}-label`} className={styles.filtersLabel}>
{variableLabel
? `${variableLabel}:`
: t('grafana-scenes.variables.adhoc-filters-combobox-renderer.filters-label', 'Filters:')}
</span>
)}

{adhocFiltersToRender.length > 0 && (
// if there are filters already selected, this makes sure
// that the input is announced before focussing on the pills
<span
tabIndex={0}
aria-labelledby={variableControlId}
aria-labelledby={hideLabel ? `${variableControlId}-label` : variableControlId}
className={styles.screenReaderOnlyLabel}
data-testid="AdHocFilter-label-announcer"
/>
Expand Down Expand Up @@ -318,6 +335,12 @@ const getStyles = (theme: GrafanaTheme2) => ({
backgroundColor: theme.colors.border.weak,
flexShrink: 0,
}),
filtersLabel: css({
...theme.typography.bodySmall,
fontWeight: theme.typography.fontWeightBold,
color: theme.colors.text.primary,
whiteSpace: 'nowrap',
}),
groupByLabel: css({
...theme.typography.bodySmall,
fontWeight: theme.typography.fontWeightBold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface AdHocFiltersControllerState {
valueRecommendations?: AdHocFiltersRecommendations;
drilldownRecommendationsEnabled?: boolean;
enableGroupBy?: boolean;
hideLabel?: boolean;
variableLabel?: string;
groupByRestorable?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SelectableValue } from '@grafana/data';
import { SelectableValue, VariableHide } from '@grafana/data';
import { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';
import { AdHocFiltersController, AdHocFiltersControllerState } from './AdHocFiltersController';
import { getQueryController } from '../../../core/sceneGraph/getQueryController';
Expand Down Expand Up @@ -29,6 +29,8 @@ export class AdHocFiltersVariableController implements AdHocFiltersController {
valueRecommendations: this.model.getRecommendations(),
drilldownRecommendationsEnabled: state.drilldownRecommendationsEnabled,
enableGroupBy: state.enableGroupBy,
hideLabel: state.hide === VariableHide.hideLabel,
variableLabel: state.label,
groupByRestorable: this.model.isGroupByRestorable(),
};
}
Expand Down
Loading