2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 * Created by obarda on 3/30/2016.
25 import {IUserProperties, IAppMenu, Resource, Component} from "app/models";
27 WorkspaceMode, ComponentFactory, ChangeLifecycleStateHandler, Role, ComponentState, MenuItemGroup, MenuHandler,
28 MenuItem, ModalsHandler, States, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ResourceType
35 LeftPaletteLoaderService
36 } from "app/services";
37 import {FileUploadModel} from "../../directives/file-upload/file-upload";
40 export interface IWorkspaceViewModelScope extends ng.IScope {
43 isCreateProgress:boolean;
45 originComponent:Component;
48 leftBarTabs:MenuItemGroup;
53 breadcrumbsModel:Array<MenuItemGroup>;
55 changeLifecycleStateButtons:any;
57 versionsList:Array<any>;
59 isComposition:boolean;
61 $state:ng.ui.IStateService;
64 disabledButtons:boolean;
65 menuComponentTitle:string;
66 progressService:ProgressService;
67 progressMessage:string;
68 // leftPanelComponents:Array<Models.Components.Component>; //this is in order to load the left panel once, and not wait long time when moving to composition
70 showChangeStateButton():boolean;
71 getComponent():Component;
72 setComponent(component:Component):void;
73 onMenuItemPressed(state:string):ng.IPromise<boolean>;
74 save():ng.IPromise<boolean>;
75 setValidState(isValid:boolean):void;
77 changeLifecycleState(state:string):void;
82 isCreateMode():boolean;
83 isDisableMode():boolean;
84 showFullIcons():boolean;
85 goToBreadcrumbHome():void;
86 onVersionChanged(selectedId:string):void;
87 getLatestVersion():void;
89 showLifecycleIcon():boolean;
90 updateSelectedMenuItem():void;
91 uploadFileChangedInGeneralTab():void;
92 updateMenuComponentName(ComponentName:string):void;
94 reload(component:Component):void;
97 export class WorkspaceViewModel {
107 'Sdc.Services.CacheService',
108 'ChangeLifecycleStateHandler',
110 'LeftPaletteLoaderService',
112 'EventListenerService',
113 'Sdc.Services.EntityService',
116 'Sdc.Services.ProgressService'
119 constructor(private $scope:IWorkspaceViewModelScope,
120 private injectComponent:Component,
121 private ComponentFactory:ComponentFactory,
122 private $state:ng.ui.IStateService,
123 private sdcMenu:IAppMenu,
124 private $q:ng.IQService,
125 private MenuHandler:MenuHandler,
126 private cacheService:CacheService,
127 private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler,
128 private ModalsHandler:ModalsHandler,
129 private LeftPaletteLoaderService:LeftPaletteLoaderService,
130 private $filter:ng.IFilterService,
131 private EventListenerService:EventListenerService,
132 private EntityService:EntityService,
133 private Notification:any,
134 private $stateParams:any,
135 private progressService:ProgressService) {
138 this.initAfterScope();
142 private components:Array<Component>;
144 private initViewMode = ():WorkspaceMode => {
145 let mode = WorkspaceMode.VIEW;
147 if (!this.$state.params['id']) { //&& !this.$state.params['vspComponent']
148 mode = WorkspaceMode.CREATE;
150 if (this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKOUT &&
151 this.$scope.component.lastUpdaterUserId === this.cacheService.get("user").userId) {
152 if ((this.$scope.component.isService() || this.$scope.component.isResource()) && this.role == Role.DESIGNER) {
153 mode = WorkspaceMode.EDIT;
160 private initChangeLifecycleStateButtons = ():void => {
161 let state = this.$scope.component.isService() && (Role.OPS == this.role || Role.GOVERNOR == this.role) ? this.$scope.component.distributionStatus : this.$scope.component.lifecycleState;
162 this.$scope.changeLifecycleStateButtons = this.sdcMenu.roles[this.role].changeLifecycleStateButtons[state];
165 private isNeedSave = ():boolean => {
166 return this.$scope.isEditMode() &&
167 this.$state.current.data && this.$state.current.data.unsavedChanges;
170 private initLeftPalette = ():void => {
171 this.LeftPaletteLoaderService.loadLeftPanel(this.$scope.component);
174 private initScope = ():void => {
176 this.$scope.component = this.injectComponent;
177 this.initLeftPalette();
178 this.$scope.menuComponentTitle = this.$scope.component.name;
179 this.$scope.disabledButtons = false;
180 this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component);
181 this.$scope.componentType = this.$scope.component.componentType;
182 this.$scope.version = this.cacheService.get('version');
183 this.$scope.user = this.cacheService.get("user");
184 this.role = this.$scope.user.role;
185 this.$scope.mode = this.initViewMode();
186 this.$scope.isValidForm = true;
187 this.initChangeLifecycleStateButtons();
188 this.initVersionObject();
189 this.$scope.$state = this.$state;
190 this.$scope.isLoading = false;
191 this.$scope.isComposition = (this.$state.current.name.indexOf(States.WORKSPACE_COMPOSITION) > -1);
192 this.$scope.isDeployment = this.$state.current.name == States.WORKSPACE_DEPLOYMENT;
193 this.$scope.progressService = this.progressService;
195 this.$scope.getComponent = ():Component => {
196 return this.$scope.component;
199 this.$scope.updateMenuComponentName = (ComponentName:string):void => {
200 this.$scope.menuComponentTitle = ComponentName;
203 this.$scope.sdcMenu = this.sdcMenu;
204 // Will be called from each step after save to update the resource.
205 this.$scope.setComponent = (component:Component):void => {
206 this.$scope.component = component;
209 this.$scope.uploadFileChangedInGeneralTab = ():void => {
210 // In case user select browse file, and in update mode, need to disable submit for testing and checkin buttons.
211 if (this.$scope.isEditMode() && this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType == ResourceType.VF) {
212 this.$scope.disabledButtons = true;
216 this.$scope.onMenuItemPressed = (state:string):ng.IPromise<boolean> => {
217 let deferred = this.$q.defer();
218 let goToState = ():void => {
219 this.$state.go(state, {
220 id: this.$scope.component.uniqueId,
221 type: this.$scope.component.componentType.toLowerCase(),
222 components: this.components
224 deferred.resolve(true);
226 if (this.isNeedSave()) {
227 if (this.$scope.isValidForm) {
228 this.$scope.save().then(goToState);
230 console.log('form is not valid');
231 deferred.reject(false);
233 } else if (this.$scope.isEditMode() && //this is a workaround for amdocs - we need to get the artifact in order to avoid saving the vf when moving from their tabs
234 (this.$state.current.name === States.WORKSPACE_MANAGEMENT_WORKFLOW || this.$state.current.name === States.WORKSPACE_NETWORK_CALL_FLOW)) {
235 let onGetSuccess = (component:Component) => {
236 this.$scope.isLoading = false;
237 // Update the components
238 this.$scope.component = component;
241 let onFailed = () => {
242 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR);
243 this.$scope.isLoading = false; // stop the progress.
244 deferred.reject(false);
246 this.$scope.component.getComponent().then(onGetSuccess, onFailed);
250 return deferred.promise;
253 this.$scope.setValidState = (isValid:boolean):void => {
254 this.$scope.isValidForm = isValid;
257 this.$scope.onVersionChanged = (selectedId:string):void => {
258 if (this.$state.current.data && this.$state.current.data.unsavedChanges) {
259 this.$scope.changeVersion.selectedVersion = _.find(this.$scope.versionsList, (versionObj)=> {
260 return versionObj.versionId === this.$scope.component.uniqueId;
263 this.$scope.isLoading = true;
264 this.$state.go(this.$state.current.name, {
266 type: this.$scope.componentType.toLowerCase(),
267 mode: WorkspaceMode.VIEW,
268 components: this.$state.params['components']
273 this.$scope.getLatestVersion = ():void => {
274 this.$scope.onVersionChanged(_.first(this.$scope.versionsList).versionId);
277 this.$scope.save = (state?:string):ng.IPromise<boolean> => {
278 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_CLICK);
280 this.progressService.initCreateComponentProgress(this.$scope.component.uniqueId);
282 let deferred = this.$q.defer();
283 let modalInstance:ng.ui.bootstrap.IModalServiceInstance;
285 let onFailed = () => {
286 _.first(this.$scope.leftBarTabs.menuItems).isDisabled = false;//enabled click on general tab (DE246274)
287 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR);
288 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
289 modalInstance && modalInstance.close(); // Close the modal in case it is opened.
290 this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name);// for fix DE246217
291 this.$scope.isCreateProgress = false;
292 this.$scope.isLoading = false; // stop the progress.
294 this.$scope.setValidState(true); // Set the form valid (if sent form is valid, the error from server).
295 if (!this.$scope.isCreateMode()) {
296 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); // Set the component back to the original.
297 this.enableMenuItems(); // Enable the menu items (left tabs), so user can press on them.
298 this.$scope.disabledButtons = false; // Enable "submit for testing" & checking buttons.
301 deferred.reject(false);
304 let onSuccessCreate = (component:Component) => {
306 this.showSuccessNotificationMessage();
307 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
308 //update components for breadcrumbs
309 this.components.unshift(component);
310 this.$state.go(States.WORKSPACE_GENERAL, {
311 id: component.uniqueId,
312 type: component.componentType.toLowerCase(),
313 components: this.components
316 deferred.resolve(true);
319 let onSuccessUpdate = (component:Component) => {
320 this.$scope.isCreateProgress = false;
321 this.$scope.disabledButtons = false;
322 this.showSuccessNotificationMessage();
323 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
325 // Stop the circle loader.
326 this.$scope.isLoading = false;
328 component.tags = _.reject(component.tags, (item)=> {
329 return item === component.name
332 // Update the components
333 this.$scope.component = component;
334 this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component);
336 //update components for breadcrumbs
337 this.components.unshift(component);
340 this.$scope.enabledTabs();
343 if (this.$state.current.data) {
344 this.$state.current.data.unsavedChanges = false;
347 deferred.resolve(true);
350 if (this.$scope.isCreateMode()) {
351 this.$scope.progressMessage = "Creating Asset...";
353 this.$scope.isCreateProgress = true;
355 _.first(this.$scope.leftBarTabs.menuItems).isDisabled = true;//disabled click on general tab (DE246274)
357 // Start creating the component
358 this.ComponentFactory.createComponentOnServer(this.$scope.component).then(onSuccessCreate, onFailed);
360 // In case we import CSAR. Notify user that import VF will take long time (the create is performed in the background).
361 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).csarUUID) {
362 this.Notification.info({
363 message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_DESCRIPTION"),
364 title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE")
369 this.$scope.isCreateProgress = true;
370 this.$scope.progressMessage = "Updating Asset...";
371 this.disableMenuItems();
374 // Work around to change the csar version
375 if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
376 (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
377 this.cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
380 this.$scope.component.updateComponent().then(onSuccessUpdate, onFailed);
382 return deferred.promise;
385 this.$scope.revert = ():void => {
386 //in state of import file leave the file in place
387 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) {
388 let tempFile:FileUploadModel = (<Resource>this.$scope.component).importedFile;
389 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent);
390 (<Resource>this.$scope.component).importedFile = tempFile;
392 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent);
397 this.$scope.changeLifecycleState = (state:string):void => {
398 if (this.isNeedSave() && state !== 'deleteVersion') {
399 this.$scope.save().then(() => {
400 changeLifecycleState(state);
403 changeLifecycleState(state);
407 let defaultActionAfterChangeLifecycleState = ():void => {
408 if (this.$state.current.data && this.$state.current.data.unsavedChanges) {
409 this.$state.current.data.unsavedChanges = false;
411 this.$state.go('dashboard');
414 let changeLifecycleState = (state:string) => {
415 if ('monitor' === state) {
416 this.$state.go('workspace.distribution');
420 let data = this.$scope.changeLifecycleStateButtons[state];
421 let onSuccess = (component:Component, url:string):void => {
422 //Updating the component from server response
424 //the server returns only metaData (small component) except checkout (Full component) ,so we update only the statuses of distribution & lifecycle
425 this.$scope.component.lifecycleState = component.lifecycleState;
426 this.$scope.component.distributionStatus = component.distributionStatus;
429 case 'lifecycleState/CHECKOUT':
430 // only checkOut get the full component from server
431 // this.$scope.component = component;
432 // Work around to change the csar version
433 if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
434 (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
437 //when checking out a minor version uuid remains
438 let bcComponent:Component = _.find(this.components, (item) => {
439 return item.uuid === component.uuid;
442 this.components[this.components.indexOf(bcComponent)] = component;
444 //when checking out a major(certified) version
445 this.components.unshift(component);
447 // this.$state.go(this.$state.current.name, {
448 // id: component.uniqueId,
449 // type: component.componentType.toLowerCase(),
450 // components: this.components
452 this.$scope.mode = this.initViewMode();
453 this.initChangeLifecycleStateButtons();
454 this.initVersionObject();
455 this.$scope.isLoading = false;
456 this.EventListenerService.notifyObservers(EVENTS.ON_CHECKOUT, component);
457 this.Notification.success({
458 message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"),
459 title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE")
462 case 'lifecycleState/CHECKIN':
463 defaultActionAfterChangeLifecycleState();
464 this.Notification.success({
465 message: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TEXT"),
466 title: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TITLE")
469 case 'lifecycleState/UNDOCHECKOUT':
470 defaultActionAfterChangeLifecycleState();
471 this.Notification.success({
472 message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
473 title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE")
476 case 'lifecycleState/certificationRequest':
477 defaultActionAfterChangeLifecycleState();
478 this.Notification.success({
479 message: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TEXT"),
480 title: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TITLE")
484 case 'lifecycleState/failCertification':
485 defaultActionAfterChangeLifecycleState();
486 this.Notification.success({
487 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
488 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
491 case 'lifecycleState/certify':
492 defaultActionAfterChangeLifecycleState();
493 this.Notification.success({
494 message: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TEXT"),
495 title: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TITLE")
498 //DE203504 Bug Fix Start
499 case 'lifecycleState/startCertification':
500 this.initChangeLifecycleStateButtons();
501 this.Notification.success({
502 message: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TEXT"),
503 title: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TITLE")
506 case 'lifecycleState/cancelCertification':
507 this.initChangeLifecycleStateButtons();
508 this.Notification.success({
509 message: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TEXT"),
510 title: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TITLE")
514 case 'distribution/PROD/activate':
515 this.initChangeLifecycleStateButtons();
516 this.Notification.success({
517 message: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TEXT"),
518 title: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TITLE")
522 case 'distribution-state/reject':
523 this.initChangeLifecycleStateButtons();
524 this.Notification.success({
525 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
526 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
529 case 'distribution-state/approve':
530 this.initChangeLifecycleStateButtons();
531 this.$state.go('catalog');
532 this.Notification.success({
533 message: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TEXT"),
534 title: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TITLE")
537 //DE203504 Bug Fix End
540 defaultActionAfterChangeLifecycleState();
543 if (data.url != 'lifecycleState/CHECKOUT') {
544 this.$scope.isLoading = false;
547 //this.$scope.isLoading = true;
548 this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess);
551 this.$scope.enabledTabs = ():void => {
552 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
553 item.isDisabled = false;
557 this.$scope.isViewMode = ():boolean => {
558 return this.$scope.mode === WorkspaceMode.VIEW;
561 this.$scope.isDesigner = ():boolean => {
562 return this.role == Role.DESIGNER;
565 this.$scope.isDisableMode = ():boolean => {
566 return this.$scope.mode === WorkspaceMode.VIEW && this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKIN;
569 this.$scope.showFullIcons = ():boolean => {
570 //we show revert and save icons only in general view
571 return this.$state.current.name === States.WORKSPACE_GENERAL;
574 this.$scope.isCreateMode = ():boolean => {
575 return this.$scope.mode === WorkspaceMode.CREATE;
578 this.$scope.isEditMode = ():boolean => {
579 return this.$scope.mode === WorkspaceMode.EDIT;
582 this.$scope.goToBreadcrumbHome = ():void => {
583 let bcHome:MenuItemGroup = this.$scope.breadcrumbsModel[0];
584 this.$state.go(bcHome.menuItems[bcHome.selectedIndex].state);
587 this.$scope.showLifecycleIcon = ():boolean => {
588 return this.role == Role.DESIGNER;
591 this.$scope.getStatus = ():string => {
592 if (this.$scope.isCreateMode()) {
596 return this.$scope.component.getStatus(this.sdcMenu);
599 this.initMenuItems();
601 this.$scope.showChangeStateButton = ():boolean => {
602 let result:boolean = true;
603 if (!this.$scope.component.isLatestVersion() && Role.OPS != this.role && Role.GOVERNOR != this.role) {
606 if (ComponentState.NOT_CERTIFIED_CHECKOUT === this.$scope.component.lifecycleState && this.$scope.isViewMode()) {
609 if (ComponentState.CERTIFIED != this.$scope.component.lifecycleState &&
610 (Role.OPS == this.role || Role.GOVERNOR == this.role)) {
616 this.$scope.updateSelectedMenuItem = ():void => {
617 let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => {
618 return item.state === this.$state.current.name;
620 this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0;
623 this.$scope.$watch('$state.current.name', (newVal:string):void => {
625 this.$scope.isComposition = (newVal.indexOf(States.WORKSPACE_COMPOSITION) > -1);
626 this.$scope.isDeployment = newVal == States.WORKSPACE_DEPLOYMENT;
630 this.$scope.getTabTitle = ():string => {
631 return this.$scope.leftBarTabs.menuItems.find((menuItem:MenuItem)=>{
632 return menuItem.state == this.$scope.$state.current.name;
636 this.$scope.reload = (component:Component):void => {
637 this.$state.go(this.$state.current.name,{id:component.uniqueId},{reload:true});
642 private initAfterScope = ():void => {
643 // In case user select csar from the onboarding modal, need to disable checkout and submit for testing.
644 if (this.$state.params['disableButtons'] === true) {
645 this.$scope.uploadFileChangedInGeneralTab();
649 private initVersionObject = ():void => {
650 this.$scope.versionsList = (this.$scope.component.getAllVersionsAsSortedArray()).reverse();
651 this.$scope.changeVersion = {
652 selectedVersion: _.find(this.$scope.versionsList, (versionObj)=> {
653 return versionObj.versionId === this.$scope.component.uniqueId;
658 private getNewComponentBreadcrumbItem = ():MenuItem => {
660 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) {
661 text = this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name;
663 text = 'Create new ' + this.$state.params['type'];
665 return new MenuItem(text, null, States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]);
668 private updateMenuItemByRole = (menuItems:Array<MenuItem>, role:string) => {
669 let tempMenuItems:Array<MenuItem> = new Array<MenuItem>();
670 menuItems.forEach((item:MenuItem) => {
671 //remove item if role is disabled
672 if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) {
673 tempMenuItems.push(item);
676 return tempMenuItems;
679 private initBreadcrumbs = () => {
680 this.components = this.cacheService.get('breadcrumbsComponents');
681 let breadcrumbsComponentsLvl = this.MenuHandler.generateBreadcrumbsModelFromComponents(this.components, this.$scope.component);
683 if (this.$scope.isCreateMode()) {
684 let createItem = this.getNewComponentBreadcrumbItem();
685 if (!breadcrumbsComponentsLvl.menuItems) {
686 breadcrumbsComponentsLvl.menuItems = [];
688 breadcrumbsComponentsLvl.menuItems.unshift(createItem);
689 breadcrumbsComponentsLvl.selectedIndex = 0;
692 this.$scope.breadcrumbsModel = [breadcrumbsComponentsLvl, this.$scope.leftBarTabs];
695 private initMenuItems() {
697 let inCreateMode = this.$scope.isCreateMode();
698 this.$scope.leftBarTabs = new MenuItemGroup();
699 this.$scope.leftBarTabs.menuItems = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
701 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
702 item.params = [item.state];
703 item.callback = this.$scope.onMenuItemPressed;
704 item.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != item.state) ||
705 (States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource());
708 if (this.cacheService.get('breadcrumbsComponents')) {
709 this.initBreadcrumbs();
711 let onSuccess = (components:Array<Component>) => {
712 this.cacheService.set('breadcrumbsComponents', components);
713 this.initBreadcrumbs();
715 this.EntityService.getCatalog().then(onSuccess); //getAllComponents() doesnt return components from catalog
719 private disableMenuItems() {
720 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
721 item.params = [item.state];
722 item.callback = this.$scope.onMenuItemPressed;
723 item.isDisabled = (States.WORKSPACE_GENERAL != item.state);
727 private enableMenuItems() {
728 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
729 item.params = [item.state];
730 item.callback = this.$scope.onMenuItemPressed;
731 item.isDisabled = false;
735 private showSuccessNotificationMessage = ():void => {
736 this.Notification.success({
737 message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_DESCRIPTION"),
738 title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE")