Skip to content

Commit

Permalink
Merge branch 'master' into f/10461-discussion-board-map-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerjt committed Jun 25, 2024
2 parents e081f14 + b00b2df commit 1b40be3
Show file tree
Hide file tree
Showing 24 changed files with 308 additions and 210 deletions.
7 changes: 7 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# @esri/hub-common [14.150.0](https://github.com/Esri/hub.js/compare/@esri/hub-common@14.149.0...@esri/hub-common@14.150.0) (2024-06-24)


### Features

* **hub-common:** disable categories field and provide notice when no options are available ([#1561](https://github.com/Esri/hub.js/issues/1561)) ([95035c0](https://github.com/Esri/hub.js/commit/95035c019fd141e80df8d94ac1dacfb5322ae86f))

# @esri/hub-common [14.149.0](https://github.com/Esri/hub.js/compare/@esri/hub-common@14.148.2...@esri/hub-common@14.149.0) (2024-06-24)


Expand Down
4 changes: 2 additions & 2 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@esri/hub-common",
"version": "14.149.0",
"version": "14.150.0",
"description": "Common TypeScript types and utility functions for @esri/hub.js.",
"main": "dist/node/index.js",
"module": "dist/esm/index.js",
Expand Down
21 changes: 2 additions & 19 deletions packages/common/src/content/_internal/ContentUiSchemaEdit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IArcGISContext } from "../../ArcGISContext";
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 { IUiSchema } from "../../core/schemas/types";
import { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement";
import { IHubEditableContent } from "../../core/types";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -109,24 +109,7 @@ export const buildUiSchema = async (
},
},
// categories
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.agolHint`, // TODO: hint should describe whether it can be set on Enterprise or Online
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
// license
{
labelKey: `${i18nScope}.fields.license.label`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { IArcGISContext } from "../../../ArcGISContext";
import {
IUiSchemaElement,
IUiSchemaMessage,
UiSchemaMessageTypes,
} from "../types";
import { fetchCategoryItems } from "./fetchCategoryItems";

/**
* Returns the UI schema element needed to render
* the categories editing control for an entity.
*
* @param i18nScope i18n scope for the entity translations
* @param entity The entity to build the UI schema for
* @returns the UI schema element for thumbnail editing
*/
export async function fetchCategoriesUiSchemaElement(
i18nScope: string,
context: IArcGISContext
): Promise<IUiSchemaElement> {
const categoryItems = await fetchCategoryItems(
context.portal.id,
context.hubRequestOptions
);

const result: IUiSchemaElement = {
labelKey: `shared.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: categoryItems,
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
// helper text varies between entity types
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
};

if (!categoryItems.length) {
result.options.disabled = true;
result.options.messages = [
{
type: UiSchemaMessageTypes.custom,
display: "notice",
kind: "warning",
icon: "exclamation-mark-triangle",
labelKey: "shared.fields.categories.noCategoriesNotice.body",
link: {
kind: "external",
label:
"{{shared.fields.categories.noCategoriesNotice.link:translate}}",
href: "https://doc.arcgis.com/en/arcgis-online/reference/content-categories.htm",
target: "_blank",
},
allowShowBeforeInteract: true,
alwaysShow: true,
} as IUiSchemaMessage,
];
}

return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IUiSchemaComboboxItem } from "../types";
* @param hubRequestOptions The hub request options
* @returns a _nested_ structure of categories
*/
export async function getCategoryItems(
export async function fetchCategoryItems(
orgId: string,
hubRequestOptions: IHubRequestOptions
): Promise<IUiSchemaComboboxItem[]> {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/core/schemas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "./internal/EditorOptions";
import { IArcGISContext } from "../../ArcGISContext";
import { EventEditorTypes } from "../../events/_internal/EventSchemaCreate";
import { HubActionLink } from "../types";

export interface IEditorConfig {
schema: IConfigurationSchema;
Expand Down Expand Up @@ -250,6 +251,7 @@ export interface IUiSchemaMessage {
labelKey?: string;
icon?: boolean | string;
kind?: "brand" | "danger" | "info" | "success" | "warning";
link?: HubActionLink;
hidden?: boolean;
// NOTE: condition is deprecated and remains for backwards compatibility only. Please use conditions instead.
condition?: IUiSchemaCondition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IUiSchema } from "../../core/schemas/types";
import { IArcGISContext } from "../../ArcGISContext";
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 { IHubDiscussion } from "../../core/types";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -121,21 +121,7 @@ export const buildUiSchema = async (
placeholderIcon: "label",
},
},
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
{
labelKey: `${i18nScope}.fields.summary.label`,
scope: "/properties/summary",
Expand Down
21 changes: 2 additions & 19 deletions packages/common/src/events/_internal/EventUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types";
import { IArcGISContext } from "../../ArcGISContext";
import { getDatePickerDate } from "../../utils/date/getDatePickerDate";
import { IHubEvent } from "../../core/types/IHubEvent";
import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems";
import { getTagItems } from "../../core/schemas/internal/getTagItems";
import { HubEventAttendanceType, HubEventCapacityType } from "../types";
import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent";
import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -433,24 +433,7 @@ export const buildUiSchema = async (
},
},
},
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
{
labelKey: `${i18nScope}.fields.summary.label`,
scope: "/properties/summary",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { IUiSchema, UiSchemaRuleEffects } from "../../core/schemas/types";
import { IArcGISContext } from "../../ArcGISContext";
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 { IHubInitiative } from "../../core";
import { getAuthedImageUrl } from "../../core/_internal/getAuthedImageUrl";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -181,24 +181,7 @@ export const buildUiSchema = async (
type: "Section",
labelKey: `${i18nScope}.sections.searchDiscoverability.label`,
elements: [
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
{
labelKey: `${i18nScope}.fields.tags.label`,
scope: "/properties/tags",
Expand Down
21 changes: 2 additions & 19 deletions packages/common/src/pages/_internal/PageUiSchemaEdit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IUiSchema } from "../../core/schemas/types";
import { IArcGISContext } from "../../ArcGISContext";
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 { IHubPage } from "../../core/types";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -101,24 +101,7 @@ export const buildUiSchema = async (
helperText: { labelKey: `${i18nScope}.fields.tags.helperText` },
},
},
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
],
},
{
Expand Down
21 changes: 2 additions & 19 deletions packages/common/src/projects/_internal/ProjectUiSchemaEdit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { IArcGISContext } from "../../ArcGISContext";
import { IUiSchema } from "../../core/schemas/types";
import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems";
import { getFeaturedContentCatalogs } from "../../core/schemas/internal/getFeaturedContentCatalogs";
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 { IHubProject } from "../../core/types";
import { getAuthedImageUrl } from "../../core/_internal/getAuthedImageUrl";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -164,24 +164,7 @@ export const buildUiSchema = async (
helperText: { labelKey: `${i18nScope}.fields.tags.helperText` },
},
},
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
getThumbnailUiSchemaElement(
i18nScope,
options.thumbnail,
Expand Down
21 changes: 2 additions & 19 deletions packages/common/src/sites/_internal/SiteUiSchemaEdit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IArcGISContext } from "../../ArcGISContext";
import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems";
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 { getThumbnailUiSchemaElement } from "../../core/schemas/internal/getThumbnailUiSchemaElement";
import { IHubSite } from "../../core/types";
import { fetchCategoriesUiSchemaElement } from "../../core/schemas/internal/fetchCategoriesUiSchemaElement";

/**
* @private
Expand Down Expand Up @@ -101,24 +101,7 @@ export const buildUiSchema = async (
helperText: { labelKey: `${i18nScope}.fields.tags.helperText` },
},
},
{
labelKey: `${i18nScope}.fields.categories.label`,
scope: "/properties/categories",
type: "Control",
options: {
control: "hub-field-input-combobox",
items: await getCategoryItems(
context.portal.id,
context.hubRequestOptions
),
allowCustomValues: false,
selectionMode: "ancestors",
placeholderIcon: "select-category",
helperText: {
labelKey: `${i18nScope}.fields.categories.helperText`,
},
},
},
await fetchCategoriesUiSchemaElement(i18nScope, context),
],
},
{
Expand Down
Loading

0 comments on commit 1b40be3

Please sign in to comment.