Fix to set Edit Collection to utilize findAdminAuthorized instead of findSubmitAuthorized

This commit is contained in:
im-shubham-vish
2025-09-09 18:35:18 +05:30
parent 93d43bcbd7
commit a26c718db4
6 changed files with 37 additions and 13 deletions

View File

@@ -77,11 +77,11 @@ export class CollectionDataService extends ComColDataService<Collection> {
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
* @param searchHref The backend search endpoint to use (default to submit)
* @return Observable<RemoteData<PaginatedList<Collection>>>
* collection list
*/
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
const searchHref = 'findSubmitAuthorized';
getAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, searchHref: string = 'findSubmitAuthorized', ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
options = Object.assign({}, options, {
searchParams: [new RequestParam('query', query)],
});

View File

@@ -144,6 +144,12 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
*/
@Input() entityType: string;
/**
* Search endpoint to use for finding authorized collections.
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
*/
@Input() searchHref = 'findSubmitAuthorized';
/**
* Emit to notify whether search is complete
*/
@@ -252,7 +258,7 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
followLink('parentCommunity'));
} else {
searchListService$ = this.collectionDataService
.getAuthorizedCollection(query, findOptions, true, true, followLink('parentCommunity'));
.getAuthorizedCollection(query, findOptions, true, true, this.searchHref, followLink('parentCommunity'));
}
this.searchListCollection$ = searchListService$.pipe(
getFirstCompletedRemoteData(),

View File

@@ -83,5 +83,19 @@ describe('AuthorizedCollectionSelectorComponent', () => {
});
});
});
describe('when using searchHref', () => {
it('should call getAuthorizedCollection with "findAdminAuthorized" when overridden', (done) => {
component.searchHref = 'findAdminAuthorized';
component.search('', 1).subscribe(() => {
expect(collectionService.getAuthorizedCollection).toHaveBeenCalledWith(
'', jasmine.any(Object), true, false, 'findAdminAuthorized', jasmine.anything()
);
done();
});
});
});
});
});

View File

@@ -66,6 +66,12 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
*/
@Input() entityType: string;
/**
* Search endpoint to use for finding authorized collections.
* Defaults to 'findSubmitAuthorized', but can be overridden (e.g. to 'findAdminAuthorized')
*/
@Input() searchHref = 'findSubmitAuthorized';
constructor(
protected searchService: SearchService,
protected collectionDataService: CollectionDataService,
@@ -104,7 +110,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
findOptions);
} else {
searchListService$ = this.collectionDataService
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity'));
.getAuthorizedCollection(query, findOptions, useCache, false, this.searchHref, followLink('parentCommunity'));
}
return searchListService$.pipe(
getFirstCompletedRemoteData(),

View File

@@ -59,16 +59,13 @@ describe('AuthorizedCommunitySelectorComponent', () => {
});
describe('search', () => {
describe('when has no entity type', () => {
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
component.search('', 1).subscribe((resultRD) => {
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
expect(resultRD.payload.page.length).toEqual(1);
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
done();
});
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
component.search('', 1).subscribe((resultRD) => {
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
expect(resultRD.payload.page.length).toEqual(1);
expect(resultRD.payload.page[0].indexableObject).toEqual(community);
done();
});
});
});
});

View File

@@ -9,6 +9,7 @@
}
<ds-authorized-collection-selector [currentDSOId]="dsoRD?.payload.uuid"
[types]="selectorTypes"
searchHref="findAdminAuthorized"
(onSelect)="selectObject($event)"></ds-authorized-collection-selector>
</div>
</div>