{ "version": 3, "sources": ["../ui/app/components/mn_pluggable_ui_registry.js"], "sourcesContent": ["/*\nCopyright 2015-Present Couchbase, Inc.\n\nUse of this software is governed by the Business Source License included in\nthe file licenses/BSL-Couchbase.txt. As of the Change Date specified in that\nfile, in accordance with the Business Source License, use of this software will\nbe governed by the Apache License, Version 2.0, included in the file\nlicenses/APL2.txt.\n*/\n\nimport angular from 'angular';\nimport _ from 'lodash';\n\nlet MnPluggableUiRegistry = 'mnPluggableUiRegistry';\nexport default MnPluggableUiRegistry;\n\nangular\n .module(MnPluggableUiRegistry, [])\n .provider(MnPluggableUiRegistry, MnPluggableUiRegistryProvider)\n .factory('mnPluggableTabUtil', MnPluggableTabUtil)\n .directive('mnPluggableUiTabs', [\"mnPluggableUiRegistry\", \"mnPluggableTabUtil\", \"$compile\", MnPluggableUiTabs]);\n\n\nfunction MnPluggableTabUtil() {\n\n return {\n getTabTemplate: getTabTemplate\n };\n\n function getTabTemplate(config, tabBarName) {\n return \"\" +\n config.name +\n \"\";\n }\n\n}\n\n\nfunction MnPluggableUiTabs(mnPluggableUiRegistry, mnPluggableTabUtil, $compile) {\n return {\n link: link\n };\n\n function link($scope, $element, $attrs) {\n var pluggableUiConfigs = mnPluggableUiRegistry.getConfigsByTabBarName($attrs.mnTabBarName);\n if (!pluggableUiConfigs.length) {\n return;\n }\n pluggableUiConfigs = _.sortBy(pluggableUiConfigs, 'index');\n angular.forEach(pluggableUiConfigs, function (config) {\n config.ngShow = config.ngShow == undefined ? true : config.ngShow;\n if (config.after) {\n var targetTab = $element[0].querySelector(\"[mn-tab='\" + config.after + \"']\");\n if (!targetTab) {\n throw new Error(\"There is no tab with mn-tab=\" + config.after + \" in \" + $attrs.mnTabBarName);\n }\n let compiled = $compile(mnPluggableTabUtil.getTabTemplate(config, $attrs.mnTabBarName))($scope);\n angular.element(targetTab).after(compiled);\n } else {\n let compiled = $compile(mnPluggableTabUtil.getTabTemplate(config, $attrs.mnTabBarName))($scope);\n $element.append(compiled);\n }\n });\n }\n}\n\nfunction MnPluggableUiRegistryProvider() {\n var _configs = [];\n\n this.registerConfig = registerConfig;\n this.$get = mnPluggableUiRegistryFactory;\n\n /**\n * Registers a UI component config with the pluggable UI registry service so that the\n * component can be displayed in the UI.\n *\n * The pluggable UI framework understands the following attributes of the config:\n * 1) name - the name of the UI component to be registered. This is used appropriately\n * in the UI when the component is displayed. For instance, if the component is\n * rendered in a tab, the value of name will be used in the tab name.\n * 2) state - the name of the ui.router state for this component. When the time comes to\n * render the component this is what is used to find it.\n * 3) plugIn - where the component plugs-in to the UI. Currently only 2 values are supported.\n * If a value other than these 2 is specified, the component won't be displayed.\n * a) 'adminTab' - to be used in the case that the pluggable component wishes to plug-in to\n * global nav bar\n * b) 'settingsTab' - to be used in the case that the pluggable component wishes to\n * plug in to the the settings tab bar\n *\n * Any attributes beyond these are not understood and are ignored.\n * @param config\n */\n function registerConfig(config) {\n _configs.push(config);\n }\n\n function mnPluggableUiRegistryFactory() {\n\n return {\n getConfigs: getConfigs,\n getConfigsByTabBarName: getConfigsByTabBarName\n };\n\n /**\n * Returns a list of the registered plugabble UI configs.\n * @returns {Array}\n */\n function getConfigs() {\n return _configs;\n }\n function getConfigsByTabBarName(tabBarName) {\n return _.filter(_configs, {plugIn: tabBarName});\n }\n }\n}\n"], "mappings": "mIAaA,GAAI,uBAAwB,wBACrB,iCAAQ,sBAEf,UACG,OAAO,sBAAuB,IAC9B,SAAS,sBAAuB,+BAChC,QAAQ,qBAAsB,oBAC9B,UAAU,oBAAqB,CAAC,wBAAyB,qBAAsB,WAAY,oBAG9F,6BAA8B,CAE5B,MAAO,CACL,gBAGF,wBAAwB,OAAQ,WAAY,CAC1C,MAAO,eACU,OAAO,OACtB,WAAgB,QAAO,eAAiB,iBAAmB,IAC1D,aAAc,aAAe,QAC7B,IACD,aAAiB,OAAO,MACvB,QAAO,gBACP,6BAAiC,OAAO,gBAAkB,yBAC1D,gCAAqC,IACtC,OAAO,KACP,QAjBG,gDAuBT,2B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