summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/utils/menu-handler.ts
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-03-04 14:53:33 +0200
committerMichael Lando <ml636r@att.com>2018-03-07 13:19:05 +0000
commita5445100050e49e83f73424198d73cd72d672a4d (patch)
treecacf4df817df31be23e4e790d1dda857bdae061e /catalog-ui/src/app/utils/menu-handler.ts
parent51157f92c21976cba4914c378aaa3cba49826931 (diff)
Sync Integ to Master
Change-Id: I71e3acc26fa612127756ac04073a522b9cc6cd74 Issue-ID: SDC-977 Signed-off-by: Gitelman, Tal (tg851x) <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/utils/menu-handler.ts')
-rw-r--r--catalog-ui/src/app/utils/menu-handler.ts53
1 files changed, 27 insertions, 26 deletions
diff --git a/catalog-ui/src/app/utils/menu-handler.ts b/catalog-ui/src/app/utils/menu-handler.ts
index d48412a6ed..fc6eb2081a 100644
--- a/catalog-ui/src/app/utils/menu-handler.ts
+++ b/catalog-ui/src/app/utils/menu-handler.ts
@@ -19,6 +19,7 @@
*/
'use strict';
+import * as _ from "lodash";
import {WorkspaceMode, ComponentState} from "./constants";
import {IAppConfigurtaion, IAppMenu, Component} from "../models";
import {ComponentFactory} from "./component-factory";
@@ -92,36 +93,36 @@ export class MenuHandler {
}
- generateBreadcrumbsModelFromComponents = (components:Array<Component>, selected:Component):MenuItemGroup => {
- let result = new MenuItemGroup(0, [], false);
- if (components) {
+ findBreadcrumbComponentIndex = (components:Array<Component>, selected:Component):number => {
+ let selectedItemIdx;
+
+ // Search the component in all components by uuid (and not uniqueid, gives access to an assets's minor versions).
+ selectedItemIdx = _.findIndex(components, (item:Component) => {
+ return item.uuid === selected.uuid;
+ });
- // Search the component in all components by uuid (and not uniqueid, gives access to an assets's minor versions).
- let selectedItem = _.find(components, (item:Component) => {
- return item.uuid === selected.uuid;
+ // If not found search by invariantUUID
+ if (selectedItemIdx === -1) {
+ selectedItemIdx = _.findIndex(components, (item:Component) => {
+ //invariantUUID && Certified State matches between major versions
+ return item.invariantUUID === selected.invariantUUID && item.lifecycleState === ComponentState.CERTIFIED;
});
+ }
- // If not found search by invariantUUID
- if (undefined == selectedItem) {
- selectedItem = _.find(components, (item:Component) => {
- //invariantUUID && Certified State matches between major versions
- return item.invariantUUID === selected.invariantUUID && item.lifecycleState === ComponentState.CERTIFIED;
- });
- }
+ // If not found search by name (name is unique).
+ if (selectedItemIdx === -1) {
+ selectedItemIdx = _.findIndex(components, (item:Component) => {
+ return item.name === selected.name;
+ });
+ }
- // If not found search by name (name is unique).
- if (undefined == selectedItem) {
- selectedItem = _.find(components, (item:Component) => {
- return item.name === selected.name;
- });
- }
-
- if(!selectedItem){
- result.selectedIndex = components.length;
- }else{
- result.selectedIndex = components.indexOf(selectedItem);
- }
- components[result.selectedIndex] = selected;
+ return selectedItemIdx;
+ };
+
+ generateBreadcrumbsModelFromComponents = (components:Array<Component>, selected:Component):MenuItemGroup => {
+ let result = new MenuItemGroup(0, [], false);
+ if (components) {
+ result.selectedIndex = this.findBreadcrumbComponentIndex(components, selected);
let clickItemCallback = (component:Component):ng.IPromise<boolean> => {
this.$state.go('workspace.general', {
id: component.uniqueId,