Skip to content
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

Resource Members show to include inherited members #508

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/core/templates/ResourceMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ import {
RequestHelper,
Sudo,
} from '../infrastructure';

import { AccessLevel } from './ResourceAccessRequests';

interface IncludeInherited {
includeInherited?: boolean;
Copy link
Contributor

@jetersen jetersen Dec 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm

Argument of type '{ includeInherited: boolean; }' is not assignable to parameter of type 'boolean'.ts(2345)

api.ProjectMembers.all(project.id, { includeInherited: false })

}

export class ResourceMembers extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {
super({ url: resourceType, ...options });
}

all(resourceId: string | number, includeInherited = false, options?: PaginatedRequestOptions) {
all(
resourceId: string | number,
{ includeInherited, ...options }: IncludeInherited & PaginatedRequestOptions = {},
) {
const rId = encodeURIComponent(resourceId);
const url = [rId, 'members'];

Expand Down Expand Up @@ -52,10 +58,19 @@ export class ResourceMembers extends BaseService {
});
}

show(resourceId: string | number, userId: number, options?: Sudo) {
show(
resourceId: string | number,
userId: number,
{ includeInherited, ...options }: IncludeInherited & Sudo = {},
) {
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
const url = [rId, 'members'];

if (includeInherited) url.push('all');

url.push(uId);

return RequestHelper.get(this, `${rId}/members/${uId}`, options);
return RequestHelper.get(this, url.join('/'), { options });
}

remove(resourceId: string | number, userId: number, options?: Sudo) {
Expand Down