Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add displayConfig in Hub Catalog, update GalleryDisplayConfigSchema #1747

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/common/src/content/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ const getMetadataUpdatedDateInfo = (item: IItem, metadata?: any) => {
};

// public API
// AGO has a util for determining display name and item type icons
// that we can use for reference
// https://devtopia.esri.com/WebGIS/arcgis-app-components/blob/master/src/components/arcgis-item-type/utils.ts
Comment on lines +222 to +224
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wow...should we be using this for the combobox/item type work then?

Copy link
Contributor Author

@vivzhang vivzhang Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say we stick with our getContentTypeIcon for now for consistency. I added this comment here because I just got that info from the AGO team, it was new to me as well. I think this needs a holistic review by Design first before we decide what to do.

/**
* Compute the content type calcite-icon based on the content type
* @param content type
Expand Down
34 changes: 33 additions & 1 deletion packages/common/src/core/schemas/shared/CatalogSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EntityType, targetEntities } from "../../../search/types/IHubCatalog";
import { IConfigurationSchema } from "../types";
import { CARD_TITLE_TAGS, CORNERS, DROP_SHADOWS } from "./enums";

/** JSON schema for an IPredicate */
export const PredicateSchema: IConfigurationSchema = {
Expand Down Expand Up @@ -82,7 +83,38 @@ export const GalleryDisplayConfigSchema: IConfigurationSchema = {
type: "object",
properties: {
hidden: { type: "boolean", default: false },
// TODO: fill in properties
layout: {
type: "string",
enum: ["list", "grid", "table", "map", "compact"],
default: "list",
},
cardTitleTag: {
type: "string",
enum: Object.keys(CARD_TITLE_TAGS),
default: CARD_TITLE_TAGS.h3,
},
showThumbnail: {
type: "string",
enum: ["show", "hide", "grid"],
default: "show",
},
corners: {
type: "string",
enum: Object.keys(CORNERS),
default: CORNERS.square,
},
shadow: {
type: "string",
enum: Object.keys(DROP_SHADOWS),
default: DROP_SHADOWS.none,
},
showLinkButton: { type: "boolean", default: false },
linkButtonStyle: {
type: "string",
enum: ["outline", "outline-filled"],
default: "outline-filled",
},
linkButtonText: { type: "string", default: "Explore" },
},
};

Expand Down
12 changes: 12 additions & 0 deletions packages/common/src/core/schemas/shared/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ export enum DROP_SHADOWS {
medium = "medium",
heavy = "heavy",
}

/**
* Tags to wrap the title on each card
*/
export enum CARD_TITLE_TAGS {
h1 = "h1",
h2 = "h2",
h3 = "h3",
h4 = "h4",
h5 = "h5",
h6 = "h6",
}
8 changes: 8 additions & 0 deletions packages/common/src/search/Catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
IQuery,
IFilter,
IHubCollection,
IGalleryDisplayConfig,
} from "./types";
import { upgradeCatalogSchema } from "./upgradeCatalogSchema";

Expand Down Expand Up @@ -128,6 +129,13 @@ export class Catalog implements IHubCatalog {
return Object.keys(this.scopes) as unknown as EntityType[];
}

/**
* Return the display configuration for the gallery
*/
get displayConfig(): IGalleryDisplayConfig {
return this._catalog.displayConfig;
}

/**
* Get the scope's query for a particular entity type
* @param type
Expand Down
18 changes: 18 additions & 0 deletions packages/common/src/search/types/IHubCatalog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
CARD_TITLE_TAGS,
CORNERS,
DROP_SHADOWS,
} from "../../core/schemas/shared/enums";
import { WellKnownCollection } from "../wellKnownCatalog";

export type CatalogType = "content" | "exclusion";
Expand Down Expand Up @@ -35,6 +40,11 @@ export interface IHubCatalog {
scopes: string;
collections: string;
};

/**
* Optional display configuration to control a catalog's appearance in the UI
*/
displayConfig?: IGalleryDisplayConfig;
}

export interface ICatalogScope extends Partial<Record<EntityType, IQuery>> {}
Expand Down Expand Up @@ -185,4 +195,12 @@ export interface IGalleryDisplayConfig {
* If this is true on a collection's display config, that collection will not be shown in the gallery.
*/
hidden?: boolean;
layout?: "list" | "grid" | "map" | "table" | "calendar" | "compact";
cardTitleTag?: CARD_TITLE_TAGS;
showThumbnail?: "show" | "hide" | "grid";
corners?: CORNERS;
shadow?: DROP_SHADOWS;
showLinkButton?: boolean;
linkButtonStyle?: "solid" | "outline" | "outline-fill" | "transparent";
linkButtonText?: string;
}
16 changes: 15 additions & 1 deletion packages/common/test/search/Catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import { ArcGISContextManager } from "../../src/ArcGISContextManager";
import {
ICatalogScope,
IFilter,
IGalleryDisplayConfig,
IHubCatalog,
IHubCollection,
IHubSearchResponse,
IHubSearchResult,
IPredicate,
IQuery,
} from "../../src/search";
import { Catalog } from "../../src";
import * as FetchEntityCatalogModule from "../../src/search/fetchEntityCatalog";
import * as HubSearchModule from "../../src/search/hubSearch";
import * as CatalogContainsModule from "../../src/core/catalogContains";
import { MOCK_AUTH } from "../mocks/mock-auth";
import { CORNERS, DROP_SHADOWS } from "../../src/core/schemas/shared/enums";

const catalogJson: IHubCatalog = {
title: "Demo Catalog",
Expand Down Expand Up @@ -95,6 +96,16 @@ const catalogJson: IHubCatalog = {
},
},
],
displayConfig: {
hidden: false,
showThumbnail: "show",
showLinkButton: true,
linkButtonStyle: "outline",
linkButtonText: "Explore",
corners: CORNERS.square,
shadow: DROP_SHADOWS.none,
layout: "list",
},
};

const noScopeCatalog: IHubCatalog = {
Expand Down Expand Up @@ -157,6 +168,9 @@ describe("Catalog Class:", () => {
instance.title = "Changed Title";
expect(instance.title).toBe("Changed Title");
expect(instance.availableScopes).toEqual(["item", "group", "user"]);
expect(instance.displayConfig).toEqual(
catalogJson.displayConfig as IGalleryDisplayConfig
);
});
it("allows null scopes", () => {
const instance = Catalog.fromJson(cloneObject(noScopeCatalog), context);
Expand Down
Loading