Skip to content

Commit 315f8d5

Browse files
author
Andrea Barbasso
committed
[DSC-1661] check canCorrectItem feature
1 parent fe226c4 commit 315f8d5

3 files changed

Lines changed: 14 additions & 23 deletions

File tree

src/app/search-page/configuration-search-page.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { RouteService } from '../core/services/route.service';
99
import { SearchService } from '../core/shared/search/search.service';
1010
import { Router } from '@angular/router';
1111
import { SearchManager } from '../core/browse/search-manager';
12-
import { ConfigurationDataService } from '../core/data/configuration-data.service';
12+
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
1313

1414
/**
1515
* This component renders a search page using a configuration as input.
@@ -37,7 +37,7 @@ export class ConfigurationSearchPageComponent extends SearchComponent {
3737
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
3838
protected routeService: RouteService,
3939
protected router: Router,
40-
protected configurationService: ConfigurationDataService,) {
41-
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router, configurationService);
40+
protected authorizationService: AuthorizationDataService,) {
41+
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router, authorizationService);
4242
}
4343
}

src/app/shared/search/search.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RouterTestingModule } from '@angular/router/testing';
55
import { Store } from '@ngrx/store';
66
import { TranslateModule } from '@ngx-translate/core';
77
import { cold } from 'jasmine-marbles';
8-
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
8+
import { BehaviorSubject, Observable, of, of as observableOf } from 'rxjs';
99
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
1010
import { CommunityDataService } from '../../core/data/community-data.service';
1111
import { HostWindowService } from '../host-window.service';
@@ -34,15 +34,15 @@ import { SearchFilterConfig } from './models/search-filter-config.model';
3434
import { FilterType } from './models/filter-type.model';
3535
import { getCommunityPageRoute } from '../../community-page/community-page-routing-paths';
3636
import { getCollectionPageRoute } from '../../collection-page/collection-page-routing-paths';
37-
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
37+
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
3838

3939
let comp: SearchComponent;
4040
let fixture: ComponentFixture<SearchComponent>;
4141
let searchServiceObject: SearchService;
4242
let searchConfigurationServiceObject: SearchConfigurationService;
4343

44-
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
45-
findByPropertyName: createSuccessfulRemoteDataObject$({ values: ['true'] })
44+
const authorizationDataService = jasmine.createSpyObj('authorizationDataService', {
45+
isAuthorized: of(true)
4646
});
4747

4848
const store: Store<SearchComponent> = jasmine.createSpyObj('store', {
@@ -247,8 +247,8 @@ export function configureSearchComponentTestingModule(compType, additionalDeclar
247247
useValue: searchConfigurationServiceStub
248248
},
249249
{
250-
provide: ConfigurationDataService,
251-
useValue: configurationDataService
250+
provide: AuthorizationDataService,
251+
useValue: authorizationDataService
252252
}
253253
],
254254
schemas: [NO_ERRORS_SCHEMA]

src/app/shared/search/search.component.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ import { COMMUNITY_MODULE_PATH } from '../../community-page/community-page-routi
5151
import { SearchManager } from '../../core/browse/search-manager';
5252
import { AlertType } from '../alert/alert-type';
5353
import { isPlatformServer } from '@angular/common';
54-
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
54+
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
55+
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
5556

5657
@Component({
5758
selector: 'ds-search',
@@ -375,7 +376,7 @@ export class SearchComponent implements OnInit, OnDestroy {
375376
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
376377
protected routeService: RouteService,
377378
protected router: Router,
378-
protected configurationService: ConfigurationDataService,) {
379+
protected authorizationService: AuthorizationDataService,) {
379380
this.isXsOrSm$ = this.windowService.isXsOrSm();
380381
}
381382

@@ -394,18 +395,8 @@ export class SearchComponent implements OnInit, OnDestroy {
394395

395396
if (this.showCorrection === null || this.showCorrection === undefined) {
396397
this.subs.push(
397-
this.configurationService.findByPropertyName('context-menu-entry.requestcorrection.enabled').pipe(
398-
getFirstCompletedRemoteData(),
399-
map((res) => {
400-
switch (res?.payload?.values[0]) {
401-
case 'true':
402-
return true;
403-
case 'false':
404-
default:
405-
return false;
406-
}
407-
}),
408-
).subscribe((showCorrection) => {
398+
this.authorizationService.isAuthorized(FeatureID.CanCorrectItem, null, null, true)
399+
.subscribe((showCorrection) => {
409400
this.showCorrection = showCorrection;
410401
}));
411402
}

0 commit comments

Comments
 (0)