diff --git a/packages/common/src/content/HubContent.ts b/packages/common/src/content/HubContent.ts index 0f1082c60ff..0fa00520e90 100644 --- a/packages/common/src/content/HubContent.ts +++ b/packages/common/src/content/HubContent.ts @@ -1,10 +1,7 @@ import { IArcGISContext } from "../ArcGISContext"; import { HubItemEntity } from "../core/HubItemEntity"; - -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { IHubContentEditor, IHubEditableContent, diff --git a/packages/common/src/content/_internal/ContentUiSchemaDiscussions.ts b/packages/common/src/content/_internal/ContentUiSchemaDiscussions.ts index cf2611c43f7..584daa33b4e 100644 --- a/packages/common/src/content/_internal/ContentUiSchemaDiscussions.ts +++ b/packages/common/src/content/_internal/ContentUiSchemaDiscussions.ts @@ -1,6 +1,6 @@ -import { IHubEditableContent } from "../../core/types"; import { IArcGISContext } from "../../ArcGISContext"; import { IUiSchema } from "../../core/schemas/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IUiSchema } from "../../core/schemas/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubEditableContent, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/content/_internal/ContentUiSchemaEdit.ts b/packages/common/src/content/_internal/ContentUiSchemaEdit.ts index cbe42476a9f..88deb51e93b 100644 --- a/packages/common/src/content/_internal/ContentUiSchemaEdit.ts +++ b/packages/common/src/content/_internal/ContentUiSchemaEdit.ts @@ -3,9 +3,9 @@ import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; -import { IHubEditableContent } from "../../core/types/IHubEditableContent"; import { IUiSchema } from "../../core/schemas/types"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -15,7 +15,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubEditableContent, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -71,7 +71,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), // tags { labelKey: `${i18nScope}.fields.tags.label`, @@ -80,7 +80,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -139,11 +139,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/content/_internal/ContentUiSchemaSettings.ts b/packages/common/src/content/_internal/ContentUiSchemaSettings.ts index 35462f84159..19ababab1b8 100644 --- a/packages/common/src/content/_internal/ContentUiSchemaSettings.ts +++ b/packages/common/src/content/_internal/ContentUiSchemaSettings.ts @@ -1,4 +1,5 @@ import { IArcGISContext } from "../../ArcGISContext"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types"; import { IHubEditableContent } from "../../core/types/IHubEditableContent"; import { isHostedFeatureServiceEntity } from "../hostedServiceUtils"; @@ -11,14 +12,14 @@ import { isHostedFeatureServiceEntity } from "../hostedServiceUtils"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubEditableContent, + options: EntityEditorOptions, _context: IArcGISContext ): Promise => { const uiSchema: IUiSchema = { type: "Layout", elements: [], }; - if (isHostedFeatureServiceEntity(entity)) { + if (isHostedFeatureServiceEntity(options as IHubEditableContent)) { uiSchema.elements.push({ type: "Section", labelKey: `${i18nScope}.sections.downloads.label`, diff --git a/packages/common/src/core/EntityEditor.ts b/packages/common/src/core/EntityEditor.ts index 3c834c308d4..9b3ccd411a7 100644 --- a/packages/common/src/core/EntityEditor.ts +++ b/packages/common/src/core/EntityEditor.ts @@ -8,9 +8,9 @@ import { HubPage } from "../pages/HubPage"; import { HubProject } from "../projects/HubProject"; import { HubSite } from "../sites/HubSite"; import { HubTemplate } from "../templates"; -import { IEditorConfig, IWithEditorBehavior } from "./behaviors"; +import { IEditorConfig, EntityEditorType } from "./schemas/types"; +import { IWithEditorBehavior } from "./behaviors"; import { getTypeFromEntity } from "./getTypeFromEntity"; -import { EditorType } from "./schemas"; import { HubEntity } from "./types/HubEntity"; import { HubEntityEditor, IEntityEditorContext } from "./types/HubEntityEditor"; @@ -65,7 +65,10 @@ export class EntityEditor { } } - async getConfig(i18nScope: string, type: EditorType): Promise { + async getConfig( + i18nScope: string, + type: EntityEditorType + ): Promise { return this.instance.getEditorConfig(i18nScope, type); } diff --git a/packages/common/src/core/behaviors/IWithEditorBehavior.ts b/packages/common/src/core/behaviors/IWithEditorBehavior.ts index 853343ca37e..7217624e3a8 100644 --- a/packages/common/src/core/behaviors/IWithEditorBehavior.ts +++ b/packages/common/src/core/behaviors/IWithEditorBehavior.ts @@ -1,11 +1,6 @@ -import { IConfigurationSchema, IUiSchema, EditorType } from "../schemas"; +import { IEditorConfig, EditorType } from "../schemas/types"; import { HubEntity, HubEntityEditor, IEntityEditorContext } from "../types"; -export interface IEditorConfig { - schema: IConfigurationSchema; - uiSchema: IUiSchema; -} - /** * Functions that are used by the arcgis-hub-entity-editor component */ diff --git a/packages/common/src/core/getTypeFromEntity.ts b/packages/common/src/core/getTypeFromEntity.ts index 6833e2930a0..ef142e8e9a6 100644 --- a/packages/common/src/core/getTypeFromEntity.ts +++ b/packages/common/src/core/getTypeFromEntity.ts @@ -1,14 +1,13 @@ import { getFamily } from "../content/get-family"; -import { ConfigurableEntity } from "./schemas/internal/ConfigurableEntity"; import { HubEntity, IHubItemEntity, HubEntityType } from "./types"; /** - * Given a HubEntity, return it's HubEntityType + * Given a HubEntity, return its HubEntityType * @param entity * @returns */ export function getTypeFromEntity( - entity: IHubItemEntity | HubEntity | ConfigurableEntity + entity: IHubItemEntity | Partial ): HubEntityType { let type: HubEntityType; switch (entity.type) { diff --git a/packages/common/src/core/schemas/getEditorConfig.ts b/packages/common/src/core/schemas/getEditorConfig.ts index ed9bc378eda..3e98a290a29 100644 --- a/packages/common/src/core/schemas/getEditorConfig.ts +++ b/packages/common/src/core/schemas/getEditorConfig.ts @@ -1,22 +1,52 @@ -import { IEditorConfig } from "../behaviors/IWithEditorBehavior"; +import { EntityEditorType, IEditorConfig, StatCardEditorType } from "./types"; import { IArcGISContext } from "../../ArcGISContext"; -import { ConfigurableEntity } from "./internal/ConfigurableEntity"; -import { getEntityEditorSchemas } from "./internal/getEntityEditorSchemas"; +import { + EditorOptions, + EntityEditorOptions, + IStatCardEditorOptions, +} from "./internal/EditorOptions"; +import { getEditorSchemas } from "./internal/getEditorSchemas"; import { EditorType } from "./types"; /** - * Construct the Editor Configuration for a given entity type + * NOTE: We use the concept of function overloading to write getEditorConfig. + * In doing so, we create multiple signatures for the function. + * When the function is called, its types will need to agree with one of the signatures. + * This prevents a function call from having an EntityEditorType type, and IStatCardEditorOptions options, for example. + */ + +/** + * Construct the Editor Configuration (schema + uiSchema) + * for a given entity editor type * @param i18nScope * @param type - * @param entity + * @param options - options to integrate into the schema + uiSchema * @param context * @returns */ + +// Entity editor overload +export async function getEditorConfig( + i18nScope: string, + type: EntityEditorType, + options: EntityEditorOptions, + context: IArcGISContext +): Promise; + +// Stat card editor overload +export async function getEditorConfig( + i18nScope: string, + type: StatCardEditorType, + options: IStatCardEditorOptions, + context: IArcGISContext +): Promise; + +// General function export async function getEditorConfig( i18nScope: string, type: EditorType, - entity: ConfigurableEntity, + options: EditorOptions, context: IArcGISContext ): Promise { - return getEntityEditorSchemas(i18nScope, type, entity, context); + return getEditorSchemas(i18nScope, type, options, context); } diff --git a/packages/common/src/core/schemas/internal/ConfigurableEntity.ts b/packages/common/src/core/schemas/internal/ConfigurableEntity.ts deleted file mode 100644 index 6207c399713..00000000000 --- a/packages/common/src/core/schemas/internal/ConfigurableEntity.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Generic interface for a Hub Entity - */ -export type ConfigurableEntity = Record; diff --git a/packages/common/src/core/schemas/internal/EditorOptions.ts b/packages/common/src/core/schemas/internal/EditorOptions.ts new file mode 100644 index 00000000000..cb433eb7205 --- /dev/null +++ b/packages/common/src/core/schemas/internal/EditorOptions.ts @@ -0,0 +1,28 @@ +import { HubEntity } from "../../types"; + +/** Intersection type of all EditorOptions */ +export type EditorOptions = EntityEditorOptions | CardEditorOptions; + +/** + * Options to use when constructing a schema and uiSchema for + * an entity's editor. Often times, this can just be the entity + * object itself. + * + * However, it must always have "type" on the options, even if not the entire entity. + */ +export type EntityEditorOptions = HubEntity & Record; + +/** + * Options to use when constructing a schema and uiSchema for + * a layout card's editor. This should be a union of all of the different + * layout card editor options, i.e. IStatCardEditorOptions | ICountdownCardEditorOptions | ... + */ +export type CardEditorOptions = IStatCardEditorOptions; + +/** + * Options to use when constructing a schema and uiSchema for + * a stat card editor. + */ +export interface IStatCardEditorOptions { + themeColors: string[]; +} diff --git a/packages/common/src/core/schemas/internal/getCardEditorSchemas.ts b/packages/common/src/core/schemas/internal/getCardEditorSchemas.ts new file mode 100644 index 00000000000..a3003e4f03b --- /dev/null +++ b/packages/common/src/core/schemas/internal/getCardEditorSchemas.ts @@ -0,0 +1,59 @@ +import { CardEditorType, IEditorConfig, StatCardEditorType } from "../types"; +import { getCardType } from "./getCardType"; +import { filterSchemaToUiSchema } from "./filterSchemaToUiSchema"; +import { CardEditorOptions } from "./EditorOptions"; +import { cloneObject } from "../../../util"; +import { IArcGISContext } from "../../../ArcGISContext"; + +/** + * get the editor schema and uiSchema defined for a layout card. + * The schema and uiSchema that are returned can be used to + * render a form UI (using the configuration editor). + * + * @param i18nScope translation scope to be interpolated into the uiSchema + * @param type editor type - corresponds to the returned uiSchema + * @param options optional hash of dynamic uiSchema element options + * @param context + * @returns + */ +export async function getCardEditorSchemas( + i18nScope: string, + type: CardEditorType, + options: CardEditorOptions, + context: IArcGISContext +): Promise { + const cardType = getCardType(type); + + // schema and uiSchema are dynamically imported based + // on the previous editor types + + let schema; + let uiSchema; + + switch (cardType) { + case "stat": + // get correct module + const schemaPromise = import("./metrics/MetricSchema"); + const uiSchemaPromise = { + "hub:card:stat": () => import("./metrics/StatCardUiSchema"), + }[type as StatCardEditorType]; + + // Allow imports to run in parallel + await Promise.all([schemaPromise, uiSchemaPromise()]).then( + ([schemaModuleResolved, statModuleResolved]) => { + const { MetricSchema } = schemaModuleResolved; + schema = cloneObject(MetricSchema); + uiSchema = statModuleResolved.buildUiSchema( + i18nScope, + options, + context + ); + } + ); + break; + } + // filter out properties not used in uiSchema + schema = filterSchemaToUiSchema(schema, uiSchema); + + return Promise.resolve({ schema, uiSchema }); +} diff --git a/packages/common/src/core/schemas/internal/getCardType.ts b/packages/common/src/core/schemas/internal/getCardType.ts new file mode 100644 index 00000000000..2a7a33fecf9 --- /dev/null +++ b/packages/common/src/core/schemas/internal/getCardType.ts @@ -0,0 +1,8 @@ +import { CardEditorType } from "../types"; + +/** + * Helper function to get card type string from full type + */ +export function getCardType(type: CardEditorType): string { + return type && type.split(":")[2]; +} diff --git a/packages/common/src/core/schemas/internal/getEntityEditorSchemas.ts b/packages/common/src/core/schemas/internal/getEditorSchemas.ts similarity index 87% rename from packages/common/src/core/schemas/internal/getEntityEditorSchemas.ts rename to packages/common/src/core/schemas/internal/getEditorSchemas.ts index 5e2952451d2..48aab8b627b 100644 --- a/packages/common/src/core/schemas/internal/getEntityEditorSchemas.ts +++ b/packages/common/src/core/schemas/internal/getEditorSchemas.ts @@ -1,6 +1,11 @@ import { cloneObject } from "../../../util"; -import { IEditorConfig } from "../../behaviors/IWithEditorBehavior"; -import { EditorType, IConfigurationSchema, IUiSchema } from "../types"; +import { + CardEditorType, + EditorType, + IConfigurationSchema, + IUiSchema, + IEditorConfig, +} from "../types"; import { filterSchemaToUiSchema } from "./filterSchemaToUiSchema"; import { SiteEditorType } from "../../../sites/_internal/SiteSchema"; import { ProjectEditorType } from "../../../projects/_internal/ProjectSchema"; @@ -10,23 +15,17 @@ import { PageEditorType } from "../../../pages/_internal/PageSchema"; import { ContentEditorType } from "../../../content/_internal/ContentSchema"; import { TemplateEditorType } from "../../../templates/_internal/TemplateSchema"; import { GroupEditorType } from "../../../groups/_internal/GroupSchema"; -import { ConfigurableEntity } from "./ConfigurableEntity"; -import { IArcGISContext } from "../../../ArcGISContext"; import { - IHubDiscussion, - IHubEditableContent, - IHubGroup, - IHubInitiative, - IHubInitiativeTemplate, - IHubPage, - IHubProject, - IHubSite, - IHubTemplate, -} from "../../../core/types"; + CardEditorOptions, + EditorOptions, + EntityEditorOptions, +} from "./EditorOptions"; +import { IArcGISContext } from "../../../ArcGISContext"; import { InitiativeTemplateEditorType } from "../../../initiative-templates/_internal/InitiativeTemplateSchema"; +import { getCardEditorSchemas } from "./getCardEditorSchemas"; /** - * get the editor schema and uiSchema defined for an entity. + * get the editor schema and uiSchema defined for an editor (either an entity or a card). * The schema and uiSchema that are returned can be used to * render a form UI (using the configuration editor) * @@ -35,19 +34,19 @@ import { InitiativeTemplateEditorType } from "../../../initiative-templates/_int * @param options optional hash of dynamic uiSchema element options * @returns */ -export async function getEntityEditorSchemas( +export async function getEditorSchemas( i18nScope: string, type: EditorType, - entity: ConfigurableEntity, + options: EditorOptions, context: IArcGISContext ): Promise { - const entityType = type.split(":")[1]; + const editorType = type.split(":")[1]; // schema and uiSchema are dynamically imported based on // the entity type and the provided editor type let schema: IConfigurationSchema; let uiSchema: IUiSchema; - switch (entityType) { + switch (editorType) { case "site": const { SiteSchema } = await import( "../../../sites/_internal/SiteSchema" @@ -68,7 +67,7 @@ export async function getEntityEditorSchemas( }[type as SiteEditorType](); uiSchema = await siteModule.buildUiSchema( i18nScope, - entity as IHubSite, + options as EntityEditorOptions, context ); @@ -90,7 +89,7 @@ export async function getEntityEditorSchemas( }[type as DiscussionEditorType](); uiSchema = await discussionModule.buildUiSchema( i18nScope, - entity as IHubDiscussion, + options as EntityEditorOptions, context ); @@ -110,7 +109,7 @@ export async function getEntityEditorSchemas( }[type as ProjectEditorType](); uiSchema = await projectModule.buildUiSchema( i18nScope, - entity as IHubProject, + options as EntityEditorOptions, context ); @@ -130,7 +129,7 @@ export async function getEntityEditorSchemas( }[type as InitiativeEditorType](); uiSchema = await initiativeModule.buildUiSchema( i18nScope, - entity as IHubInitiative, + options as EntityEditorOptions, context ); @@ -148,7 +147,7 @@ export async function getEntityEditorSchemas( }[type as PageEditorType](); uiSchema = await pageModule.buildUiSchema( i18nScope, - entity as IHubPage, + options as EntityEditorOptions, context ); @@ -170,7 +169,7 @@ export async function getEntityEditorSchemas( }[type as ContentEditorType](); uiSchema = await contentModule.buildUiSchema( i18nScope, - entity as IHubEditableContent, + options as EntityEditorOptions, context ); @@ -188,7 +187,7 @@ export async function getEntityEditorSchemas( }[type as TemplateEditorType](); uiSchema = await templateModule.buildUiSchema( i18nScope, - entity as IHubTemplate, + options as EntityEditorOptions, context ); @@ -210,7 +209,7 @@ export async function getEntityEditorSchemas( }[type as GroupEditorType](); uiSchema = await groupModule.buildUiSchema( i18nScope, - entity as IHubGroup, + options as EntityEditorOptions, context ); @@ -230,11 +229,21 @@ export async function getEntityEditorSchemas( uiSchema = await initiativeTemplateModule.buildUiSchema( i18nScope, - entity as IHubInitiativeTemplate, + options as EntityEditorOptions, context ); break; + + case "card": + const result = await getCardEditorSchemas( + i18nScope, + type as CardEditorType, + options as CardEditorOptions, + context + ); + schema = result.schema; + uiSchema = result.uiSchema; } // filter out properties not used in the UI schema diff --git a/packages/common/src/core/schemas/internal/getFeaturedImageUrl.ts b/packages/common/src/core/schemas/internal/getFeaturedImageUrl.ts index 0fee747710f..f9373534ed5 100644 --- a/packages/common/src/core/schemas/internal/getFeaturedImageUrl.ts +++ b/packages/common/src/core/schemas/internal/getFeaturedImageUrl.ts @@ -1,9 +1,9 @@ import { IArcGISContext } from "../../../ArcGISContext"; import { cacheBustUrl } from "../../../urls/cacheBustUrl"; -import { ConfigurableEntity } from "./ConfigurableEntity"; +import { EntityEditorOptions } from "./EditorOptions"; export function getFeaturedImageUrl( - entity: ConfigurableEntity, + options: EntityEditorOptions, context: IArcGISContext ) { const queryParams = context.isAuthenticated @@ -11,7 +11,7 @@ export function getFeaturedImageUrl( : ""; // TODO: Decide if the url should be passed in or plucked out of this deep path here return ( - entity.view?.featuredImageUrl && - cacheBustUrl(`${entity.view.featuredImageUrl}${queryParams}`) + options.view?.featuredImageUrl && + cacheBustUrl(`${options.view.featuredImageUrl}${queryParams}`) ); } diff --git a/packages/common/src/core/schemas/internal/getLocationExtent.ts b/packages/common/src/core/schemas/internal/getLocationExtent.ts index 0ade767504b..48279a4a863 100644 --- a/packages/common/src/core/schemas/internal/getLocationExtent.ts +++ b/packages/common/src/core/schemas/internal/getLocationExtent.ts @@ -1,15 +1,15 @@ import { bBoxToExtent, orgExtent } from "../../../extent"; import { IHubRequestOptions } from "../../../types"; -import { ConfigurableEntity } from "./ConfigurableEntity"; +import { EntityEditorOptions } from "./EditorOptions"; /** * Get the extent from the entity's location, if it has one. * Otherwise, fall back to using the org extent. */ export async function getLocationExtent( - entity: ConfigurableEntity, + options: EntityEditorOptions, hubRequestOptions: IHubRequestOptions ) { - return entity.location?.extent?.length - ? bBoxToExtent(entity.location.extent) + return options.location?.extent?.length + ? bBoxToExtent(options.location.extent) : await orgExtent(hubRequestOptions); } diff --git a/packages/common/src/core/schemas/internal/getLocationOptions.ts b/packages/common/src/core/schemas/internal/getLocationOptions.ts index 3ec077aaa69..b75567bbdd3 100644 --- a/packages/common/src/core/schemas/internal/getLocationOptions.ts +++ b/packages/common/src/core/schemas/internal/getLocationOptions.ts @@ -1,7 +1,7 @@ import { extentToBBox, orgExtent as orgExtent } from "../../../extent"; import { IHubRequestOptions } from "../../../types"; import { getTypeFromEntity } from "../../getTypeFromEntity"; -import { ConfigurableEntity } from "./ConfigurableEntity"; +import { EntityEditorOptions } from "./EditorOptions"; import { IHubLocation, IHubLocationOption } from "../../types/IHubLocation"; import { IExtent } from "@esri/arcgis-rest-types"; @@ -18,12 +18,12 @@ import { IExtent } from "@esri/arcgis-rest-types"; * location */ export async function getLocationOptions( - entity: ConfigurableEntity, + options: EntityEditorOptions, portalName: string, hubRequestOptions: IHubRequestOptions ): Promise { const defaultExtent: IExtent = await orgExtent(hubRequestOptions); - const location: IHubLocation = entity.location; + const location: IHubLocation = options.location; // Base options const optionsArray = [ @@ -43,7 +43,7 @@ export async function getLocationOptions( { label: "{{shared.fields.location.custom:translate}}", description: "{{shared.fields.location.customDescription:translate}}", - entityType: getTypeFromEntity(entity), + entityType: getTypeFromEntity(options), location: { type: "custom", spatialReference: defaultExtent.spatialReference, @@ -60,9 +60,9 @@ export async function getLocationOptions( return optionsArray.map((option) => { // If this is a new entity, select the custom option by default - if (!entity.id && option.location.type === "custom") { + if (!options.id && option.location.type === "custom") { option.selected = true; - } else if (entity.id && !location && option.location.type === "none") { + } else if (options.id && !location && option.location.type === "none") { option.selected = true; } else if (location?.type === option.location.type) { option.location = location; diff --git a/packages/common/src/core/schemas/internal/getTagItems.ts b/packages/common/src/core/schemas/internal/getTagItems.ts index 0dd20597435..af1cba99940 100644 --- a/packages/common/src/core/schemas/internal/getTagItems.ts +++ b/packages/common/src/core/schemas/internal/getTagItems.ts @@ -5,7 +5,7 @@ import { ISearchOptions, searchItems } from "@esri/arcgis-rest-portal"; import { IHubRequestOptions } from "../../../types"; import { IUiSchemaComboboxItem } from "../types"; -import { ConfigurableEntity } from "./ConfigurableEntity"; +import { EntityEditorOptions } from "./EditorOptions"; /** * Fetch the entity's org tags (limited to the top 200), * merge with any configured on the entity itself, and convert @@ -15,7 +15,7 @@ import { ConfigurableEntity } from "./ConfigurableEntity"; * be hoisted to hub.js */ export async function getTagItems( - entity: ConfigurableEntity, + options: EntityEditorOptions, orgId: string, hubRequestOptions: IHubRequestOptions ): Promise { @@ -60,7 +60,7 @@ export async function getTagItems( * and the tags fetched from the orgs, then remove duplicates, filter out * any empty values and convert them to the IUiSchemaComboboxItem format */ - const entityTags = entity.tags || []; + const entityTags = options.tags || []; return [...new Set([...tagsAgg.values.map((t) => t.value), ...entityTags])] .filter((t) => t) .map((t) => ({ value: t })); diff --git a/packages/common/src/core/schemas/internal/getThumbnailUiSchemaElement.ts b/packages/common/src/core/schemas/internal/getThumbnailUiSchemaElement.ts index 352aef0768c..18bfd7a8d71 100644 --- a/packages/common/src/core/schemas/internal/getThumbnailUiSchemaElement.ts +++ b/packages/common/src/core/schemas/internal/getThumbnailUiSchemaElement.ts @@ -1,9 +1,9 @@ -import { IHubItemEntity } from "../../types/IHubItemEntity"; import { IUiSchemaElement, IUiSchemaMessage, UiSchemaMessageTypes, } from "../types"; +import { EntityEditorOptions } from "./EditorOptions"; /** * Returns the UI schema element needed to render @@ -15,13 +15,13 @@ import { */ export function getThumbnailUiSchemaElement( i18nScope: string, - entity: IHubItemEntity + options: EntityEditorOptions ): IUiSchemaElement { const messages: IUiSchemaMessage[] = []; // Advise the user if the entity's thumbnail is either of the default values if ( - !entity.thumbnail || - entity.thumbnail === "thumbnail/ago_downloaded.png" + !options.thumbnail || + options.thumbnail === "thumbnail/ago_downloaded.png" ) { messages.push({ type: UiSchemaMessageTypes.custom, @@ -38,7 +38,7 @@ export function getThumbnailUiSchemaElement( type: "Control", options: { control: "hub-field-input-image-picker", - imgSrc: entity.thumbnailUrl, + imgSrc: options.thumbnailUrl, maxWidth: 727, maxHeight: 484, aspectRatio: 1.5, diff --git a/packages/common/src/core/schemas/internal/metrics/MetricSchema.ts b/packages/common/src/core/schemas/internal/metrics/MetricSchema.ts new file mode 100644 index 00000000000..7dba20f230e --- /dev/null +++ b/packages/common/src/core/schemas/internal/metrics/MetricSchema.ts @@ -0,0 +1,130 @@ +import { IConfigurationSchema, ALIGNMENTS, DROP_SHADOWS } from "../../types"; +import { UNIT_POSITIONS, VISUAL_INTEREST, LAYOUTS, SOURCE } from "./interfaces"; + +// when the user selects the dataViz uiSchema/layout, we show fewer visual interest options +const ALTERNATE_VISUAL_INTEREST = Object.keys(VISUAL_INTEREST).filter( + (x) => x !== VISUAL_INTEREST.sparkline +); + +export const MetricSchema: IConfigurationSchema = { + type: "object", + required: [], + properties: { + type: { + type: "string", + enum: Object.keys(SOURCE), + default: SOURCE.dynamic, + }, + cardTitle: { + type: "string", + }, + value: { + type: "string", + }, + dynamicMetric: { + type: "object", + }, + allowUnitFormatting: { + type: "boolean", + default: false, + }, + unit: { + type: "string", + }, + unitPosition: { + type: "string", + default: UNIT_POSITIONS.after, + enum: Object.keys(UNIT_POSITIONS), + }, + serverTimeout: { + type: "number", + maximum: 95, + minimum: 5, + default: 10, + }, + subtitle: { + type: "string", + }, + trailingText: { + type: "string", + }, + textAlign: { + type: "string", + default: ALIGNMENTS.start, + }, + allowLink: { + type: "boolean", + default: false, + }, + allowDynamicLink: { + type: "boolean", + default: true, + }, + sourceLink: { + type: "string", + }, + sourceTitle: { + type: "string", + }, + valueColor: { + type: "string", + }, + layout: { + type: "string", + default: LAYOUTS.simple, + enum: Object.keys(LAYOUTS), + }, + dropShadow: { + type: "string", + default: DROP_SHADOWS.none, + enum: Object.keys(DROP_SHADOWS), + }, + visualInterest: { + type: "string", + default: VISUAL_INTEREST.none, + if: { properties: { layout: { const: "simple" } } }, + then: { enum: Object.keys(VISUAL_INTEREST) }, + else: { enum: ALTERNATE_VISUAL_INTEREST }, + }, + shareable: { + type: "boolean", + default: false, + }, + shareableByValue: { + type: "boolean", + default: false, + }, + shareableOnHover: { + type: "boolean", + default: true, + }, + popoverTitle: { + type: "string", + }, + popoverDescription: { + type: "string", + }, + }, + allOf: [{ $ref: "#/definitions/if-source-title-then-source-link" }], + definitions: { + // TODO: reimplement popover with layouts release + "if-layout-moreinfo-then-require-popover-title-description": { + if: { + properties: { layout: { const: LAYOUTS.moreInfo } }, + required: ["layout"], + }, + then: { + required: ["popoverTitle", "popoverDescription"], + }, + }, + "if-source-title-then-source-link": { + if: { + properties: { sourceTitle: { not: { enum: ["", undefined] } } }, + required: ["sourceTitle"], + }, + then: { + required: ["sourceLink"], + }, + }, + }, +}; diff --git a/packages/common/src/core/schemas/internal/metrics/StatCardUiSchema.ts b/packages/common/src/core/schemas/internal/metrics/StatCardUiSchema.ts new file mode 100644 index 00000000000..4edd20d925e --- /dev/null +++ b/packages/common/src/core/schemas/internal/metrics/StatCardUiSchema.ts @@ -0,0 +1,389 @@ +import { IArcGISContext } from "../../../../ArcGISContext"; +import { IStatCardEditorOptions } from "../EditorOptions"; +import { UiSchemaRuleEffects, IUiSchema } from "../../types"; + +/** + * @private + * Exports the uiSchema of the stat card + * @returns + */ +export const buildUiSchema = ( + i18nScope: string, + config: IStatCardEditorOptions, + context: IArcGISContext +): IUiSchema => { + const { themeColors } = config; + return { + type: "Layout", + elements: [ + { + type: "Section", + labelKey: `${i18nScope}.statistic.sectionTitle`, + options: { + section: "block", + open: true, + }, + elements: [ + { + type: "Control", + scope: "/properties/type", + labelKey: `${i18nScope}.statistic.type.label`, + options: { + control: "hub-field-input-tile-select", + enum: { + i18nScope: `${i18nScope}.statistic.type.enum`, + }, + }, + }, + { + labelKey: `${i18nScope}.statistic.displayValue`, + scope: "/properties/value", + type: "Control", + rule: SHOW_FOR_STATIC_RULE, + }, + { + scope: "/properties/dynamicMetric", + type: "Control", + labelKey: `${i18nScope}.statistic.dataSource`, + rule: SHOW_FOR_DYNAMIC_RULE, + options: { + control: "hub-composite-input-service-query-metric", + }, + }, + { + type: "Section", + labelKey: `${i18nScope}.formatting.sectionTitle`, + scope: "/properties/allowUnitFormatting", + options: { + section: "subblock", + toggleDisplay: "switch", + scope: "/properties/unit", + }, + elements: [ + { + labelKey: `${i18nScope}.formatting.unit.label`, + scope: "/properties/unit", + type: "Control", + rule: SHOW_FOR_UNITS_SECTION_ENABLED, + options: { + helperText: { + labelKey: `${i18nScope}.formatting.unit.helperText`, + placement: "bottom", + }, + }, + }, + { + labelKey: `${i18nScope}.formatting.unitPosition.label`, + scope: "/properties/unitPosition", + type: "Control", + rule: SHOW_FOR_UNITS_SECTION_ENABLED, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `${i18nScope}.formatting.unitPosition.enum`, + }, + }, + }, + ], + }, + { + type: "Section", + labelKey: `${i18nScope}.advancedConfig.label`, + options: { + section: "subblock", + }, + rule: SHOW_FOR_DYNAMIC_RULE, + elements: [ + { + scope: "/properties/serverTimeout", + labelKey: `${i18nScope}.advancedConfig.serverTimeout.label`, + type: "Control", + rule: SHOW_FOR_DYNAMIC_RULE, + options: { + control: "hub-field-input-input", + type: "number", + helperText: { + labelKey: `${i18nScope}.advancedConfig.serverTimeout.helperText`, + placement: "bottom", + }, + messages: [ + { + type: "ERROR", + keyword: "type", + labelKey: `${i18nScope}.advancedConfig.serverTimeout.errors.type`, + icon: true, + }, + { + type: "ERROR", + keyword: "minimum", + labelKey: `${i18nScope}.advancedConfig.serverTimeout.errors.minimum`, + icon: true, + }, + { + type: "ERROR", + keyword: "maximum", + labelKey: `${i18nScope}.advancedConfig.serverTimeout.errors.maximum`, + icon: true, + }, + ], + }, + }, + ], + }, + ], + }, + { + type: "Section", + labelKey: `${i18nScope}.details.sectionTitle`, + options: { + section: "block", + }, + elements: [ + { + labelKey: `${i18nScope}.details.title`, + scope: "/properties/cardTitle", + type: "Control", + }, + { + labelKey: `${i18nScope}.details.subtitle`, + scope: "/properties/subtitle", + type: "Control", + }, + { + labelKey: `${i18nScope}.details.trailingText`, + scope: "/properties/trailingText", + type: "Control", + }, + { + type: "Section", + labelKey: `${i18nScope}.details.link.sectionTitle`, + scope: "/properties/allowLink", + options: { + section: "subblock", + toggleDisplay: "switch", + }, + rule: SHOW_FOR_STATIC_RULE, + elements: [ + { + labelKey: `${i18nScope}.details.link.sourceLink`, + scope: "/properties/sourceLink", + type: "Control", + rule: SHOW_FOR_LINK_SECTION_ENABLED_AND_STATIC, + options: { + placeholder: "https://esri.com", + messages: [ + { + type: "ERROR", + keyword: "required", + icon: true, + labelKey: `${i18nScope}.errors.sourceLink.required`, + allowShowBeforeInteract: true, + }, + ], + }, + }, + { + labelKey: `${i18nScope}.details.link.sourceTitle`, + scope: "/properties/sourceTitle", + type: "Control", + rule: SHOW_FOR_LINK_SECTION_ENABLED_AND_STATIC, + }, + ], + }, + { + type: "Control", + scope: "/properties/allowDynamicLink", + labelKey: `${i18nScope}.details.allowDynamicLink`, + rule: SHOW_FOR_DYNAMIC_RULE, + options: { + layout: "inline-space-between", + control: "hub-field-input-switch", + }, + }, + ], + }, + { + type: "Section", + labelKey: `${i18nScope}.appearance.sectionTitle`, + options: { section: "block" }, + elements: [ + { + labelKey: `${i18nScope}.appearance.layout.label`, + scope: "/properties/layout", + type: "Control", + rule: HIDE_FOR_ALL, // Temporary while no layouts + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `${i18nScope}.layout.enum`, + }, + }, + }, + { + labelKey: `${i18nScope}.appearance.textAlign`, + scope: "/properties/textAlign", + type: "Control", + rule: HIDE_FOR_DATA_VIZ_RULE, + options: { + control: "hub-field-input-alignment", + }, + }, + { + labelKey: `${i18nScope}.appearance.valueColor`, + scope: "/properties/valueColor", + type: "Control", + options: { + control: "hub-field-input-color", + savedColors: themeColors, + }, + }, + { + labelKey: `${i18nScope}.appearance.dropShadow.label`, + scope: "/properties/dropShadow", + type: "Control", + rule: HIDE_FOR_ALL, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `${i18nScope}.appearance.dropShadow.enum`, + }, + }, + }, + + { + labelKey: `${i18nScope}.appearance.visualInterest.label`, + scope: "/properties/visualInterest", + type: "Control", + rule: HIDE_FOR_ALL, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `${i18nScope}.appearance.visualInterest.enum`, + }, + }, + }, + { + labelKey: `${i18nScope}.appearance.popoverTitle`, + scope: "/properties/popoverTitle", + type: "Control", + rule: SHOW_FOR_MORE_INFO_RULE, + }, + { + labelKey: `${i18nScope}.appearance.popoverDescription`, + scope: "/properties/popoverDescription", + type: "Control", + rule: SHOW_FOR_MORE_INFO_RULE, + }, + ], + }, + { + type: "Section", + labelKey: `${i18nScope}.sharing.sectionTitle`, + options: { + section: "block", + }, + elements: [ + { + labelKey: `${i18nScope}.sharing.showShareIcon`, + scope: "/properties/shareable", + type: "Control", + options: { + helperText: { + labelKey: `${i18nScope}.sharing.showShareIconHelperText`, + }, + control: "hub-field-input-switch", + layout: "inline-space-between", + }, + }, + { + labelKey: `${i18nScope}.sharing.shareableByValue`, + scope: "/properties/shareableByValue", + type: "Control", + rule: HIDE_FOR_ALL, + }, + { + labelKey: `${i18nScope}.sharing.shareableOnHover.label`, + scope: "/properties/shareableOnHover", + type: "Control", + rule: SHOW_FOR_SHARING_RULE, + options: { + control: "hub-field-input-switch", + helperText: { + labelKey: `${i18nScope}.sharing.shareableOnHover.helperText.label`, + }, + layout: "inline-space-between", + }, + }, + ], + }, + ], + }; +}; + +const HIDE_FOR_ALL = { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/type", + schema: { enum: [undefined, "static", "dynamic"] }, + }, +}; + +const HIDE_FOR_DATA_VIZ_RULE = { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/layout", + schema: { enum: ["dataViz"] }, + }, +}; + +const SHOW_FOR_MORE_INFO_RULE = { + effect: UiSchemaRuleEffects.SHOW, + condition: { + scope: "/properties/layout", + schema: { const: "moreInfo" }, + }, +}; + +const SHOW_FOR_DYNAMIC_RULE = { + condition: { + scope: "/properties/type", + schema: { const: "dynamic" }, + }, + effect: UiSchemaRuleEffects.SHOW, +}; + +const SHOW_FOR_STATIC_RULE = { + condition: { + scope: "/properties/type", + schema: { const: "static" }, + }, + effect: UiSchemaRuleEffects.SHOW, +}; + +const SHOW_FOR_SHARING_RULE = { + condition: { + scope: "/properties/shareable", + schema: { const: true }, + }, + effect: UiSchemaRuleEffects.SHOW, +}; + +const SHOW_FOR_UNITS_SECTION_ENABLED = { + condition: { + schema: { const: true }, + scope: "/properties/allowUnitFormatting", + }, + effect: UiSchemaRuleEffects.SHOW, +}; + +const SHOW_FOR_LINK_SECTION_ENABLED_AND_STATIC = { + condition: { + schema: { + properties: { + type: { const: "static" }, + allowLink: { const: true }, + }, + }, + }, + effect: UiSchemaRuleEffects.SHOW, +}; diff --git a/packages/common/src/core/schemas/internal/metrics/interfaces.ts b/packages/common/src/core/schemas/internal/metrics/interfaces.ts new file mode 100644 index 00000000000..830f4adac51 --- /dev/null +++ b/packages/common/src/core/schemas/internal/metrics/interfaces.ts @@ -0,0 +1,25 @@ +export enum LAYOUTS { + simple = "simple", + dataViz = "dataViz", + moreInfo = "moreInfo", +} +export enum SCALE { + small = "s", + medium = "m", + large = "l", +} +export enum UNIT_POSITIONS { + before = "before", + after = "after", + below = "below", +} +export enum VISUAL_INTEREST { + none = "none", + sparkline = "sparkline", + icon = "icon", + logo = "logo", +} +export enum SOURCE { + dynamic = "dynamic", + static = "static", +} diff --git a/packages/common/src/core/schemas/types.ts b/packages/common/src/core/schemas/types.ts index 6344dcc82bd..cc7d830fbb8 100644 --- a/packages/common/src/core/schemas/types.ts +++ b/packages/common/src/core/schemas/types.ts @@ -11,12 +11,17 @@ import { TemplateEditorTypes } from "../../templates/_internal/TemplateSchema"; import { GroupEditorTypes } from "../../groups/_internal/GroupSchema"; import { InitiativeTemplateEditorTypes } from "../../initiative-templates/_internal/InitiativeTemplateSchema"; +export interface IEditorConfig { + schema: IConfigurationSchema; + uiSchema: IUiSchema; +} + /** * Defines the possible editor type values - these correspond * to the supported/defined uiSchema configurations */ -export type EditorType = (typeof validEditorTypes)[number]; -export const validEditorTypes = [ +export type EntityEditorType = (typeof validEntityEditorTypes)[number]; +export const validEntityEditorTypes = [ ...ProjectEditorTypes, ...ContentEditorTypes, ...InitiativeEditorTypes, @@ -28,6 +33,30 @@ export const validEditorTypes = [ ...InitiativeTemplateEditorTypes, ] as const; +/** Defines the possible editor type values for a stat card. These + * correspond to the supported/defined uiSchema configurations. This should + * have its own signature in the getEditorConfig function. + */ +export type StatCardEditorType = (typeof validStatCardEditorTypes)[number]; +export const validStatCardEditorTypes = ["hub:card:stat"] as const; + +/** + * Defines the possible editor type values for any layout card. These + * correspond to the supported/defined uiSchema configurations for cards. + */ +export type CardEditorType = (typeof validCardEditorTypes)[number]; +export const validCardEditorTypes = [...validStatCardEditorTypes] as const; + +/** + * All supported editor types - these "map" + * to defined schema/uiSchema configurations + */ +export type EditorType = (typeof validEditorTypes)[number]; +export const validEditorTypes = [ + ...validEntityEditorTypes, + ...validCardEditorTypes, +] as const; + export enum UiSchemaRuleEffects { SHOW = "SHOW", HIDE = "HIDE", @@ -151,3 +180,19 @@ export interface IUiSchemaCondition { scope?: string; schema: IConfigurationSchema; } + +export enum ALIGNMENTS { + start = "start", + center = "center", + end = "end", +} +export enum CORNERS { + square = "square", + round = "round", +} +export enum DROP_SHADOWS { + none = "none", + low = "low", + medium = "medium", + heavy = "heavy", +} diff --git a/packages/common/src/discussions/HubDiscussion.ts b/packages/common/src/discussions/HubDiscussion.ts index 4a8d8499865..a6c447cc40f 100644 --- a/packages/common/src/discussions/HubDiscussion.ts +++ b/packages/common/src/discussions/HubDiscussion.ts @@ -9,10 +9,8 @@ import { import { HubItemEntity } from "../core/HubItemEntity"; import { fetchDiscussion } from "./fetch"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { cloneObject } from "../util"; import { DiscussionEditorType } from "./_internal/DiscussionSchema"; import { enrichEntity } from "../core/enrichEntity"; diff --git a/packages/common/src/discussions/_internal/DiscussionUiSchemaCreate.ts b/packages/common/src/discussions/_internal/DiscussionUiSchemaCreate.ts index 45b4f59ee4a..ae8d81e3ee2 100644 --- a/packages/common/src/discussions/_internal/DiscussionUiSchemaCreate.ts +++ b/packages/common/src/discussions/_internal/DiscussionUiSchemaCreate.ts @@ -1,6 +1,6 @@ import { IUiSchema } from "../../core"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubDiscussion } from "../../core/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private * constructs the complete create uiSchema for Hub Discussions. @@ -9,7 +9,7 @@ import { IHubDiscussion } from "../../core/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubDiscussion, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/discussions/_internal/DiscussionUiSchemaEdit.ts b/packages/common/src/discussions/_internal/DiscussionUiSchemaEdit.ts index cb227d2095e..98f6f2aa86a 100644 --- a/packages/common/src/discussions/_internal/DiscussionUiSchemaEdit.ts +++ b/packages/common/src/discussions/_internal/DiscussionUiSchemaEdit.ts @@ -1,12 +1,12 @@ import { IUiSchema } from "../../core/schemas/types"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubDiscussion } from "../../core/types"; import { getFeaturedImageUrl } from "../../core/schemas/internal/getFeaturedImageUrl"; import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -16,7 +16,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubDiscussion, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -84,14 +84,14 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), { labelKey: `${i18nScope}.fields.featuredImage.label`, scope: "/properties/view/properties/featuredImage", type: "Control", options: { control: "hub-field-input-image-picker", - imgSrc: getFeaturedImageUrl(entity, context), + imgSrc: getFeaturedImageUrl(options, context), maxWidth: 727, maxHeight: 484, aspectRatio: 1.5, @@ -122,7 +122,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -158,11 +158,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/discussions/_internal/DiscussionUiSchemaSettings.ts b/packages/common/src/discussions/_internal/DiscussionUiSchemaSettings.ts index d1d1c0ece64..dd1ef2e71ad 100644 --- a/packages/common/src/discussions/_internal/DiscussionUiSchemaSettings.ts +++ b/packages/common/src/discussions/_internal/DiscussionUiSchemaSettings.ts @@ -1,6 +1,6 @@ -import { IHubDiscussion } from "../../core/types"; import { IArcGISContext } from "../../ArcGISContext"; import { IUiSchema } from "../../core/schemas/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IUiSchema } from "../../core/schemas/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubDiscussion, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/groups/HubGroup.ts b/packages/common/src/groups/HubGroup.ts index 2eef961da9c..5b440f4ade2 100644 --- a/packages/common/src/groups/HubGroup.ts +++ b/packages/common/src/groups/HubGroup.ts @@ -19,10 +19,8 @@ import { IWithStoreBehavior } from "../core/behaviors/IWithStoreBehavior"; import { IWithPermissionBehavior } from "../core/behaviors/IWithPermissionBehavior"; import { IArcGISContext } from "../ArcGISContext"; import { cloneObject } from "../util"; -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; import { setGroupThumbnail } from "./setGroupThumbnail"; import { getGroupThumbnailUrl } from "../search/utils"; diff --git a/packages/common/src/groups/_internal/GroupUiSchemaDiscussions.ts b/packages/common/src/groups/_internal/GroupUiSchemaDiscussions.ts index 0211c817ab2..9cba6d2e450 100644 --- a/packages/common/src/groups/_internal/GroupUiSchemaDiscussions.ts +++ b/packages/common/src/groups/_internal/GroupUiSchemaDiscussions.ts @@ -1,6 +1,6 @@ -import { IHubGroup } from "../../core/types"; import { IArcGISContext } from "../../ArcGISContext"; import { IUiSchema } from "../../core/schemas/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private * settings uiSchema for Hub Discussions - this @@ -9,7 +9,7 @@ import { IUiSchema } from "../../core/schemas/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubGroup, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/groups/_internal/GroupUiSchemaEdit.ts b/packages/common/src/groups/_internal/GroupUiSchemaEdit.ts index 81b3857c31d..c0873a55336 100644 --- a/packages/common/src/groups/_internal/GroupUiSchemaEdit.ts +++ b/packages/common/src/groups/_internal/GroupUiSchemaEdit.ts @@ -1,6 +1,6 @@ import { IUiSchema } from "../../core/schemas/types"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubGroup } from "../../core/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IHubGroup } from "../../core/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubGroup, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -51,7 +51,7 @@ export const buildUiSchema = async ( type: "Control", options: { control: "hub-field-input-image-picker", - imgSrc: entity.thumbnailUrl, + imgSrc: options.thumbnailUrl, maxWidth: 727, maxHeight: 484, aspectRatio: 1, diff --git a/packages/common/src/groups/_internal/GroupUiSchemaSettings.ts b/packages/common/src/groups/_internal/GroupUiSchemaSettings.ts index 3d8aa2b0eed..c065ed12de1 100644 --- a/packages/common/src/groups/_internal/GroupUiSchemaSettings.ts +++ b/packages/common/src/groups/_internal/GroupUiSchemaSettings.ts @@ -1,6 +1,6 @@ import { IUiSchema } from "../../core"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubGroup } from "../../core/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IHubGroup } from "../../core/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubGroup, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -31,7 +31,7 @@ export const buildUiSchema = async ( `{{${i18nScope}.fields.membershipAccess.collab:translate}}`, `{{${i18nScope}.fields.membershipAccess.any:translate}}`, ], - disabled: [false, false, entity.isSharedUpdate], + disabled: [false, false, options.isSharedUpdate], }, }, { diff --git a/packages/common/src/initiative-templates/HubInitiativeTemplate.ts b/packages/common/src/initiative-templates/HubInitiativeTemplate.ts index e8aec4e7726..acd8e69330b 100644 --- a/packages/common/src/initiative-templates/HubInitiativeTemplate.ts +++ b/packages/common/src/initiative-templates/HubInitiativeTemplate.ts @@ -9,14 +9,9 @@ import { IHubInitiativeTemplateEditor, HubEntity, } from "../core"; - -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; -import { EditorType } from "../core/schemas/types"; - import { IArcGISContext } from ".."; import { Catalog } from "../search"; import { DEFAULT_INITIATIVE_TEMPLATE } from "./defaults"; @@ -30,6 +25,7 @@ import { deleteInitiativeTemplate, } from "./edit"; import { enrichEntity } from "../core/enrichEntity"; +import { InitiativeTemplateEditorType } from "./_internal/InitiativeTemplateSchema"; /** * Hub Initiative Template Class @@ -156,7 +152,7 @@ export class HubInitiativeTemplate */ async getEditorConfig( i18nScope: string, - type: EditorType + type: InitiativeTemplateEditorType ): Promise { // delegate to the schema subsystem return getEditorConfig(i18nScope, type, this.entity, this.context); diff --git a/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts b/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts index f57e266ed57..a464a35fa80 100644 --- a/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts +++ b/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts @@ -1,5 +1,5 @@ import { IArcGISContext } from "../.."; -import { IHubInitiativeTemplate } from "../../core"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; import { IUiSchema, UiSchemaMessageTypes } from "../../core/schemas/types"; import { getRecommendedTemplatesCatalog } from "./getRecommendedTemplatesCatalog"; @@ -17,7 +17,7 @@ import { getRecommendedTemplatesCatalog } from "./getRecommendedTemplatesCatalog */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubInitiativeTemplate, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -90,7 +90,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), ], }, { diff --git a/packages/common/src/initiatives/HubInitiative.ts b/packages/common/src/initiatives/HubInitiative.ts index 98f80da9886..459a12eac56 100644 --- a/packages/common/src/initiatives/HubInitiative.ts +++ b/packages/common/src/initiatives/HubInitiative.ts @@ -26,12 +26,12 @@ import { IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior, - IEditorConfig, IResolvedMetric, IWithCardBehavior, IWithEditorBehavior, IHubInitiativeEditor, } from "../core"; +import { IEditorConfig } from "../core/schemas/types"; import { enrichEntity } from "../core/enrichEntity"; /** diff --git a/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts b/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts index d5c42a6ae2c..f11867cd92b 100644 --- a/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts +++ b/packages/common/src/initiatives/_internal/InitiativeUiSchemaCreate.ts @@ -1,10 +1,10 @@ import { IArcGISContext } from "../../ArcGISContext"; import { checkPermission } from "../../permissions/checkPermission"; -import { IHubInitiative } from "../../core/types"; import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getSharableGroupsComboBoxItems"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -17,7 +17,7 @@ import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getS */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubInitiative, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -93,11 +93,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/initiatives/_internal/InitiativeUiSchemaEdit.ts b/packages/common/src/initiatives/_internal/InitiativeUiSchemaEdit.ts index 85872496531..17ee08676a7 100644 --- a/packages/common/src/initiatives/_internal/InitiativeUiSchemaEdit.ts +++ b/packages/common/src/initiatives/_internal/InitiativeUiSchemaEdit.ts @@ -1,12 +1,12 @@ import { IUiSchema } from "../../core/schemas/types"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubInitiative } from "../../core/types"; import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getFeaturedContentCatalogs } from "../../core/schemas/internal/getFeaturedContentCatalogs"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -16,7 +16,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubInitiative, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -66,7 +66,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), { labelKey: `${i18nScope}.fields.tags.label`, scope: "/properties/tags", @@ -74,7 +74,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -119,11 +119,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/pages/HubPage.ts b/packages/common/src/pages/HubPage.ts index eb2cc23fd1a..5be89ce4a3a 100644 --- a/packages/common/src/pages/HubPage.ts +++ b/packages/common/src/pages/HubPage.ts @@ -14,10 +14,8 @@ import { import { getEditorConfig } from "../core/schemas/getEditorConfig"; import { IArcGISContext } from "../ArcGISContext"; import { HubItemEntity } from "../core/HubItemEntity"; -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { createPage, deletePage, fetchPage, updatePage } from "./HubPages"; diff --git a/packages/common/src/pages/_internal/PageUiSchemaEdit.ts b/packages/common/src/pages/_internal/PageUiSchemaEdit.ts index 46bac792502..1923d47a6ba 100644 --- a/packages/common/src/pages/_internal/PageUiSchemaEdit.ts +++ b/packages/common/src/pages/_internal/PageUiSchemaEdit.ts @@ -1,11 +1,11 @@ import { IUiSchema } from "../../core/schemas/types"; import { IArcGISContext } from "../../ArcGISContext"; -import { IHubPage } from "../../core/types"; import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -15,7 +15,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubPage, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -65,7 +65,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), { labelKey: `${i18nScope}.fields.tags.label`, scope: "/properties/tags", @@ -73,7 +73,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -118,11 +118,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/projects/HubProject.ts b/packages/common/src/projects/HubProject.ts index 8c8bc4e8283..55cac0dfad1 100644 --- a/packages/common/src/projects/HubProject.ts +++ b/packages/common/src/projects/HubProject.ts @@ -14,10 +14,8 @@ import { import { Catalog } from "../search/Catalog"; import { IArcGISContext } from "../ArcGISContext"; import { HubItemEntity } from "../core/HubItemEntity"; -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; diff --git a/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts b/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts index 2924f8001b8..8f8820d7dfb 100644 --- a/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts +++ b/packages/common/src/projects/_internal/ProjectUiSchemaCreate.ts @@ -1,10 +1,10 @@ import { IArcGISContext } from "../../ArcGISContext"; import { checkPermission } from "../../permissions/checkPermission"; -import { IHubProject } from "../../core/types"; import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getSharableGroupsComboBoxItems"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -14,7 +14,7 @@ import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getS */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubProject, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -101,11 +101,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts b/packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts index dfecb8b88bf..beae89fe11a 100644 --- a/packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts +++ b/packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts @@ -1,5 +1,4 @@ import { IArcGISContext } from "../../ArcGISContext"; -import { IHubProject } from "../../core/types"; import { IUiSchema } from "../../core/schemas/types"; import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems"; import { getFeaturedContentCatalogs } from "../../core/schemas/internal/getFeaturedContentCatalogs"; @@ -8,6 +7,7 @@ import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -17,7 +17,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubProject, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -73,7 +73,7 @@ export const buildUiSchema = async ( type: "Control", options: { control: "hub-field-input-image-picker", - imgSrc: getFeaturedImageUrl(entity, context), + imgSrc: getFeaturedImageUrl(options, context), maxWidth: 727, maxHeight: 484, aspectRatio: 1.5, @@ -112,11 +112,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), @@ -135,7 +135,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -163,7 +163,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), ], }, { diff --git a/packages/common/src/sites/HubSite.ts b/packages/common/src/sites/HubSite.ts index 55ba0617713..4ba9dba6f67 100644 --- a/packages/common/src/sites/HubSite.ts +++ b/packages/common/src/sites/HubSite.ts @@ -12,10 +12,8 @@ import { IArcGISContext } from "../ArcGISContext"; import { HubItemEntity } from "../core/HubItemEntity"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; import { enrichEntity } from "../core/enrichEntity"; -import { - IEditorConfig, - IWithEditorBehavior, -} from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; +import { IWithEditorBehavior } from "../core/behaviors/IWithEditorBehavior"; import { DEFAULT_SITE } from "./defaults"; import { createSite, diff --git a/packages/common/src/sites/_internal/SiteUiSchemaCreate.ts b/packages/common/src/sites/_internal/SiteUiSchemaCreate.ts index c1149bc82e0..7a63e2e38ae 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaCreate.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaCreate.ts @@ -1,10 +1,10 @@ import { IArcGISContext } from "../../ArcGISContext"; import { checkPermission } from "../../permissions/checkPermission"; -import { IHubSite } from "../../core/types"; import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types"; import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent"; import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getSharableGroupsComboBoxItems"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -17,7 +17,7 @@ import { getSharableGroupsComboBoxItems } from "../../core/schemas/internal/getS */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubSite, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -93,11 +93,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/sites/_internal/SiteUiSchemaDiscussions.ts b/packages/common/src/sites/_internal/SiteUiSchemaDiscussions.ts index 2be613024d6..71accb8b425 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaDiscussions.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaDiscussions.ts @@ -1,6 +1,6 @@ -import { IHubSite } from "../../core/types"; import { IArcGISContext } from "../../ArcGISContext"; import { IUiSchema } from "../../core/schemas/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IUiSchema } from "../../core/schemas/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubSite, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/sites/_internal/SiteUiSchemaEdit.ts b/packages/common/src/sites/_internal/SiteUiSchemaEdit.ts index 741ad9d2b66..7efb5a99cdb 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaEdit.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaEdit.ts @@ -4,8 +4,8 @@ import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions"; import { getTagItems } from "../../core/schemas/internal/getTagItems"; import { IUiSchema } from "../../core/schemas/types"; -import { IHubSite } from "../../core/types"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -15,7 +15,7 @@ import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThum */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubSite, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -65,7 +65,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), { labelKey: `${i18nScope}.fields.tags.label`, scope: "/properties/tags", @@ -73,7 +73,7 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-combobox", items: await getTagItems( - entity, + options, context.portal.id, context.hubRequestOptions ), @@ -118,11 +118,11 @@ export const buildUiSchema = async ( options: { control: "hub-field-input-location-picker", extent: await getLocationExtent( - entity, + options, context.hubRequestOptions ), options: await getLocationOptions( - entity, + options, context.portal.name, context.hubRequestOptions ), diff --git a/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts b/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts index 2499898c169..4ca513d4ac7 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaFollowers.ts @@ -1,6 +1,6 @@ import { IArcGISContext } from "../../ArcGISContext"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; import { IUiSchema } from "../../core/schemas/types"; -import { IHubSite } from "../../core/types"; /** * @private @@ -11,7 +11,7 @@ import { IHubSite } from "../../core/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubSite, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/sites/_internal/SiteUiSchemaSettings.ts b/packages/common/src/sites/_internal/SiteUiSchemaSettings.ts index 304e3e279f9..65e579f4c9b 100644 --- a/packages/common/src/sites/_internal/SiteUiSchemaSettings.ts +++ b/packages/common/src/sites/_internal/SiteUiSchemaSettings.ts @@ -1,6 +1,6 @@ -import { IHubSite } from "../../core/types"; import { IArcGISContext } from "../../ArcGISContext"; import { IUiSchema } from "../../core/schemas/types"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; /** * @private @@ -10,7 +10,7 @@ import { IUiSchema } from "../../core/schemas/types"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubSite, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { diff --git a/packages/common/src/templates/HubTemplate.ts b/packages/common/src/templates/HubTemplate.ts index 174f15c8df0..49ca56935d0 100644 --- a/packages/common/src/templates/HubTemplate.ts +++ b/packages/common/src/templates/HubTemplate.ts @@ -1,6 +1,6 @@ import { IArcGISContext } from "../ArcGISContext"; import { getEditorConfig } from "../core/schemas/getEditorConfig"; -import { IEditorConfig } from "../core/behaviors/IWithEditorBehavior"; +import { IEditorConfig } from "../core/schemas/types"; import { HubItemEntity } from "../core/HubItemEntity"; import { IHubTemplate, IHubTemplateEditor } from "../core/types/IHubTemplate"; import { TemplateEditorType } from "./_internal/TemplateSchema"; diff --git a/packages/common/src/templates/_internal/TemplateUiSchemaEdit.ts b/packages/common/src/templates/_internal/TemplateUiSchemaEdit.ts index e17d95c7d2d..981b5eea192 100644 --- a/packages/common/src/templates/_internal/TemplateUiSchemaEdit.ts +++ b/packages/common/src/templates/_internal/TemplateUiSchemaEdit.ts @@ -1,7 +1,7 @@ import { IArcGISContext } from "../../ArcGISContext"; +import { EntityEditorOptions } from "../../core/schemas/internal/EditorOptions"; import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement"; import { IUiSchema, UiSchemaMessageTypes } from "../../core/schemas/types"; -import { IHubTemplate } from "../../core/types/IHubTemplate"; /** * @private @@ -16,7 +16,7 @@ import { IHubTemplate } from "../../core/types/IHubTemplate"; */ export const buildUiSchema = async ( i18nScope: string, - entity: IHubTemplate, + options: EntityEditorOptions, context: IArcGISContext ): Promise => { return { @@ -89,7 +89,7 @@ export const buildUiSchema = async ( }, }, }, - getThumbnailUiSchemaElement(i18nScope, entity), + getThumbnailUiSchemaElement(i18nScope, options), ], }, ], diff --git a/packages/common/test/core/schemas/getEditorConfig.test.ts b/packages/common/test/core/schemas/getEditorConfig.test.ts index d6877526e2f..7980a546ef9 100644 --- a/packages/common/test/core/schemas/getEditorConfig.test.ts +++ b/packages/common/test/core/schemas/getEditorConfig.test.ts @@ -1,11 +1,14 @@ -import { getEditorConfig } from "../../../src"; -import * as GetSchemasModule from "../../../src/core/schemas/internal/getEntityEditorSchemas"; +import { getEditorConfig } from "../../../src/core/schemas"; +import { IArcGISContext } from "../../../src/ArcGISContext"; +import { EntityEditorOptions } from "../../../src/core/schemas/internal/EditorOptions"; +import * as GetEntitySchemasModule from "../../../src/core/schemas/internal/getEditorSchemas"; +import { HubEntity } from "../../../src/core/types/HubEntity"; describe("getEditorConfig:", () => { - it("delegates", async () => { - const getSchemasSpy = spyOn( - GetSchemasModule, - "getEntityEditorSchemas" + it("delegates to getEditorSchemas with entity", async () => { + const getEditorSchemas = spyOn( + GetEntitySchemasModule, + "getEditorSchemas" ).and.callFake(() => { return Promise.resolve({ schema: {} } as any); }); @@ -13,13 +16,13 @@ describe("getEditorConfig:", () => { const chk = await getEditorConfig( "someScope", "hub:discussion:edit", - {} as any, + {} as HubEntity, {} as any ); - expect(getSchemasSpy).toHaveBeenCalled(); + expect(getEditorSchemas).toHaveBeenCalled(); // verify that the options are passed to the schemas - expect(getSchemasSpy).toHaveBeenCalledWith( + expect(getEditorSchemas).toHaveBeenCalledWith( "someScope", "hub:discussion:edit", {}, @@ -28,4 +31,31 @@ describe("getEditorConfig:", () => { expect(chk).toBeDefined(); expect(chk.schema).toBeDefined(); }); + + it("delegates to getEditorSchemas with card", async () => { + const getEditorSchemas = spyOn( + GetEntitySchemasModule, + "getEditorSchemas" + ).and.callFake(() => { + return Promise.resolve({ schema: {} } as any); + }); + + const chk = await getEditorConfig( + "someScope", + "hub:card:stat", + { themeColors: [] }, + {} as IArcGISContext + ); + + expect(getEditorSchemas).toHaveBeenCalled(); + // verify that the options are passed to the schemas + expect(getEditorSchemas).toHaveBeenCalledWith( + "someScope", + "hub:card:stat", + { themeColors: [] }, + {} + ); + expect(chk).toBeDefined(); + expect(chk.schema).toBeDefined(); + }); }); diff --git a/packages/common/test/core/schemas/internal/getCardEditorSchemas.test.ts b/packages/common/test/core/schemas/internal/getCardEditorSchemas.test.ts new file mode 100644 index 00000000000..c54ed86a927 --- /dev/null +++ b/packages/common/test/core/schemas/internal/getCardEditorSchemas.test.ts @@ -0,0 +1,52 @@ +import { getCardEditorSchemas } from "../../../../src/core/schemas/internal/getCardEditorSchemas"; +import * as filterSchemaModule from "../../../../src/core/schemas/internal/filterSchemaToUiSchema"; +import { CardEditorType } from "../../../../src/core/schemas/types"; + +import * as statUiSchemaModule from "../../../../src/core/schemas/internal/metrics/StatCardUiSchema"; + +describe("getCardEditorSchemas", () => { + let uiSchemaBuildFnSpy: any; + afterEach(() => { + uiSchemaBuildFnSpy.calls.reset(); + }); + + [{ type: "hub:card:stat", buildFn: statUiSchemaModule }].forEach( + async ({ type, buildFn }) => { + it("returns a schema & uiSchema for a given card and card type", async () => { + uiSchemaBuildFnSpy = spyOn(buildFn, "buildUiSchema").and.returnValue({ + type: "Layout", + }); + const { schema, uiSchema } = await getCardEditorSchemas( + "some.scope", + type as CardEditorType, + {} as any, + {} as any + ); + + expect(uiSchemaBuildFnSpy).toHaveBeenCalledTimes(1); + expect(schema).toBeDefined(); + expect(uiSchema).toEqual({ type: "Layout" }); + }); + } + ); + it("filters the schemas to the uiSchema elements before returning", async () => { + const filterSchemaToUiSchemaSpy = spyOn( + filterSchemaModule, + "filterSchemaToUiSchema" + ).and.callThrough(); + uiSchemaBuildFnSpy = spyOn( + statUiSchemaModule, + "buildUiSchema" + ).and.returnValue({}); + + await getCardEditorSchemas( + "some.scope", + "hub:card:stat", + {} as any, + {} as any + ); + + expect(uiSchemaBuildFnSpy).toHaveBeenCalledTimes(1); + expect(filterSchemaToUiSchemaSpy).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/common/test/core/schemas/internal/getEntityEditorSchemas.test.ts b/packages/common/test/core/schemas/internal/getEditorSchemas.test.ts similarity index 92% rename from packages/common/test/core/schemas/internal/getEntityEditorSchemas.test.ts rename to packages/common/test/core/schemas/internal/getEditorSchemas.test.ts index 4e8c8084250..ef30f2be246 100644 --- a/packages/common/test/core/schemas/internal/getEntityEditorSchemas.test.ts +++ b/packages/common/test/core/schemas/internal/getEditorSchemas.test.ts @@ -1,4 +1,4 @@ -import { getEntityEditorSchemas } from "../../../../src/core/schemas/internal/getEntityEditorSchemas"; +import { getEditorSchemas } from "../../../../src/core/schemas/internal/getEditorSchemas"; import * as filterSchemaModule from "../../../../src/core/schemas/internal/filterSchemaToUiSchema"; import { ProjectEditorTypes } from "../../../../src/projects/_internal/ProjectSchema"; @@ -40,7 +40,10 @@ import * as GroupBuildDiscussionsUiSchema from "../../../../src/groups/_internal import { InitiativeTemplateEditorTypes } from "../../../../src/initiative-templates/_internal/InitiativeTemplateSchema"; import * as InitiativeTemplateBuildEditUiSchema from "../../../../src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit"; -describe("getEntityEditorSchemas: ", () => { +import { validCardEditorTypes } from "../../../../src/core/schemas/types"; +import * as statUiSchemaModule from "../../../../src/core/schemas/internal/metrics/StatCardUiSchema"; + +describe("getEditorSchemas: ", () => { let uiSchemaBuildFnSpy: any; afterEach(() => { uiSchemaBuildFnSpy.calls.reset(); @@ -73,12 +76,13 @@ describe("getEntityEditorSchemas: ", () => { buildFn: InitiativeTemplateBuildEditUiSchema, }, { type: GroupEditorTypes[2], buildFn: GroupBuildDiscussionsUiSchema }, + { type: validCardEditorTypes[0], buildFn: statUiSchemaModule }, ].forEach(async ({ type, buildFn }) => { it("returns a schema & uiSchema for a given entity and editor type", async () => { uiSchemaBuildFnSpy = spyOn(buildFn, "buildUiSchema").and.returnValue( Promise.resolve({}) ); - const { schema, uiSchema } = await getEntityEditorSchemas( + const { schema, uiSchema } = await getEditorSchemas( "some.scope", type, {} as any, @@ -99,7 +103,7 @@ describe("getEntityEditorSchemas: ", () => { "buildUiSchema" ).and.returnValue({}); - await getEntityEditorSchemas( + await getEditorSchemas( "some.scope", "hub:project:edit", {} as any, diff --git a/packages/common/test/core/schemas/internal/getThumbnailUiSchemaElement.test.ts b/packages/common/test/core/schemas/internal/getThumbnailUiSchemaElement.test.ts index 98a60636af2..0f41001724f 100644 --- a/packages/common/test/core/schemas/internal/getThumbnailUiSchemaElement.test.ts +++ b/packages/common/test/core/schemas/internal/getThumbnailUiSchemaElement.test.ts @@ -1,4 +1,5 @@ import { IHubItemEntity } from "../../../../src"; +import { EntityEditorOptions } from "../../../../src/core/schemas/internal/EditorOptions"; import { getThumbnailUiSchemaElement } from "../../../../src/core/schemas/internal/getThumbnailUiSchemaElement"; describe("getThumbnailUiSchemaElement:", () => { @@ -19,7 +20,10 @@ describe("getThumbnailUiSchemaElement:", () => { updatedDateSource: "item.modified", type: "Feature Service", }; - const uiSchema = getThumbnailUiSchemaElement("scope", entity); + const uiSchema = getThumbnailUiSchemaElement( + "scope", + entity as EntityEditorOptions + ); expect(uiSchema.options?.messages.length).toBe(0); }); @@ -39,7 +43,10 @@ describe("getThumbnailUiSchemaElement:", () => { updatedDateSource: "item.modified", type: "Feature Service", }; - const uiSchema = getThumbnailUiSchemaElement("scope", entity); + const uiSchema = getThumbnailUiSchemaElement( + "scope", + entity as EntityEditorOptions + ); expect(uiSchema.options?.messages.length).toBe(1); }); @@ -60,7 +67,10 @@ describe("getThumbnailUiSchemaElement:", () => { updatedDateSource: "item.modified", type: "Feature Service", }; - const uiSchema = getThumbnailUiSchemaElement("scope", entity); + const uiSchema = getThumbnailUiSchemaElement( + "scope", + entity as EntityEditorOptions + ); expect(uiSchema.options?.messages.length).toBe(1); }); }); diff --git a/packages/common/test/core/schemas/internal/metrics/StatCardUiSchema.test.ts b/packages/common/test/core/schemas/internal/metrics/StatCardUiSchema.test.ts new file mode 100644 index 00000000000..ded9e584181 --- /dev/null +++ b/packages/common/test/core/schemas/internal/metrics/StatCardUiSchema.test.ts @@ -0,0 +1,447 @@ +import { buildUiSchema } from "../../../../../src/core/schemas/internal/metrics/StatCardUiSchema"; +import { UiSchemaRuleEffects } from "../../../../../src/core/schemas/types"; +import { MOCK_CONTEXT } from "../../../../mocks/mock-auth"; + +describe("buildUiSchema: stat", () => { + it("returns the full stat card uiSchema", async () => { + const uiSchema = buildUiSchema( + "some.scope", + { themeColors: ["#ffffff"] }, + MOCK_CONTEXT + ); + + expect(uiSchema).toEqual({ + type: "Layout", + elements: [ + { + type: "Section", + labelKey: `some.scope.statistic.sectionTitle`, + options: { + section: "block", + open: true, + }, + elements: [ + { + type: "Control", + scope: "/properties/type", + labelKey: `some.scope.statistic.type.label`, + options: { + control: "hub-field-input-tile-select", + enum: { + i18nScope: `some.scope.statistic.type.enum`, + }, + }, + }, + { + labelKey: `some.scope.statistic.displayValue`, + scope: "/properties/value", + type: "Control", + rule: { + condition: { + scope: "/properties/type", + schema: { const: "static" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + }, + { + scope: "/properties/dynamicMetric", + type: "Control", + labelKey: `some.scope.statistic.dataSource`, + rule: { + condition: { + scope: "/properties/type", + schema: { const: "dynamic" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + control: "hub-composite-input-service-query-metric", + }, + }, + { + type: "Section", + labelKey: `some.scope.formatting.sectionTitle`, + scope: "/properties/allowUnitFormatting", + options: { + section: "subblock", + toggleDisplay: "switch", + scope: "/properties/unit", + }, + elements: [ + { + labelKey: `some.scope.formatting.unit.label`, + scope: "/properties/unit", + type: "Control", + rule: { + condition: { + schema: { const: true }, + scope: "/properties/allowUnitFormatting", + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + helperText: { + labelKey: `some.scope.formatting.unit.helperText`, + placement: "bottom", + }, + }, + }, + { + labelKey: `some.scope.formatting.unitPosition.label`, + scope: "/properties/unitPosition", + type: "Control", + rule: { + condition: { + schema: { const: true }, + scope: "/properties/allowUnitFormatting", + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `some.scope.formatting.unitPosition.enum`, + }, + }, + }, + ], + }, + { + type: "Section", + labelKey: `some.scope.advancedConfig.label`, + options: { + section: "subblock", + }, + rule: { + condition: { + scope: "/properties/type", + schema: { const: "dynamic" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + elements: [ + { + scope: "/properties/serverTimeout", + labelKey: `some.scope.advancedConfig.serverTimeout.label`, + type: "Control", + rule: { + condition: { + scope: "/properties/type", + schema: { const: "dynamic" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + control: "hub-field-input-input", + type: "number", + helperText: { + labelKey: `some.scope.advancedConfig.serverTimeout.helperText`, + placement: "bottom", + }, + messages: [ + { + type: "ERROR", + keyword: "type", + labelKey: `some.scope.advancedConfig.serverTimeout.errors.type`, + icon: true, + }, + { + type: "ERROR", + keyword: "minimum", + labelKey: `some.scope.advancedConfig.serverTimeout.errors.minimum`, + icon: true, + }, + { + type: "ERROR", + keyword: "maximum", + labelKey: `some.scope.advancedConfig.serverTimeout.errors.maximum`, + icon: true, + }, + ], + }, + }, + ], + }, + ], + }, + { + type: "Section", + labelKey: `some.scope.details.sectionTitle`, + options: { + section: "block", + }, + elements: [ + { + labelKey: `some.scope.details.title`, + scope: "/properties/cardTitle", + type: "Control", + }, + { + labelKey: `some.scope.details.subtitle`, + scope: "/properties/subtitle", + type: "Control", + }, + { + labelKey: `some.scope.details.trailingText`, + scope: "/properties/trailingText", + type: "Control", + }, + { + type: "Section", + labelKey: `some.scope.details.link.sectionTitle`, + scope: "/properties/allowLink", + options: { + section: "subblock", + toggleDisplay: "switch", + }, + rule: { + condition: { + scope: "/properties/type", + schema: { const: "static" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + elements: [ + { + labelKey: `some.scope.details.link.sourceLink`, + scope: "/properties/sourceLink", + type: "Control", + rule: { + condition: { + schema: { + properties: { + type: { const: "static" }, + allowLink: { const: true }, + }, + }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + placeholder: "https://esri.com", + messages: [ + { + type: "ERROR", + keyword: "required", + icon: true, + labelKey: `some.scope.errors.sourceLink.required`, + allowShowBeforeInteract: true, + }, + ], + }, + }, + { + labelKey: `some.scope.details.link.sourceTitle`, + scope: "/properties/sourceTitle", + type: "Control", + rule: { + condition: { + schema: { + properties: { + type: { const: "static" }, + allowLink: { const: true }, + }, + }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + }, + ], + }, + { + type: "Control", + scope: "/properties/allowDynamicLink", + labelKey: `some.scope.details.allowDynamicLink`, + rule: { + condition: { + scope: "/properties/type", + schema: { const: "dynamic" }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + layout: "inline-space-between", + control: "hub-field-input-switch", + }, + }, + ], + }, + { + type: "Section", + labelKey: `some.scope.appearance.sectionTitle`, + options: { section: "block" }, + elements: [ + { + labelKey: `some.scope.appearance.layout.label`, + scope: "/properties/layout", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/type", + schema: { enum: [undefined, "static", "dynamic"] }, + }, + }, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `some.scope.layout.enum`, + }, + }, + }, + { + labelKey: `some.scope.appearance.textAlign`, + scope: "/properties/textAlign", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/layout", + schema: { enum: ["dataViz"] }, + }, + }, + options: { + control: "hub-field-input-alignment", + }, + }, + { + labelKey: `some.scope.appearance.valueColor`, + scope: "/properties/valueColor", + type: "Control", + options: { + control: "hub-field-input-color", + savedColors: ["#ffffff"], + }, + }, + { + labelKey: `some.scope.appearance.dropShadow.label`, + scope: "/properties/dropShadow", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/type", + schema: { enum: [undefined, "static", "dynamic"] }, + }, + }, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `some.scope.appearance.dropShadow.enum`, + }, + }, + }, + + { + labelKey: `some.scope.appearance.visualInterest.label`, + scope: "/properties/visualInterest", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/type", + schema: { enum: [undefined, "static", "dynamic"] }, + }, + }, + options: { + control: "hub-field-input-select", + enum: { + i18nScope: `some.scope.appearance.visualInterest.enum`, + }, + }, + }, + // { + // type: 'Control', + // scope: '/properties/icon', + // options: { control: 'hub-composite-input-icon' }, + // rule: { + // effect: UiSchemaRuleEffects.SHOW, + // condition: { + // scope: '/properties/visualInterest', + // schema: { const: 'icon' } + // } + // } + // }, + { + labelKey: `some.scope.appearance.popoverTitle`, + scope: "/properties/popoverTitle", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.SHOW, + condition: { + scope: "/properties/layout", + schema: { const: "moreInfo" }, + }, + }, + }, + { + labelKey: `some.scope.appearance.popoverDescription`, + scope: "/properties/popoverDescription", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.SHOW, + condition: { + scope: "/properties/layout", + schema: { const: "moreInfo" }, + }, + }, + }, + ], + }, + { + type: "Section", + labelKey: `some.scope.sharing.sectionTitle`, + options: { + section: "block", + }, + elements: [ + { + labelKey: `some.scope.sharing.showShareIcon`, + scope: "/properties/shareable", + type: "Control", + options: { + helperText: { + labelKey: `some.scope.sharing.showShareIconHelperText`, + }, + control: "hub-field-input-switch", + layout: "inline-space-between", + }, + }, + { + labelKey: `some.scope.sharing.shareableByValue`, + scope: "/properties/shareableByValue", + type: "Control", + rule: { + effect: UiSchemaRuleEffects.HIDE, + condition: { + scope: "/properties/type", + schema: { enum: [undefined, "static", "dynamic"] }, + }, + }, + }, + { + labelKey: `some.scope.sharing.shareableOnHover.label`, + scope: "/properties/shareableOnHover", + type: "Control", + rule: { + condition: { + scope: "/properties/shareable", + schema: { const: true }, + }, + effect: UiSchemaRuleEffects.SHOW, + }, + options: { + control: "hub-field-input-switch", + helperText: { + labelKey: `some.scope.sharing.shareableOnHover.helperText.label`, + }, + layout: "inline-space-between", + }, + }, + ], + }, + ], + }); + }); +}); diff --git a/packages/common/test/initiative-templates/HubInitiativeTemplate.test.ts b/packages/common/test/initiative-templates/HubInitiativeTemplate.test.ts index a7d75cb997f..bfdada1a0ed 100644 --- a/packages/common/test/initiative-templates/HubInitiativeTemplate.test.ts +++ b/packages/common/test/initiative-templates/HubInitiativeTemplate.test.ts @@ -103,7 +103,7 @@ describe("HubInitiativeTemplate Class: ", () => { }); // it("returns editorConfig", async () => { - // const spy = spyOn(schemasModule, "getEntityEditorSchemas").and.callFake( + // const spy = spyOn(schemasModule, "getEditorSchemas").and.callFake( // () => { // return Promise.resolve({ schema: {}, uiSchema: {} }); // } @@ -115,7 +115,7 @@ describe("HubInitiativeTemplate Class: ", () => { // }); // it("returns editorConfig integrating options", async () => { - // const spy = spyOn(schemasModule, "getEntityEditorSchemas").and.callFake( + // const spy = spyOn(schemasModule, "getEditorSchemas").and.callFake( // () => { // return Promise.resolve({ schema: {}, uiSchema: {} }); // } diff --git a/packages/common/test/projects/HubProject.test.ts b/packages/common/test/projects/HubProject.test.ts index 8f782c2adba..153e97117b0 100644 --- a/packages/common/test/projects/HubProject.test.ts +++ b/packages/common/test/projects/HubProject.test.ts @@ -104,32 +104,6 @@ describe("HubProject Class:", () => { expect((ex as any).message).toBe("ZOMG!"); } }); - - // it("returns editorConfig", async () => { - // const spy = spyOn(schemasModule, "getEntityEditorSchemas").and.callFake( - // () => { - // return Promise.resolve({ schema: {}, uiSchema: {} }); - // } - // ); - - // await HubProject.getEditorConfig("test.scope", "hub:project:edit"); - // expect(spy).toHaveBeenCalledTimes(1); - // expect(spy).toHaveBeenCalledWith("test.scope", "hub:project:edit", []); - // }); - - // it("returns editorConfig integrating options", async () => { - // const spy = spyOn(schemasModule, "getEntityEditorSchemas").and.callFake( - // () => { - // return Promise.resolve({ schema: {}, uiSchema: {} }); - // } - // ); - - // const opts: UiSchemaElementOptions[] = []; - - // await HubProject.getEditorConfig("test.scope", "hub:project:edit", opts); - // expect(spy).toHaveBeenCalledTimes(1); - // expect(spy).toHaveBeenCalledWith("test.scope", "hub:project:edit", opts); - // }); }); it("convertToCardModel: delegates to the projectToCardModel util", async () => {