Commit 206c570abbfa9eacf5d5ec2c0a64827533376f2b

Authored by deaflynx
1 parent 48fd55a6

Hide edge widget if edgesSupportEnabled()

@@ -33,11 +33,12 @@ import { WidgetsBundleComponent } from '@modules/home/pages/widget/widgets-bundl @@ -33,11 +33,12 @@ import { WidgetsBundleComponent } from '@modules/home/pages/widget/widgets-bundl
33 import { NULL_UUID } from '@shared/models/id/has-uuid'; 33 import { NULL_UUID } from '@shared/models/id/has-uuid';
34 import { Store } from '@ngrx/store'; 34 import { Store } from '@ngrx/store';
35 import { AppState } from '@core/core.state'; 35 import { AppState } from '@core/core.state';
36 -import { getCurrentAuthUser } from '@app/core/auth/auth.selectors'; 36 +import { getCurrentAuthState, getCurrentAuthUser } from '@app/core/auth/auth.selectors';
37 import { Authority } from '@shared/models/authority.enum'; 37 import { Authority } from '@shared/models/authority.enum';
38 import { DialogService } from '@core/services/dialog.service'; 38 import { DialogService } from '@core/services/dialog.service';
39 import { ImportExportService } from '@home/components/import-export/import-export.service'; 39 import { ImportExportService } from '@home/components/import-export/import-export.service';
40 import { Direction } from "@shared/models/page/sort-order"; 40 import { Direction } from "@shared/models/page/sort-order";
  41 +import { map } from "rxjs/operators";
41 42
42 @Injectable() 43 @Injectable()
43 export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableConfig<WidgetsBundle>> { 44 export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableConfig<WidgetsBundle>> {
@@ -106,7 +107,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon @@ -106,7 +107,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
106 this.config.deleteEntitiesTitle = count => this.translate.instant('widgets-bundle.delete-widgets-bundles-title', {count}); 107 this.config.deleteEntitiesTitle = count => this.translate.instant('widgets-bundle.delete-widgets-bundles-title', {count});
107 this.config.deleteEntitiesContent = () => this.translate.instant('widgets-bundle.delete-widgets-bundles-text'); 108 this.config.deleteEntitiesContent = () => this.translate.instant('widgets-bundle.delete-widgets-bundles-text');
108 109
109 - this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink); 110 +
110 this.config.loadEntity = id => this.widgetsService.getWidgetsBundle(id.id); 111 this.config.loadEntity = id => this.widgetsService.getWidgetsBundle(id.id);
111 this.config.saveEntity = widgetsBundle => this.widgetsService.saveWidgetsBundle(widgetsBundle); 112 this.config.saveEntity = widgetsBundle => this.widgetsService.saveWidgetsBundle(widgetsBundle);
112 this.config.deleteEntity = id => this.widgetsService.deleteWidgetsBundle(id.id); 113 this.config.deleteEntity = id => this.widgetsService.deleteWidgetsBundle(id.id);
@@ -119,6 +120,17 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon @@ -119,6 +120,17 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
119 this.config.deleteEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); 120 this.config.deleteEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
120 this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); 121 this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
121 this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); 122 this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
  123 + const authState = getCurrentAuthState(this.store);
  124 + if (!authState.edgesSupportEnabled) {
  125 + this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(
  126 + map((widgetBundles) => {
  127 + widgetBundles.data = widgetBundles.data.filter(widgetBundle => widgetBundle.alias !== 'edge_widgets');
  128 + return widgetBundles;
  129 + })
  130 + );
  131 + } else {
  132 + this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink);
  133 + }
122 return this.config; 134 return this.config;
123 } 135 }
124 136
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 import { Component, forwardRef, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; 17 import { Component, forwardRef, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core';
18 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; 18 import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
19 import { Observable } from 'rxjs'; 19 import { Observable } from 'rxjs';
20 -import { share, tap } from 'rxjs/operators'; 20 +import { map, share, tap } from 'rxjs/operators';
21 import { Store } from '@ngrx/store'; 21 import { Store } from '@ngrx/store';
22 import { AppState } from '@app/core/core.state'; 22 import { AppState } from '@app/core/core.state';
23 import { coerceBooleanProperty } from '@angular/cdk/coercion'; 23 import { coerceBooleanProperty } from '@angular/cdk/coercion';
@@ -25,6 +25,7 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; @@ -25,6 +25,7 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
25 import { WidgetService } from '@core/http/widget.service'; 25 import { WidgetService } from '@core/http/widget.service';
26 import { isDefined } from '@core/utils'; 26 import { isDefined } from '@core/utils';
27 import { NULL_UUID } from '@shared/models/id/has-uuid'; 27 import { NULL_UUID } from '@shared/models/id/has-uuid';
  28 +import { getCurrentAuthState } from "@core/auth/auth.selectors";
28 29
29 @Component({ 30 @Component({
30 selector: 'tb-widgets-bundle-select', 31 selector: 'tb-widgets-bundle-select',
@@ -94,6 +95,13 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni @@ -94,6 +95,13 @@ export class WidgetsBundleSelectComponent implements ControlValueAccessor, OnIni
94 } 95 }
95 } 96 }
96 }), 97 }),
  98 + map((widgetsBundles) => {
  99 + const authState = getCurrentAuthState(this.store);
  100 + if (!authState.edgesSupportEnabled) {
  101 + widgetsBundles = widgetsBundles.filter(widgetsBundle => widgetsBundle.alias !== 'edge_widgets');
  102 + }
  103 + return widgetsBundles;
  104 + }),
97 share() 105 share()
98 ); 106 );
99 } 107 }