Skip to content

Commit

Permalink
feat(hub-common): updates DiscussionUiSchemaEdit schema layout and de… (
Browse files Browse the repository at this point in the history
#1325)

* feat(hub-common): updates DiscussionUiSchemaEdit schema layout and defaults

affects: @esri/hub-common

* feat(): add prompt to new discussion schema
  • Loading branch information
tannerjt authored Nov 15, 2023
1 parent dae2025 commit 1336de1
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export const DiscussionEditorTypes = [
*/
export const DiscussionSchema: IConfigurationSchema = {
...HubItemEntitySchema,
required: ["name", "prompt"],
properties: {
...HubItemEntitySchema.properties,
prompt: {
type: "string",
default: "We want to hear from you!",
default: "",
},
},
} as IConfigurationSchema;
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ export const buildUiSchema = async (
],
},
},
{
labelKey: `${i18nScope}.fields.prompt.label`,
scope: "/properties/prompt",
type: "Control",
options: {
helperText: {
labelKey: `${i18nScope}.fields.prompt.helperText`,
},
messages: [
{
type: "ERROR",
keyword: "required",
icon: true,
labelKey: `${i18nScope}.fields.prompt.requiredError`,
},
],
},
},
],
};
};
141 changes: 57 additions & 84 deletions packages/common/src/discussions/_internal/DiscussionUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,77 +65,47 @@ export const buildUiSchema = async (
],
},
},
{
labelKey: `${i18nScope}.fields.summary.label`,
scope: "/properties/summary",
type: "Control",
options: {
control: "hub-field-input-input",
type: "textarea",
rows: 4,
helperText: {
labelKey: `${i18nScope}.fields.summary.helperText`,
},
messages: [
{
type: "ERROR",
keyword: "maxLength",
icon: true,
labelKey: `shared.fields.purpose.maxLengthError`,
},
],
},
},
{
labelKey: `${i18nScope}.fields.description.label`,
scope: "/properties/description",
type: "Control",
options: {
control: "hub-field-input-input",
type: "textarea",
helperText: {
labelKey: `${i18nScope}.fields.description.helperText`,
},
},
},
getThumbnailUiSchemaElement(
i18nScope,
options.thumbnail,
options.thumbnailUrl
),
{
labelKey: `${i18nScope}.fields.featuredImage.label`,
scope: "/properties/view/properties/featuredImage",
type: "Control",
options: {
control: "hub-field-input-image-picker",
imgSrc: getAuthedImageUrl(
options.view?.featuredImageUrl,
context
),
maxWidth: 727,
maxHeight: 484,
aspectRatio: 1.5,
sizeDescription: {
labelKey: `${i18nScope}.fields.featuredImage.sizeDescription`,
},
},
],
},
{
type: "Section",
labelKey: `${i18nScope}.sections.location.label`,
options: {
helperText: {
labelKey: `${i18nScope}.sections.location.helperText`,
},
},
elements: [
{
labelKey: `${i18nScope}.fields.featuredImage.altText.label`,
scope: "/properties/view/properties/featuredImageAltText",
scope: "/properties/location",
type: "Control",
options: {
helperText: {
labelKey: `${i18nScope}.fields.featuredImage.altText.helperText`,
},
control: "hub-field-input-location-picker",
extent: await getLocationExtent(
options.location,
context.hubRequestOptions
),
options: await getLocationOptions(
options.id,
options.type,
options.location,
context.portal.name,
context.hubRequestOptions
),
mapTools: ["polygon", "rectangle"],
},
},
{
labelKey: `${i18nScope}.fields.featuredImage.name.label`,
scope: "/properties/view/properties/featuredImageName",
type: "Control",
},
],
},
{
type: "Section",
labelKey: `${i18nScope}.sections.searchDiscoverability.label`,
elements: [
{
labelKey: `${i18nScope}.fields.tags.label`,
scope: "/properties/tags",
Expand Down Expand Up @@ -167,34 +137,37 @@ export const buildUiSchema = async (
placeholderIcon: "select-category",
},
},
],
},
{
type: "Section",
labelKey: `${i18nScope}.sections.location.label`,
options: {
helperText: {
labelKey: `${i18nScope}.sections.location.helperText`,
{
labelKey: `${i18nScope}.fields.summary.label`,
scope: "/properties/summary",
type: "Control",
options: {
control: "hub-field-input-input",
type: "textarea",
rows: 4,
helperText: {
labelKey: `${i18nScope}.fields.summary.helperText`,
},
messages: [
{
type: "ERROR",
keyword: "maxLength",
icon: true,
labelKey: `shared.fields.purpose.maxLengthError`,
},
],
},
},
},
elements: [
{
scope: "/properties/location",
labelKey: `${i18nScope}.fields.description.label`,
scope: "/properties/description",
type: "Control",
options: {
control: "hub-field-input-location-picker",
extent: await getLocationExtent(
options.location,
context.hubRequestOptions
),
options: await getLocationOptions(
options.id,
options.type,
options.location,
context.portal.name,
context.hubRequestOptions
),
mapTools: ["polygon", "rectangle"],
control: "hub-field-input-input",
type: "textarea",
helperText: {
labelKey: `${i18nScope}.fields.description.helperText`,
},
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/discussions/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const HUB_DISCUSSION_ITEM_TYPE = "Discussion";
* Default values of a IHubDiscussion
*/
export const DEFAULT_DISCUSSION: Partial<IHubDiscussion> = {
name: "No title provided",
name: "",
tags: [],
typeKeywords: ["Hub Discussion"],
permissions: [],
Expand All @@ -21,8 +21,8 @@ export const DEFAULT_DISCUSSION: Partial<IHubDiscussion> = {
export const DEFAULT_DISCUSSION_MODEL: IModel = {
item: {
type: HUB_DISCUSSION_ITEM_TYPE,
title: "No Title Provided",
description: "No Description Provided",
title: "",
description: "",
snippet: "",
tags: [],
typeKeywords: ["Hub Discussion"],
Expand All @@ -32,6 +32,6 @@ export const DEFAULT_DISCUSSION_MODEL: IModel = {
},
},
data: {
prompt: "We want to hear from you!",
prompt: "",
},
} as unknown as IModel;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ describe("buildUiSchema: discussion create", () => {
],
},
},
{
labelKey: "some.scope.fields.prompt.label",
scope: "/properties/prompt",
type: "Control",
options: {
helperText: {
labelKey: "some.scope.fields.prompt.helperText",
},
messages: [
{
type: "ERROR",
keyword: "required",
icon: true,
labelKey: "some.scope.fields.prompt.requiredError",
},
],
},
},
],
});
});
Expand Down
Loading

0 comments on commit 1336de1

Please sign in to comment.