2 * Created by obarda on 3/30/2016.
5 import {IUserProperties, IAppMenu, Resource, Component} from "app/models";
7 WorkspaceMode, ComponentFactory, ChangeLifecycleStateHandler, Role, ComponentState, MenuItemGroup, MenuHandler,
8 MenuItem, ModalsHandler, States, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ResourceType
15 LeftPaletteLoaderService
16 } from "app/services";
17 import {FileUploadModel} from "../../directives/file-upload/file-upload";
20 export interface IWorkspaceViewModelScope extends ng.IScope {
23 isCreateProgress:boolean;
25 originComponent:Component;
28 leftBarTabs:MenuItemGroup;
33 breadcrumbsModel:Array<MenuItemGroup>;
35 changeLifecycleStateButtons:any;
37 versionsList:Array<any>;
39 isComposition:boolean;
41 $state:ng.ui.IStateService;
44 disabledButtons:boolean;
45 menuComponentTitle:string;
46 progressService:ProgressService;
47 progressMessage:string;
48 // leftPanelComponents:Array<Models.Components.Component>; //this is in order to load the left panel once, and not wait long time when moving to composition
50 showChangeStateButton():boolean;
51 getComponent():Component;
52 setComponent(component:Component):void;
53 onMenuItemPressed(state:string):ng.IPromise<boolean>;
54 save():ng.IPromise<boolean>;
55 setValidState(isValid:boolean):void;
57 changeLifecycleState(state:string):void;
60 isProductManager():boolean;
63 isCreateMode():boolean;
64 isDisableMode():boolean;
65 showFullIcons():boolean;
66 goToBreadcrumbHome():void;
67 onVersionChanged(selectedId:string):void;
68 getLatestVersion():void;
70 showLifecycleIcon():boolean;
71 updateSelectedMenuItem():void;
72 uploadFileChangedInGeneralTab():void;
73 updateMenuComponentName(ComponentName:string):void;
76 export class WorkspaceViewModel {
86 'Sdc.Services.CacheService',
87 'ChangeLifecycleStateHandler',
89 'LeftPaletteLoaderService',
91 'EventListenerService',
92 'Sdc.Services.EntityService',
95 'Sdc.Services.ProgressService'
98 constructor(private $scope:IWorkspaceViewModelScope,
99 private injectComponent:Component,
100 private ComponentFactory:ComponentFactory,
101 private $state:ng.ui.IStateService,
102 private sdcMenu:IAppMenu,
103 private $q:ng.IQService,
104 private MenuHandler:MenuHandler,
105 private cacheService:CacheService,
106 private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler,
107 private ModalsHandler:ModalsHandler,
108 private LeftPaletteLoaderService:LeftPaletteLoaderService,
109 private $filter:ng.IFilterService,
110 private EventListenerService:EventListenerService,
111 private EntityService:EntityService,
112 private Notification:any,
113 private $stateParams:any,
114 private progressService:ProgressService) {
117 this.initAfterScope();
121 private components:Array<Component>;
123 private initViewMode = ():WorkspaceMode => {
124 let mode = WorkspaceMode.VIEW;
126 if (!this.$state.params['id']) { //&& !this.$state.params['vspComponent']
127 mode = WorkspaceMode.CREATE;
129 if (this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKOUT &&
130 this.$scope.component.lastUpdaterUserId === this.cacheService.get("user").userId) {
131 if (this.$scope.component.isProduct() && this.role == Role.PRODUCT_MANAGER) {
132 mode = WorkspaceMode.EDIT;
134 if ((this.$scope.component.isService() || this.$scope.component.isResource()) && this.role == Role.DESIGNER) {
135 mode = WorkspaceMode.EDIT;
142 private initChangeLifecycleStateButtons = ():void => {
143 let state = this.$scope.component.isService() && (Role.OPS == this.role || Role.GOVERNOR == this.role) ? this.$scope.component.distributionStatus : this.$scope.component.lifecycleState;
144 this.$scope.changeLifecycleStateButtons = this.sdcMenu.roles[this.role].changeLifecycleStateButtons[state];
147 private isNeedSave = ():boolean => {
148 return this.$scope.isEditMode() &&
149 this.$state.current.data && this.$state.current.data.unsavedChanges;
152 private initLeftPalette = ():void => {
153 this.LeftPaletteLoaderService.loadLeftPanel(this.$scope.component.componentType);
156 private initScope = ():void => {
158 this.$scope.component = this.injectComponent;
159 this.initLeftPalette();
160 this.$scope.menuComponentTitle = this.$scope.component.name;
161 this.$scope.disabledButtons = false;
162 this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component);
163 this.$scope.componentType = this.$scope.component.componentType;
164 this.$scope.version = this.cacheService.get('version');
165 this.$scope.user = this.cacheService.get("user");
166 this.role = this.$scope.user.role;
167 this.$scope.mode = this.initViewMode();
168 this.$scope.isValidForm = true;
169 this.initChangeLifecycleStateButtons();
170 this.initVersionObject();
171 this.$scope.$state = this.$state;
172 this.$scope.isLoading = false;
173 this.$scope.isComposition = (this.$state.current.name.indexOf(States.WORKSPACE_COMPOSITION) > -1);
174 this.$scope.isDeployment = (this.$state.current.name.indexOf(States.WORKSPACE_DEPLOYMENT) > -1);
175 this.$scope.progressService = this.progressService;
177 this.$scope.getComponent = ():Component => {
178 return this.$scope.component;
181 this.$scope.updateMenuComponentName = (ComponentName:string):void => {
182 this.$scope.menuComponentTitle = ComponentName;
185 this.$scope.sdcMenu = this.sdcMenu;
186 // Will be called from each step after save to update the resource.
187 this.$scope.setComponent = (component:Component):void => {
188 this.$scope.component = component;
191 this.$scope.uploadFileChangedInGeneralTab = ():void => {
192 // In case user select browse file, and in update mode, need to disable submit for testing and checkin buttons.
193 if (this.$scope.isEditMode() && this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType == ResourceType.VF) {
194 this.$scope.disabledButtons = true;
198 this.$scope.onMenuItemPressed = (state:string):ng.IPromise<boolean> => {
199 let deferred = this.$q.defer();
200 let goToState = ():void => {
201 this.$state.go(state, {
202 id: this.$scope.component.uniqueId,
203 type: this.$scope.component.componentType.toLowerCase(),
204 components: this.components
206 deferred.resolve(true);
208 if (this.isNeedSave()) {
209 if (this.$scope.isValidForm) {
210 this.$scope.save().then(goToState);
212 console.log('form is not valid');
213 deferred.reject(false);
215 } 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
216 (this.$state.current.name === States.WORKSPACE_MANAGEMENT_WORKFLOW || this.$state.current.name === States.WORKSPACE_NETWORK_CALL_FLOW)) {
217 let onGetSuccess = (component:Component) => {
218 this.$scope.isLoading = false;
219 // Update the components
220 this.$scope.component = component;
223 let onFailed = () => {
224 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR);
225 this.$scope.isLoading = false; // stop the progress.
226 deferred.reject(false);
228 this.$scope.component.getComponent().then(onGetSuccess, onFailed);
232 return deferred.promise;
235 this.$scope.setValidState = (isValid:boolean):void => {
236 this.$scope.isValidForm = isValid;
239 this.$scope.onVersionChanged = (selectedId:string):void => {
240 if (this.$state.current.data && this.$state.current.data.unsavedChanges) {
241 this.$scope.changeVersion.selectedVersion = _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId});
243 this.$scope.isLoading = true;
244 this.$state.go(this.$state.current.name, {
246 type: this.$scope.componentType.toLowerCase(),
247 mode: WorkspaceMode.VIEW,
248 components: this.$state.params['components']
253 this.$scope.getLatestVersion = ():void => {
254 this.$scope.onVersionChanged(_.first(this.$scope.versionsList).versionId);
257 this.$scope.save = (state?:string):ng.IPromise<boolean> => {
258 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_CLICK);
260 this.progressService.initCreateComponentProgress(this.$scope.component.uniqueId);
262 let deferred = this.$q.defer();
263 let modalInstance:ng.ui.bootstrap.IModalServiceInstance;
265 let onFailed = () => {
266 _.first(this.$scope.leftBarTabs.menuItems).isDisabled = false;//enabled click on general tab (DE246274)
267 this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR);
268 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
269 modalInstance && modalInstance.close(); // Close the modal in case it is opened.
270 this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name);// for fix DE246217
271 this.$scope.isCreateProgress = false;
272 this.$scope.isLoading = false; // stop the progress.
274 this.$scope.setValidState(true); // Set the form valid (if sent form is valid, the error from server).
275 if (!this.$scope.isCreateMode()) {
276 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); // Set the component back to the original.
277 this.enableMenuItems(); // Enable the menu items (left tabs), so user can press on them.
278 this.$scope.disabledButtons = false; // Enable "submit for testing" & checking buttons.
281 deferred.reject(false);
284 let onSuccessCreate = (component:Component) => {
286 this.showSuccessNotificationMessage();
287 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
288 //update components for breadcrumbs
289 this.components.unshift(component);
290 this.$state.go(States.WORKSPACE_GENERAL, {
291 id: component.uniqueId,
292 type: component.componentType.toLowerCase(),
293 components: this.components
296 deferred.resolve(true);
299 let onSuccessUpdate = (component:Component) => {
300 this.$scope.isCreateProgress = false;
301 this.$scope.disabledButtons = false;
302 this.showSuccessNotificationMessage();
303 this.progressService.deleteProgressValue(this.$scope.component.uniqueId);
305 // Stop the circle loader.
306 this.$scope.isLoading = false;
308 component.tags = _.reject(component.tags, (item)=> {
309 return item === component.name
312 // Update the components
313 this.$scope.component = component;
314 this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component);
316 //update components for breadcrumbs
317 this.components.unshift(component);
320 this.$scope.enabledTabs();
323 if (this.$state.current.data) {
324 this.$state.current.data.unsavedChanges = false;
327 deferred.resolve(true);
330 if (this.$scope.isCreateMode()) {
331 this.$scope.progressMessage = "Creating Asset...";
333 this.$scope.isCreateProgress = true;
335 _.first(this.$scope.leftBarTabs.menuItems).isDisabled = true;//disabled click on general tab (DE246274)
337 // Start creating the component
338 this.ComponentFactory.createComponentOnServer(this.$scope.component).then(onSuccessCreate, onFailed);
340 // In case we import CSAR. Notify user that import VF will take long time (the create is performed in the background).
341 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).csarUUID) {
342 this.Notification.info({
343 message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_DESCRIPTION"),
344 title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE")
349 this.$scope.isCreateProgress = true;
350 this.$scope.progressMessage = "Updating Asset...";
351 this.disableMenuItems();
354 // Work around to change the csar version
355 if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
356 (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
357 this.cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
360 this.$scope.component.updateComponent().then(onSuccessUpdate, onFailed);
362 return deferred.promise;
365 this.$scope.revert = ():void => {
366 //in state of import file leave the file in place
367 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) {
368 let tempFile:FileUploadModel = (<Resource>this.$scope.component).importedFile;
369 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent);
370 (<Resource>this.$scope.component).importedFile = tempFile;
372 this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent);
377 this.$scope.changeLifecycleState = (state:string):void => {
378 if (this.isNeedSave() && state !== 'deleteVersion') {
379 this.$scope.save().then(() => {
380 changeLifecycleState(state);
383 changeLifecycleState(state);
387 let defaultActionAfterChangeLifecycleState = ():void => {
388 if (this.$state.current.data && this.$state.current.data.unsavedChanges) {
389 this.$state.current.data.unsavedChanges = false;
391 this.$state.go('dashboard');
394 let changeLifecycleState = (state:string) => {
395 if ('monitor' === state) {
396 this.$state.go('workspace.distribution');
400 let data = this.$scope.changeLifecycleStateButtons[state];
401 let onSuccess = (component:Component, url:string):void => {
402 //Updating the component from server response
404 //the server returns only metaData (small component) except checkout (Full component) ,so we update only the statuses of distribution & lifecycle
405 this.$scope.component.lifecycleState = component.lifecycleState;
406 this.$scope.component.distributionStatus = component.distributionStatus;
409 case 'lifecycleState/CHECKOUT':
410 // only checkOut get the full component from server
411 // this.$scope.component = component;
412 // Work around to change the csar version
413 if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) {
414 (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
417 //when checking out a minor version uuid remains
418 let bcComponent:Component = _.find(this.components, (item) => {
419 return item.uuid === component.uuid;
422 this.components[this.components.indexOf(bcComponent)] = component;
424 //when checking out a major(certified) version
425 this.components.unshift(component);
427 // this.$state.go(this.$state.current.name, {
428 // id: component.uniqueId,
429 // type: component.componentType.toLowerCase(),
430 // components: this.components
432 this.$scope.mode = this.initViewMode();
433 this.initChangeLifecycleStateButtons();
434 this.initVersionObject();
435 this.$scope.isLoading = false;
436 this.EventListenerService.notifyObservers(EVENTS.ON_CHECKOUT, component);
437 this.Notification.success({
438 message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"),
439 title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE")
442 case 'lifecycleState/CHECKIN':
443 defaultActionAfterChangeLifecycleState();
444 this.Notification.success({
445 message: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TEXT"),
446 title: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TITLE")
449 case 'lifecycleState/UNDOCHECKOUT':
450 defaultActionAfterChangeLifecycleState();
451 this.Notification.success({
452 message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
453 title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE")
456 case 'lifecycleState/certificationRequest':
457 defaultActionAfterChangeLifecycleState();
458 this.Notification.success({
459 message: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TEXT"),
460 title: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TITLE")
464 case 'lifecycleState/failCertification':
465 defaultActionAfterChangeLifecycleState();
466 this.Notification.success({
467 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
468 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
471 case 'lifecycleState/certify':
472 defaultActionAfterChangeLifecycleState();
473 this.Notification.success({
474 message: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TEXT"),
475 title: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TITLE")
478 //DE203504 Bug Fix Start
479 case 'lifecycleState/startCertification':
480 this.initChangeLifecycleStateButtons();
481 this.Notification.success({
482 message: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TEXT"),
483 title: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TITLE")
486 case 'lifecycleState/cancelCertification':
487 this.initChangeLifecycleStateButtons();
488 this.Notification.success({
489 message: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TEXT"),
490 title: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TITLE")
494 case 'distribution/PROD/activate':
495 this.initChangeLifecycleStateButtons();
496 this.Notification.success({
497 message: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TEXT"),
498 title: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TITLE")
502 case 'distribution-state/reject':
503 this.initChangeLifecycleStateButtons();
504 this.Notification.success({
505 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
506 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
509 case 'distribution-state/approve':
510 this.initChangeLifecycleStateButtons();
511 this.$state.go('catalog');
512 this.Notification.success({
513 message: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TEXT"),
514 title: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TITLE")
517 //DE203504 Bug Fix End
520 defaultActionAfterChangeLifecycleState();
523 if (data.url != 'lifecycleState/CHECKOUT') {
524 this.$scope.isLoading = false;
527 //this.$scope.isLoading = true;
528 this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess);
531 this.$scope.enabledTabs = ():void => {
532 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
533 item.isDisabled = false;
537 this.$scope.isViewMode = ():boolean => {
538 return this.$scope.mode === WorkspaceMode.VIEW;
541 this.$scope.isDesigner = ():boolean => {
542 return this.role == Role.DESIGNER;
545 this.$scope.isProductManager = ():boolean => {
546 return this.role == Role.PRODUCT_MANAGER;
549 this.$scope.isDisableMode = ():boolean => {
550 return this.$scope.mode === WorkspaceMode.VIEW && this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKIN;
553 this.$scope.showFullIcons = ():boolean => {
554 //we show revert and save icons only in general\icon view
555 return this.$state.current.name === States.WORKSPACE_GENERAL ||
556 this.$state.current.name === States.WORKSPACE_ICONS;
559 this.$scope.isCreateMode = ():boolean => {
560 return this.$scope.mode === WorkspaceMode.CREATE;
563 this.$scope.isEditMode = ():boolean => {
564 return this.$scope.mode === WorkspaceMode.EDIT;
567 this.$scope.goToBreadcrumbHome = ():void => {
568 let bcHome:MenuItemGroup = this.$scope.breadcrumbsModel[0];
569 this.$state.go(bcHome.menuItems[bcHome.selectedIndex].state);
572 this.$scope.showLifecycleIcon = ():boolean => {
573 return this.role == Role.DESIGNER ||
574 this.role == Role.PRODUCT_MANAGER;
577 this.$scope.getStatus = ():string => {
578 if (this.$scope.isCreateMode()) {
582 return this.$scope.component.getStatus(this.sdcMenu);
585 this.initMenuItems();
587 this.$scope.showChangeStateButton = ():boolean => {
588 let result:boolean = true;
589 if (!this.$scope.component.isLatestVersion() && Role.OPS != this.role && Role.GOVERNOR != this.role) {
592 if (this.role === Role.PRODUCT_MANAGER && !this.$scope.component.isProduct()) {
595 if ((this.role === Role.DESIGNER || this.role === Role.TESTER)
596 && this.$scope.component.isProduct()) {
599 if (ComponentState.NOT_CERTIFIED_CHECKOUT === this.$scope.component.lifecycleState && this.$scope.isViewMode()) {
602 if (ComponentState.CERTIFIED != this.$scope.component.lifecycleState &&
603 (Role.OPS == this.role || Role.GOVERNOR == this.role)) {
609 this.$scope.updateSelectedMenuItem = ():void => {
610 let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => {
611 return item.state === this.$state.current.name;
613 this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0;
616 this.$scope.$watch('$state.current.name', (newVal:string):void => {
618 this.$scope.isComposition = (newVal.indexOf(States.WORKSPACE_COMPOSITION) > -1);
619 this.$scope.isDeployment = (newVal.indexOf(States.WORKSPACE_DEPLOYMENT) > -1);
624 private initAfterScope = ():void => {
625 // In case user select csar from the onboarding modal, need to disable checkout and submit for testing.
626 if (this.$state.params['disableButtons'] === true) {
627 this.$scope.uploadFileChangedInGeneralTab();
631 private initVersionObject = ():void => {
632 this.$scope.versionsList = (this.$scope.component.getAllVersionsAsSortedArray()).reverse();
633 this.$scope.changeVersion = {selectedVersion: _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId})};
636 private getNewComponentBreadcrumbItem = ():MenuItem => {
638 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) {
639 text = this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name;
641 text = 'Create new ' + this.$state.params['type'];
643 return new MenuItem(text, null, States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]);
646 private updateMenuItemByRole = (menuItems:Array<MenuItem>, role:string) => {
647 let tempMenuItems:Array<MenuItem> = new Array<MenuItem>();
648 menuItems.forEach((item:MenuItem) => {
649 //remove item if role is disabled
650 if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) {
651 tempMenuItems.push(item);
654 return tempMenuItems;
657 private initBreadcrumbs = () => {
658 this.components = this.cacheService.get('breadcrumbsComponents');
659 let breadcrumbsComponentsLvl = this.MenuHandler.generateBreadcrumbsModelFromComponents(this.components, this.$scope.component);
661 if (this.$scope.isCreateMode()) {
662 let createItem = this.getNewComponentBreadcrumbItem();
663 if (!breadcrumbsComponentsLvl.menuItems) {
664 breadcrumbsComponentsLvl.menuItems = [];
666 breadcrumbsComponentsLvl.menuItems.unshift(createItem);
667 breadcrumbsComponentsLvl.selectedIndex = 0;
670 this.$scope.breadcrumbsModel = [breadcrumbsComponentsLvl, this.$scope.leftBarTabs];
673 private initMenuItems() {
675 let inCreateMode = this.$scope.isCreateMode();
676 this.$scope.leftBarTabs = new MenuItemGroup();
677 this.$scope.leftBarTabs.menuItems = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
679 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
680 item.params = [item.state];
681 item.callback = this.$scope.onMenuItemPressed;
682 item.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != item.state) ||
683 (States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource());
686 if (this.cacheService.get('breadcrumbsComponents')) {
687 this.initBreadcrumbs();
689 let onSuccess = (components:Array<Component>) => {
690 this.cacheService.set('breadcrumbsComponents', components);
691 this.initBreadcrumbs();
693 this.EntityService.getCatalog().then(onSuccess); //getAllComponents() doesnt return components from catalog
697 private disableMenuItems() {
698 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
699 item.params = [item.state];
700 item.callback = this.$scope.onMenuItemPressed;
701 item.isDisabled = (States.WORKSPACE_GENERAL != item.state);
705 private enableMenuItems() {
706 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
707 item.params = [item.state];
708 item.callback = this.$scope.onMenuItemPressed;
709 item.isDisabled = false;
713 private showSuccessNotificationMessage = ():void => {
714 this.Notification.success({
715 message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_DESCRIPTION"),
716 title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE")