QueryEditor: datasource getQueryDisplayText error (#114106)
Fixes an issue where `getQueryDisplayText` throes an error and breaks the query editor.
This commit is contained in:
@@ -310,11 +310,18 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
|
||||
|
||||
renderCollapsedText(): string | null {
|
||||
const { datasource } = this.state;
|
||||
if (datasource?.getQueryDisplayText) {
|
||||
return datasource.getQueryDisplayText(this.props.query);
|
||||
|
||||
if (!datasource || typeof datasource.getQueryDisplayText !== 'function') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
try {
|
||||
return datasource.getQueryDisplayText(this.props.query);
|
||||
} catch (error) {
|
||||
// Some datasource plugins may throw errors in getQueryDisplayText
|
||||
// Return null gracefully to prevent the query editor from crashing.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
renderWarnings = (type: string): JSX.Element | null => {
|
||||
|
||||
Reference in New Issue
Block a user