Remove PermissionsService and replace its usage with the CurrentUserService (#9282)
This removes the only usage of the permissions service in the invite-user-button and puts the new capabilities based APIs in its place. It also unifies the action being checked for both outside the ium and insidepull/9291/head
parent
2957236a07
commit
97489ca1e1
@ -1,17 +0,0 @@ |
||||
import { TestBed } from '@angular/core/testing'; |
||||
|
||||
import { PermissionsService } from './permissions.service'; |
||||
|
||||
// TODO: Test this service
|
||||
/*describe('PermissionsService', () => { |
||||
let service:PermissionsService; |
||||
|
||||
beforeEach(() => { |
||||
TestBed.configureTestingModule({}); |
||||
service = TestBed.inject(PermissionsService); |
||||
}); |
||||
|
||||
it('should be created', () => { |
||||
expect(service).toBeTruthy(); |
||||
}); |
||||
});*/ |
@ -1,33 +0,0 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import { APIV3Service } from 'core-app/modules/apiv3/api-v3.service'; |
||||
import { Observable, of } from 'rxjs'; |
||||
import { CurrentProjectService } from 'core-components/projects/current-project.service'; |
||||
import { map, catchError } from 'rxjs/operators'; |
||||
import { FilterOperator } from 'core-components/api/api-v3/api-v3-filter-builder'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root', |
||||
}) |
||||
export class PermissionsService { |
||||
constructor( |
||||
private apiV3Service:APIV3Service, |
||||
private currentProjectService:CurrentProjectService, |
||||
) { } |
||||
|
||||
canInviteUsersToProject(projectId = this.currentProjectService.id!):Observable<boolean> { |
||||
// TODO: Remove/Fix this typing issue
|
||||
const filters:[string, FilterOperator, string[]][] = [['id', '=', [projectId]]]; |
||||
|
||||
return this.apiV3Service |
||||
.memberships |
||||
.available_projects |
||||
.list({ filters }) |
||||
.pipe( |
||||
map(collection => !!collection.elements.length), |
||||
catchError((error) => { |
||||
console.error(error); |
||||
return of(false); |
||||
}), |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue