Annotations: Ensure legacy annotation editors are cleaned up properly when switching datasource (#41115) (#41208)

* Annotations: Ensure Angular-based annotation editors are cleaned up properly

* Annotations: Remove ng-if instead of wrapping in div

(cherry picked from commit e0b2e0b152)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-11-02 17:04:29 +01:00
committed by GitHub
co-authored by Ashley Harrison
parent 49416ac031
commit a306205a58
@@ -52,7 +52,10 @@ export class AngularEditorLoader extends React.PureComponent<Props> {
}
const loader = getAngularLoader();
const template = `<plugin-component ng-if="!ctrl.currentDatasource.annotations" type="annotations-query-ctrl"> </plugin-component>`;
// NOTE: BE CAREFUL HERE
// If this template contains an ng-if, then it won't be removed correctly by AngularLoader.
// The compiledElem will only contain the single comment node (e.g. <!-- ngIf !ctrl.currentDatasource.annotations -->)
const template = `<plugin-component type="annotations-query-ctrl"> </plugin-component>`;
const scopeProps = {
ctrl: {
currentDatasource: this.props.datasource,