diff --git a/.changeset/thin-steaks-trade.md b/.changeset/thin-steaks-trade.md index 20c8446f86..cd428601e6 100644 --- a/.changeset/thin-steaks-trade.md +++ b/.changeset/thin-steaks-trade.md @@ -4,7 +4,19 @@ Update the default entity page extension component to support grouping multiple entity content items in the same tab. -Disable a default group via configuration: +Disable all default groups: + +```diff +# app-config.yaml +app: + extensions: + # Pages ++ - page:catalog/entity: ++ config: ++ groups: [] +``` + +Create a custom list of : ```diff # app-config.yaml @@ -14,32 +26,7 @@ app: + - page:catalog/entity: + config: + groups: -+ deployment: false -``` - -Change a default group title via configuration: - -```diff -# app-config.yaml -app: - extensions: - # Pages -+ - page:catalog/entity: -+ config: -+ groups: -+ deployment: Infrastructure # this is overriding the default group title -``` - -Create a custom entity content group via configuration: - -```diff -# app-config.yaml -app: - extensions: - # Pages -+ - page:catalog/entity: -+ config: -+ groups: -+ # : -+ custom: Custom ++ # This array of groups completely replaces the default groups ++ - custom: ++ title: 'Custom' ``` diff --git a/packages/app-next/app-config.yaml b/packages/app-next/app-config.yaml index ee3007a1a0..6a757f3cb2 100644 --- a/packages/app-next/app-config.yaml +++ b/packages/app-next/app-config.yaml @@ -17,12 +17,13 @@ app: config: groups: # example disabling a default group - development: false + - development: false # example overriding a default group title - documentation: Docs + - documentation: + title: Docs # example adding a new group - # Format <GROUP_ID>: <GROUP_TITLE> - custom: Custom + - custom: + title: Custom # Entity page cards - entity-card:catalog/about diff --git a/plugins/catalog/report-alpha.api.md b/plugins/catalog/report-alpha.api.md index 64ed11928d..ec53d87a31 100644 --- a/plugins/catalog/report-alpha.api.md +++ b/plugins/catalog/report-alpha.api.md @@ -802,12 +802,28 @@ const _default: FrontendPlugin< }>; 'page:catalog/entity': ExtensionDefinition<{ config: { - groups: Record<string, string | false> | undefined; + groups: + | Record< + string, + | false + | { + title: string; + } + >[] + | undefined; } & { path: string | undefined; }; configInput: { - groups?: Record<string, string | false> | undefined; + groups?: + | Record< + string, + | false + | { + title: string; + } + >[] + | undefined; } & { path?: string | undefined; }; diff --git a/plugins/catalog/src/alpha/pages.test.tsx b/plugins/catalog/src/alpha/pages.test.tsx index c21fd51f62..ac47843e1a 100644 --- a/plugins/catalog/src/alpha/pages.test.tsx +++ b/plugins/catalog/src/alpha/pages.test.tsx @@ -198,9 +198,11 @@ describe('Index page', () => { Object.assign({ namespace: 'catalog' }, catalogEntityPage), { config: { - groups: { - documentation: 'Docs', - }, + groups: [ + { + documentation: { title: 'Docs' }, + }, + ], }, }, ) @@ -257,9 +259,11 @@ describe('Index page', () => { Object.assign({ namespace: 'catalog' }, catalogEntityPage), { config: { - groups: { - documentation: false, - }, + groups: [ + { + documentation: false, + }, + ], }, }, ) @@ -360,9 +364,11 @@ describe('Index page', () => { Object.assign({ namespace: 'catalog' }, catalogEntityPage), { config: { - groups: { - docs: 'Docs', - }, + groups: [ + { + docs: { title: 'Docs' }, + }, + ], }, }, ) diff --git a/plugins/catalog/src/alpha/pages.tsx b/plugins/catalog/src/alpha/pages.tsx index 3fd5ab1d56..8fd73e1061 100644 --- a/plugins/catalog/src/alpha/pages.tsx +++ b/plugins/catalog/src/alpha/pages.tsx @@ -71,7 +71,14 @@ export const catalogEntityPage = PageBlueprint.makeWithOverrides({ config: { schema: { groups: z => - z.record(z.string(), z.string().or(z.literal(false))).optional(), + z + .array( + z.record( + z.string(), + z.literal(false).or(z.object({ title: z.string() })), + ), + ) + .optional(), }, }, factory(originalFactory, { config, inputs }) { @@ -82,10 +89,17 @@ export const catalogEntityPage = PageBlueprint.makeWithOverrides({ const { EntityLayout } = await import('./components/EntityLayout'); // config groups override default groups - const groups: Record<string, string> = { - ...defaultEntityContentGroups, - ...config.groups, - }; + const groups: Record<string, string> = config.groups?.length + ? config.groups.reduce<Record<string, string>>((rest, group) => { + const [groupId, groupValue] = Object.entries(group)[0]; + return groupValue + ? { + ...rest, + [groupId]: groupValue.title, + } + : rest; + }, {}) + : defaultEntityContentGroups; // the groups order is determined by the order of the contents // a group will appear in the order of the first item that belongs to it