mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Annotations: Add custom label for custom values in builtin annotations (#36691)
This commit is contained in:
@@ -15,6 +15,7 @@ export interface TermCount {
|
|||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
allowCustomValue?: boolean;
|
allowCustomValue?: boolean;
|
||||||
|
formatCreateLabel?: (input: string) => string;
|
||||||
/** Do not show selected values inside Select. Useful when the values need to be shown in some other components */
|
/** Do not show selected values inside Select. Useful when the values need to be shown in some other components */
|
||||||
hideValues?: boolean;
|
hideValues?: boolean;
|
||||||
inputId?: string;
|
inputId?: string;
|
||||||
@@ -33,6 +34,7 @@ const filterOption = (option: any, searchQuery: string) => {
|
|||||||
|
|
||||||
export const TagFilter: FC<Props> = ({
|
export const TagFilter: FC<Props> = ({
|
||||||
allowCustomValue = false,
|
allowCustomValue = false,
|
||||||
|
formatCreateLabel,
|
||||||
hideValues,
|
hideValues,
|
||||||
inputId,
|
inputId,
|
||||||
isClearable,
|
isClearable,
|
||||||
@@ -65,6 +67,7 @@ export const TagFilter: FC<Props> = ({
|
|||||||
|
|
||||||
const selectOptions = {
|
const selectOptions = {
|
||||||
allowCustomValue,
|
allowCustomValue,
|
||||||
|
formatCreateLabel,
|
||||||
defaultOptions: true,
|
defaultOptions: true,
|
||||||
filterOption,
|
filterOption,
|
||||||
getOptionLabel: (i: any) => i.label,
|
getOptionLabel: (i: any) => i.label,
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export default function AnnotationQueryEditor({ query, onChange }: Props) {
|
|||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onFormatCreateLabel = (input: string) => `Use custom value: ${input}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FieldSet className={styles.container}>
|
<FieldSet className={styles.container}>
|
||||||
<Field label="Filter by">
|
<Field label="Filter by">
|
||||||
@@ -92,6 +94,7 @@ export default function AnnotationQueryEditor({ query, onChange }: Props) {
|
|||||||
<Field label="Tags" description={tagsTooltipContent}>
|
<Field label="Tags" description={tagsTooltipContent}>
|
||||||
<TagFilter
|
<TagFilter
|
||||||
allowCustomValue
|
allowCustomValue
|
||||||
|
formatCreateLabel={onFormatCreateLabel}
|
||||||
inputId="grafana-annotations__tags"
|
inputId="grafana-annotations__tags"
|
||||||
onChange={onTagsChange}
|
onChange={onTagsChange}
|
||||||
tagOptions={getAnnotationTags}
|
tagOptions={getAnnotationTags}
|
||||||
|
|||||||
Reference in New Issue
Block a user