-
Notifications
You must be signed in to change notification settings - Fork 517
Fix for #8916 #8917 #8918 The Community Administrator should not be able to view all communities/collections in the create/edit community and collection sections. Previous PR #9814 #4639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5aab53e
Fix for #8918 The Community Administrator should not be able to view …
im-shubham-vish 93d43bc
Merge branch 'DSpace:main' into fix-8918
im-shubham-vish a26c718
Fix to set Edit Collection to utilize findAdminAuthorized instead of …
im-shubham-vish 15d9cb0
Fix Lint Error
im-shubham-vish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...so-selector/authorized-community-selector/authorized-community-selector.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
| import { | ||
| ComponentFixture, | ||
| TestBed, | ||
| waitForAsync, | ||
| } from '@angular/core/testing'; | ||
| import { RouterTestingModule } from '@angular/router/testing'; | ||
| import { TranslateModule } from '@ngx-translate/core'; | ||
|
|
||
| import { CommunityDataService } from '../../../../core/data/community-data.service'; | ||
| import { Community } from '../../../../core/shared/community.model'; | ||
| import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.model'; | ||
| import { SearchService } from '../../../../core/shared/search/search.service'; | ||
| import { ThemedLoadingComponent } from '../../../loading/themed-loading.component'; | ||
| import { NotificationsService } from '../../../notifications/notifications.service'; | ||
| import { ListableObjectComponentLoaderComponent } from '../../../object-collection/shared/listable-object/listable-object-component-loader.component'; | ||
| import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils'; | ||
| import { createPaginatedList } from '../../../testing/utils.test'; | ||
| import { VarDirective } from '../../../utils/var.directive'; | ||
| import { AuthorizedCommunitySelectorComponent } from './authorized-community-selector.component'; | ||
|
|
||
| describe('AuthorizedCommunitySelectorComponent', () => { | ||
| let component: AuthorizedCommunitySelectorComponent; | ||
| let fixture: ComponentFixture<AuthorizedCommunitySelectorComponent>; | ||
|
|
||
| let communityService; | ||
| let community; | ||
|
|
||
| let notificationsService: NotificationsService; | ||
|
|
||
| beforeEach(waitForAsync(() => { | ||
| community = Object.assign(new Community(), { | ||
| id: 'authorized-community', | ||
| }); | ||
| communityService = jasmine.createSpyObj('communityService', { | ||
| getAuthorizedCommunity: createSuccessfulRemoteDataObject$(createPaginatedList([community])), | ||
| }); | ||
| notificationsService = jasmine.createSpyObj('notificationsService', ['error']); | ||
| TestBed.configureTestingModule({ | ||
| imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), AuthorizedCommunitySelectorComponent, VarDirective], | ||
| providers: [ | ||
| { provide: SearchService, useValue: {} }, | ||
| { provide: CommunityDataService, useValue: communityService }, | ||
| { provide: NotificationsService, useValue: notificationsService }, | ||
| ], | ||
| schemas: [NO_ERRORS_SCHEMA], | ||
| }) | ||
| .overrideComponent(AuthorizedCommunitySelectorComponent, { | ||
| remove: { imports: [ListableObjectComponentLoaderComponent, ThemedLoadingComponent] }, | ||
| }) | ||
| .compileComponents(); | ||
| })); | ||
|
|
||
| beforeEach(() => { | ||
| fixture = TestBed.createComponent(AuthorizedCommunitySelectorComponent); | ||
| component = fixture.componentInstance; | ||
| component.types = [DSpaceObjectType.COMMUNITY]; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| describe('search', () => { | ||
| 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(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
105 changes: 105 additions & 0 deletions
105
...tor/dso-selector/authorized-community-selector/authorized-community-selector.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { | ||
| AsyncPipe, | ||
| NgClass, | ||
| } from '@angular/common'; | ||
| import { Component } from '@angular/core'; | ||
| import { | ||
| FormsModule, | ||
| ReactiveFormsModule, | ||
| } from '@angular/forms'; | ||
| import { | ||
| TranslateModule, | ||
| TranslateService, | ||
| } from '@ngx-translate/core'; | ||
| import { InfiniteScrollModule } from 'ngx-infinite-scroll'; | ||
| import { Observable } from 'rxjs'; | ||
| import { map } from 'rxjs/operators'; | ||
|
|
||
| import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; | ||
| import { CommunityDataService } from '../../../../core/data/community-data.service'; | ||
| import { FindListOptions } from '../../../../core/data/find-list-options.model'; | ||
| import { | ||
| buildPaginatedList, | ||
| PaginatedList, | ||
| } from '../../../../core/data/paginated-list.model'; | ||
| import { RemoteData } from '../../../../core/data/remote-data'; | ||
| import { Community } from '../../../../core/shared/community.model'; | ||
| import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; | ||
| import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; | ||
| import { SearchService } from '../../../../core/shared/search/search.service'; | ||
| import { hasValue } from '../../../empty.util'; | ||
| import { HoverClassDirective } from '../../../hover-class.directive'; | ||
| import { ThemedLoadingComponent } from '../../../loading/themed-loading.component'; | ||
| import { NotificationsService } from '../../../notifications/notifications.service'; | ||
| import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; | ||
| import { ListableObjectComponentLoaderComponent } from '../../../object-collection/shared/listable-object/listable-object-component-loader.component'; | ||
| import { SearchResult } from '../../../search/models/search-result.model'; | ||
| import { followLink } from '../../../utils/follow-link-config.model'; | ||
| import { DSOSelectorComponent } from '../dso-selector.component'; | ||
|
|
||
| @Component({ | ||
| selector: 'ds-authorized-community-selector', | ||
| styleUrls: ['../dso-selector.component.scss'], | ||
| templateUrl: '../dso-selector.component.html', | ||
| standalone: true, | ||
| imports: [ | ||
| AsyncPipe, | ||
| FormsModule, | ||
| HoverClassDirective, | ||
| InfiniteScrollModule, | ||
| ListableObjectComponentLoaderComponent, | ||
| NgClass, | ||
| ReactiveFormsModule, | ||
| ThemedLoadingComponent, | ||
| TranslateModule, | ||
| ], | ||
| }) | ||
| /** | ||
| * Component rendering a list of communities to select from | ||
| */ | ||
| export class AuthorizedCommunitySelectorComponent extends DSOSelectorComponent { | ||
| /** | ||
| * If present this value is used to filter community list by entity type | ||
| */ | ||
|
|
||
| constructor( | ||
| protected searchService: SearchService, | ||
| protected communityDataService: CommunityDataService, | ||
| protected notifcationsService: NotificationsService, | ||
| protected translate: TranslateService, | ||
| protected dsoNameService: DSONameService, | ||
| ) { | ||
| super(searchService, notifcationsService, translate, dsoNameService); | ||
| } | ||
|
|
||
| /** | ||
| * Get a query to send for retrieving the current DSO | ||
| */ | ||
| getCurrentDSOQuery(): string { | ||
| return this.currentDSOId; | ||
| } | ||
|
|
||
| /** | ||
| * Perform a search for authorized communities with the current query and page | ||
| * @param query Query to search objects for | ||
| * @param page Page to retrieve | ||
| * @param useCache Whether or not to use the cache | ||
| */ | ||
| search(query: string, page: number, useCache: boolean = true): Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>> { | ||
| let searchListService$: Observable<RemoteData<PaginatedList<Community>>> = null; | ||
| const findOptions: FindListOptions = { | ||
| currentPage: page, | ||
| elementsPerPage: this.defaultPagination.pageSize, | ||
| }; | ||
|
|
||
| searchListService$ = this.communityDataService | ||
| .getAuthorizedCommunity(query, findOptions, useCache, false, followLink('parentCommunity')); | ||
|
|
||
| return searchListService$.pipe( | ||
| getFirstCompletedRemoteData(), | ||
| map((rd) => Object.assign(new RemoteData(null, null, null, null), rd, { | ||
| payload: hasValue(rd.payload) ? buildPaginatedList(rd.payload.pageInfo, rd.payload.page.map((col) => Object.assign(new CommunitySearchResult(), { indexableObject: col }))) : null, | ||
| })), | ||
| ); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...appers/create-collection-parent-selector/create-collection-parent-selector.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <div> | ||
| <div class="modal-header">{{'dso-selector.'+ action + '.' + objectType.toString().toLowerCase() + '.head' | translate}} | ||
| <button type="button" class="btn-close" (click)="close()" aria-label="Close"> | ||
| </button> | ||
| </div> | ||
| <div class="modal-body"> | ||
| @if (header) { | ||
| <span class="h5 px-2">{{header | translate}}</span> | ||
| } | ||
| <ds-authorized-community-selector [currentDSOId]="dsoRD?.payload.uuid" | ||
| [types]="selectorTypes" | ||
| (onSelect)="selectObject($event)"></ds-authorized-community-selector> | ||
| </div> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: I don't believe this
@ifsyntax will work for DSpace 7, because it was introduced in Angular 17 (which we first used in DSpace 8). In DSpace 7, this same behavior was controlled via*ngIf.So, this just means that I'm only attempting to backport this to DSpace 8.x and 9.x. If we want to backport also to 7.6.x, we'd need a separate PR.