panel_editor_tab.ts 798 B

123456789101112131415161718192021222324252627282930
  1. import angular from 'angular';
  2. var directiveModule = angular.module('grafana.directives');
  3. /** @ngInject */
  4. function panelEditorTab(dynamicDirectiveSrv) {
  5. return dynamicDirectiveSrv.create({
  6. scope: {
  7. ctrl: '=',
  8. editorTab: '=',
  9. index: '=',
  10. },
  11. directive: scope => {
  12. var pluginId = scope.ctrl.pluginId;
  13. var tabIndex = scope.index;
  14. // create a wrapper for directiveFn
  15. // required for metrics tab directive
  16. // that is the same for many panels but
  17. // given different names in this function
  18. var fn = () => scope.editorTab.directiveFn();
  19. return Promise.resolve({
  20. name: `panel-editor-tab-${pluginId}${tabIndex}`,
  21. fn: fn,
  22. });
  23. },
  24. });
  25. }
  26. directiveModule.directive('panelEditorTab', panelEditorTab);