mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* build(webpack): replace babel-loader with esbuild-loader * build(webpack): add esbuild minifier to production builds * Wip * Removed ngInject and replaced with manual inject params * chore: bump esbuild to 0.15.13 * Fixed angular issues * build(frontend): update esbuild to 0.16.16 * chore(webpack): support browserslist for esbuild * build(esbuild): unify versions of esbuild to 0.16.17 and esbuild-loader to 2.21.0 Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import angular from 'angular';
|
|
|
|
const directiveModule = angular.module('grafana.directives');
|
|
const directiveCache: any = {};
|
|
|
|
directiveModule.directive('panelEditorTab', ['dynamicDirectiveSrv', panelEditorTab]);
|
|
|
|
function panelEditorTab(dynamicDirectiveSrv: any) {
|
|
return dynamicDirectiveSrv.create({
|
|
scope: {
|
|
ctrl: '=',
|
|
editorTab: '=',
|
|
},
|
|
directive: (scope: any) => {
|
|
const pluginId = scope.ctrl.pluginId;
|
|
const tabName = scope.editorTab.title
|
|
.toLowerCase()
|
|
.replace(' ', '-')
|
|
.replace('&', '')
|
|
.replace(' ', '')
|
|
.replace(' ', '-');
|
|
|
|
if (directiveCache[pluginId]) {
|
|
if (directiveCache[pluginId][tabName]) {
|
|
return directiveCache[pluginId][tabName];
|
|
}
|
|
} else {
|
|
directiveCache[pluginId] = [];
|
|
}
|
|
|
|
const result = {
|
|
fn: () => scope.editorTab.directiveFn(),
|
|
name: `panel-editor-tab-${pluginId}${tabName}`,
|
|
};
|
|
|
|
directiveCache[pluginId][tabName] = result;
|
|
|
|
return result;
|
|
},
|
|
});
|
|
}
|