Commit e6b156df63a8ed23c96ea851a0ab6a277d2dc14e

Authored by Artem Babak
1 parent f99d7171

Hide edge management for customers if Edge is disabled

... ... @@ -43,7 +43,8 @@
43 43 <button mat-raised-button color="primary"
44 44 [disabled]="(isLoading$ | async)"
45 45 (click)="onEntityAction($event, 'manageEdges')"
46   - [fxShow]="!isEdit">
  46 + [fxShow]="!isEdit"
  47 + *ngIf="edgesSupportEnabled()">
47 48 {{'customer.manage-edges' | translate }}
48 49 </button>
49 50 <button mat-raised-button color="primary"
... ...
... ... @@ -23,6 +23,7 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti
23 23 import { TranslateService } from '@ngx-translate/core';
24 24 import { ContactBasedComponent } from '../../components/entity/contact-based.component';
25 25 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
  26 +import { getCurrentAuthState } from '@core/auth/auth.selectors';
26 27
27 28 @Component({
28 29 selector: 'tb-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 31 import { CustomerService } from '@app/core/http/customer.service';
32 32 import { CustomerComponent } from '@modules/home/pages/customer/customer.component';
33 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 38 @Injectable()
36 39 export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<Customer>> {
... ... @@ -40,13 +43,15 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
40 43 constructor(private customerService: CustomerService,
41 44 private translate: TranslateService,
42 45 private datePipe: DatePipe,
43   - private router: Router) {
  46 + private router: Router,
  47 + private store: Store<AppState>) {
44 48
45 49 this.config.entityType = EntityType.CUSTOMER;
46 50 this.config.entityComponent = CustomerComponent;
47 51 this.config.entityTabsComponent = CustomerTabsComponent;
48 52 this.config.entityTranslations = entityTypeTranslations.get(EntityType.CUSTOMER);
49 53 this.config.entityResources = entityTypeResources.get(EntityType.CUSTOMER);
  54 + const authState = getCurrentAuthState(this.store);
50 55
51 56 this.config.columns.push(
52 57 new DateEntityTableColumn<Customer>('createdTime', 'common.created-time', this.datePipe, '150px'),
... ... @@ -55,7 +60,6 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
55 60 new EntityTableColumn<Customer>('country', 'contact.country', '25%'),
56 61 new EntityTableColumn<Customer>('city', 'contact.city', '25%')
57 62 );
58   -
59 63 this.config.cellActionDescriptors.push(
60 64 {
61 65 name: this.translate.instant('customer.manage-customer-users'),
... ... @@ -95,19 +99,22 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
95 99 icon: 'dashboard',
96 100 isEnabled: (customer) => true,
97 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 119 this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title });
113 120 this.config.deleteEntityContent = () => this.translate.instant('customer.delete-customer-text');
... ...
... ... @@ -627,7 +627,8 @@
627 627 "default-customer-required": "Default customer is required in order to debug dashboard on Tenant level",
628 628 "search": "Search customers",
629 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 633 "datetime": {
633 634 "date-from": "Date from",
... ...