Skip to content

Commit e0beb59

Browse files
authored
feat(hub-common): adds followers group discussion settings on site wo… (#1251)
* feat(hub-common): adds followers group discussion settings on site workspace affects: @esri/hub-common * chore(): lint * fix(hub-common): pR feedback affects: @esri/hub-common
1 parent 98c4545 commit e0beb59

File tree

65 files changed

+317
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+317
-210
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/e2e/associations.e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Artifactory from "./helpers/Artifactory";
88
import config from "./helpers/config";
99
import {
1010
ICreateOutput,
11-
cleanupItems,
1211
createInitiative,
1312
createProjects,
1413
createScopeGroup,

packages/common/e2e/fixtures/initiative.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IHubInitiative, IModel } from "../../src";
1+
import { IModel } from "../../src";
22

33
const model: IModel = {
44
item: {

packages/common/e2e/fixtures/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IHubProject, IModel } from "../../src";
1+
import { IModel } from "../../src";
22

33
const projectmodel: IModel = {
44
item: {

packages/common/e2e/metrics.e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Artifactory from "./helpers/Artifactory";
1010
import config from "./helpers/config";
1111
import {
1212
ICreateOutput,
13-
cleanupItems,
1413
createInitiative,
1514
createProjects,
1615
createScopeGroup,

packages/common/e2e/permissions.e2e.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { IArcGISContext } from "../src/ArcGISContext";
22
import { fetchHubEntity } from "../src/core/fetchHubEntity";
33
import { HubEntity } from "../src/core/types/HubEntity";
4-
import { IHubInitiative } from "../src/core/types/IHubInitiative";
5-
import { HubInitiative } from "../src/initiatives/HubInitiative";
64
import { checkPermission } from "../src/permissions/checkPermission";
75
import Artifactory from "./helpers/Artifactory";
86
import config from "./helpers/config";

packages/common/e2e/purge-domains.e2e.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ import {
33
lookupDomain,
44
deleteSite,
55
removeDomain,
6-
batch,
76
IArcGISContext,
87
failSafe,
98
} from "../src";
10-
import { hostnames } from "./fixtures/sample";
11-
import Artifactory from "./helpers/Artifactory";
12-
import config from "./helpers/config";
139
let count = 0;
1410
async function processDomain(cfg: {
1511
domain: string;

packages/common/src/content/_internal/computeProps.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { IRequestOptions } from "@esri/arcgis-rest-request";
22
import { UserSession } from "@esri/arcgis-rest-auth";
33
import { getItemThumbnailUrl } from "../../resources";
44
import { IModel } from "../../types";
5-
import { bBoxToExtent, extentToPolygon, isBBox } from "../../extent";
5+
import { bBoxToExtent, isBBox } from "../../extent";
66
import { IExtent } from "@esri/arcgis-rest-types";
7-
import Geometry = __esri.Geometry;
87
import { getItemHomeUrl } from "../../urls/get-item-home-url";
98
import { getContentEditUrl, getHubRelativeUrl } from "./internalContentUtils";
109
import { IHubLocation } from "../../core/types/IHubLocation";

packages/common/src/content/search.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { IItem } from "@esri/arcgis-rest-types";
2-
import { isMaster } from "cluster";
32
import { fetchItemEnrichments } from "../items/_enrichments";
43
import { getProp } from "../objects";
54
import { getItemThumbnailUrl } from "../resources";

packages/common/src/core/EntityEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { HubSite } from "../sites/HubSite";
1010
import { HubTemplate } from "../templates";
1111
import { IEditorConfig, IWithEditorBehavior } from "./behaviors";
1212
import { getTypeFromEntity } from "./getTypeFromEntity";
13-
import { EditorType, UiSchemaElementOptions } from "./schemas";
13+
import { EditorType } from "./schemas";
1414
import { HubEntity } from "./types/HubEntity";
1515
import { HubEntityEditor, IEntityEditorContext } from "./types/HubEntityEditor";
1616

packages/common/src/core/HubItemEntity.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from "./behaviors";
3333

3434
import { IWithThumbnailBehavior } from "./behaviors/IWithThumbnailBehavior";
35-
import { AccessLevel, IHubItemEntity, SettableAccessLevel } from "./types";
35+
import { IHubItemEntity, SettableAccessLevel } from "./types";
3636
import { sharedWith } from "./_internal/sharedWith";
3737
import { IWithDiscussionsBehavior } from "./behaviors/IWithDiscussionsBehavior";
3838
import { setDiscussableKeyword } from "../discussions";
@@ -256,6 +256,25 @@ export abstract class HubItemEntity<T extends IHubItemEntity>
256256
});
257257
}
258258

259+
/**
260+
* Sets whether or not the followers group is discussable
261+
* @param isDiscussable
262+
*/
263+
async setFollowersGroupIsDiscussable(isDiscussable: boolean) {
264+
const group = await this.getFollowersGroup();
265+
const typeKeywords = setDiscussableKeyword(
266+
group.typeKeywords,
267+
isDiscussable
268+
);
269+
await updateGroup({
270+
group: {
271+
id: group.id,
272+
typeKeywords,
273+
},
274+
authentication: this.context.session,
275+
});
276+
}
277+
259278
/**
260279
* Return a list of groups the Entity is shared to.
261280
* @returns

packages/common/src/core/behaviors/IWithEditorBehavior.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
IConfigurationSchema,
3-
IUiSchema,
4-
UiSchemaElementOptions,
5-
EditorType,
6-
} from "../schemas";
1+
import { IConfigurationSchema, IUiSchema, EditorType } from "../schemas";
72
import { HubEntity, HubEntityEditor, IEntityEditorContext } from "../types";
83

94
export interface IEditorConfig {

packages/common/src/core/behaviors/IWithFollowersBehavior.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export interface IWithFollowersBehavior {
1313
* Set the access level of the followers group
1414
*/
1515
setFollowersGroupAccess(access: SettableAccessLevel): Promise<void>;
16+
/**
17+
* Set whether or not the followers group is discussable
18+
*/
19+
setFollowersGroupIsDiscussable(isDiscussable: boolean): Promise<void>;
1620
}

packages/common/src/core/behaviors/IWithSharingBehavior.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IGetItemGroupsResponse, IGroup } from "@esri/arcgis-rest-portal";
1+
import { IGroup } from "@esri/arcgis-rest-portal";
22
import { AccessLevel } from "../types";
33

44
/**

packages/common/src/core/schemas/internal/getCategoryItems.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { request } from "@esri/arcgis-rest-request";
22
import { IHubRequestOptions } from "../../../types";
3-
import { HubEntity } from "../../types/HubEntity";
43
import { IUiSchemaComboboxItem } from "../types";
54

65
/**

packages/common/src/core/schemas/shared/HubItemEntitySchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const HubItemEntitySchema: IConfigurationSchema = {
4141
type: "boolean",
4242
default: true,
4343
},
44+
isDiscussable: ENTITY_IS_DISCUSSABLE_SCHEMA,
4445
},
4546
},
4647
view: {

packages/common/src/core/traits/IWithMetrics.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { IReference } from "../types";
21
import { IMetric } from "../types/Metrics";
32

43
/**

packages/common/src/core/types/IAccessResponse.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { IPolicyCheck } from "../../permissions/types/IPolicyCheck";
21
import { PolicyResponse } from "../../permissions/types/PolicyResponse";
32

43
export interface IAccessResponse {

packages/common/src/core/types/IHubInitiative.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
IWithSlug,
3-
IWithLayout,
4-
IWithPermissions,
5-
IWithCatalog,
6-
} from "../traits";
7-
import {} from "../traits/IWithCatalog";
1+
import { IWithSlug, IWithPermissions, IWithCatalog } from "../traits";
82
import { IWithMetrics } from "../traits/IWithMetrics";
93
import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity";
104

packages/common/src/core/types/IHubItemEntity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,6 @@ export type IHubItemEntityEditor<T> = Omit<T, "extent"> & {
150150
_followers?: {
151151
groupAccess?: AccessLevel;
152152
showFollowAction?: boolean;
153+
isDiscussable?: boolean;
153154
};
154155
};

packages/common/src/core/types/IHubProject.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
IWithCatalog,
77
} from "../traits/index";
88
import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity";
9-
import { IExtent } from "@esri/arcgis-rest-feature-layer";
109

1110
/**
1211
* Defines the properties of a Hub Project object

packages/common/src/discussions/utils.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,9 @@ import {
55
AclCategory,
66
AclSubCategory,
77
IChannel,
8-
IChannelAclPermission,
98
SharingAccess,
109
} from "./api/types";
11-
import {
12-
IFilter,
13-
IHubSearchOptions,
14-
IHubSearchResponse,
15-
IHubSearchResult,
16-
IPredicate,
17-
IQuery,
18-
hubSearch,
19-
} from "../search";
10+
import { IFilter, IPredicate, IQuery } from "../search";
2011

2112
/**
2213
* Utility to determine if a given IGroup, IItem, IHubContent, or IHubItemEntity

packages/common/src/groups/addGroupMembers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { IAuthenticationManager } from "@esri/arcgis-rest-request";
21
import { IUser } from "@esri/arcgis-rest-types";
32
import { failSafe } from "../utils";
43
import { autoAddUsers } from "./autoAddUsers";

packages/common/src/metrics/resolveMetric.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { getProp } from "../objects/get-prop";
1414
import { IPredicate, IQuery } from "../search/types/IHubCatalog";
1515
import { combineQueries } from "../search/_internal/combineQueries";
1616
import { IHubSearchOptions } from "../search/types/IHubSearchOptions";
17-
import { memoize } from "../utils/memoize";
1817
import { portalSearchItemsAsItems } from "../search/_internal/portalSearchItems";
1918

2019
/**

packages/common/src/pages/HubPages.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ import { getPropertyMap } from "./_internal/getPropertyMap";
2929
import { computeProps } from "./_internal/computeProps";
3030
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
3131
import { IUserItemOptions, removeItem } from "@esri/arcgis-rest-portal";
32-
import {
33-
DEFAULT_PAGE,
34-
DEFAULT_PAGE_MODEL,
35-
HUB_PAGE_ITEM_TYPE,
36-
ENTERPRISE_PAGE_ITEM_TYPE,
37-
} from "./defaults";
32+
import { DEFAULT_PAGE, DEFAULT_PAGE_MODEL } from "./defaults";
3833

3934
/**
4035
* @private

packages/common/src/pages/_internal/computeProps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { processEntityFeatures } from "../../permissions/_internal/processEntity
77
import { PageDefaultFeatures } from "./PageBusinessRules";
88
import { getItemHomeUrl } from "../../urls/get-item-home-url";
99
import { IHubPage } from "../../core/types/IHubPage";
10-
import { getHubRelativeUrl } from "../../content/_internal/internalContentUtils";
1110
import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl";
1211

1312
/**

packages/common/src/projects/HubProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
IHubCardViewModel,
3333
} from "../core/types/IHubCardViewModel";
3434
import { projectToCardModel } from "./view";
35-
import { cloneObject, maybePush } from "../util";
35+
import { cloneObject } from "../util";
3636
import { createProject, editorToProject, updateProject } from "./edit";
3737
import { ProjectEditorType } from "./_internal/ProjectSchema";
3838
import { enrichEntity } from "../core/enrichEntity";

packages/common/src/search/_internal/explainPredicate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { IRequestOptions } from "@esri/arcgis-rest-request";
22
import { GenericResult, IPredicateExplanation } from "../explainQueryResult";
3-
import { cloneObject } from "../../util";
43
import { IMatchOptions } from "../types";
54
import {
65
PREDICATE_DATE_PROPS,

packages/common/src/search/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from "@esri/arcgis-rest-portal";
1212
import { isPageType } from "../content/_internal/internalContentUtils";
1313
import { IHubSite } from "../core";
14-
import { getProp } from "../objects/get-prop";
1514
import { ISearchResponse } from "../types";
1615
import { cloneObject } from "../util";
1716
import { IHubSearchResult } from "./types";

packages/common/src/sites/HubSite.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { IContainsResponse, IDeepCatalogInfo, IHubCatalog } from "../search";
3030
import { deepContains } from "../core/_internal/deepContains";
3131

3232
import {
33-
applyVersion,
3433
createVersion,
3534
deleteVersion,
3635
getVersion,
@@ -47,7 +46,13 @@ import { cloneObject } from "../util";
4746
import { PropertyMapper } from "../core/_internal/PropertyMapper";
4847
import { getPropertyMap } from "./_internal/getPropertyMap";
4948

50-
import { IHubSiteEditor, IModel, setProp, SettableAccessLevel } from "../index";
49+
import {
50+
IHubSiteEditor,
51+
IModel,
52+
isDiscussable,
53+
setProp,
54+
SettableAccessLevel,
55+
} from "../index";
5156
import { SiteEditorType } from "./_internal/SiteSchema";
5257

5358
/**
@@ -424,6 +429,9 @@ export class HubSite
424429
editor
425430
);
426431

432+
const followersGroup = await this.getFollowersGroup();
433+
setProp("_followers.isDiscussable", isDiscussable(followersGroup), editor);
434+
427435
editor._discussions = this.entity.features["hub:site:feature:discussions"];
428436

429437
return editor;
@@ -458,6 +466,13 @@ export class HubSite
458466

459467
delete editor._thumbnail;
460468

469+
// set whether or not the followers group is discussable
470+
if (editor._followers?.isDiscussable !== undefined) {
471+
await this.setFollowersGroupIsDiscussable(
472+
editor._followers.isDiscussable
473+
);
474+
}
475+
461476
// set the followers group access
462477
if (editor._followers?.groupAccess) {
463478
await this.setFollowersGroupAccess(

packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ export const buildUiSchema = async (
5656
},
5757
},
5858
},
59+
{
60+
labelKey: `${i18nScope}.fields.followers.discussable.label`,
61+
scope: "/properties/_followers/properties/isDiscussable",
62+
type: "Control",
63+
options: {
64+
control: "hub-field-input-radio",
65+
labels: [
66+
`{{${i18nScope}.fields.followers.discussable.enabled.label:translate}}`,
67+
`{{${i18nScope}.fields.followers.discussable.disabled.label:translate}}`,
68+
],
69+
descriptions: [
70+
`{{${i18nScope}.fields.followers.discussable.enabled.description:translate}}`,
71+
`{{${i18nScope}.fields.followers.discussable.disabled.description:translate}}`,
72+
],
73+
icons: ["speech-bubbles", "circle-disallowed"],
74+
},
75+
},
5976
],
6077
},
6178
],

packages/common/src/sites/_internal/applyCatalogStructureMigration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getProp } from "../../objects/get-prop";
21
import { IHubCatalog } from "../../search/types/IHubCatalog";
32
import { IModel } from "../../types";
43

packages/common/test/Hub.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IUser } from "@esri/arcgis-rest-types";
44
// imported with a full path
55
import { ArcGISContextManager } from "../src/ArcGISContextManager";
66
import { Hub } from "../src/Hub";
7-
import { IArcGISContextManagerOptions, IHubProject } from "../src";
7+
import { IArcGISContextManagerOptions } from "../src";
88
import { MOCK_AUTH } from "./mocks/mock-auth";
99
// import * as ProjectsModule from "../src/projects/HubProjects";
1010

packages/common/test/content/_internal/internalContentUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IItem } from "@esri/arcgis-rest-types";
22
import { getContentEditUrl } from "../../../src/content/_internal/internalContentUtils";
3-
import { IHubRequestOptions, IModel } from "../../../src/types";
3+
import { IHubRequestOptions } from "../../../src/types";
44
import { cloneObject } from "../../../src/util";
55
import { MOCK_HUB_REQOPTS } from "../../mocks/mock-auth";
66

packages/common/test/content/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
cloneObject,
55
enrichContentSearchResult,
66
IHubRequestOptions,
7-
IHubSearchResult,
87
} from "../../src";
98
import * as FetchEnrichments from "../../src/items/_enrichments";
109

0 commit comments

Comments
 (0)