Skip to content

Commit 8f4166b

Browse files
authored
Merge branch 'master' into b/12610-respect-hidden-site-collections
2 parents 947f3e7 + bbe57ea commit 8f4166b

File tree

7 files changed

+124
-71
lines changed

7 files changed

+124
-71
lines changed

packages/common/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## @esri/hub-common [15.41.1](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2025-03-10)
2+
3+
4+
### Bug Fixes
5+
6+
* add displayConfig to CollectionSchema ([#1823](https://github.com/Esri/hub.js/issues/1823)) ([a42f3bd](https://github.com/Esri/hub.js/commit/a42f3bd5f5fda5de4591493bb1bc3839e0bac59c))
7+
18
# @esri/hub-common [15.41.0](https://github.com/Esri/hub.js/compare/@esri/[email protected]...@esri/[email protected]) (2025-03-06)
29

310

packages/common/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@esri/hub-common",
3-
"version": "15.41.0",
3+
"version": "15.41.1",
44
"description": "Common TypeScript types and utility functions for @esri/hub.js.",
55
"main": "dist/node/index.js",
66
"module": "dist/esm/index.js",

packages/common/src/core/schemas/shared/CatalogSchema.ts

+98-54
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,93 @@ import { EntityType, targetEntities } from "../../../search/types/IHubCatalog";
22
import { IConfigurationSchema } from "../types";
33
import { CARD_TITLE_TAGS, CORNERS, DROP_SHADOWS } from "./enums";
44

5+
/**
6+
* JSON schema for the appearance of a gallery display
7+
* This can be for a catalog, a collection, a gallery card, etc
8+
*/
9+
export const GalleryDisplayConfigSchema: IConfigurationSchema = {
10+
type: "object",
11+
properties: {
12+
hidden: { type: "boolean", default: false },
13+
layout: {
14+
type: "string",
15+
enum: [
16+
"list",
17+
"grid",
18+
"grid-filled",
19+
"table",
20+
"map",
21+
"compact",
22+
"calendar",
23+
],
24+
default: "list",
25+
},
26+
cardTitleTag: {
27+
type: "string",
28+
enum: Object.keys(CARD_TITLE_TAGS),
29+
default: CARD_TITLE_TAGS.h3,
30+
},
31+
showThumbnail: {
32+
type: "string",
33+
enum: ["show", "hide", "grid"],
34+
default: "show",
35+
},
36+
corners: {
37+
type: "string",
38+
enum: Object.keys(CORNERS),
39+
default: CORNERS.square,
40+
},
41+
shadow: {
42+
type: "string",
43+
enum: Object.keys(DROP_SHADOWS),
44+
default: DROP_SHADOWS.none,
45+
},
46+
showLinkButton: { type: "boolean", default: false },
47+
linkButtonStyle: {
48+
type: "string",
49+
enum: ["outline", "outline-filled"],
50+
default: "outline-filled",
51+
},
52+
linkButtonText: { type: "string", default: "Explore" },
53+
sort: {
54+
type: "string",
55+
enum: ["relevance", "title", "created", "modified"],
56+
default: "relevance",
57+
},
58+
filters: {
59+
type: "array",
60+
items: {
61+
type: "object",
62+
properties: {
63+
key: {
64+
type: "string",
65+
enum: [
66+
"location",
67+
"type",
68+
"source",
69+
"event-occurrence",
70+
"event-from",
71+
"event-attendance",
72+
"tags",
73+
"categories",
74+
"license",
75+
"modified",
76+
"access",
77+
"group-role",
78+
"group-type",
79+
"group-access",
80+
"event-access",
81+
"event-date",
82+
],
83+
},
84+
hidden: { type: "boolean" },
85+
label: { type: "string" },
86+
},
87+
},
88+
},
89+
},
90+
};
91+
592
/** JSON schema for an IPredicate */
693
export const PredicateSchema: IConfigurationSchema = {
794
type: "object",
@@ -53,49 +140,7 @@ export const CollectionSchema: IConfigurationSchema = {
53140
type: "string",
54141
},
55142
scope: QuerySchema,
56-
},
57-
};
58-
59-
/**
60-
* JSON schema for the appearance of a gallery display
61-
* This can be for a catalog, a collection, a gallery card, etc
62-
*/
63-
export const GalleryDisplayConfigSchema: IConfigurationSchema = {
64-
type: "object",
65-
properties: {
66-
hidden: { type: "boolean", default: false },
67-
layout: {
68-
type: "string",
69-
enum: ["list", "grid", "table", "map", "compact"],
70-
default: "list",
71-
},
72-
cardTitleTag: {
73-
type: "string",
74-
enum: Object.keys(CARD_TITLE_TAGS),
75-
default: CARD_TITLE_TAGS.h3,
76-
},
77-
showThumbnail: {
78-
type: "string",
79-
enum: ["show", "hide", "grid"],
80-
default: "show",
81-
},
82-
corners: {
83-
type: "string",
84-
enum: Object.keys(CORNERS),
85-
default: CORNERS.square,
86-
},
87-
shadow: {
88-
type: "string",
89-
enum: Object.keys(DROP_SHADOWS),
90-
default: DROP_SHADOWS.none,
91-
},
92-
showLinkButton: { type: "boolean", default: false },
93-
linkButtonStyle: {
94-
type: "string",
95-
enum: ["outline", "outline-filled"],
96-
default: "outline-filled",
97-
},
98-
linkButtonText: { type: "string", default: "Explore" },
143+
displayConfig: GalleryDisplayConfigSchema,
99144
},
100145
};
101146

@@ -120,16 +165,15 @@ export const CatalogSchema: IConfigurationSchema = {
120165
type: "array",
121166
items: CollectionSchema,
122167
},
123-
displayConfig: GalleryDisplayConfigSchema,
124-
},
125-
};
126-
127-
/**
128-
* JSON schema for the appearance of an IHubCollection
129-
*/
130-
export const CollectionAppearanceSchema: IConfigurationSchema = {
131-
type: "object",
132-
properties: {
133-
displayConfig: GalleryDisplayConfigSchema,
168+
displayConfig: {
169+
type: "object",
170+
properties: targetEntities.reduce(
171+
(acc: Record<EntityType, any>, targetEntity: EntityType) => {
172+
acc[targetEntity] = GalleryDisplayConfigSchema;
173+
return acc;
174+
},
175+
{} as Record<EntityType, any>
176+
),
177+
},
134178
},
135179
};

