mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
fix: datatrails: show a warning when search yields empty results (#81444)
* fix: datatrails: show a warning when search yields empty results
This commit is contained in:
parent
226c76dc93
commit
24a6e6a1b4
@ -217,9 +217,14 @@ export class MetricSelectScene extends SceneObjectBase<MetricSelectSceneState> {
|
||||
};
|
||||
|
||||
public static Component = ({ model }: SceneComponentProps<MetricSelectScene>) => {
|
||||
const { showHeading, searchQuery, showPreviews } = model.useState();
|
||||
const { showHeading, searchQuery, showPreviews, body } = model.useState();
|
||||
const { children } = body.useState();
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
const searchTooStrictWarning = children.length === 0 && searchQuery && (
|
||||
<div className={styles.alternateMessage}>There are no results found. Try adjusting your search or filters.</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
{showHeading && (
|
||||
@ -231,6 +236,7 @@ export class MetricSelectScene extends SceneObjectBase<MetricSelectSceneState> {
|
||||
<Input placeholder="Search metrics" value={searchQuery} onChange={model.onSearchChange} />
|
||||
<InlineSwitch showLabel={true} label="Show previews" value={showPreviews} onChange={model.onTogglePreviews} />
|
||||
</div>
|
||||
{searchTooStrictWarning}
|
||||
<model.state.body.Component model={model.state.body} />
|
||||
</div>
|
||||
);
|
||||
@ -318,6 +324,11 @@ function getStyles(theme: GrafanaTheme2) {
|
||||
gap: theme.spacing(2),
|
||||
marginBottom: theme.spacing(1),
|
||||
}),
|
||||
alternateMessage: css({
|
||||
fontStyle: 'italic',
|
||||
marginTop: theme.spacing(7),
|
||||
textAlign: 'center',
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user