-
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(hub-common): add support for discussion settings for entities (#…
…1284) * feat(hub-common): add support for discussion settings for entities affects: @esri/hub-common, @esri/hub-discussions ISSUES CLOSED: 7412 * feat(): pr feedback * feat(): update updateHubEntity to pass hubRequestOptions to updateDiscussion * feat(): move getDefaultEntitySettings so it can be exported * feat(): tweak updateDiscussion logic * feat(): make extending discussion settings to other entities easier * fix(): rename discussionsSettings to discussionSettings * fix(): ihubgroup interface extends iwithdiscussions * fix(hub-common): fixes some tests affects: @esri/hub-common ISSUES CLOSED: 7412 * test(): tweak import statements, await removeSetting * fix(hub-common): add test coverage affects: @esri/hub-common ISSUES CLOSED: 7412 --------- Co-authored-by: Randy Weber <[email protected]>
- Loading branch information
1 parent
ce3be36
commit 951c455
Showing
19 changed files
with
425 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import { IDiscussionsSettings } from "../../discussions/api/types"; | ||
import { IWithEntitySettings } from "./IWithEntitySettings"; | ||
|
||
/** | ||
* Discussions-related properties | ||
*/ | ||
export interface IWithDiscussions { | ||
export interface IWithDiscussions extends IWithEntitySettings { | ||
/** | ||
* If the item has discussions enabled | ||
*/ | ||
isDiscussable?: boolean; | ||
|
||
/** | ||
* The entity's discussion settings | ||
*/ | ||
discussionSettings?: IDiscussionsSettings; | ||
} |
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,6 @@ | ||
/** | ||
* Entity settings | ||
*/ | ||
export interface IWithEntitySettings { | ||
entitySettingsId?: string; | ||
} |
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
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
42 changes: 42 additions & 0 deletions
42
packages/common/src/discussions/api/settings/getDefaultEntitySettings.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,42 @@ | ||
import { EntitySettingType, IEntitySetting, IEntitySettings } from "../types"; | ||
import { HubEntityType } from "../../../core/types"; | ||
|
||
const DISCUSSION_SETTINGS: IEntitySettings = { | ||
discussions: { | ||
allowedChannelIds: null, | ||
allowedLocations: null, | ||
}, | ||
}; | ||
|
||
const DEFAULT_ENTITY_SETTINGS_BY_ENTITY_TYPE: Record< | ||
HubEntityType, | ||
{ type: EntitySettingType; settings: IEntitySettings } | ||
> = { | ||
discussion: { | ||
type: EntitySettingType.CONTENT, | ||
settings: { ...DISCUSSION_SETTINGS }, | ||
}, | ||
site: null, | ||
project: null, | ||
initiative: null, | ||
initiativeTemplate: null, | ||
page: null, | ||
content: null, | ||
org: null, | ||
group: null, | ||
template: null, | ||
}; | ||
|
||
export function getDefaultEntitySettings( | ||
entityType: HubEntityType | ||
): Partial<IEntitySetting> { | ||
if (!DEFAULT_ENTITY_SETTINGS_BY_ENTITY_TYPE[entityType]) { | ||
throw new Error(`no default entity settings defined for ${entityType}`); | ||
} | ||
return { | ||
type: DEFAULT_ENTITY_SETTINGS_BY_ENTITY_TYPE[entityType].type, | ||
settings: { | ||
...DEFAULT_ENTITY_SETTINGS_BY_ENTITY_TYPE[entityType].settings, | ||
}, | ||
}; | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./settings"; | ||
export * from "./getDefaultEntitySettings"; |
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.