Alerting: Move Visualization to QueryRow (#34658)

* move visualization to queryeditorrow

* add prop to hide disable query

* move panel plugin state outside the vizwrapper
This commit is contained in:
Peter Holmberg
2021-05-27 10:46:06 +02:00
committed by GitHub
parent 811704fd2e
commit 23cf31a567
4 changed files with 30 additions and 18 deletions

View File

@@ -42,6 +42,8 @@ interface Props {
onRemoveQuery: (query: DataQuery) => void;
onChange: (query: DataQuery) => void;
onRunQuery: () => void;
visualization?: ReactNode;
hideDisableQuery?: boolean;
}
interface State {
@@ -271,7 +273,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
}
renderActions = (props: QueryOperationRowRenderProps) => {
const { query } = this.props;
const { query, hideDisableQuery = false } = this.props;
const { hasTextEditMode, datasource } = this.state;
const isDisabled = query.hide;
@@ -292,11 +294,13 @@ export class QueryEditorRow extends PureComponent<Props, State> {
/>
)}
<QueryOperationAction title="Duplicate query" icon="copy" onClick={this.onCopyQuery} />
<QueryOperationAction
title="Disable/enable query"
icon={isDisabled ? 'eye-slash' : 'eye'}
onClick={this.onDisableQuery}
/>
{!hideDisableQuery ? (
<QueryOperationAction
title="Disable/enable query"
icon={isDisabled ? 'eye-slash' : 'eye'}
onClick={this.onDisableQuery}
/>
) : null}
<QueryOperationAction title="Remove query" icon="trash-alt" onClick={this.onRemoveQuery} />
</HorizontalGroup>
);
@@ -321,7 +325,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
};
render() {
const { query, id, index } = this.props;
const { query, id, index, visualization } = this.props;
const { datasource, showingHelp } = this.state;
const isDisabled = query.hide;
@@ -359,6 +363,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
)}
{editor}
</ErrorBoundaryAlert>
{visualization}
</div>
</QueryOperationRow>
</div>