-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #663 from Esri/f/update-sharing-logic-for-admins
feat(portal): add updateGroupMembership, isItemSharedWithGroup
- Loading branch information
Showing
12 changed files
with
1,068 additions
and
450 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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
63 changes: 63 additions & 0 deletions
63
packages/arcgis-rest-portal/src/groups/update-user-membership.ts
This file contains 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,63 @@ | ||
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; | ||
import { getPortalUrl } from "../util/get-portal-url"; | ||
import { request } from "@esri/arcgis-rest-request"; | ||
|
||
export interface IUpdateGroupUsersResult { | ||
/** | ||
* Array of results | ||
*/ | ||
results: any[]; | ||
} | ||
|
||
export interface IUpdateGroupUsersOptions extends IUserRequestOptions { | ||
/** | ||
* Group ID | ||
*/ | ||
id: string; | ||
/** | ||
* An array of usernames to be updated | ||
*/ | ||
users: string[]; | ||
/** | ||
* Membership Type to update to | ||
*/ | ||
newMemberType: "member" | "admin"; | ||
} | ||
|
||
/** | ||
* ```js | ||
* import { updateUserMemberships } from "@esri/arcgis-rest-portal"; | ||
* // | ||
* updateUserMemberships({ | ||
* id: groupId, | ||
* admins: ["username3"], | ||
* authentication | ||
* }) | ||
* .then(response); | ||
* ``` | ||
* Change the user membership levels of existing users in a group | ||
* | ||
* @param requestOptions - Options for the request | ||
* @returns A Promise | ||
*/ | ||
export function updateUserMemberships( | ||
requestOptions: IUpdateGroupUsersOptions | ||
): Promise<IUpdateGroupUsersResult> { | ||
const url = `${getPortalUrl(requestOptions)}/community/groups/${ | ||
requestOptions.id | ||
}/updateUsers`; | ||
const opts: any = { | ||
authentication: requestOptions.authentication, | ||
params: {} | ||
}; | ||
// add the correct params depending on the type of membership we are changing to | ||
if (requestOptions.newMemberType === "admin") { | ||
opts.params.admins = requestOptions.users; | ||
} else { | ||
opts.params.users = requestOptions.users; | ||
} | ||
// make the request | ||
return request(url, opts); | ||
} |
This file contains 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 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.