-
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.
feat(portal): add updateGroupMembership, isItemSharedWithGroup
Add two new functions and make shareItemWithGroup smarter AFFECTS PACKAGES: @esri/arcgis-rest-feature-layer @esri/arcgis-rest-portal @esri/arcgis-rest-service-admin
- Loading branch information
Showing
13 changed files
with
575 additions
and
150 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
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.