From 5bd747da338d44c601f2fb066887df542016b744 Mon Sep 17 00:00:00 2001 From: Shailendra Ahir Date: Wed, 30 Mar 2022 06:28:05 +0530 Subject: [PATCH 1/6] #10453 Added options to CatalogTable.tsx to provide a way to pass options config to table. Signed-off-by: Shailendra Ahir --- plugins/catalog/api-report.md | 2 ++ .../catalog/src/components/CatalogTable/CatalogTable.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index eddbe913d7..2780c85184 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -138,6 +138,8 @@ export interface CatalogTableProps { actions?: TableProps['actions']; // (undocumented) columns?: TableColumn[]; + // (undocumented) + options?: TableProps['options']; } // @public (undocumented) diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 9d59d57647..98283793e2 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -50,6 +50,7 @@ import Star from '@material-ui/icons/Star'; export interface CatalogTableProps { columns?: TableColumn[]; actions?: TableProps['actions']; + options?: TableProps['options']; } const YellowStar = withStyles({ @@ -60,7 +61,7 @@ const YellowStar = withStyles({ /** @public */ export const CatalogTable = (props: CatalogTableProps) => { - const { columns, actions } = props; + const { columns, actions, options } = props; const { isStarredEntity, toggleStarredEntity } = useStarredEntities(); const { loading, error, entities, filters } = useEntityList(); @@ -163,6 +164,8 @@ export const CatalogTable = (props: CatalogTableProps) => { typeColumn.hidden = !showTypeColumn; } const showPagination = rows.length > 20; + const optionsOverride = + options && Object.keys(options).length > 0 ? options : {}; return ( @@ -176,6 +179,7 @@ export const CatalogTable = (props: CatalogTableProps) => { showEmptyDataSourceMessage: !loading, padding: 'dense', pageSizeOptions: [20, 50, 100], + ...optionsOverride, }} title={`${titlePreamble} (${entities.length})`} data={rows} From f6d26940925a774d6e69c34cb53bc957b5409b2f Mon Sep 17 00:00:00 2001 From: Shailendra Ahir Date: Wed, 30 Mar 2022 06:52:52 +0530 Subject: [PATCH 2/6] #10453 Added props to DefaultCatalogPage.tsx and updated changeset Signed-off-by: Shailendra Ahir --- .changeset/moody-apes-tickle.md | 5 +++++ plugins/catalog/api-report.md | 2 ++ .../components/CatalogPage/DefaultCatalogPage.tsx | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changeset/moody-apes-tickle.md diff --git a/.changeset/moody-apes-tickle.md b/.changeset/moody-apes-tickle.md new file mode 100644 index 0000000000..03600c411a --- /dev/null +++ b/.changeset/moody-apes-tickle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Added options property to CatalogTable and DefaultCatalogPage to support customization of the Catalog Table. Related issue #10453 diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index 2780c85184..08ec68990c 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -164,6 +164,8 @@ export interface DefaultCatalogPageProps { columns?: TableColumn[]; // (undocumented) initiallySelectedFilter?: UserListFilterKind; + // (undocumented) + options?: TableProps['options']; } // @public diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx index 2a2861ac29..b2c1f92f9a 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx @@ -48,10 +48,16 @@ export interface DefaultCatalogPageProps { initiallySelectedFilter?: UserListFilterKind; columns?: TableColumn[]; actions?: TableProps['actions']; + options?: TableProps['options']; } export function DefaultCatalogPage(props: DefaultCatalogPageProps) { - const { columns, actions, initiallySelectedFilter = 'owned' } = props; + const { + columns, + actions, + initiallySelectedFilter = 'owned', + options = {}, + } = props; const orgName = useApi(configApiRef).getOptionalString('organization.name') ?? 'Backstage'; const createComponentLink = useRouteRef(createComponentRouteRef); @@ -76,7 +82,11 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) { - + From c2551c9ca1ff6782eb28b719955ec80497718cc9 Mon Sep 17 00:00:00 2001 From: Shailendra Ahir Date: Wed, 30 Mar 2022 07:21:04 +0530 Subject: [PATCH 3/6] #10453 Resolved conflicts Signed-off-by: Shailendra Ahir --- plugins/catalog/api-report.md | 2 ++ .../src/components/CatalogPage/DefaultCatalogPage.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index 08ec68990c..d28cd13f95 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -163,6 +163,8 @@ export interface DefaultCatalogPageProps { // (undocumented) columns?: TableColumn[]; // (undocumented) + initialKind?: string; + // (undocumented) initiallySelectedFilter?: UserListFilterKind; // (undocumented) options?: TableProps['options']; diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx index b2c1f92f9a..b92d993203 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx @@ -48,6 +48,7 @@ export interface DefaultCatalogPageProps { initiallySelectedFilter?: UserListFilterKind; columns?: TableColumn[]; actions?: TableProps['actions']; + initialKind?: string; options?: TableProps['options']; } @@ -56,6 +57,7 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) { columns, actions, initiallySelectedFilter = 'owned', + initialKind = 'component', options = {}, } = props; const orgName = @@ -66,7 +68,9 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) { - }> + } + > Date: Thu, 31 Mar 2022 20:40:27 +0530 Subject: [PATCH 4/6] #10453 Updated variable names after feedback Signed-off-by: Shailendra Ahir --- .../src/components/CatalogPage/DefaultCatalogPage.tsx | 6 +++--- .../catalog/src/components/CatalogTable/CatalogTable.tsx | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx index b92d993203..5250dcec0d 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.tsx @@ -49,7 +49,7 @@ export interface DefaultCatalogPageProps { columns?: TableColumn[]; actions?: TableProps['actions']; initialKind?: string; - options?: TableProps['options']; + tableOptions?: TableProps['options']; } export function DefaultCatalogPage(props: DefaultCatalogPageProps) { @@ -58,7 +58,7 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) { actions, initiallySelectedFilter = 'owned', initialKind = 'component', - options = {}, + tableOptions = {}, } = props; const orgName = useApi(configApiRef).getOptionalString('organization.name') ?? 'Backstage'; @@ -89,7 +89,7 @@ export function DefaultCatalogPage(props: DefaultCatalogPageProps) { diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index 98283793e2..433032a69e 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -50,7 +50,7 @@ import Star from '@material-ui/icons/Star'; export interface CatalogTableProps { columns?: TableColumn[]; actions?: TableProps['actions']; - options?: TableProps['options']; + tableOptions?: TableProps['options']; } const YellowStar = withStyles({ @@ -61,7 +61,7 @@ const YellowStar = withStyles({ /** @public */ export const CatalogTable = (props: CatalogTableProps) => { - const { columns, actions, options } = props; + const { columns, actions, tableOptions } = props; const { isStarredEntity, toggleStarredEntity } = useStarredEntities(); const { loading, error, entities, filters } = useEntityList(); @@ -164,8 +164,6 @@ export const CatalogTable = (props: CatalogTableProps) => { typeColumn.hidden = !showTypeColumn; } const showPagination = rows.length > 20; - const optionsOverride = - options && Object.keys(options).length > 0 ? options : {}; return ( @@ -179,7 +177,7 @@ export const CatalogTable = (props: CatalogTableProps) => { showEmptyDataSourceMessage: !loading, padding: 'dense', pageSizeOptions: [20, 50, 100], - ...optionsOverride, + ...tableOptions, }} title={`${titlePreamble} (${entities.length})`} data={rows} From f86bba8fb825316086c08b0f538e48e4795ecf64 Mon Sep 17 00:00:00 2001 From: Shailendra Ahir Date: Thu, 31 Mar 2022 20:50:28 +0530 Subject: [PATCH 5/6] #10453 Updated api-report.md Signed-off-by: Shailendra Ahir --- plugins/catalog/api-report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index d28cd13f95..d1e733a553 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -139,7 +139,7 @@ export interface CatalogTableProps { // (undocumented) columns?: TableColumn[]; // (undocumented) - options?: TableProps['options']; + tableOptions?: TableProps['options']; } // @public (undocumented) @@ -167,7 +167,7 @@ export interface DefaultCatalogPageProps { // (undocumented) initiallySelectedFilter?: UserListFilterKind; // (undocumented) - options?: TableProps['options']; + tableOptions?: TableProps['options']; } // @public From ecaf8ff3a4ffea6d9d9b94ec78501d339bf7e560 Mon Sep 17 00:00:00 2001 From: Shailendra Ahir <31934874+shailahir@users.noreply.github.com> Date: Thu, 31 Mar 2022 20:54:11 +0530 Subject: [PATCH 6/6] Update moody-apes-tickle.md Signed-off-by: Shailendra Ahir --- .changeset/moody-apes-tickle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/moody-apes-tickle.md b/.changeset/moody-apes-tickle.md index 03600c411a..bdf593c9ad 100644 --- a/.changeset/moody-apes-tickle.md +++ b/.changeset/moody-apes-tickle.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog': patch --- -Added options property to CatalogTable and DefaultCatalogPage to support customization of the Catalog Table. Related issue #10453 +Added tableOptions property to CatalogTable and DefaultCatalogPage to support customization of the Catalog Table. Related issue #10453