Commit 206c570abbfa9eacf5d5ec2c0a64827533376f2b
1 parent
48fd55a6
Hide edge widget if edgesSupportEnabled()
Showing
2 changed files
with
23 additions
and
3 deletions
... | ... | @@ -33,11 +33,12 @@ import { WidgetsBundleComponent } from '@modules/home/pages/widget/widgets-bundl |
33 | 33 | import { NULL_UUID } from '@shared/models/id/has-uuid'; |
34 | 34 | import { Store } from '@ngrx/store'; |
35 | 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 | 37 | import { Authority } from '@shared/models/authority.enum'; |
38 | 38 | import { DialogService } from '@core/services/dialog.service'; |
39 | 39 | import { ImportExportService } from '@home/components/import-export/import-export.service'; |
40 | 40 | import { Direction } from "@shared/models/page/sort-order"; |
41 | +import { map } from "rxjs/operators"; | |
41 | 42 | |
42 | 43 | @Injectable() |
43 | 44 | export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableConfig<WidgetsBundle>> { |
... | ... | @@ -106,7 +107,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon |
106 | 107 | this.config.deleteEntitiesTitle = count => this.translate.instant('widgets-bundle.delete-widgets-bundles-title', {count}); |
107 | 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 | 111 | this.config.loadEntity = id => this.widgetsService.getWidgetsBundle(id.id); |
111 | 112 | this.config.saveEntity = widgetsBundle => this.widgetsService.saveWidgetsBundle(widgetsBundle); |
112 | 113 | this.config.deleteEntity = id => this.widgetsService.deleteWidgetsBundle(id.id); |
... | ... | @@ -119,6 +120,17 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon |
119 | 120 | this.config.deleteEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); |
120 | 121 | this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); |
121 | 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 | 134 | return this.config; |
123 | 135 | } |
124 | 136 | ... | ... |
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | import { Component, forwardRef, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; |
18 | 18 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; |
19 | 19 | import { Observable } from 'rxjs'; |
20 | -import { share, tap } from 'rxjs/operators'; | |
20 | +import { map, share, tap } from 'rxjs/operators'; | |
21 | 21 | import { Store } from '@ngrx/store'; |
22 | 22 | import { AppState } from '@app/core/core.state'; |
23 | 23 | import { coerceBooleanProperty } from '@angular/cdk/coercion'; |
... | ... | @@ -25,6 +25,7 @@ import { WidgetsBundle } from '@shared/models/widgets-bundle.model'; |
25 | 25 | import { WidgetService } from '@core/http/widget.service'; |
26 | 26 | import { isDefined } from '@core/utils'; |
27 | 27 | import { NULL_UUID } from '@shared/models/id/has-uuid'; |
28 | +import { getCurrentAuthState } from "@core/auth/auth.selectors"; | |
28 | 29 | |
29 | 30 | @Component({ |
30 | 31 | selector: 'tb-widgets-bundle-select', |
... | ... | @@ -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 | 105 | share() |
98 | 106 | ); |
99 | 107 | } | ... | ... |