Skip to content

Commit

Permalink
Unified alerting query type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
unflag committed Oct 26, 2023
1 parent b05d1ac commit 79e15b2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export class QueryEditor extends PureComponent<Props> {
children?: React.ReactNode;
}>
) {
if (
this.props.query.queryType = 'query';
if (this.props.app && this.props.app === CoreApp.UnifiedAlerting) {
this.props.query.queryType = 'alert';
}

const { onChange, query } = this.props;
onChange({ ...query, queryType: props.query.queryType });

if ((
props.query.keyspace &&
props.query.keyspace !== '' &&
props.query.table &&
Expand All @@ -41,7 +49,8 @@ export class QueryEditor extends PureComponent<Props> {
props.query.columnId !== '' &&
props.query.valueId &&
props.query.valueId !== ''
) {
) || (props.query.target && props.query.target !== ''))
{
this.props.onRunQuery();
}
}
Expand Down Expand Up @@ -149,11 +158,6 @@ export class QueryEditor extends PureComponent<Props> {
render() {
const options = this.props;

this.props.query.queryType = 'query';
if (this.props.app !== undefined && this.props.app === CoreApp.UnifiedAlerting) {
this.props.query.queryType = 'alert';
}

return (
<div>
{options.query.rawQuery && (
Expand All @@ -168,7 +172,9 @@ export class QueryEditor extends PureComponent<Props> {
<TextArea
placeholder={'Enter a CQL query'}
onChange={this.onQueryTextChange}
onBlur={this.props.onRunQuery}
onBlur={() => {
this.onRunQuery(this.props);
}}
value={this.props.query.target}
/>
</InlineField>
Expand All @@ -179,7 +185,9 @@ export class QueryEditor extends PureComponent<Props> {
<Input
name="alias"
onChange={this.onAliasChange}
onBlur={this.props.onRunQuery}
onBlur={() => {
this.onRunQuery(this.props);
}}
value={this.props.query.alias || ''}
/>
</InlineField>
Expand Down

0 comments on commit 79e15b2

Please sign in to comment.