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.EventListenerService.notifyObservers(EVENTS.ON_CHECKOUT, component);
428 // this.$state.go(this.$state.current.name, {
429 // id: component.uniqueId,
430 // type: component.componentType.toLowerCase(),
431 // components: this.components
433 this.$scope.mode = this.initViewMode();
434 this.initChangeLifecycleStateButtons();
435 this.initVersionObject();
436 this.$scope.isLoading = false;
438 this.Notification.success({
439 message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"),
440 title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE")
443 case 'lifecycleState/CHECKIN':
444 defaultActionAfterChangeLifecycleState();
445 this.Notification.success({
446 message: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TEXT"),
447 title: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TITLE")
450 case 'lifecycleState/UNDOCHECKOUT':
451 defaultActionAfterChangeLifecycleState();
452 this.Notification.success({
453 message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
454 title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE")
457 case 'lifecycleState/certificationRequest':
458 defaultActionAfterChangeLifecycleState();
459 this.Notification.success({
460 message: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TEXT"),
461 title: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TITLE")
465 case 'lifecycleState/failCertification':
466 defaultActionAfterChangeLifecycleState();
467 this.Notification.success({
468 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
469 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
472 case 'lifecycleState/certify':
473 defaultActionAfterChangeLifecycleState();
474 this.Notification.success({
475 message: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TEXT"),
476 title: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TITLE")
479 //DE203504 Bug Fix Start
480 case 'lifecycleState/startCertification':
481 this.initChangeLifecycleStateButtons();
482 this.Notification.success({
483 message: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TEXT"),
484 title: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TITLE")
487 case 'lifecycleState/cancelCertification':
488 this.initChangeLifecycleStateButtons();
489 this.Notification.success({
490 message: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TEXT"),
491 title: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TITLE")
495 case 'distribution/PROD/activate':
496 this.initChangeLifecycleStateButtons();
497 this.Notification.success({
498 message: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TEXT"),
499 title: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TITLE")
503 case 'distribution-state/reject':
504 this.initChangeLifecycleStateButtons();
505 this.Notification.success({
506 message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"),
507 title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE")
510 case 'distribution-state/approve':
511 this.initChangeLifecycleStateButtons();
512 this.$state.go('catalog');
513 this.Notification.success({
514 message: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TEXT"),
515 title: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TITLE")
518 //DE203504 Bug Fix End
521 defaultActionAfterChangeLifecycleState();
524 if (data.url != 'lifecycleState/CHECKOUT') {
525 this.$scope.isLoading = false;
528 //this.$scope.isLoading = true;
529 this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess);
532 this.$scope.enabledTabs = ():void => {
533 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
534 item.isDisabled = false;
538 this.$scope.isViewMode = ():boolean => {
539 return this.$scope.mode === WorkspaceMode.VIEW;
542 this.$scope.isDesigner = ():boolean => {
543 return this.role == Role.DESIGNER;
546 this.$scope.isProductManager = ():boolean => {
547 return this.role == Role.PRODUCT_MANAGER;
550 this.$scope.isDisableMode = ():boolean => {
551 return this.$scope.mode === WorkspaceMode.VIEW && this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKIN;
554 this.$scope.showFullIcons = ():boolean => {
555 //we show revert and save icons only in general\icon view
556 return this.$state.current.name === States.WORKSPACE_GENERAL ||
557 this.$state.current.name === States.WORKSPACE_ICONS;
560 this.$scope.isCreateMode = ():boolean => {
561 return this.$scope.mode === WorkspaceMode.CREATE;
564 this.$scope.isEditMode = ():boolean => {
565 return this.$scope.mode === WorkspaceMode.EDIT;
568 this.$scope.goToBreadcrumbHome = ():void => {
569 let bcHome:MenuItemGroup = this.$scope.breadcrumbsModel[0];
570 this.$state.go(bcHome.menuItems[bcHome.selectedIndex].state);
573 this.$scope.showLifecycleIcon = ():boolean => {
574 return this.role == Role.DESIGNER ||
575 this.role == Role.PRODUCT_MANAGER;
578 this.$scope.getStatus = ():string => {
579 if (this.$scope.isCreateMode()) {
583 return this.$scope.component.getStatus(this.sdcMenu);
586 this.initMenuItems();
588 this.$scope.showChangeStateButton = ():boolean => {
589 let result:boolean = true;
590 if (!this.$scope.component.isLatestVersion() && Role.OPS != this.role && Role.GOVERNOR != this.role) {
593 if (this.role === Role.PRODUCT_MANAGER && !this.$scope.component.isProduct()) {
596 if ((this.role === Role.DESIGNER || this.role === Role.TESTER)
597 && this.$scope.component.isProduct()) {
600 if (ComponentState.NOT_CERTIFIED_CHECKOUT === this.$scope.component.lifecycleState && this.$scope.isViewMode()) {
603 if (ComponentState.CERTIFIED != this.$scope.component.lifecycleState &&
604 (Role.OPS == this.role || Role.GOVERNOR == this.role)) {
610 this.$scope.updateSelectedMenuItem = ():void => {
611 let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => {
612 return item.state === this.$state.current.name;
614 this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0;
617 this.$scope.$watch('$state.current.name', (newVal:string):void => {
619 this.$scope.isComposition = (newVal.indexOf(States.WORKSPACE_COMPOSITION) > -1);
620 this.$scope.isDeployment = (newVal.indexOf(States.WORKSPACE_DEPLOYMENT) > -1);
625 private initAfterScope = ():void => {
626 // In case user select csar from the onboarding modal, need to disable checkout and submit for testing.
627 if (this.$state.params['disableButtons'] === true) {
628 this.$scope.uploadFileChangedInGeneralTab();
632 private initVersionObject = ():void => {
633 this.$scope.versionsList = (this.$scope.component.getAllVersionsAsSortedArray()).reverse();
634 this.$scope.changeVersion = {selectedVersion: _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId})};
637 private getNewComponentBreadcrumbItem = ():MenuItem => {
639 if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) {
640 text = this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name;
642 text = 'Create new ' + this.$state.params['type'];
644 return new MenuItem(text, null, States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]);
647 private updateMenuItemByRole = (menuItems:Array<MenuItem>, role:string) => {
648 let tempMenuItems:Array<MenuItem> = new Array<MenuItem>();
649 menuItems.forEach((item:MenuItem) => {
650 //remove item if role is disabled
651 if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) {
652 tempMenuItems.push(item);
655 return tempMenuItems;
658 private initBreadcrumbs = () => {
659 this.components = this.cacheService.get('breadcrumbsComponents');
660 let breadcrumbsComponentsLvl = this.MenuHandler.generateBreadcrumbsModelFromComponents(this.components, this.$scope.component);
662 if (this.$scope.isCreateMode()) {
663 let createItem = this.getNewComponentBreadcrumbItem();
664 if (!breadcrumbsComponentsLvl.menuItems) {
665 breadcrumbsComponentsLvl.menuItems = [];
667 breadcrumbsComponentsLvl.menuItems.unshift(createItem);
668 breadcrumbsComponentsLvl.selectedIndex = 0;
671 this.$scope.breadcrumbsModel = [breadcrumbsComponentsLvl, this.$scope.leftBarTabs];
674 private initMenuItems() {
676 let inCreateMode = this.$scope.isCreateMode();
677 this.$scope.leftBarTabs = new MenuItemGroup();
678 this.$scope.leftBarTabs.menuItems = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role);
680 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
681 item.params = [item.state];
682 item.callback = this.$scope.onMenuItemPressed;
683 item.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != item.state) ||
684 (States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource());
687 if (this.cacheService.get('breadcrumbsComponents')) {
688 this.initBreadcrumbs();
690 let onSuccess = (components:Array<Component>) => {
691 this.cacheService.set('breadcrumbsComponents', components);
692 this.initBreadcrumbs();
694 this.EntityService.getCatalog().then(onSuccess); //getAllComponents() doesnt return components from catalog
698 private disableMenuItems() {
699 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
700 item.params = [item.state];
701 item.callback = this.$scope.onMenuItemPressed;
702 item.isDisabled = (States.WORKSPACE_GENERAL != item.state);
706 private enableMenuItems() {
707 this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => {
708 item.params = [item.state];
709 item.callback = this.$scope.onMenuItemPressed;
710 item.isDisabled = false;
714 private showSuccessNotificationMessage = ():void => {
715 this.Notification.success({
716 message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_DESCRIPTION"),
717 title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE")