-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: follow card permission and editor support (#1394)
- Loading branch information
Showing
9 changed files
with
263 additions
and
5 deletions.
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
96 changes: 96 additions & 0 deletions
96
packages/common/src/core/schemas/internal/follow/FollowCardUiSchema.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,96 @@ | ||
import { IArcGISContext } from "../../../../ArcGISContext"; | ||
import { CardEditorOptions } from "../EditorOptions"; | ||
import { IUiSchema } from "../../types"; | ||
|
||
/** | ||
* @private | ||
* Exports the uiSchema of the stat card | ||
* @returns | ||
*/ | ||
export const buildUiSchema = ( | ||
i18nScope: string, | ||
config: CardEditorOptions, | ||
context: IArcGISContext | ||
): IUiSchema => { | ||
return { | ||
type: "Layout", | ||
elements: [ | ||
{ | ||
label: "Select Entity to Follow", | ||
scope: "/properties/followedItemId", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-gallery-picker", | ||
targetEntity: "item", | ||
catalogs: [ | ||
{ | ||
schemaVersion: 1, | ||
title: "Esri", | ||
scopes: { | ||
item: { | ||
targetEntity: "item", | ||
filters: [ | ||
{ | ||
predicates: [ | ||
{ | ||
type: "Hub Project", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
label: "Call-to-Action", | ||
scope: "/properties/callToAction", | ||
type: "Control", | ||
}, | ||
{ | ||
label: "Alignment", | ||
scope: "/properties/callToActionAlignment", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-alignment", | ||
}, | ||
}, | ||
{ | ||
label: "Button State", | ||
scope: "/properties/followStateText", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-input", | ||
type: "textarea", | ||
}, | ||
}, | ||
{ | ||
scope: "/properties/unfollowStateText", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-input", | ||
type: "textarea", | ||
}, | ||
}, | ||
{ | ||
label: "Button Alignment", | ||
scope: "/properties/callToActionAlignment", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-alignment", | ||
}, | ||
}, | ||
{ | ||
label: "Button Style", | ||
scope: "/properties/buttonStyle", | ||
type: "Control", | ||
options: { | ||
control: "hub-field-input-select", | ||
labels: ["Solid Background", "Ounline"], | ||
}, | ||
}, | ||
], | ||
}; | ||
}; |
44 changes: 44 additions & 0 deletions
44
packages/common/src/core/schemas/internal/follow/FollowSchema.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,44 @@ | ||
import { IConfigurationSchema } from "../../types"; | ||
|
||
export const FollowSchema: IConfigurationSchema = { | ||
type: "object", | ||
required: [], | ||
properties: { | ||
itemGalleryWithDefault: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
}, | ||
maxItems: 10, | ||
default: [], | ||
}, | ||
callToAction: { | ||
type: "string", | ||
default: | ||
"By following this site you will get updates about new events, surveys, and tools that you can use to help us achieve our goals.", | ||
}, | ||
callToActionAlignment: { | ||
enum: ["start", "center", "end"], | ||
default: "center", | ||
type: "string", | ||
}, | ||
followStateText: { | ||
type: "string", | ||
default: "Follow", | ||
}, | ||
unfollowStateText: { | ||
type: "string", | ||
default: "Unfollow", | ||
}, | ||
buttonAlignment: { | ||
enum: ["start", "center", "end"], | ||
default: "center", | ||
type: "string", | ||
}, | ||
buttonStyle: { | ||
type: "string", | ||
enum: ["solid", "outline"], | ||
default: "solid", | ||
}, | ||
}, | ||
}; |
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
17 changes: 17 additions & 0 deletions
17
packages/common/test/core/schemas/internal/follow/FollowCardUiSchema.test.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,17 @@ | ||
import { CardEditorOptions } from "../../../../../src/core/schemas/internal/EditorOptions"; | ||
import { buildUiSchema } from "../../../../../src/core/schemas/internal/follow/FollowCardUiSchema"; | ||
import { MOCK_CONTEXT } from "../../../../mocks/mock-auth"; | ||
|
||
describe("buildUiSchema: follow", () => { | ||
it("returns the full follow card uiSchema", async () => { | ||
const uiSchema = buildUiSchema("", {} as CardEditorOptions, MOCK_CONTEXT); | ||
|
||
expect(uiSchema.type).toBe("Layout"); | ||
expect(uiSchema.elements?.length).toBe(7); | ||
expect(uiSchema.elements![0].scope).toBe("/properties/followedItemId"); | ||
expect(uiSchema.elements![0].options!.control).toBe( | ||
"hub-field-input-gallery-picker" | ||
); | ||
// TODO: add more explicit tests when we complete the ui schema | ||
}); | ||
}); |
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