packages/common/src/search/Catalog.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
IQuery,
2323
IFilter,
2424
IHubCollection,
25-
IGalleryDisplayConfig,
25+
ICatalogDisplayConfig,
2626
} from "./types";
2727
import { upgradeCatalogSchema } from "./upgradeCatalogSchema";
2828

@@ -132,7 +132,7 @@ export class Catalog implements IHubCatalog {
132132
/**
133133
* Return the display configuration for the gallery
134134
*/
135-
get displayConfig(): IGalleryDisplayConfig {
135+
get displayConfig(): ICatalogDisplayConfig {
136136
return this._catalog.displayConfig;
137137
}
138138

packages/common/src/search/types/IHubCatalog.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ export interface IHubCatalog {
4444
/**
4545
* Optional display configuration to control a catalog's appearance in the UI
4646
*/
47-
displayConfig?: IGalleryDisplayConfig;
47+
displayConfig?: ICatalogDisplayConfig;
4848
}
4949

5050
export interface ICatalogScope extends Partial<Record<EntityType, IQuery>> {}
5151

52+
export interface ICatalogDisplayConfig
53+
extends Partial<Record<EntityType, IGalleryDisplayConfig>> {}
5254
export interface IHubCollection {
5355
/**
5456
* String to show in the UI. translated.

packages/common/test/search/Catalog.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@ const catalogJson: IHubCatalog = {
9797
},
9898
],
9999
displayConfig: {
100-
hidden: false,
101-
showThumbnail: "show",
102-
showLinkButton: true,
103-
linkButtonStyle: "outline",
104-
linkButtonText: "Explore",
105-
corners: CORNERS.square,
106-
shadow: DROP_SHADOWS.none,
107-
layout: "list",
100+
item: {
101+
hidden: false,
102+
showThumbnail: "show",
103+
showLinkButton: true,
104+
linkButtonStyle: "outline",
105+
linkButtonText: "Explore",
106+
corners: CORNERS.square,
107+
shadow: DROP_SHADOWS.none,
108+
layout: "list",
109+
},
108110
},
109111
};
110112

@@ -168,9 +170,7 @@ describe("Catalog Class:", () => {
168170
instance.title = "Changed Title";
169171
expect(instance.title).toBe("Changed Title");
170172
expect(instance.availableScopes).toEqual(["item", "group", "user"]);
171-
expect(instance.displayConfig).toEqual(
172-
catalogJson.displayConfig as IGalleryDisplayConfig
173-
);
173+
expect(instance.displayConfig).toEqual(catalogJson.displayConfig);
174174
});
175175
it("allows null scopes", () => {
176176
const instance = Catalog.fromJson(cloneObject(noScopeCatalog), context);

0 commit comments

Comments
 (0)