Hide edge management for customers if Edge is disabled
This commit is contained in:
parent
f99d7171a2
commit
e6b156df63
@ -43,7 +43,8 @@
|
|||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
[disabled]="(isLoading$ | async)"
|
[disabled]="(isLoading$ | async)"
|
||||||
(click)="onEntityAction($event, 'manageEdges')"
|
(click)="onEntityAction($event, 'manageEdges')"
|
||||||
[fxShow]="!isEdit">
|
[fxShow]="!isEdit"
|
||||||
|
*ngIf="edgesSupportEnabled()">
|
||||||
{{'customer.manage-edges' | translate }}
|
{{'customer.manage-edges' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-raised-button color="primary"
|
<button mat-raised-button color="primary"
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import { ActionNotificationShow } from '@app/core/notification/notification.acti
|
|||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ContactBasedComponent } from '../../components/entity/contact-based.component';
|
import { ContactBasedComponent } from '../../components/entity/contact-based.component';
|
||||||
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
|
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
|
||||||
|
import { getCurrentAuthState } from '@core/auth/auth.selectors';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-customer',
|
selector: 'tb-customer',
|
||||||
@ -78,4 +79,9 @@ export class CustomerComponent extends ContactBasedComponent<Customer> {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edgesSupportEnabled() {
|
||||||
|
const authState = getCurrentAuthState(this.store);
|
||||||
|
return authState.edgesSupportEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,9 @@ import { Customer } from '@app/shared/models/customer.model';
|
|||||||
import { CustomerService } from '@app/core/http/customer.service';
|
import { CustomerService } from '@app/core/http/customer.service';
|
||||||
import { CustomerComponent } from '@modules/home/pages/customer/customer.component';
|
import { CustomerComponent } from '@modules/home/pages/customer/customer.component';
|
||||||
import { CustomerTabsComponent } from '@home/pages/customer/customer-tabs.component';
|
import { CustomerTabsComponent } from '@home/pages/customer/customer-tabs.component';
|
||||||
|
import { getCurrentAuthState } from '@core/auth/auth.selectors';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AppState } from '@core/core.state';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<Customer>> {
|
export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<Customer>> {
|
||||||
@ -40,13 +43,15 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
|
|||||||
constructor(private customerService: CustomerService,
|
constructor(private customerService: CustomerService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private datePipe: DatePipe,
|
private datePipe: DatePipe,
|
||||||
private router: Router) {
|
private router: Router,
|
||||||
|
private store: Store<AppState>) {
|
||||||
|
|
||||||
this.config.entityType = EntityType.CUSTOMER;
|
this.config.entityType = EntityType.CUSTOMER;
|
||||||
this.config.entityComponent = CustomerComponent;
|
this.config.entityComponent = CustomerComponent;
|
||||||
this.config.entityTabsComponent = CustomerTabsComponent;
|
this.config.entityTabsComponent = CustomerTabsComponent;
|
||||||
this.config.entityTranslations = entityTypeTranslations.get(EntityType.CUSTOMER);
|
this.config.entityTranslations = entityTypeTranslations.get(EntityType.CUSTOMER);
|
||||||
this.config.entityResources = entityTypeResources.get(EntityType.CUSTOMER);
|
this.config.entityResources = entityTypeResources.get(EntityType.CUSTOMER);
|
||||||
|
const authState = getCurrentAuthState(this.store);
|
||||||
|
|
||||||
this.config.columns.push(
|
this.config.columns.push(
|
||||||
new DateEntityTableColumn<Customer>('createdTime', 'common.created-time', this.datePipe, '150px'),
|
new DateEntityTableColumn<Customer>('createdTime', 'common.created-time', this.datePipe, '150px'),
|
||||||
@ -55,7 +60,6 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
|
|||||||
new EntityTableColumn<Customer>('country', 'contact.country', '25%'),
|
new EntityTableColumn<Customer>('country', 'contact.country', '25%'),
|
||||||
new EntityTableColumn<Customer>('city', 'contact.city', '25%')
|
new EntityTableColumn<Customer>('city', 'contact.city', '25%')
|
||||||
);
|
);
|
||||||
|
|
||||||
this.config.cellActionDescriptors.push(
|
this.config.cellActionDescriptors.push(
|
||||||
{
|
{
|
||||||
name: this.translate.instant('customer.manage-customer-users'),
|
name: this.translate.instant('customer.manage-customer-users'),
|
||||||
@ -95,19 +99,22 @@ export class CustomersTableConfigResolver implements Resolve<EntityTableConfig<C
|
|||||||
icon: 'dashboard',
|
icon: 'dashboard',
|
||||||
isEnabled: (customer) => true,
|
isEnabled: (customer) => true,
|
||||||
onAction: ($event, entity) => this.manageCustomerDashboards($event, entity)
|
onAction: ($event, entity) => this.manageCustomerDashboards($event, entity)
|
||||||
},
|
});
|
||||||
{
|
if (authState.edgesSupportEnabled) {
|
||||||
name: this.translate.instant('customer.manage-customer-edges'),
|
this.config.cellActionDescriptors.push(
|
||||||
nameFunction: (customer) => {
|
{
|
||||||
return customer.additionalInfo && customer.additionalInfo.isPublic
|
name: this.translate.instant('customer.manage-customer-edges'),
|
||||||
? this.translate.instant('customer.manage-public-edges')
|
nameFunction: (customer) => {
|
||||||
: this.translate.instant('customer.manage-customer-edges');
|
return customer.additionalInfo && customer.additionalInfo.isPublic
|
||||||
},
|
? this.translate.instant('customer.manage-public-edges')
|
||||||
icon: 'router',
|
: this.translate.instant('customer.manage-customer-edges');
|
||||||
isEnabled: (customer) => true,
|
},
|
||||||
onAction: ($event, entity) => this.manageCustomerEdges($event, entity)
|
icon: 'router',
|
||||||
},
|
isEnabled: (customer) => true,
|
||||||
);
|
onAction: ($event, entity) => this.manageCustomerEdges($event, entity)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title });
|
this.config.deleteEntityTitle = customer => this.translate.instant('customer.delete-customer-title', { customerTitle: customer.title });
|
||||||
this.config.deleteEntityContent = () => this.translate.instant('customer.delete-customer-text');
|
this.config.deleteEntityContent = () => this.translate.instant('customer.delete-customer-text');
|
||||||
|
|||||||
@ -627,7 +627,8 @@
|
|||||||
"default-customer-required": "Default customer is required in order to debug dashboard on Tenant level",
|
"default-customer-required": "Default customer is required in order to debug dashboard on Tenant level",
|
||||||
"search": "Search customers",
|
"search": "Search customers",
|
||||||
"selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected",
|
"selected-customers": "{ count, plural, 1 {1 customer} other {# customers} } selected",
|
||||||
"edges": "Customer edge instances"
|
"edges": "Customer edge instances",
|
||||||
|
"manage-edges": "Manage edges"
|
||||||
},
|
},
|
||||||
"datetime": {
|
"datetime": {
|
||||||
"date-from": "Date from",
|
"date-from": "Date from",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user