-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: showInfoBanner for user org settings (#1676)
- Loading branch information
Showing
8 changed files
with
415 additions
and
51 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
1 change: 0 additions & 1 deletion
1
packages/common/src/utils/internal/updateCommunityOrgSettings.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
44 changes: 44 additions & 0 deletions
44
packages/common/src/utils/internal/updatePortalOrgSettings.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,44 @@ | ||
import { IArcGISContext } from "../../ArcGISContext"; | ||
import { IHubUserOrgSettings } from "../../core/types/IHubUser"; | ||
import { request } from "@esri/arcgis-rest-request"; | ||
import { cloneObject } from "../../util"; | ||
|
||
/** | ||
* Function to update a user's org settings. Expects the user to be an org admin in the current org. | ||
* Currently only updates whether to show the informational banner. | ||
* @param settings | ||
*/ | ||
export async function updatePortalOrgSettings( | ||
settings: IHubUserOrgSettings, | ||
context: IArcGISContext | ||
) { | ||
// check that user is authed | ||
if (!context.currentUser) { | ||
throw new Error("User is not authenticated"); | ||
} | ||
|
||
// check that user is org admin | ||
if (!context.isOrgAdmin) { | ||
throw new Error("User is not an org admin in the current org"); | ||
} | ||
|
||
// grab and clone portalProperties | ||
const portalProperties = cloneObject(context.portal.portalProperties); | ||
// grab settings | ||
const { showInformationalBanner } = settings; | ||
// update infoBanner value in portalProperties | ||
portalProperties.hub.settings.informationalBanner = showInformationalBanner; | ||
|
||
// build the url | ||
const urlPath = `/sharing/rest/portals/self/update?f=json`; | ||
const url = `${context.portalUrl}${urlPath}`; | ||
|
||
// send the request to update | ||
return request(url, { | ||
httpMethod: "POST", | ||
params: { | ||
portalProperties: JSON.stringify(portalProperties), | ||
token: context.hubRequestOptions.authentication.token, | ||
}, | ||
}); | ||
} |
Oops, something went wrong.