mirror of
https://github.com/grafana/grafana.git
synced 2025-01-06 14:13:11 -06:00
Search: Fix expanded folder icon (#23903)
This commit is contained in:
parent
3bd9e1dda3
commit
b9a40fc346
@ -1,9 +1,10 @@
|
||||
import React, { FC, useCallback } from 'react';
|
||||
import { css, cx } from 'emotion';
|
||||
import { GrafanaTheme } from '@grafana/data';
|
||||
import { Icon, IconButton, IconName, stylesFactory, useTheme } from '@grafana/ui';
|
||||
import { Icon, IconButton, stylesFactory, useTheme } from '@grafana/ui';
|
||||
import { DashboardSection, OnToggleChecked } from '../types';
|
||||
import { SearchCheckbox } from './SearchCheckbox';
|
||||
import { getSectionIcon } from '../utils';
|
||||
|
||||
interface SectionHeaderProps {
|
||||
editable?: boolean;
|
||||
@ -41,7 +42,7 @@ export const SectionHeader: FC<SectionHeaderProps> = ({
|
||||
<SearchCheckbox editable={editable} checked={section.checked} onClick={onSectionChecked} />
|
||||
|
||||
<div className={styles.icon}>
|
||||
<Icon name={section.icon as IconName} />
|
||||
<Icon name={getSectionIcon(section)} />
|
||||
</div>
|
||||
|
||||
<span className={styles.text}>{section.title}</span>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { parse, SearchParserResult } from 'search-query-parser';
|
||||
import { IconName } from '@grafana/ui';
|
||||
import { DashboardQuery, DashboardSection, DashboardSectionItem, SearchAction, UidsToDelete } from './types';
|
||||
import { NO_ID_SECTIONS } from './constants';
|
||||
import { getDashboardSrv } from '../dashboard/services/DashboardSrv';
|
||||
@ -194,9 +195,25 @@ export const getParsedQuery = (query: DashboardQuery, queryParsing = false) => {
|
||||
return { ...parsedQuery, query: parseQuery(query.query).text as string, folderIds };
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if search query has filters enabled. Excludes folderId
|
||||
* @param query
|
||||
*/
|
||||
export const hasFilters = (query: DashboardQuery) => {
|
||||
if (!query) {
|
||||
return false;
|
||||
}
|
||||
return Boolean(query.query || query.tag?.length > 0 || query.starred || query.sort);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get section icon depending on expanded state. Currently works for folder icons only
|
||||
* @param section
|
||||
*/
|
||||
export const getSectionIcon = (section: DashboardSection): IconName => {
|
||||
if (!hasId(section.title)) {
|
||||
return section.icon as IconName;
|
||||
}
|
||||
|
||||
return section.expanded ? 'folder-open' : 'folder';
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user