Skip to content

Commit

Permalink
feat: implement hub user settings and integrate with context (#1305)
Browse files Browse the repository at this point in the history
* fix: add user hub settings to context and context manager

* feat: finalize context manager integration with hub user settings

* feat: refactor context manager, update tests

* refactor: suppress console logging during tests

* test: suppress console warnings from search package

* refactor: update hub user resource functions

* docs: remove deprecation notice
  • Loading branch information
dbouwman authored Oct 31, 2023
1 parent e28824a commit 47de708
Show file tree
Hide file tree
Showing 35 changed files with 2,312 additions and 1,674 deletions.
25 changes: 25 additions & 0 deletions packages/common/src/ArcGISContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { HubEnvironment, HubLicense, IFeatureFlags } from "./permissions/types";
import { IHubRequestOptions, IHubTrustedOrgsResponse } from "./types";
import { getEnvironmentFromPortalUrl } from "./utils/getEnvironmentFromPortalUrl";
import { IUserResourceToken, UserResourceApp } from "./ArcGISContextManager";
import { IUserHubSettings } from "./utils";

/**
* Hash of Hub API end points so updates
Expand Down Expand Up @@ -203,6 +204,12 @@ export interface IArcGISContext {
*/
userResourceTokens?: IUserResourceToken[];

/**
* Hash of user hub settings. These are stored as
* user-app-resources, associated with the `hubforarcgis` clientId
*/
userHubSettings?: IUserHubSettings;

/**
* Return the token for a given app, if defined
* @param app
Expand Down Expand Up @@ -242,6 +249,7 @@ export interface IArcGISContextOptions {
* ArcGISContextManager handles this internally
*/
portalSelf?: IPortal;

/**
* If the user is authenticated, the user should be passed in
* so various getters can work as expected.
Expand Down Expand Up @@ -280,6 +288,12 @@ export interface IArcGISContextOptions {
* with user-app-resources
*/
userResourceTokens?: IUserResourceToken[];

/**
* Hash of user hub settings. These are stored as
* user-app-resources, associated with the `hubforarcgis` clientId
*/
userHubSettings?: IUserHubSettings;
}

/**
Expand Down Expand Up @@ -325,6 +339,8 @@ export class ArcGISContext implements IArcGISContext {

private _userResourceTokens: IUserResourceToken[] = [];

private _userHubSettings: IUserHubSettings;

/**
* Create a new instance of `ArcGISContext`.
*
Expand Down Expand Up @@ -360,6 +376,7 @@ export class ArcGISContext implements IArcGISContext {

this._featureFlags = opts.featureFlags || {};
this._userResourceTokens = opts.userResourceTokens || [];
this._userHubSettings = opts.userHubSettings || null;
}

/**
Expand Down Expand Up @@ -698,6 +715,14 @@ export class ArcGISContext implements IArcGISContext {
return this._userResourceTokens;
}

/**
* Return the user hub settings.
* Updates must be done via `contextManager.updateUserHubSettings`
*/
public get userHubSettings(): IUserHubSettings {
return this._userHubSettings;
}

/**
* Return a token for a specific app
* @param app
Expand Down
Loading

0 comments on commit 47de708

Please sign in to comment.