UtilSrv.ts 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { deprecationWarning } from '@grafana/data';
  2. import { appEvents } from 'app/core/app_events';
  3. import { HideModalEvent, ShowModalEvent } from '../../types/events';
  4. /**
  5. * Old legacy utilSrv exposed to angular services and handles angular modals.
  6. * Not used by any core or known external plugin.
  7. */
  8. export class UtilSrv {
  9. modalScope: any;
  10. /** @ngInject */
  11. constructor() {}
  12. init() {
  13. appEvents.subscribe(ShowModalEvent, (e) => this.showModal(e.payload));
  14. appEvents.subscribe(HideModalEvent, this.hideModal.bind(this));
  15. }
  16. /**
  17. * @deprecated use showModalReact instead that has this capability built in
  18. */
  19. hideModal() {
  20. deprecationWarning('UtilSrv', 'hideModal', '');
  21. if (this.modalScope && this.modalScope.dismiss) {
  22. this.modalScope.dismiss();
  23. }
  24. }
  25. /**
  26. * @deprecated
  27. */
  28. showModal(options: any) {
  29. deprecationWarning('UtilSrv', 'showModal', 'publish ShowModalReactEvent');
  30. }
  31. }