-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: followers settings schema and behavior #1211
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a7ae4c1
feat: add IWithFollowersBehavior and add to HubItemEntity
juliannemarik 4c18854
feat: extend IHubItemEntity with IWithFollowers trait
juliannemarik af21fb9
feat: add followers properties to base item entity schema
juliannemarik dc8ddc5
feat: add new site followers uiSchema
juliannemarik 8a9dd0a
chore: update IWithEditorBehavior toEditor method to be async
juliannemarik a26576c
feat: add toEditor and fromEditor logic for site followers
juliannemarik 0271d3f
fix: refactor to use permissions and add legacy capability migration
juliannemarik eda68a9
fix: make followersGroupId optional
juliannemarik dd2cc98
chore: add test for convertFeaturesToLegacyCapabilities
juliannemarik 0cfb057
fix: ensure required properties are subset when we filter schema to u…
juliannemarik 81b11df
chore: update IWithFollowersBehavior
juliannemarik 2d99b09
chore: revert async toEditor behavior for now
juliannemarik d06ce53
chore: cleanup
juliannemarik 0ebf8eb
fix: update getFollowers function in IWithFollowersBehavior
juliannemarik c0d6e4d
chore: update tests
juliannemarik ef37951
chore: add function comment to convertFeaturesToLegacyCapabilities
juliannemarik c707133
fix: rename IWithFollowersBehavior methods
juliannemarik 8d8fe5e
chore: rename feature flag
juliannemarik f632210
feat: add capabilities module that takes card of forward/backward leg…
juliannemarik 9b8ff71
chore: add/update tests
juliannemarik bebc3e8
chore: comment cleanup
juliannemarik dc0f2e4
fix: change access to groupAccess on schema
juliannemarik 4f61169
fix: failing uiSchema test
juliannemarik 18ab559
fix: minor cleanup
juliannemarik 3b85be3
chore: add additional comments
juliannemarik 6d251c5
fix: move migrateLegacyCapabilitiesToFeatures to upgrade-site-schema
juliannemarik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
packages/common/src/core/behaviors/IWithFollowersBehavior.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,16 @@ | ||
import { IGroup } from "@esri/arcgis-rest-types"; | ||
import { SettableAccessLevel } from "../types"; | ||
|
||
/** | ||
* Followers behavior for Item-Backed Entities | ||
*/ | ||
export interface IWithFollowersBehavior { | ||
/** | ||
* Get the followers group | ||
*/ | ||
getFollowersGroup(): Promise<IGroup>; | ||
/** | ||
* Set the access level of the followers group | ||
*/ | ||
setFollowersGroupAccess(access: SettableAccessLevel): Promise<void>; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ import { cloneObject } from "../util"; | |
import { PropertyMapper } from "../core/_internal/PropertyMapper"; | ||
import { getPropertyMap } from "./_internal/getPropertyMap"; | ||
|
||
import { IHubSiteEditor, IModel } from "../index"; | ||
import { IHubSiteEditor, IModel, SettableAccessLevel } from "../index"; | ||
import { SiteEditorType } from "./_internal/SiteSchema"; | ||
|
||
/** | ||
|
@@ -403,10 +403,15 @@ export class HubSite | |
* @returns | ||
*/ | ||
toEditor(editorContext: IEntityEditorContext = {}): IHubSiteEditor { | ||
// Cast the entity to it's editor | ||
// 1. Cast entity to editor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw- these incremental comments are great - I'm going to start doing this |
||
const editor = cloneObject(this.entity) as IHubSiteEditor; | ||
|
||
// Add other transforms here... | ||
// 2. Apply transforms to relevant entity values so they | ||
// can be consumed by the editor | ||
editor._followers = {}; | ||
editor._followers.showFollowAction = | ||
this.entity.features["hub:site:feature:follow"]; | ||
|
||
return editor; | ||
} | ||
|
||
|
@@ -418,6 +423,9 @@ export class HubSite | |
async fromEditor(editor: IHubSiteEditor): Promise<IHubSite> { | ||
const isCreate = !editor.id; | ||
|
||
// 1. Perform any pre-save operations e.g. storing | ||
// image resources on the item, setting access, etc. | ||
|
||
// Setting the thumbnailCache will ensure that | ||
// the thumbnail is updated on next save | ||
if (editor._thumbnail) { | ||
|
@@ -436,18 +444,29 @@ export class HubSite | |
|
||
delete editor._thumbnail; | ||
|
||
// convert back to an entity. Apply any reverse transforms used in | ||
// of the toEditor method | ||
// set the followers group access | ||
if (editor._followers?.groupAccess) { | ||
await this.setFollowersGroupAccess( | ||
editor._followers.groupAccess as SettableAccessLevel | ||
); | ||
} | ||
|
||
// 2. Convert editor values back to an entity e.g. apply | ||
// any reverse transforms used in the toEditor method | ||
const entity = cloneObject(editor) as IHubSite; | ||
|
||
entity.features = { | ||
...entity.features, | ||
"hub:site:feature:follow": editor._followers?.showFollowAction, | ||
}; | ||
|
||
// copy the location extent up one level | ||
entity.extent = editor.location?.extent; | ||
|
||
// create it if it does not yet exist... | ||
// 3. create or update the in-memory entity and save | ||
if (isCreate) { | ||
throw new Error("Cannot create content using the Editor."); | ||
} else { | ||
// ...otherwise, update the in-memory entity and save it | ||
this.entity = entity; | ||
await this.save(); | ||
} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
_followers
need to be on the base schema, or should it only exist onSiteSchema
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good callout - I put it here because although the concept of a followers group only exists for sites today, I think the idea is that any item-backed entity could have a followers group in the future. That's also why I've added the
IWithFollowers
andIWithFollowersBehavior
to theIHubItemEntity
andHubItemEntity
respectively rather than just to theHubSite
.With that said, if you think it would make more sense to keep this scoped to sites until followers are actually implemented for other entities, I can move it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks makes sense to leave it for potential future use cases. Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will add followers for Initiative and Project - the only reason it's on now Site is b/c that was/is synonymous with "Initiative".