Commit e6b156df63a8ed23c96ea851a0ab6a277d2dc14e

Authored by Artem Babak
1 parent f99d7171

Hide edge management for customers if Edge is disabled

@@ -43,7 +43,8 @@ @@ -43,7 +43,8 @@
43 <button mat-raised-button color="primary" 43 <button mat-raised-button color="primary"
44 [disabled]="(isLoading$ | async)" 44 [disabled]="(isLoading$ | async)"
45 (click)="onEntityAction($event, 'manageEdges')" 45 (click)="onEntityAction($event, 'manageEdges')"
46 - [fxShow]="!isEdit"> 46 + [fxShow]="!isEdit"
  47 + *ngIf="edgesSupportEnabled()">
47 {{'customer.manage-edges' | translate }} 48 {{'customer.manage-edges' | translate }}
48 </button> 49 </button>
49 <button mat-raised-button color="primary" 50 <button mat-raised-button color="primary"
@@ -23,6 +23,7 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti @@ -23,6 +23,7 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti
23 import { TranslateService } from '@ngx-translate/core'; 23 import { TranslateService } from '@ngx-translate/core';
24 import { ContactBasedComponent } from '../../components/entity/contact-based.component'; 24 import { ContactBasedComponent } from '../../components/entity/contact-based.component';
25 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; 25 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
  26 +import { getCurrentAuthState } from '@core/auth/auth.selectors';
26 27
27 @Component({ 28 @Component({
28 selector: 'tb-customer', 29 selector: 'tb-customer',
@@ -78,4 +79,9 @@ export class CustomerComponent extends ContactBasedComponent<Customer> { @@ -78,4 +79,9 @@ export class CustomerComponent extends ContactBasedComponent<Customer> {
78 })); 79 }));
79 } 80 }
80 81
  82 + edgesSupportEnabled() {
  83 + const authState = getCurrentAuthState(this.store);
  84 + return authState.edgesSupportEnabled;
  85 + }
  86 +
81 } 87 }
@@ -31,6 +31,9 @@ import { Customer } from '@app/shared/models/customer.model'; @@ -31,6 +31,9 @@ import { Customer } from '@app/shared/models/customer.model';
31 import { CustomerService } from '@app/core/http/customer.service'; 31 import { CustomerService } from '@app/core/http/customer.service';
32 import { CustomerComponent } from '@modules/home/pages/customer/customer.component'; 32 import { CustomerComponent } from '@modules/home/pages/customer/customer.component';
33 import { CustomerTabsComponent } from '@home/pages/customer/customer-tabs.component'; 33 import { CustomerTabsComponent } from '@home/pages/customer/customer-tabs.component';
  34 +import { getCurrentAuthState } from '@core/auth/auth.selectors';
  35 +import { Store } from '@ngrx/store';
  36 +import { AppState } from '@core/core.state';
34 37
35 @Injectable() 38 @Injectable()
36 export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<Customer>> { 39 export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<Customer>> {
@@ -40,13 +43,15 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C @@ -40,13 +43,15 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
40 constructor(private customerService: CustomerService, 43 constructor(private customerService: CustomerService,
41 private translate: TranslateService, 44 private translate: TranslateService,
42 private datePipe: DatePipe, 45 private datePipe: DatePipe,
43 - private router: Router) { 46 + private router: Router,
  47 + private store: Store<AppState>) {
44 48
45 this.config.entityType = EntityType.CUSTOMER; 49 this.config.entityType = EntityType.CUSTOMER;
46 this.config.entityComponent = CustomerComponent; 50 this.config.entityComponent = CustomerComponent;
47 this.config.entityTabsComponent = CustomerTabsComponent; 51 this.config.entityTabsComponent = CustomerTabsComponent;
48 this.config.entityTranslations = entityTypeTranslations.get(EntityType.CUSTOMER); 52 this.config.entityTranslations = entityTypeTranslations.get(EntityType.CUSTOMER);
49 this.config.entityResources = entityTypeResources.get(EntityType.CUSTOMER); 53 this.config.entityResources = entityTypeResources.get(EntityType.CUSTOMER);
  54 + const authState = getCurrentAuthState(this.store);
50 55
51 this.config.columns.push( 56 this.config.columns.push(
52 new DateEntityTableColumn<Customer>('createdTime', 'common.created-time', this.datePipe, '150px'), 57 new DateEntityTableColumn<Customer>('createdTime', 'common.created-time', this.datePipe, '150px'),
@@ -55,7 +60,6 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C @@ -55,7 +60,6 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
55 new EntityTableColumn<Customer>('country', 'contact.country', '25%'), 60 new EntityTableColumn<Customer>('country', 'contact.country', '25%'),
56 new EntityTableColumn<Customer>('city', 'contact.city', '25%') 61 new EntityTableColumn<Customer>('city', 'contact.city', '25%')
57 ); 62 );
58 -  
59 this.config.cellActionDescriptors.push( 63 this.config.cellActionDescriptors.push(
60 { 64 {
61 name: this.translate.instant('customer.manage-customer-users'), 65 name: this.translate.instant('customer.manage-customer-users'),
@@ -95,19 +99,22 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C @@ -95,19 +99,22 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
95 icon: 'dashboard', 99 icon: 'dashboard',
96 isEnabled: (customer) => true, 100 isEnabled: (customer) => true,
97 onAction: ($event, entity) => this.manageCustomerDashboards($event, entity) 101 onAction: ($event, entity) => this.manageCustomerDashboards($event, entity)
98 - },  
99 - {  
100 - name: this.translate.instant('customer.manage-customer-edges'),  
101 - nameFunction: (customer) => {  
102 - return customer.additionalInfo && customer.additionalInfo.isPublic  
103 - ? this.translate.instant('customer.manage-public-edges')  
104 - : this.translate.instant('customer.manage-customer-edges');  
105 - },  
106 - icon: 'router',  
107 - isEnabled: (customer) => true,  
108 - onAction: ($event, entity) => this.manageCustomerEdges($event, entity)  
109 - },  
110 - ); 102 + });
  103 + if (authState.edgesSupportEnabled) {
  104 + this.config.cellActionDescriptors.push(
  105 + {
  106 + name: this.translate.instant('customer.manage-customer-edges'),
  107 + nameFunction: (customer) => {
  108 + return customer.additionalInfo && customer.additionalInfo.isPublic
  109 + ? this.translate.instant('customer.manage-public-edges')
  110 + : this.translate.instant('customer.manage-customer-edges');
  111 + },
  112 + icon: 'router',
  113 + isEnabled: (customer) => true,
  114 + onAction: ($event, entity) => this.manageCustomerEdges($event, entity)
  115 + }
  116 + );
  117 + }
111 118
112 this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title }); 119 this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title });
113 this.config.deleteEntityContent = () => this.translate.instant('customer.delete-customer-text'); 120 this.config.deleteEntityContent = () => this.translate.instant('customer.delete-customer-text');
@@ -627,7 +627,8 @@ @@ -627,7 +627,8 @@
627 "default-customer-required": "Default customer is required in order to debug dashboard on Tenant level", 627 "default-customer-required": "Default customer is required in order to debug dashboard on Tenant level",
628 "search": "Search customers", 628 "search": "Search customers",
629 "selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected", 629 "selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected",
630 - "edges": "Customer edge instances" 630 + "edges": "Customer edge instances",
  631 + "manage-edges": "Manage edges"
631 }, 632 },
632 "datetime": { 633 "datetime": {
633 "date-from": "Date from", 634 "date-from": "Date from",