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

View File

@@ -144,6 +144,12 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
*/ */
@Input() entityType: string; @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 * Emit to notify whether search is complete
*/ */
@@ -252,7 +258,7 @@ export class CollectionDropdownComponent implements OnInit, OnDestroy {
followLink('parentCommunity')); followLink('parentCommunity'));
} else { } else {
searchListService$ = this.collectionDataService searchListService$ = this.collectionDataService
.getAuthorizedCollection(query, findOptions, true, true, followLink('parentCommunity')); .getAuthorizedCollection(query, findOptions, true, true, this.searchHref, followLink('parentCommunity'));
} }
this.searchListCollection$ = searchListService$.pipe( this.searchListCollection$ = searchListService$.pipe(
getFirstCompletedRemoteData(), 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; @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( constructor(
protected searchService: SearchService, protected searchService: SearchService,
protected collectionDataService: CollectionDataService, protected collectionDataService: CollectionDataService,
@@ -104,7 +110,7 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent
findOptions); findOptions);
} else { } else {
searchListService$ = this.collectionDataService searchListService$ = this.collectionDataService
.getAuthorizedCollection(query, findOptions, useCache, false, followLink('parentCommunity')); .getAuthorizedCollection(query, findOptions, useCache, false, this.searchHref, followLink('parentCommunity'));
} }
return searchListService$.pipe( return searchListService$.pipe(
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),

View File

@@ -59,7 +59,6 @@ describe('AuthorizedCommunitySelectorComponent', () => {
}); });
describe('search', () => { describe('search', () => {
describe('when has no entity type', () => {
it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => { it('should call getAuthorizedCommunity and return the authorized community in a SearchResult', (done) => {
component.search('', 1).subscribe((resultRD) => { component.search('', 1).subscribe((resultRD) => {
expect(communityService.getAuthorizedCommunity).toHaveBeenCalled(); expect(communityService.getAuthorizedCommunity).toHaveBeenCalled();
@@ -69,6 +68,4 @@ describe('AuthorizedCommunitySelectorComponent', () => {
}); });
}); });
}); });
});
}); });

View File

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