64644: Removal of filtered discovery page

This commit is contained in:
Yana De Pauw
2019-08-29 16:33:38 +02:00
parent 7903a93042
commit 22df3ec7f2
8 changed files with 6 additions and 137 deletions

View File

@@ -82,9 +82,6 @@ describe('MyDSpacePageComponent', () => {
expand: () => this.isCollapsed = observableOf(false)
};
const mockFixedFilterService: SearchFixedFilterService = {
getQueryByFilterName: (filter: string) => {
return observableOf(undefined)
}
} as SearchFixedFilterService;
beforeEach(async(() => {

View File

@@ -28,11 +28,7 @@ describe('SearchFilterService', () => {
pageSize: 2
});
const mockFixedFilterService: SearchFixedFilterService = {
getQueryByFilterName: (filter: string) => {
return observableOf(undefined)
}
} as SearchFixedFilterService
const mockFixedFilterService: SearchFixedFilterService = {} as SearchFixedFilterService
const value1 = 'random value';
// const value2 = 'another value';
const store: Store<SearchFiltersState> = jasmine.createSpyObj('store', {
@@ -264,19 +260,7 @@ describe('SearchFilterService', () => {
});
});
describe('when the getCurrentFixedFilter method is called', () => {
const filter = 'filter';
beforeEach(() => {
spyOn(routeServiceStub, 'getRouteParameterValue').and.returnValue(observableOf(filter));
spyOn(mockFixedFilterService, 'getQueryByFilterName').and.returnValue(observableOf(filter));
service.getCurrentFixedFilter().subscribe();
});
it('should call getQueryByFilterName on the fixed-filter service with the correct filter', () => {
expect(mockFixedFilterService.getQueryByFilterName).toHaveBeenCalledWith(filter);
});
});
describe('when the getCurrentView method is called', () => {
beforeEach(() => {

View File

@@ -117,15 +117,6 @@ export class SearchFilterService {
return this.routeService.getQueryParamsWithPrefix('f.');
}
/**
* Fetch the current active fixed filter from the route parameters and return the query by filter name
* @returns {Observable<string>}
*/
getCurrentFixedFilter(): Observable<string> {
const filter: Observable<string> = this.routeService.getRouteParameterValue('filter');
return filter.pipe(mergeMap((f) => this.fixedFilterService.getQueryByFilterName(f)));
}
/**
* Fetch the current view from the query parameters
* @returns {Observable<string>}

View File

@@ -4,7 +4,7 @@ import { RequestService } from '../../../core/data/request.service';
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
import { of as observableOf } from 'rxjs';
import { RequestEntry } from '../../../core/data/request.reducer';
import { FilteredDiscoveryQueryResponse, RestResponse } from '../../../core/cache/response.models';
import { FilteredDiscoveryQueryResponse } from '../../../core/cache/response.models';
describe('SearchFixedFilterService', () => {
let service: SearchFixedFilterService;
@@ -14,7 +14,8 @@ describe('SearchFixedFilterService', () => {
const routeServiceStub = {} as RouteService;
const requestServiceStub = Object.assign({
/* tslint:disable:no-empty */
configure: () => {},
configure: () => {
},
/* tslint:enable:no-empty */
generateRequestId: () => 'fake-id',
getByHref: () => observableOf(Object.assign(new RequestEntry(), {
@@ -26,23 +27,7 @@ describe('SearchFixedFilterService', () => {
});
beforeEach(() => {
service = new SearchFixedFilterService(routeServiceStub, requestServiceStub, halServiceStub);
});
describe('when getQueryByFilterName is called with a filterName', () => {
it('should return the filter query', () => {
service.getQueryByFilterName('filter').subscribe((query) => {
expect(query).toBe(filterQuery);
});
});
});
describe('when getQueryByFilterName is called without a filterName', () => {
it('should return undefined', () => {
service.getQueryByFilterName(undefined).subscribe((query) => {
expect(query).toBeUndefined();
});
});
service = new SearchFixedFilterService();
});
describe('when getQueryByRelations is called', () => {

View File

@@ -1,63 +1,10 @@
import { Injectable } from '@angular/core';
import { flatMap, map, switchMap, tap } from 'rxjs/operators';
import { Observable, of as observableOf } from 'rxjs';
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
import { GetRequest, RestRequest } from '../../../core/data/request.models';
import { RequestService } from '../../../core/data/request.service';
import { ResponseParsingService } from '../../../core/data/parsing.service';
import { GenericConstructor } from '../../../core/shared/generic-constructor';
import { FilteredDiscoveryPageResponseParsingService } from '../../../core/data/filtered-discovery-page-response-parsing.service';
import { hasValue } from '../../../shared/empty.util';
import { configureRequest, getResponseFromEntry } from '../../../core/shared/operators';
import { RouteService } from '../../../shared/services/route.service';
import { FilteredDiscoveryQueryResponse } from '../../../core/cache/response.models';
/**
* Service for performing actions on the filtered-discovery-pages REST endpoint
*/
@Injectable()
export class SearchFixedFilterService {
private queryByFilterPath = 'filtered-discovery-pages';
constructor(private routeService: RouteService,
protected requestService: RequestService,
private halService: HALEndpointService) {
}
/**
* Get the filter query for a certain filter by name
* @param {string} filterName Name of the filter
* @returns {Observable<string>} Filter query
*/
getQueryByFilterName(filterName: string): Observable<string> {
if (hasValue(filterName)) {
const requestUuid = this.requestService.generateRequestId();
const requestObs = this.halService.getEndpoint(this.queryByFilterPath).pipe(
map((url: string) => {
url += ('/' + filterName);
const request = new GetRequest(requestUuid, url);
return Object.assign(request, {
getResponseParser(): GenericConstructor<ResponseParsingService> {
return FilteredDiscoveryPageResponseParsingService;
}
});
}),
configureRequest(this.requestService)
);
const requestEntryObs = requestObs.pipe(
switchMap((request: RestRequest) => this.requestService.getByHref(request.href)),
);
const filterQuery = requestEntryObs.pipe(
getResponseFromEntry(),
map((response: FilteredDiscoveryQueryResponse) =>
response.filterQuery
));
return filterQuery;
}
return observableOf(undefined);
}
/**
* Get the query for looking up items by relation type

View File

@@ -89,11 +89,7 @@ const routeServiceStub = {
return observableOf('')
}
};
const mockFixedFilterService: SearchFixedFilterService = {
getQueryByFilterName: (filter: string) => {
return observableOf(undefined)
}
} as SearchFixedFilterService;
const mockFixedFilterService: SearchFixedFilterService = {} as SearchFixedFilterService;
export function configureSearchComponentTestingModule(compType) {
TestBed.configureTestingModule({

View File

@@ -163,12 +163,4 @@ describe('SearchConfigurationService', () => {
});
});
describe('when getCurrentFixedFilter is called', () => {
beforeEach(() => {
service.getCurrentFixedFilter();
});
it('should call getRouteParameterValue on the routeService with parameter name \'filter\'', () => {
expect((service as any).routeService.getRouteParameterValue).toHaveBeenCalledWith('filter');
});
});
});

View File

@@ -205,15 +205,6 @@ export class SearchConfigurationService implements OnDestroy {
}));
}
/**
* @returns {Observable<string>} Emits the current fixed filter as a string
*/
getCurrentFixedFilter(): Observable<string> {
return this.routeService.getRouteParameterValue('filter').pipe(
switchMap((f) => this.fixedFilterService.getQueryByFilterName(f))
);
}
/**
* @returns {Observable<Params>} Emits the current active filters with their values as they are displayed in the frontend URL
*/
@@ -233,7 +224,6 @@ export class SearchConfigurationService implements OnDestroy {
this.getQueryPart(defaults.query),
this.getDSOTypePart(),
this.getFiltersPart(),
this.getFixedFilterPart()
).subscribe((update) => {
const currentValue: SearchOptions = this.searchOptions.getValue();
const updatedValue: SearchOptions = Object.assign(currentValue, update);
@@ -255,7 +245,6 @@ export class SearchConfigurationService implements OnDestroy {
this.getQueryPart(defaults.query),
this.getDSOTypePart(),
this.getFiltersPart(),
this.getFixedFilterPart()
).subscribe((update) => {
const currentValue: PaginatedSearchOptions = this.paginatedSearchOptions.getValue();
const updatedValue: PaginatedSearchOptions = Object.assign(currentValue, update);
@@ -352,16 +341,4 @@ export class SearchConfigurationService implements OnDestroy {
return { filters }
}));
}
/**
* @returns {Observable<string>} Emits the current fixed filter as a partial SearchOptions object
*/
private getFixedFilterPart(): Observable<any> {
return this.getCurrentFixedFilter().pipe(
isNotEmptyOperator(),
map((fixedFilter) => {
return { fixedFilter }
}),
);
}
}