Annotations: Use query object instead of passing annotation
This commit is contained in:
1 parent
30f120fa63
commit
ad150afac3
3 files changed
+14
-14
No files matched your search
@@ -354,7 +354,6 @@ export interface QueryEditorProps<
|
||||
TOptions extends DataSourceJsonData = DataSourceJsonData,
|
||||
TVQuery extends DataQuery = TQuery
|
||||
> {
|
||||
annotation?: AnnotationQuery<DataQuery>;
|
||||
datasource: DSType;
|
||||
query: TVQuery;
|
||||
onRunQuery: () => void;
|
||||
|
||||
@@ -167,7 +167,6 @@ export default class StandardAnnotationQueryEditor extends PureComponent<Props,
|
||||
return (
|
||||
<>
|
||||
<QueryEditor
|
||||
annotation={annotation}
|
||||
key={datasource?.name}
|
||||
query={query}
|
||||
datasource={datasource}
|
||||
@@ -176,10 +175,12 @@ export default class StandardAnnotationQueryEditor extends PureComponent<Props,
|
||||
data={response?.panelData}
|
||||
range={getTimeSrv().timeRange()}
|
||||
/>
|
||||
{this.renderStatus()}
|
||||
|
||||
<AnnotationFieldMapper response={response} mappings={annotation.mappings} change={this.onMappingChange} />
|
||||
<br />
|
||||
{datasource.type !== 'datasource' && (
|
||||
<>
|
||||
{this.renderStatus()}
|
||||
<AnnotationFieldMapper response={response} mappings={annotation.mappings} change={this.onMappingChange} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,34 +42,34 @@ const limitOptions = [10, 50, 100, 200, 300, 500, 1000, 2000].map((limit) => ({
|
||||
}));
|
||||
|
||||
interface Props {
|
||||
annotation: GrafanaAnnotationQuery;
|
||||
query: GrafanaAnnotationQuery;
|
||||
onChange: (newValue: GrafanaAnnotationQuery) => void;
|
||||
}
|
||||
|
||||
export default function AnnotationQuery({ annotation, onChange }: Props) {
|
||||
const { limit = 100, matchAny = false, tags = [], type = GrafanaAnnotationType.Tags } = annotation;
|
||||
export default function AnnotationQuery({ query, onChange }: Props) {
|
||||
const { limit = 100, matchAny = false, tags = [], type = GrafanaAnnotationType.Tags } = query;
|
||||
|
||||
const onFilterByChange = (newValue: SelectableValue<GrafanaAnnotationType>) =>
|
||||
onChange({
|
||||
...annotation,
|
||||
...query,
|
||||
type: newValue.value!,
|
||||
});
|
||||
|
||||
const onMaxLimitChange = (newValue: SelectableValue<number>) =>
|
||||
onChange({
|
||||
...annotation,
|
||||
...query,
|
||||
limit: newValue.value!,
|
||||
});
|
||||
|
||||
const onMatchAnyChange = (newValue: React.ChangeEvent<HTMLInputElement>) =>
|
||||
onChange({
|
||||
...annotation,
|
||||
...query,
|
||||
matchAny: newValue.target.checked,
|
||||
});
|
||||
|
||||
const onTagsChange = (tags: string[]) =>
|
||||
onChange({
|
||||
...annotation,
|
||||
...query,
|
||||
tags,
|
||||
});
|
||||
|
||||
@@ -84,7 +84,7 @@ export default function AnnotationQuery({ annotation, onChange }: Props) {
|
||||
</InlineField>
|
||||
</div>
|
||||
<div className="gf-form-inline">
|
||||
{annotation.type === 'tags' && (
|
||||
{query.type === 'tags' && (
|
||||
<>
|
||||
<InlineField label="Match any" labelWidth={18} tooltip={matchTooltipContent}>
|
||||
<div className="gf-form-switch">
|
||||
|
||||
Reference in new issue
Block a user