2021-11-17 06:12:18 -06:00
|
|
|
import { deprecationWarning } from '@grafana/data';
|
|
|
|
import { appEvents } from 'app/core/app_events';
|
|
|
|
|
2022-04-22 08:33:13 -05:00
|
|
|
import { HideModalEvent, ShowModalEvent } from '../../types/events';
|
|
|
|
|
2021-11-17 06:12:18 -06:00
|
|
|
/**
|
|
|
|
* Old legacy utilSrv exposed to angular services and handles angular modals.
|
|
|
|
* Not used by any core or known external plugin.
|
|
|
|
*/
|
|
|
|
export class UtilSrv {
|
|
|
|
modalScope: any;
|
|
|
|
|
2022-05-31 01:19:29 -05:00
|
|
|
constructor() {}
|
2021-11-17 06:12:18 -06:00
|
|
|
|
|
|
|
init() {
|
|
|
|
appEvents.subscribe(ShowModalEvent, (e) => this.showModal(e.payload));
|
|
|
|
appEvents.subscribe(HideModalEvent, this.hideModal.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated use showModalReact instead that has this capability built in
|
|
|
|
*/
|
|
|
|
hideModal() {
|
2022-05-31 01:19:29 -05:00
|
|
|
deprecationWarning('UtilSrv', 'hideModal', '');
|
2021-11-17 06:12:18 -06:00
|
|
|
if (this.modalScope && this.modalScope.dismiss) {
|
|
|
|
this.modalScope.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-05-31 01:19:29 -05:00
|
|
|
* @deprecated
|
2021-11-17 06:12:18 -06:00
|
|
|
*/
|
|
|
|
showModal(options: any) {
|
2022-05-31 01:19:29 -05:00
|
|
|
deprecationWarning('UtilSrv', 'showModal', 'publish ShowModalReactEvent');
|
2021-11-17 06:12:18 -06:00
|
|
|
}
|
|
|
|
}
|