|
@@ -161,6 +161,10 @@ type Props = WithRouterProps & {
|
|
|
* Map of tags
|
|
|
*/
|
|
|
supportedTags?: {[key: string]: Tag};
|
|
|
+ /**
|
|
|
+ * Type of supported tags
|
|
|
+ */
|
|
|
+ supportedTagType?: ItemType;
|
|
|
/**
|
|
|
* Maximum number of search items to display or a falsey value for no
|
|
|
* maximum
|
|
@@ -702,8 +706,8 @@ class SmartSearchBar extends React.Component<Props, State> {
|
|
|
/**
|
|
|
* Returns array of possible key values that substring match `query`
|
|
|
*/
|
|
|
- getTagKeys(query: string): SearchItem[] {
|
|
|
- const {prepareQuery} = this.props;
|
|
|
+ getTagKeys(query: string): [SearchItem[], ItemType] {
|
|
|
+ const {prepareQuery, supportedTagType} = this.props;
|
|
|
|
|
|
const supportedTags = this.props.supportedTags ?? {};
|
|
|
|
|
@@ -722,7 +726,10 @@ class SmartSearchBar extends React.Component<Props, State> {
|
|
|
tagKeys = tagKeys.filter(key => key !== 'environment:');
|
|
|
}
|
|
|
|
|
|
- return tagKeys.map(value => ({value, desc: value}));
|
|
|
+ return [
|
|
|
+ tagKeys.map(value => ({value, desc: value})),
|
|
|
+ supportedTagType ?? ItemType.TAG_KEY,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -901,14 +908,14 @@ class SmartSearchBar extends React.Component<Props, State> {
|
|
|
};
|
|
|
|
|
|
async generateTagAutocompleteGroup(tagName: string): Promise<AutocompleteGroup> {
|
|
|
- const tagKeys = this.getTagKeys(tagName);
|
|
|
+ const [tagKeys, tagType] = this.getTagKeys(tagName);
|
|
|
const recentSearches = await this.getRecentSearches();
|
|
|
|
|
|
return {
|
|
|
searchItems: tagKeys,
|
|
|
recentSearchItems: recentSearches ?? [],
|
|
|
tagName,
|
|
|
- type: ItemType.TAG_KEY,
|
|
|
+ type: tagType,
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -982,10 +989,10 @@ class SmartSearchBar extends React.Component<Props, State> {
|
|
|
// does not get updated)
|
|
|
this.setState({searchTerm: query});
|
|
|
|
|
|
- const tagKeys = this.getTagKeys('');
|
|
|
+ const [tagKeys, tagType] = this.getTagKeys('');
|
|
|
const recentSearches = await this.getRecentSearches();
|
|
|
|
|
|
- this.updateAutoCompleteState(tagKeys, recentSearches ?? [], '', ItemType.TAG_KEY);
|
|
|
+ this.updateAutoCompleteState(tagKeys, recentSearches ?? [], '', tagType);
|
|
|
return;
|
|
|
}
|
|
|
// cursor on whitespace show default "help" search terms
|