Fix wrong selected tab in top-nav 05/68005/2
authorIdan Amit <ia096e@intl.att.com>
Thu, 20 Sep 2018 07:00:37 +0000 (10:00 +0300)
committerMichael Lando <ml636r@att.com>
Thu, 20 Sep 2018 10:06:59 +0000 (10:06 +0000)
Fixed a bug with wrong selected tabs in the top-nav

Change-Id: I0a4fdb2d62154207b60fee641bf28b7f971d2456
Issue-ID: SDC-1583
Signed-off-by: Idan Amit <ia096e@intl.att.com>
catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts

index 881a916..a253b3a 100644 (file)
@@ -50,6 +50,7 @@ export class TopNavComponent {
 
     public topLvlMenu:MenuItemGroup;
     public user:IUserProperties;
+    private topNavPlugins: Array<Plugin>;
 
     constructor(private translateService:TranslateService,
                 @Inject('$state') private $state:ng.ui.IStateService,
@@ -69,7 +70,7 @@ export class TopNavComponent {
         this.topLvlMenu.menuItems.every((item:MenuItem, index:number)=> {
             if (item.state === this.$state.current.name) {
                 if (this.$state.current.name === 'plugins') {
-                    const pluginIdx = _.findIndex(PluginsConfiguration.plugins, (plugin: Plugin) => plugin.pluginStateUrl === this.$state.params.path);
+                    const pluginIdx = _.findIndex(this.topNavPlugins, (plugin: Plugin) => plugin.pluginStateUrl === this.$state.params.path);
                     if (pluginIdx !== -1) {
                         result = index + pluginIdx;
                         return false;
@@ -112,6 +113,9 @@ export class TopNavComponent {
     ngOnInit() {
         console.log('Nav is init!', this.menuModel);
         this.user = this.userService.getLoggedinUser();
+        this.topNavPlugins = _.filter(PluginsConfiguration.plugins, (plugin: Plugin) => {
+            return plugin.pluginDisplayOptions["tab"] !== undefined;
+        });
 
         this.translateService.languageChangedObservable.subscribe((lang) => {
             let tmpArray: Array<MenuItem> = [