diff --git a/package-lock.json b/package-lock.json index fb3a46b1558..11aa49ef87e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64981,7 +64981,7 @@ }, "packages/common": { "name": "@esri/hub-common", - "version": "14.26.0", + "version": "14.29.0", "license": "Apache-2.0", "dependencies": { "abab": "^2.0.5", diff --git a/packages/common/e2e/associations.e2e.ts b/packages/common/e2e/associations.e2e.ts index c68728426c4..392aa0f0ff9 100644 --- a/packages/common/e2e/associations.e2e.ts +++ b/packages/common/e2e/associations.e2e.ts @@ -8,7 +8,6 @@ import Artifactory from "./helpers/Artifactory"; import config from "./helpers/config"; import { ICreateOutput, - cleanupItems, createInitiative, createProjects, createScopeGroup, diff --git a/packages/common/e2e/fixtures/initiative.ts b/packages/common/e2e/fixtures/initiative.ts index 37712273d59..d2ddd54282e 100644 --- a/packages/common/e2e/fixtures/initiative.ts +++ b/packages/common/e2e/fixtures/initiative.ts @@ -1,4 +1,4 @@ -import { IHubInitiative, IModel } from "../../src"; +import { IModel } from "../../src"; const model: IModel = { item: { diff --git a/packages/common/e2e/fixtures/project.ts b/packages/common/e2e/fixtures/project.ts index 4f7d8c09723..c6e662454f8 100644 --- a/packages/common/e2e/fixtures/project.ts +++ b/packages/common/e2e/fixtures/project.ts @@ -1,4 +1,4 @@ -import { IHubProject, IModel } from "../../src"; +import { IModel } from "../../src"; const projectmodel: IModel = { item: { diff --git a/packages/common/e2e/metrics.e2e.ts b/packages/common/e2e/metrics.e2e.ts index 1a40f6de712..4f8d38767b3 100644 --- a/packages/common/e2e/metrics.e2e.ts +++ b/packages/common/e2e/metrics.e2e.ts @@ -10,7 +10,6 @@ import Artifactory from "./helpers/Artifactory"; import config from "./helpers/config"; import { ICreateOutput, - cleanupItems, createInitiative, createProjects, createScopeGroup, diff --git a/packages/common/e2e/permissions.e2e.ts b/packages/common/e2e/permissions.e2e.ts index 152138ca731..fc9f1ef96e3 100644 --- a/packages/common/e2e/permissions.e2e.ts +++ b/packages/common/e2e/permissions.e2e.ts @@ -1,8 +1,6 @@ import { IArcGISContext } from "../src/ArcGISContext"; import { fetchHubEntity } from "../src/core/fetchHubEntity"; import { HubEntity } from "../src/core/types/HubEntity"; -import { IHubInitiative } from "../src/core/types/IHubInitiative"; -import { HubInitiative } from "../src/initiatives/HubInitiative"; import { checkPermission } from "../src/permissions/checkPermission"; import Artifactory from "./helpers/Artifactory"; import config from "./helpers/config"; diff --git a/packages/common/e2e/purge-domains.e2e.ts b/packages/common/e2e/purge-domains.e2e.ts index efe5b4672c2..54a0943e8d3 100644 --- a/packages/common/e2e/purge-domains.e2e.ts +++ b/packages/common/e2e/purge-domains.e2e.ts @@ -3,13 +3,9 @@ import { lookupDomain, deleteSite, removeDomain, - batch, IArcGISContext, failSafe, } from "../src"; -import { hostnames } from "./fixtures/sample"; -import Artifactory from "./helpers/Artifactory"; -import config from "./helpers/config"; let count = 0; async function processDomain(cfg: { domain: string; diff --git a/packages/common/src/content/_internal/computeProps.ts b/packages/common/src/content/_internal/computeProps.ts index f28bc4f1b32..6ec1cae8e93 100644 --- a/packages/common/src/content/_internal/computeProps.ts +++ b/packages/common/src/content/_internal/computeProps.ts @@ -2,9 +2,8 @@ import { IRequestOptions } from "@esri/arcgis-rest-request"; import { UserSession } from "@esri/arcgis-rest-auth"; import { getItemThumbnailUrl } from "../../resources"; import { IModel } from "../../types"; -import { bBoxToExtent, extentToPolygon, isBBox } from "../../extent"; +import { bBoxToExtent, isBBox } from "../../extent"; import { IExtent } from "@esri/arcgis-rest-types"; -import Geometry = __esri.Geometry; import { getItemHomeUrl } from "../../urls/get-item-home-url"; import { getContentEditUrl, getHubRelativeUrl } from "./internalContentUtils"; import { IHubLocation } from "../../core/types/IHubLocation"; diff --git a/packages/common/src/content/search.ts b/packages/common/src/content/search.ts index dbdfadd0fd8..e5e5fbd3ac7 100644 --- a/packages/common/src/content/search.ts +++ b/packages/common/src/content/search.ts @@ -1,5 +1,4 @@ import { IItem } from "@esri/arcgis-rest-types"; -import { isMaster } from "cluster"; import { fetchItemEnrichments } from "../items/_enrichments"; import { getProp } from "../objects"; import { getItemThumbnailUrl } from "../resources"; diff --git a/packages/common/src/core/EntityEditor.ts b/packages/common/src/core/EntityEditor.ts index 66e8f9d37f4..3c834c308d4 100644 --- a/packages/common/src/core/EntityEditor.ts +++ b/packages/common/src/core/EntityEditor.ts @@ -10,7 +10,7 @@ import { HubSite } from "../sites/HubSite"; import { HubTemplate } from "../templates"; import { IEditorConfig, IWithEditorBehavior } from "./behaviors"; import { getTypeFromEntity } from "./getTypeFromEntity"; -import { EditorType, UiSchemaElementOptions } from "./schemas"; +import { EditorType } from "./schemas"; import { HubEntity } from "./types/HubEntity"; import { HubEntityEditor, IEntityEditorContext } from "./types/HubEntityEditor"; diff --git a/packages/common/src/core/HubItemEntity.ts b/packages/common/src/core/HubItemEntity.ts index 1a0a1152112..31af057502c 100644 --- a/packages/common/src/core/HubItemEntity.ts +++ b/packages/common/src/core/HubItemEntity.ts @@ -32,7 +32,7 @@ import { } from "./behaviors"; import { IWithThumbnailBehavior } from "./behaviors/IWithThumbnailBehavior"; -import { AccessLevel, IHubItemEntity, SettableAccessLevel } from "./types"; +import { IHubItemEntity, SettableAccessLevel } from "./types"; import { sharedWith } from "./_internal/sharedWith"; import { IWithDiscussionsBehavior } from "./behaviors/IWithDiscussionsBehavior"; import { setDiscussableKeyword } from "../discussions"; @@ -256,6 +256,25 @@ export abstract class HubItemEntity }); } + /** + * Sets whether or not the followers group is discussable + * @param isDiscussable + */ + async setFollowersGroupIsDiscussable(isDiscussable: boolean) { + const group = await this.getFollowersGroup(); + const typeKeywords = setDiscussableKeyword( + group.typeKeywords, + isDiscussable + ); + await updateGroup({ + group: { + id: group.id, + typeKeywords, + }, + authentication: this.context.session, + }); + } + /** * Return a list of groups the Entity is shared to. * @returns diff --git a/packages/common/src/core/behaviors/IWithEditorBehavior.ts b/packages/common/src/core/behaviors/IWithEditorBehavior.ts index 859f1d16ce9..853343ca37e 100644 --- a/packages/common/src/core/behaviors/IWithEditorBehavior.ts +++ b/packages/common/src/core/behaviors/IWithEditorBehavior.ts @@ -1,9 +1,4 @@ -import { - IConfigurationSchema, - IUiSchema, - UiSchemaElementOptions, - EditorType, -} from "../schemas"; +import { IConfigurationSchema, IUiSchema, EditorType } from "../schemas"; import { HubEntity, HubEntityEditor, IEntityEditorContext } from "../types"; export interface IEditorConfig { diff --git a/packages/common/src/core/behaviors/IWithFollowersBehavior.ts b/packages/common/src/core/behaviors/IWithFollowersBehavior.ts index 42d178c4fff..d8ad734ebfa 100644 --- a/packages/common/src/core/behaviors/IWithFollowersBehavior.ts +++ b/packages/common/src/core/behaviors/IWithFollowersBehavior.ts @@ -13,4 +13,8 @@ export interface IWithFollowersBehavior { * Set the access level of the followers group */ setFollowersGroupAccess(access: SettableAccessLevel): Promise; + /** + * Set whether or not the followers group is discussable + */ + setFollowersGroupIsDiscussable(isDiscussable: boolean): Promise; } diff --git a/packages/common/src/core/behaviors/IWithSharingBehavior.ts b/packages/common/src/core/behaviors/IWithSharingBehavior.ts index 212b2d22ccc..26ed349df7e 100644 --- a/packages/common/src/core/behaviors/IWithSharingBehavior.ts +++ b/packages/common/src/core/behaviors/IWithSharingBehavior.ts @@ -1,4 +1,4 @@ -import { IGetItemGroupsResponse, IGroup } from "@esri/arcgis-rest-portal"; +import { IGroup } from "@esri/arcgis-rest-portal"; import { AccessLevel } from "../types"; /** diff --git a/packages/common/src/core/schemas/internal/getCategoryItems.ts b/packages/common/src/core/schemas/internal/getCategoryItems.ts index a9f3bcc17f9..4080ea99a95 100644 --- a/packages/common/src/core/schemas/internal/getCategoryItems.ts +++ b/packages/common/src/core/schemas/internal/getCategoryItems.ts @@ -1,6 +1,5 @@ import { request } from "@esri/arcgis-rest-request"; import { IHubRequestOptions } from "../../../types"; -import { HubEntity } from "../../types/HubEntity"; import { IUiSchemaComboboxItem } from "../types"; /** diff --git a/packages/common/src/core/schemas/shared/HubItemEntitySchema.ts b/packages/common/src/core/schemas/shared/HubItemEntitySchema.ts index c607b4d310e..0a28212dd56 100644 --- a/packages/common/src/core/schemas/shared/HubItemEntitySchema.ts +++ b/packages/common/src/core/schemas/shared/HubItemEntitySchema.ts @@ -41,6 +41,7 @@ export const HubItemEntitySchema: IConfigurationSchema = { type: "boolean", default: true, }, + isDiscussable: ENTITY_IS_DISCUSSABLE_SCHEMA, }, }, view: { diff --git a/packages/common/src/core/traits/IWithMetrics.ts b/packages/common/src/core/traits/IWithMetrics.ts index 2046e27c0f3..cbb24ce0999 100644 --- a/packages/common/src/core/traits/IWithMetrics.ts +++ b/packages/common/src/core/traits/IWithMetrics.ts @@ -1,4 +1,3 @@ -import { IReference } from "../types"; import { IMetric } from "../types/Metrics"; /** diff --git a/packages/common/src/core/types/IAccessResponse.ts b/packages/common/src/core/types/IAccessResponse.ts index 8632a89020a..a96de7c4a38 100644 --- a/packages/common/src/core/types/IAccessResponse.ts +++ b/packages/common/src/core/types/IAccessResponse.ts @@ -1,4 +1,3 @@ -import { IPolicyCheck } from "../../permissions/types/IPolicyCheck"; import { PolicyResponse } from "../../permissions/types/PolicyResponse"; export interface IAccessResponse { diff --git a/packages/common/src/core/types/IHubInitiative.ts b/packages/common/src/core/types/IHubInitiative.ts index 58c5f78a611..888a3fc26ce 100644 --- a/packages/common/src/core/types/IHubInitiative.ts +++ b/packages/common/src/core/types/IHubInitiative.ts @@ -1,10 +1,4 @@ -import { - IWithSlug, - IWithLayout, - IWithPermissions, - IWithCatalog, -} from "../traits"; -import {} from "../traits/IWithCatalog"; +import { IWithSlug, IWithPermissions, IWithCatalog } from "../traits"; import { IWithMetrics } from "../traits/IWithMetrics"; import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity"; diff --git a/packages/common/src/core/types/IHubItemEntity.ts b/packages/common/src/core/types/IHubItemEntity.ts index 51c79652315..c6a1e0eed4d 100644 --- a/packages/common/src/core/types/IHubItemEntity.ts +++ b/packages/common/src/core/types/IHubItemEntity.ts @@ -150,5 +150,6 @@ export type IHubItemEntityEditor = Omit & { _followers?: { groupAccess?: AccessLevel; showFollowAction?: boolean; + isDiscussable?: boolean; }; }; diff --git a/packages/common/src/core/types/IHubProject.ts b/packages/common/src/core/types/IHubProject.ts index 7b4f2040e54..64f27d7a593 100644 --- a/packages/common/src/core/types/IHubProject.ts +++ b/packages/common/src/core/types/IHubProject.ts @@ -6,7 +6,6 @@ import { IWithCatalog, } from "../traits/index"; import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity"; -import { IExtent } from "@esri/arcgis-rest-feature-layer"; /** * Defines the properties of a Hub Project object diff --git a/packages/common/src/discussions/utils.ts b/packages/common/src/discussions/utils.ts index d194295084d..4ac6e864b67 100644 --- a/packages/common/src/discussions/utils.ts +++ b/packages/common/src/discussions/utils.ts @@ -5,18 +5,9 @@ import { AclCategory, AclSubCategory, IChannel, - IChannelAclPermission, SharingAccess, } from "./api/types"; -import { - IFilter, - IHubSearchOptions, - IHubSearchResponse, - IHubSearchResult, - IPredicate, - IQuery, - hubSearch, -} from "../search"; +import { IFilter, IPredicate, IQuery } from "../search"; /** * Utility to determine if a given IGroup, IItem, IHubContent, or IHubItemEntity diff --git a/packages/common/src/groups/addGroupMembers.ts b/packages/common/src/groups/addGroupMembers.ts index 13efe571a5d..a009de28d59 100644 --- a/packages/common/src/groups/addGroupMembers.ts +++ b/packages/common/src/groups/addGroupMembers.ts @@ -1,4 +1,3 @@ -import { IAuthenticationManager } from "@esri/arcgis-rest-request"; import { IUser } from "@esri/arcgis-rest-types"; import { failSafe } from "../utils"; import { autoAddUsers } from "./autoAddUsers"; diff --git a/packages/common/src/metrics/resolveMetric.ts b/packages/common/src/metrics/resolveMetric.ts index 3cef1ce403f..1d107ab9cc5 100644 --- a/packages/common/src/metrics/resolveMetric.ts +++ b/packages/common/src/metrics/resolveMetric.ts @@ -14,7 +14,6 @@ import { getProp } from "../objects/get-prop"; import { IPredicate, IQuery } from "../search/types/IHubCatalog"; import { combineQueries } from "../search/_internal/combineQueries"; import { IHubSearchOptions } from "../search/types/IHubSearchOptions"; -import { memoize } from "../utils/memoize"; import { portalSearchItemsAsItems } from "../search/_internal/portalSearchItems"; /** diff --git a/packages/common/src/pages/HubPages.ts b/packages/common/src/pages/HubPages.ts index 395293bbcfd..f86f7be0bb2 100644 --- a/packages/common/src/pages/HubPages.ts +++ b/packages/common/src/pages/HubPages.ts @@ -29,12 +29,7 @@ import { getPropertyMap } from "./_internal/getPropertyMap"; import { computeProps } from "./_internal/computeProps"; import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; import { IUserItemOptions, removeItem } from "@esri/arcgis-rest-portal"; -import { - DEFAULT_PAGE, - DEFAULT_PAGE_MODEL, - HUB_PAGE_ITEM_TYPE, - ENTERPRISE_PAGE_ITEM_TYPE, -} from "./defaults"; +import { DEFAULT_PAGE, DEFAULT_PAGE_MODEL } from "./defaults"; /** * @private diff --git a/packages/common/src/pages/_internal/computeProps.ts b/packages/common/src/pages/_internal/computeProps.ts index 738cc9b848e..1bed944ad53 100644 --- a/packages/common/src/pages/_internal/computeProps.ts +++ b/packages/common/src/pages/_internal/computeProps.ts @@ -7,7 +7,6 @@ import { processEntityFeatures } from "../../permissions/_internal/processEntity import { PageDefaultFeatures } from "./PageBusinessRules"; import { getItemHomeUrl } from "../../urls/get-item-home-url"; import { IHubPage } from "../../core/types/IHubPage"; -import { getHubRelativeUrl } from "../../content/_internal/internalContentUtils"; import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl"; /** diff --git a/packages/common/src/projects/HubProject.ts b/packages/common/src/projects/HubProject.ts index 0c292c31cb8..8c8bc4e8283 100644 --- a/packages/common/src/projects/HubProject.ts +++ b/packages/common/src/projects/HubProject.ts @@ -32,7 +32,7 @@ import { IHubCardViewModel, } from "../core/types/IHubCardViewModel"; import { projectToCardModel } from "./view"; -import { cloneObject, maybePush } from "../util"; +import { cloneObject } from "../util"; import { createProject, editorToProject, updateProject } from "./edit"; import { ProjectEditorType } from "./_internal/ProjectSchema"; import { enrichEntity } from "../core/enrichEntity"; diff --git a/packages/common/src/search/_internal/explainPredicate.ts b/packages/common/src/search/_internal/explainPredicate.ts index 61db8b7dd5b..96c989778ff 100644 --- a/packages/common/src/search/_internal/explainPredicate.ts +++ b/packages/common/src/search/_internal/explainPredicate.ts @@ -1,6 +1,5 @@ import { IRequestOptions } from "@esri/arcgis-rest-request"; import { GenericResult, IPredicateExplanation } from "../explainQueryResult"; -import { cloneObject } from "../../util"; import { IMatchOptions } from "../types"; import { PREDICATE_DATE_PROPS, diff --git a/packages/common/src/search/utils.ts b/packages/common/src/search/utils.ts index 25888f2555b..eca07e8826e 100644 --- a/packages/common/src/search/utils.ts +++ b/packages/common/src/search/utils.ts @@ -11,7 +11,6 @@ import { } from "@esri/arcgis-rest-portal"; import { isPageType } from "../content/_internal/internalContentUtils"; import { IHubSite } from "../core"; -import { getProp } from "../objects/get-prop"; import { ISearchResponse } from "../types"; import { cloneObject } from "../util"; import { IHubSearchResult } from "./types"; diff --git a/packages/common/src/sites/HubSite.ts b/packages/common/src/sites/HubSite.ts index 4f34891b9e8..55ba0617713 100644 --- a/packages/common/src/sites/HubSite.ts +++ b/packages/common/src/sites/HubSite.ts @@ -30,7 +30,6 @@ import { IContainsResponse, IDeepCatalogInfo, IHubCatalog } from "../search"; import { deepContains } from "../core/_internal/deepContains"; import { - applyVersion, createVersion, deleteVersion, getVersion, @@ -47,7 +46,13 @@ import { cloneObject } from "../util"; import { PropertyMapper } from "../core/_internal/PropertyMapper"; import { getPropertyMap } from "./_internal/getPropertyMap"; -import { IHubSiteEditor, IModel, setProp, SettableAccessLevel } from "../index"; +import { + IHubSiteEditor, + IModel, + isDiscussable, + setProp, + SettableAccessLevel, +} from "../index"; import { SiteEditorType } from "./_internal/SiteSchema"; /** @@ -424,6 +429,9 @@ export class HubSite editor ); + const followersGroup = await this.getFollowersGroup(); + setProp("_followers.isDiscussable", isDiscussable(followersGroup), editor); + editor._discussions = this.entity.features["hub:site:feature:discussions"]; return editor; @@ -458,6 +466,13 @@ export class HubSite delete editor._thumbnail; + // set whether or not the followers group is discussable + if (editor._followers?.isDiscussable !== undefined) { + await this.setFollowersGroupIsDiscussable( + editor._followers.isDiscussable + ); + } + // set the followers group access if (editor._followers?.groupAccess) { await this.setFollowersGroupAccess( diff --git a/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts b/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts index dbe26d17d5f..2499898c169 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts @@ -56,6 +56,23 @@ export const buildUiSchema = async ( }, }, }, + { + labelKey: `${i18nScope}.fields.followers.discussable.label`, + scope: "/properties/_followers/properties/isDiscussable", + type: "Control", + options: { + control: "hub-field-input-radio", + labels: [ + `{{${i18nScope}.fields.followers.discussable.enabled.label:translate}}`, + `{{${i18nScope}.fields.followers.discussable.disabled.label:translate}}`, + ], + descriptions: [ + `{{${i18nScope}.fields.followers.discussable.enabled.description:translate}}`, + `{{${i18nScope}.fields.followers.discussable.disabled.description:translate}}`, + ], + icons: ["speech-bubbles", "circle-disallowed"], + }, + }, ], }, ], diff --git a/packages/common/src/sites/_internal/applyCatalogStructureMigration.ts b/packages/common/src/sites/_internal/applyCatalogStructureMigration.ts index 4f954672f28..323bc779b23 100644 --- a/packages/common/src/sites/_internal/applyCatalogStructureMigration.ts +++ b/packages/common/src/sites/_internal/applyCatalogStructureMigration.ts @@ -1,4 +1,3 @@ -import { getProp } from "../../objects/get-prop"; import { IHubCatalog } from "../../search/types/IHubCatalog"; import { IModel } from "../../types"; diff --git a/packages/common/test/Hub.test.ts b/packages/common/test/Hub.test.ts index f3f63adbe7c..a110f6913c5 100644 --- a/packages/common/test/Hub.test.ts +++ b/packages/common/test/Hub.test.ts @@ -4,7 +4,7 @@ import { IUser } from "@esri/arcgis-rest-types"; // imported with a full path import { ArcGISContextManager } from "../src/ArcGISContextManager"; import { Hub } from "../src/Hub"; -import { IArcGISContextManagerOptions, IHubProject } from "../src"; +import { IArcGISContextManagerOptions } from "../src"; import { MOCK_AUTH } from "./mocks/mock-auth"; // import * as ProjectsModule from "../src/projects/HubProjects"; diff --git a/packages/common/test/content/_internal/internalContentUtils.test.ts b/packages/common/test/content/_internal/internalContentUtils.test.ts index b6fd93c51f2..ce548244ad0 100644 --- a/packages/common/test/content/_internal/internalContentUtils.test.ts +++ b/packages/common/test/content/_internal/internalContentUtils.test.ts @@ -1,6 +1,6 @@ import { IItem } from "@esri/arcgis-rest-types"; import { getContentEditUrl } from "../../../src/content/_internal/internalContentUtils"; -import { IHubRequestOptions, IModel } from "../../../src/types"; +import { IHubRequestOptions } from "../../../src/types"; import { cloneObject } from "../../../src/util"; import { MOCK_HUB_REQOPTS } from "../../mocks/mock-auth"; diff --git a/packages/common/test/content/index.test.ts b/packages/common/test/content/index.test.ts index c63bf3a24bd..ded8adedfca 100644 --- a/packages/common/test/content/index.test.ts +++ b/packages/common/test/content/index.test.ts @@ -4,7 +4,6 @@ import { cloneObject, enrichContentSearchResult, IHubRequestOptions, - IHubSearchResult, } from "../../src"; import * as FetchEnrichments from "../../src/items/_enrichments"; diff --git a/packages/common/test/core/EntityEditor.test.ts b/packages/common/test/core/EntityEditor.test.ts index 92254a0262f..c89eb8a1608 100644 --- a/packages/common/test/core/EntityEditor.test.ts +++ b/packages/common/test/core/EntityEditor.test.ts @@ -181,6 +181,8 @@ describe("EntityEditor:", () => { let getConfigSpy: jasmine.Spy; let toEditorSpy: jasmine.Spy; let fromEditorSpy: jasmine.Spy; + let getFollowersGroupSpy: jasmine.Spy; + beforeEach(() => { fromJsonSpy = spyOn(HubSite, "fromJson").and.callThrough(); getConfigSpy = spyOn(HubSite.prototype, "getEditorConfig").and.callFake( @@ -194,6 +196,15 @@ describe("EntityEditor:", () => { return Promise.resolve({} as any); } ); + getFollowersGroupSpy = spyOn( + HubSite.prototype, + "getFollowersGroup" + ).and.callFake(() => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + }); }); it("verify EntityEditor with Site", async () => { @@ -210,6 +221,7 @@ describe("EntityEditor:", () => { expect(chk.id).toBe("00c"); await editor.save(chk); expect(fromEditorSpy).toHaveBeenCalledWith(chk); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); }); diff --git a/packages/common/test/core/HubItemEntity.test.ts b/packages/common/test/core/HubItemEntity.test.ts index edf664acf90..ce8997b9d22 100644 --- a/packages/common/test/core/HubItemEntity.test.ts +++ b/packages/common/test/core/HubItemEntity.test.ts @@ -8,6 +8,7 @@ import * as deleteItemThumbnailModule from "../../src/items/deleteItemThumbnail" import * as ItemsModule from "../../src/items"; import { IEntityPermissionPolicy } from "../../src/permissions"; import { CANNOT_DISCUSS, IHubItemEntity } from "../../src"; +import * as DISCUSSIONS from "../../src/discussions"; // To test the abstract class, we need to create a // concrete class that extends it @@ -319,6 +320,37 @@ describe("HubItemEntity Class: ", () => { authentication: authdCtxMgr.context.session, }); }); + it("sets whether or not the followers group is discussable", async () => { + const getFollowersGroupSpy = spyOn( + harness, + "getFollowersGroup" + ).and.callFake(() => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + }); + const setDiscussableKeywordSpy = spyOn( + DISCUSSIONS, + "setDiscussableKeyword" + ).and.callThrough(); + const updateGroupSpy = spyOn(PortalModule, "updateGroup").and.callFake( + () => { + return Promise.resolve(); + } + ); + await harness.setFollowersGroupIsDiscussable(false); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); + expect(setDiscussableKeywordSpy).toHaveBeenCalledWith([], false); + expect(updateGroupSpy).toHaveBeenCalledTimes(1); + expect(updateGroupSpy).toHaveBeenCalledWith({ + group: { + id: "followers00c", + typeKeywords: [CANNOT_DISCUSS], + }, + authentication: authdCtxMgr.context.session, + }); + }); }); describe("thumbnail behavior:", () => { diff --git a/packages/common/test/core/schemas/internal/getLocationOptions.test.ts b/packages/common/test/core/schemas/internal/getLocationOptions.test.ts index 0e136675a23..85941f36bbc 100644 --- a/packages/common/test/core/schemas/internal/getLocationOptions.test.ts +++ b/packages/common/test/core/schemas/internal/getLocationOptions.test.ts @@ -1,5 +1,4 @@ -import { IHubContent, IHubProject, IHubRequestOptions } from "../../../../src"; -import { ConfigurableEntity } from "../../../../src/core/schemas/internal/ConfigurableEntity"; +import { IHubProject, IHubRequestOptions } from "../../../../src"; import { getLocationOptions } from "../../../../src/core/schemas/internal/getLocationOptions"; import * as ExtentModule from "../../../../src/extent"; diff --git a/packages/common/test/core/schemas/internal/getTagItems.test.ts b/packages/common/test/core/schemas/internal/getTagItems.test.ts index 20322f2f45f..f78c1cbd4c1 100644 --- a/packages/common/test/core/schemas/internal/getTagItems.test.ts +++ b/packages/common/test/core/schemas/internal/getTagItems.test.ts @@ -1,4 +1,4 @@ -import { IHubProject, IHubRequestOptions, getProp } from "../../../../src"; +import { IHubProject, IHubRequestOptions } from "../../../../src"; import { getTagItems } from "../../../../src/core/schemas/internal/getTagItems"; import * as SearchModule from "@esri/arcgis-rest-portal"; diff --git a/packages/common/test/groups/add-users-workflow/output-processors/_process-invite.test.ts b/packages/common/test/groups/add-users-workflow/output-processors/_process-invite.test.ts index 7f5b63b686b..5b814baae55 100644 --- a/packages/common/test/groups/add-users-workflow/output-processors/_process-invite.test.ts +++ b/packages/common/test/groups/add-users-workflow/output-processors/_process-invite.test.ts @@ -1,7 +1,4 @@ -import { - IAddGroupUsersResult, - IInviteGroupUsersResult, -} from "@esri/arcgis-rest-portal"; +import { IInviteGroupUsersResult } from "@esri/arcgis-rest-portal"; import { IAddMemberContext, _processInvite } from "../../../../src"; import * as inviteModule from "../../../../src/groups/inviteUsers"; diff --git a/packages/common/test/initiatives/HubInitiative.test.ts b/packages/common/test/initiatives/HubInitiative.test.ts index 128175f2a3d..35c34fa3fc5 100644 --- a/packages/common/test/initiatives/HubInitiative.test.ts +++ b/packages/common/test/initiatives/HubInitiative.test.ts @@ -1,11 +1,5 @@ import * as PortalModule from "@esri/arcgis-rest-portal"; -import { - IHubInitiative, - IMetricFeature, - IResolvedMetric, - UiSchemaElementOptions, - getProp, -} from "../../src"; +import { IHubInitiative, IResolvedMetric, getProp } from "../../src"; import { Catalog } from "../../src/search"; import { ArcGISContextManager } from "../../src/ArcGISContextManager"; import { HubInitiative } from "../../src/initiatives/HubInitiative"; diff --git a/packages/common/test/metrics/getEntityMetrics.test.ts b/packages/common/test/metrics/getEntityMetrics.test.ts index 3ef93ccb006..bb7854dccf2 100644 --- a/packages/common/test/metrics/getEntityMetrics.test.ts +++ b/packages/common/test/metrics/getEntityMetrics.test.ts @@ -1,5 +1,4 @@ import { - IHubInitiative, IHubProject, IItemQueryMetricSource, IQuery, diff --git a/packages/common/test/permissions/_internal/checkAssertions.test.ts b/packages/common/test/permissions/_internal/checkAssertions.test.ts index 9b564276ca3..c102f9aa98f 100644 --- a/packages/common/test/permissions/_internal/checkAssertions.test.ts +++ b/packages/common/test/permissions/_internal/checkAssertions.test.ts @@ -1,9 +1,4 @@ -import { - IArcGISContext, - IPermissionPolicy, - IPolicyAssertion, - IPolicyCheck, -} from "../../../src"; +import { IArcGISContext, IPermissionPolicy, IPolicyCheck } from "../../../src"; import * as AssertionModule from "../../../src/permissions/_internal/checkAssertion"; import { checkAssertions } from "../../../src/permissions/_internal/checkAssertions"; diff --git a/packages/common/test/permissions/_internal/checkPrivileges.test.ts b/packages/common/test/permissions/_internal/checkPrivileges.test.ts index a9009464396..d40e49d9cb8 100644 --- a/packages/common/test/permissions/_internal/checkPrivileges.test.ts +++ b/packages/common/test/permissions/_internal/checkPrivileges.test.ts @@ -1,4 +1,4 @@ -import { HubEntity, IArcGISContext } from "../../../src"; +import { IArcGISContext } from "../../../src"; import { IPermissionPolicy } from "../../../src/permissions/types"; import { checkPrivileges } from "../../../src/permissions/_internal/checkPrivileges"; diff --git a/packages/common/test/projects/HubProject.test.ts b/packages/common/test/projects/HubProject.test.ts index 45e215a412e..8f782c2adba 100644 --- a/packages/common/test/projects/HubProject.test.ts +++ b/packages/common/test/projects/HubProject.test.ts @@ -1,11 +1,5 @@ import * as PortalModule from "@esri/arcgis-rest-portal"; -import { - IHubProject, - IResolvedMetric, - cloneObject, - getProp, - mergeObjects, -} from "../../src"; +import { IHubProject, IResolvedMetric, getProp, mergeObjects } from "../../src"; import { Catalog } from "../../src/search"; import { ArcGISContextManager } from "../../src/ArcGISContextManager"; import { HubProject } from "../../src/projects/HubProject"; diff --git a/packages/common/test/search/Catalog.test.ts b/packages/common/test/search/Catalog.test.ts index 0433583da30..750bf0ae069 100644 --- a/packages/common/test/search/Catalog.test.ts +++ b/packages/common/test/search/Catalog.test.ts @@ -2,7 +2,6 @@ import { IPortal, IUser } from "@esri/arcgis-rest-portal"; import { cloneObject, getProp, IArcGISContext } from "../../src"; import { ArcGISContextManager } from "../../src/ArcGISContextManager"; import { - EntityType, ICatalogScope, IFilter, IHubCatalog, diff --git a/packages/common/test/search/_internal/hubSearchItems.test.ts b/packages/common/test/search/_internal/hubSearchItems.test.ts index 6159265a7ad..f053607e91c 100644 --- a/packages/common/test/search/_internal/hubSearchItems.test.ts +++ b/packages/common/test/search/_internal/hubSearchItems.test.ts @@ -29,7 +29,6 @@ import { formatOgcItemsResponse } from "../../../src/search/_internal/hubSearchI import { formatOgcAggregationsResponse } from "../../../src/search/_internal/hubSearchItemsHelpers/formatOgcAggregationsResponse"; import * as searchOgcItemsModule from "../../../src/search/_internal/hubSearchItemsHelpers/searchOgcItems"; import * as portalSearchItemsModule from "../../../src/search/_internal/portalSearchItems"; -import { IItem } from "@esri/arcgis-rest-types"; import * as fetchMock from "fetch-mock"; import { ogcItemsResponse, diff --git a/packages/common/test/sites/HubSite.test.ts b/packages/common/test/sites/HubSite.test.ts index 7c3f3fcbbba..0db8cfc30ec 100644 --- a/packages/common/test/sites/HubSite.test.ts +++ b/packages/common/test/sites/HubSite.test.ts @@ -576,25 +576,39 @@ describe("HubSite Class:", () => { }); describe("toEditor:", () => { + let chk: HubSite; + let getFollowersGroupSpy: any; + + beforeEach(async () => { + chk = HubSite.fromJson( + { + id: "bc3", + name: "Test Entity", + thumbnailUrl: "https://myserver.com/thumbnail.png", + }, + authdCtxMgr.context + ); + getFollowersGroupSpy = spyOn(chk, "getFollowersGroup").and.callFake( + () => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + } + ); + }); + it("optionally enriches the entity", async () => { const enrichEntitySpy = spyOn( EnrichEntityModule, "enrichEntity" ).and.returnValue(Promise.resolve({})); - const chk = HubSite.fromJson({ id: "bc3" }, authdCtxMgr.context); await chk.toEditor({}, ["someEnrichment AS _someEnrichment"]); expect(enrichEntitySpy).toHaveBeenCalledTimes(1); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); it("converts entity to correct structure", async () => { - const chk = HubSite.fromJson( - { - id: "bc3", - name: "Test Entity", - thumbnailUrl: "https://myserver.com/thumbnail.png", - }, - authdCtxMgr.context - ); const result = await chk.toEditor(); // NOTE: If additional transforms are added in the class they should have tests here expect(result.id).toEqual("bc3"); @@ -602,12 +616,16 @@ describe("HubSite Class:", () => { expect(result.thumbnailUrl).toEqual( "https://myserver.com/thumbnail.png" ); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); }); describe("fromEditor:", () => { - it("handles simple prop change", async () => { - const chk = HubSite.fromJson( + let chk: HubSite; + let getFollowersGroupSpy: any; + + beforeEach(async () => { + chk = HubSite.fromJson( { id: "bc3", name: "Test Entity", @@ -615,32 +633,37 @@ describe("HubSite Class:", () => { }, authdCtxMgr.context ); + getFollowersGroupSpy = spyOn(chk, "getFollowersGroup").and.callFake( + () => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + } + ); + }); + it("handles simple prop change", async () => { // spy on the instance .save method and retrn void const saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); // make changes to the editor const editor = await chk.toEditor(); editor.name = "new name"; + (editor._followers as any).isDiscussable = undefined; // call fromEditor const result = await chk.fromEditor(editor); // expect the save method to have been called expect(saveSpy).toHaveBeenCalledTimes(1); // expect the name to have been updated expect(result.name).toEqual("new name"); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); it("handles thumbnail change", async () => { - const chk = HubSite.fromJson( - { - id: "bc3", - name: "Test Entity", - thumbnailUrl: "https://myserver.com/thumbnail.png", - }, - authdCtxMgr.context - ); // spy on the instance .save method and retrn void const saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); // make changes to the editor const editor = await chk.toEditor(); editor.name = "new name"; + (editor._followers as any).isDiscussable = undefined; editor._thumbnail = { blob: "fake blob", filename: "thumbnail.png", @@ -652,22 +675,16 @@ describe("HubSite Class:", () => { // since thumbnailCache is protected we can't really test that it's set // other than via code-coverage expect(getProp(result, "_thumbnail")).not.toBeDefined(); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); it("handles thumbnail clear", async () => { - const chk = HubSite.fromJson( - { - id: "bc3", - name: "Test Entity", - thumbnailUrl: "https://myserver.com/thumbnail.png", - }, - authdCtxMgr.context - ); // spy on the instance .save method and retrn void const saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); // make changes to the editor const editor = await chk.toEditor(); editor.name = "new name"; + (editor._followers as any).isDiscussable = undefined; editor._thumbnail = {}; // call fromEditor const result = await chk.fromEditor(editor); @@ -676,46 +693,72 @@ describe("HubSite Class:", () => { // since thumbnailCache is protected we can't really test that it's set // other than via code-coverage expect(getProp(result, "_thumbnail")).not.toBeDefined(); + expect(getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); describe("followers", () => { - let chk: HubSite; + let _chk: HubSite; let saveSpy: any; let setFollowersGroupAccessSpy: any; + let setFollowersGroupIsDiscussableSpy: any; + let _getFollowersGroupSpy: any; let editor: IHubSiteEditor; beforeEach(async () => { - chk = HubSite.fromJson( + _chk = HubSite.fromJson( { id: "bc3", name: "Test Entity", }, authdCtxMgr.context ); - saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); + saveSpy = spyOn(_chk, "save").and.returnValue(Promise.resolve()); setFollowersGroupAccessSpy = spyOn( - chk, + _chk, "setFollowersGroupAccess" ).and.returnValue(Promise.resolve()); - editor = await chk.toEditor(); + setFollowersGroupIsDiscussableSpy = spyOn( + _chk, + "setFollowersGroupIsDiscussable" + ).and.returnValue(Promise.resolve()); + _getFollowersGroupSpy = spyOn(_chk, "getFollowersGroup").and.callFake( + () => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + } + ); + editor = await _chk.toEditor(); }); it("does nothing if followers information is not present on the editor values", async () => { editor._followers = undefined; - await chk.fromEditor(editor); + await _chk.fromEditor(editor); expect(saveSpy).toHaveBeenCalledTimes(1); expect(setFollowersGroupAccessSpy).not.toHaveBeenCalled(); + expect(_getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); it("handles setting the followers group access", async () => { editor._followers = { groupAccess: "public" }; - await chk.fromEditor(editor); + await _chk.fromEditor(editor); expect(saveSpy).toHaveBeenCalledTimes(1); expect(setFollowersGroupAccessSpy).toHaveBeenCalledTimes(1); expect(setFollowersGroupAccessSpy).toHaveBeenCalledWith("public"); + expect(_getFollowersGroupSpy).toHaveBeenCalledTimes(1); + }); + it("handles setting followers group isDiscussable", async () => { + editor._followers = { isDiscussable: true }; + await _chk.fromEditor(editor); + + expect(saveSpy).toHaveBeenCalledTimes(1); + expect(setFollowersGroupAccessSpy).not.toHaveBeenCalled(); + expect(_getFollowersGroupSpy).toHaveBeenCalledTimes(1); + expect(setFollowersGroupIsDiscussableSpy).toHaveBeenCalledTimes(1); }); }); it("handles extent from location", async () => { - const chk = HubSite.fromJson( + const _chk = HubSite.fromJson( { id: "bc3", name: "Test Entity", @@ -728,10 +771,20 @@ describe("HubSite Class:", () => { authdCtxMgr.context ); // spy on the instance .save method and retrn void - const saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); + const saveSpy = spyOn(_chk, "save").and.returnValue(Promise.resolve()); + const _getFollowersGroupSpy = spyOn( + _chk, + "getFollowersGroup" + ).and.callFake(() => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + }); // make changes to the editor - const editor = await chk.toEditor(); + const editor = await _chk.toEditor(); editor.name = "new name"; + (editor._followers as any).isDiscussable = undefined; editor.location = { extent: [ [-2, -2], @@ -740,33 +793,45 @@ describe("HubSite Class:", () => { type: "custom", }; // call fromEditor - const result = await chk.fromEditor(editor); + const result = await _chk.fromEditor(editor); // expect the save method to have been called expect(saveSpy).toHaveBeenCalledTimes(1); expect(result.extent).toEqual([ [-2, -2], [2, 2], ]); + expect(_getFollowersGroupSpy).toHaveBeenCalledTimes(1); }); it("throws if creating", async () => { - const chk = HubSite.fromJson( + const _chk = HubSite.fromJson( { name: "Test Entity", thumbnailUrl: "https://myserver.com/thumbnail.png", }, authdCtxMgr.context ); + const _getFollowersGroupSpy = spyOn( + _chk, + "getFollowersGroup" + ).and.callFake(() => { + return Promise.resolve({ + id: "followers00c", + typeKeywords: [], + }); + }); // spy on the instance .save method and retrn void - const saveSpy = spyOn(chk, "save").and.returnValue(Promise.resolve()); + const saveSpy = spyOn(_chk, "save").and.returnValue(Promise.resolve()); // make changes to the editor - const editor = await chk.toEditor(); + const editor = await _chk.toEditor(); editor.name = "new name"; + (editor._followers as any).isDiscussable = undefined; // call fromEditor try { - await chk.fromEditor(editor); + await _chk.fromEditor(editor); } catch (ex) { expect(ex.message).toContain("Cannot create"); expect(saveSpy).toHaveBeenCalledTimes(0); + expect(_getFollowersGroupSpy).toHaveBeenCalledTimes(1); } }); }); diff --git a/packages/common/test/sites/_internal/SiteUiSchemaFollowers.test.ts b/packages/common/test/sites/_internal/SiteUiSchemaFollowers.test.ts index f5e4d2f407d..96682f13787 100644 --- a/packages/common/test/sites/_internal/SiteUiSchemaFollowers.test.ts +++ b/packages/common/test/sites/_internal/SiteUiSchemaFollowers.test.ts @@ -64,6 +64,23 @@ describe("buildUiSchema: site followers", () => { }, }, }, + { + labelKey: `some.scope.fields.followers.discussable.label`, + scope: "/properties/_followers/properties/isDiscussable", + type: "Control", + options: { + control: "hub-field-input-radio", + labels: [ + `{{some.scope.fields.followers.discussable.enabled.label:translate}}`, + `{{some.scope.fields.followers.discussable.disabled.label:translate}}`, + ], + descriptions: [ + `{{some.scope.fields.followers.discussable.enabled.description:translate}}`, + `{{some.scope.fields.followers.discussable.disabled.description:translate}}`, + ], + icons: ["speech-bubbles", "circle-disallowed"], + }, + }, ], }, ], diff --git a/packages/common/test/users/view.test.ts b/packages/common/test/users/view.test.ts index cdc72a0d81c..d51189bd87b 100644 --- a/packages/common/test/users/view.test.ts +++ b/packages/common/test/users/view.test.ts @@ -1,5 +1,5 @@ import { cloneObject } from "../../src/util"; -import { CONTEXT, USER_HUB_SEARCH_RESULT } from "./fixtures"; +import { USER_HUB_SEARCH_RESULT } from "./fixtures"; import * as internalContentUtils from "../../src/content/_internal/internalContentUtils"; import * as titleUrlModule from "../../src/urls/getCardModelUrl"; import { userResultToCardModel } from "../../src/users/view"; diff --git a/packages/discussions/src/utils/channel-permission.ts b/packages/discussions/src/utils/channel-permission.ts index 4194781e631..480bbe4fd68 100644 --- a/packages/discussions/src/utils/channel-permission.ts +++ b/packages/discussions/src/utils/channel-permission.ts @@ -1,4 +1,4 @@ -import { IGroup, IUser } from "@esri/arcgis-rest-types"; +import { IGroup } from "@esri/arcgis-rest-types"; import { AclCategory, AclSubCategory, diff --git a/packages/discussions/test/utils/channels/index.test.ts b/packages/discussions/test/utils/channels/index.test.ts index 0f9f9ebdb52..a7cda197711 100644 --- a/packages/discussions/test/utils/channels/index.test.ts +++ b/packages/discussions/test/utils/channels/index.test.ts @@ -1,10 +1,7 @@ import { IUser } from "@esri/arcgis-rest-auth"; import { IGroup } from "@esri/arcgis-rest-types"; import { SharingAccess, IChannel } from "../../../src/types"; -import { - canModifyChannel, - canReadFromChannel, -} from "../../../src/utils/channels"; +import { canReadFromChannel } from "../../../src/utils/channels"; const orgId1 = "3ef"; const orgId2 = "4dc"; diff --git a/packages/discussions/test/utils/posts/index.test.ts b/packages/discussions/test/utils/posts/index.test.ts index 9bd4262fdd2..ea1354c3dcb 100644 --- a/packages/discussions/test/utils/posts/index.test.ts +++ b/packages/discussions/test/utils/posts/index.test.ts @@ -1,4 +1,4 @@ -import { IGroup, IUser } from "@esri/arcgis-rest-types"; +import { IGroup } from "@esri/arcgis-rest-types"; import { IDiscussionParams } from "../../../src/types"; import { isDiscussable, diff --git a/packages/downloads/src/portal/portal-request-download-metadata.ts b/packages/downloads/src/portal/portal-request-download-metadata.ts index f31b0c0f918..d622aee9213 100644 --- a/packages/downloads/src/portal/portal-request-download-metadata.ts +++ b/packages/downloads/src/portal/portal-request-download-metadata.ts @@ -12,7 +12,7 @@ import { DownloadTarget } from "../download-target"; import { DownloadStatus } from "../download-status"; import { isDownloadEnabled } from "./utils"; import { isRecentlyUpdated } from "./utils"; -import { buildExistingExportsPortalQuery, includes } from "@esri/hub-common"; +import { buildExistingExportsPortalQuery } from "@esri/hub-common"; import { parseDatasetId } from "@esri/hub-common"; import { IDownloadMetadataResults } from ".."; import { ArcGISAuthError } from "@esri/arcgis-rest-request"; diff --git a/packages/search/test/util/merge-sort/merge.test.ts b/packages/search/test/util/merge-sort/merge.test.ts index 55fcb6ea633..65ff26a5382 100644 --- a/packages/search/test/util/merge-sort/merge.test.ts +++ b/packages/search/test/util/merge-sort/merge.test.ts @@ -1,4 +1,4 @@ -import { lorem, random, date, datatype } from "faker"; +import { lorem, date, datatype } from "faker"; import { BinaryHeap, kMerge } from "../../../src/util/merge-sort/merge"; describe("Binary Heap", () => { @@ -154,7 +154,7 @@ describe("Min Binary Heap", () => { seventh, eighth, ninth, - tenth + tenth, ]; const comparator = (one: string, two: string): number => { @@ -179,7 +179,7 @@ describe("Min Binary Heap", () => { seventh, fourth, eighth, - tenth + tenth, ]); // Assert minHeap insertions are correct @@ -196,7 +196,7 @@ describe("Min Binary Heap", () => { fourth, eighth, tenth, - third + third, ]); minHeap.insert(fifth); @@ -213,7 +213,7 @@ describe("Min Binary Heap", () => { eighth, tenth, third, - third + third, ]); // Assert that data is removed in correct order @@ -262,14 +262,16 @@ describe("Min Binary Heap", () => { ) => one.data.localeCompare(two.data); const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: lorem.word(), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: string; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: string[] = [...input].sort(sortFunc).map(node => node.data); + const expected: string[] = [...input] + .sort(sortFunc) + .map((node) => node.data); // Test const cmptr = (one: string, two: string) => one.localeCompare(two); @@ -292,14 +294,16 @@ describe("Min Binary Heap", () => { ) => one.data - two.data; const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: datatype.number(1000), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: number; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: number[] = [...input].sort(sortFunc).map(node => node.data); + const expected: number[] = [...input] + .sort(sortFunc) + .map((node) => node.data); // Test const cmptr = (one: number, two: number) => one - two; @@ -322,14 +326,14 @@ describe("Min Binary Heap", () => { ) => one.data.getTime() - two.data.getTime(); const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: date.past(), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: Date; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: Date[] = [...input].sort(sortFunc).map(node => node.data); + const expected: Date[] = [...input].sort(sortFunc).map((node) => node.data); // Test const cmptr = (one: Date, two: Date) => one.getTime() - two.getTime(); @@ -435,7 +439,7 @@ describe("Max Binary Heap", () => { seventh, eighth, ninth, - tenth + tenth, ]; const comparator = (one: string, two: string): number => { @@ -464,7 +468,7 @@ describe("Max Binary Heap", () => { first, second, ninth, - fifth + fifth, ]); // Assert maxHeap insertions are correct @@ -481,7 +485,7 @@ describe("Max Binary Heap", () => { second, ninth, fifth, - fourth + fourth, ]); maxHeap.insert(fifth); @@ -498,7 +502,7 @@ describe("Max Binary Heap", () => { ninth, fifth, fourth, - fifth + fifth, ]); // Assert that data is removed in correct order @@ -547,14 +551,16 @@ describe("Max Binary Heap", () => { ) => two.data.localeCompare(one.data); const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: lorem.word(), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: string; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: string[] = [...input].sort(sortFunc).map(node => node.data); + const expected: string[] = [...input] + .sort(sortFunc) + .map((node) => node.data); // Test const cmptr = (one: string, two: string) => one.localeCompare(two); @@ -581,14 +587,16 @@ describe("Max Binary Heap", () => { ) => two.data - one.data; const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: datatype.number(1000), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: number; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: number[] = [...input].sort(sortFunc).map(node => node.data); + const expected: number[] = [...input] + .sort(sortFunc) + .map((node) => node.data); // Test const cmptr = (one: number, two: number) => one - two; @@ -615,14 +623,14 @@ describe("Max Binary Heap", () => { ) => two.data.getTime() - one.data.getTime(); const randomizer = (_v: unknown, _i: number, _a: unknown[]) => ({ data: date.past(), - label: lorem.word() + label: lorem.word(), }); const input: Array<{ data: Date; label: string }> = Array.apply( null, Array(30) ).map(randomizer); - const expected: Date[] = [...input].sort(sortFunc).map(node => node.data); + const expected: Date[] = [...input].sort(sortFunc).map((node) => node.data); // Test const cmptr = (one: Date, two: Date) => one.getTime() - two.getTime(); @@ -700,7 +708,7 @@ describe("kMerge", () => { arrTwo[1], arrOne[2], arrTwo[2], - arrOne[3] + arrOne[3], ]; // Test @@ -733,7 +741,7 @@ describe("kMerge", () => { arrTwo[1], arrOne[2], arrTwo[2], - arrOne[3] + arrOne[3], ]; // Test @@ -762,7 +770,7 @@ describe("kMerge", () => { arrOne[0], arrTwo[0], arrThree[1], - arrOne[1] + arrOne[1], ]; // Test diff --git a/packages/sites/src/drafts/apply-draft.ts b/packages/sites/src/drafts/apply-draft.ts index 15ab7c26362..7e7b74d5bb7 100644 --- a/packages/sites/src/drafts/apply-draft.ts +++ b/packages/sites/src/drafts/apply-draft.ts @@ -1,4 +1,4 @@ -import { IModel, mergeObjects, cloneObject, getProp } from "@esri/hub-common"; +import { IModel, mergeObjects, cloneObject } from "@esri/hub-common"; import { _includeListFromItemType } from "./_include-list-from-item-type"; import { IDraft } from "@esri/hub-common"; diff --git a/packages/sites/src/link-site-and-page.ts b/packages/sites/src/link-site-and-page.ts index ea2289e04d0..44fdadc01a0 100644 --- a/packages/sites/src/link-site-and-page.ts +++ b/packages/sites/src/link-site-and-page.ts @@ -10,9 +10,9 @@ import { maybePush, failSafe, shareItemToGroups, - deepSet + deepSet, } from "@esri/hub-common"; -import { updateItem, IItem } from "@esri/arcgis-rest-portal"; +import { updateItem } from "@esri/arcgis-rest-portal"; import { UserSession } from "@esri/arcgis-rest-auth"; import { isSite } from "./is-site"; @@ -42,9 +42,9 @@ export function linkSiteAndPage(linkRequestOptions: { // get the models from the options... return Promise.all([ getModelFromOptions("page", linkRequestOptions), - getModelFromOptions("site", linkRequestOptions) + getModelFromOptions("site", linkRequestOptions), ]) - .then(models => { + .then((models) => { // Should we handle either item being inaccessible? [pageModel, siteModel] = models; @@ -60,7 +60,7 @@ export function linkSiteAndPage(linkRequestOptions: { // Link the Site into the Page... const siteEntry = { id: siteModel.item.id, - title: siteModel.item.title + title: siteModel.item.title, }; if (!getProp(pageModel, "data.values.sites")) { @@ -85,7 +85,7 @@ export function linkSiteAndPage(linkRequestOptions: { // Link the Page into the Site const pageEntry: any = { id: pageModel.item.id, - title: pageModel.item.title + title: pageModel.item.title, }; if (!getProp(siteModel, "data.values.pages")) { deepSet(siteModel, "data.values.pages", []); @@ -131,9 +131,7 @@ export function linkSiteAndPage(linkRequestOptions: { let msg = `The Page item (${pageModel.item.id}) is inaccessible.`; if (siteModel.isMissing) { if (pageModel.isMissing) { - msg = `Both the Page item (${ - pageModel.item.id - }) and the Site item (${siteModel.item.id}) are inaccssible`; + msg = `Both the Page item (${pageModel.item.id}) and the Site item (${siteModel.item.id}) are inaccssible`; } else { msg = `The Site item (${siteModel.item.id}) is inaccessible.`; } @@ -146,14 +144,12 @@ export function linkSiteAndPage(linkRequestOptions: { // what is in what index, so we really can't use the return values... return { pageModel, - siteModel + siteModel, }; }) .catch((err: Error) => { throw Error( - `Error occured linking site ${siteModel.item.id} with ${ - pageModel.item.id - }: ${err}` + `Error occured linking site ${siteModel.item.id} with ${pageModel.item.id}: ${err}` ); }); } diff --git a/packages/sites/src/pages/remove-page.ts b/packages/sites/src/pages/remove-page.ts index a19eeb3b327..5f979116a33 100644 --- a/packages/sites/src/pages/remove-page.ts +++ b/packages/sites/src/pages/remove-page.ts @@ -7,7 +7,7 @@ import { unprotectModel, } from "@esri/hub-common"; import { unlinkSiteAndPage } from "../unlink-site-and-page"; -import { IUserItemOptions, removeItem } from "@esri/arcgis-rest-portal"; +import { removeItem } from "@esri/arcgis-rest-portal"; import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; /** diff --git a/packages/sites/src/update-site-application-uris.ts b/packages/sites/src/update-site-application-uris.ts index 3174987dc71..1de13e57329 100644 --- a/packages/sites/src/update-site-application-uris.ts +++ b/packages/sites/src/update-site-application-uris.ts @@ -10,7 +10,6 @@ import { removeDomain, addDomain, } from "@esri/hub-common"; -import { updateAppRedirectUris } from "./update-app-redirect-uris"; /** * Update the list of valid uris associated with the Site item * @param {Object} site Site Model diff --git a/packages/sites/test/domains/index.test.ts b/packages/sites/test/domains/index.test.ts index dbd19de53ee..f6827be49a9 100644 --- a/packages/sites/test/domains/index.test.ts +++ b/packages/sites/test/domains/index.test.ts @@ -12,7 +12,6 @@ import { lookupDomain, removeDomain, updateDomain, - IDomainEntry, } from "../../src"; describe("proxy domain exports", () => { diff --git a/packages/sites/test/drafts/_get-most-recent-draft-name.test.ts b/packages/sites/test/drafts/_get-most-recent-draft-name.test.ts index 0df4e42fd51..021b1991d6d 100644 --- a/packages/sites/test/drafts/_get-most-recent-draft-name.test.ts +++ b/packages/sites/test/drafts/_get-most-recent-draft-name.test.ts @@ -1,7 +1,6 @@ import { _getMostRecentDraftName } from "../../src/drafts"; import * as getDraftNameModule from "../../src/drafts/_get-draft-resource-names"; -import * as portalModule from "@esri/arcgis-rest-portal"; -import { IHubRequestOptions, IModel } from "@esri/hub-common"; +import { IHubRequestOptions } from "@esri/hub-common"; describe("_getMostRecentDraftName", () => { const draftResourceNames = [ @@ -9,15 +8,15 @@ describe("_getMostRecentDraftName", () => { "draft-1599773122.json", "draft-968621122.json", "draft-968621122.json", - "draft-1599773123.json" + "draft-1599773123.json", ]; - const ro = ({ + const ro = { portal: "my-portal", - authentication: "my-auth" - } as unknown) as IHubRequestOptions; + authentication: "my-auth", + } as unknown as IHubRequestOptions; let getDraftSpy: jasmine.Spy; - beforeEach(function() { + beforeEach(function () { getDraftSpy = spyOn( getDraftNameModule, "_getDraftResourceNames" diff --git a/packages/sites/test/get-portal-site-hostname.test.ts b/packages/sites/test/get-portal-site-hostname.test.ts index 58ce9c454db..f0a9e382acd 100644 --- a/packages/sites/test/get-portal-site-hostname.test.ts +++ b/packages/sites/test/get-portal-site-hostname.test.ts @@ -1,63 +1,62 @@ import { getPortalSiteHostname } from "../src"; -import * as commonModule from "@esri/hub-common"; import { IPortal } from "@esri/arcgis-rest-portal"; describe("getPortalSiteHostname", () => { it("gets the site hostname + fragment", async () => { const subDomain = "sub-domain"; - let portal = ({ + let portal = { allSSL: false, httpPort: 80, customBaseUrl: "instance", - portalHostname: "foobar.com/instance" - } as unknown) as IPortal; + portalHostname: "foobar.com/instance", + } as unknown as IPortal; expect(getPortalSiteHostname(subDomain, portal)).toBe( "foobar.com/instance/apps/sites/#/sub-domain" ); - portal = ({ + portal = { allSSL: false, httpPort: 80, customBaseUrl: "other", - portalHostname: "foobar.com" - } as unknown) as IPortal; + portalHostname: "foobar.com", + } as unknown as IPortal; expect(getPortalSiteHostname(subDomain, portal)).toBe( "foobar.com/apps/sites/#/sub-domain" ); - portal = ({ + portal = { allSSL: false, httpPort: 23, customBaseUrl: "instance", - portalHostname: "foobar.com/instance" - } as unknown) as IPortal; + portalHostname: "foobar.com/instance", + } as unknown as IPortal; expect(getPortalSiteHostname(subDomain, portal)).toBe( "foobar.com:23/instance/apps/sites/#/sub-domain", "attaches custom http port" ); - portal = ({ + portal = { allSSL: true, httpsPort: 443, customBaseUrl: "other", - portalHostname: "foobar.com/instance" - } as unknown) as IPortal; + portalHostname: "foobar.com/instance", + } as unknown as IPortal; expect(getPortalSiteHostname(subDomain, portal)).toBe( "foobar.com/instance/apps/sites/#/sub-domain", "ssl default port" ); - portal = ({ + portal = { allSSL: true, httpsPort: 234, // random, not 80 customBaseUrl: "other", - portalHostname: "foobar.com/instance" - } as unknown) as IPortal; + portalHostname: "foobar.com/instance", + } as unknown as IPortal; expect(getPortalSiteHostname(subDomain, portal)).toBe( "foobar.com:234/instance/apps/sites/#/sub-domain", diff --git a/packages/sites/test/update-site-application-uris.test.ts b/packages/sites/test/update-site-application-uris.test.ts index 71d02620a80..60c0a7731db 100644 --- a/packages/sites/test/update-site-application-uris.test.ts +++ b/packages/sites/test/update-site-application-uris.test.ts @@ -1,5 +1,4 @@ import { updateSiteApplicationUris } from "../src"; -import * as updateRedirectModule from "../src/update-app-redirect-uris"; import * as commonModule from "@esri/hub-common"; import { IModel, IHubRequestOptions } from "@esri/hub-common"; diff --git a/packages/surveys/src/types.ts b/packages/surveys/src/types.ts index ca0d73eb30d..b3a0425cea7 100644 --- a/packages/surveys/src/types.ts +++ b/packages/surveys/src/types.ts @@ -1,7 +1,6 @@ /* Copyright (c) 2020 Environmental Systems Research Institute, Inc. * Apache-2.0 */ -import { IRequestOptions } from "@esri/arcgis-rest-request"; import { IItem } from "@esri/arcgis-rest-types"; /* diff --git a/packages/teams/test/utils/add-or-invite-collaboration-coordinators.test.ts b/packages/teams/test/utils/add-or-invite-collaboration-coordinators.test.ts index cf73961b8fe..167cd5a08b9 100644 --- a/packages/teams/test/utils/add-or-invite-collaboration-coordinators.test.ts +++ b/packages/teams/test/utils/add-or-invite-collaboration-coordinators.test.ts @@ -1,7 +1,6 @@ import { addOrInviteCollaborationCoordinators } from "../../src/utils/add-or-invite-collaboration-coordinators"; import { MOCK_AUTH } from "../fixtures"; import * as processAutoAddUsersModule from "../../src/utils/process-auto-add-users"; -import * as processInviteUsersModule from "../../src/utils/process-invite-users"; import * as handleNoUsersModule from "../../src/utils/handle-no-users"; import { IAddOrInviteContext } from "../../src/types";