diff --git a/.changeset/seven-dots-serve.md b/.changeset/seven-dots-serve.md
new file mode 100644
index 0000000000..80919b5d28
--- /dev/null
+++ b/.changeset/seven-dots-serve.md
@@ -0,0 +1,5 @@
+---
+'@backstage/plugin-catalog': minor
+---
+
+Exported `CatalogTable.defaultColumnsFunc` for defining the columns in `` of some Kinds while using the default columns for the others.
diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md
index bef24b50d8..feda3fd70d 100644
--- a/plugins/catalog/api-report.md
+++ b/plugins/catalog/api-report.md
@@ -182,6 +182,7 @@ export const CatalogTable: {
): TableColumn;
createNamespaceColumn(): TableColumn;
}>;
+ defaultColumnsFunc: CatalogTableColumnsFunc;
};
// @public
diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx
index 006210bb1d..7da12d7138 100644
--- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx
+++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx
@@ -47,6 +47,7 @@ import React, { ReactNode, useMemo } from 'react';
import { columnFactories } from './columns';
import { CatalogTableColumnsFunc, CatalogTableRow } from './types';
import { PaginatedCatalogTable } from './PaginatedCatalogTable';
+import { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc';
/**
* Props for {@link CatalogTable}.
@@ -77,52 +78,10 @@ const refCompare = (a: Entity, b: Entity) => {
return toRef(a).localeCompare(toRef(b));
};
-const defaultColumnsFunc: CatalogTableColumnsFunc = ({ filters, entities }) => {
- const showTypeColumn = filters.type === undefined;
-
- return [
- columnFactories.createTitleColumn({ hidden: true }),
- columnFactories.createNameColumn({ defaultKind: filters.kind?.value }),
- ...createEntitySpecificColumns(),
- columnFactories.createMetadataDescriptionColumn(),
- columnFactories.createTagsColumn(),
- ];
-
- function createEntitySpecificColumns(): TableColumn[] {
- const baseColumns = [
- columnFactories.createSystemColumn(),
- columnFactories.createOwnerColumn(),
- columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
- columnFactories.createSpecLifecycleColumn(),
- ];
- switch (filters.kind?.value) {
- case 'user':
- return [];
- case 'domain':
- case 'system':
- return [columnFactories.createOwnerColumn()];
- case 'group':
- case 'template':
- return [
- columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
- ];
- case 'location':
- return [
- columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
- columnFactories.createSpecTargetsColumn(),
- ];
- default:
- return entities.every(entity => entity.metadata.namespace === 'default')
- ? baseColumns
- : [...baseColumns, columnFactories.createNamespaceColumn()];
- }
- }
-};
-
/** @public */
export const CatalogTable = (props: CatalogTableProps) => {
const {
- columns = defaultColumnsFunc,
+ columns = defaultCatalogTableColumnsFunc,
tableOptions,
subtitle,
emptyContent,
@@ -267,6 +226,7 @@ export const CatalogTable = (props: CatalogTableProps) => {
};
CatalogTable.columns = columnFactories;
+CatalogTable.defaultColumnsFunc = defaultCatalogTableColumnsFunc;
function toEntityRow(entity: Entity) {
const partOfSystemRelations = getEntityRelations(entity, RELATION_PART_OF, {
diff --git a/plugins/catalog/src/components/CatalogTable/defaultCatalogTableColumnsFunc.tsx b/plugins/catalog/src/components/CatalogTable/defaultCatalogTableColumnsFunc.tsx
new file mode 100644
index 0000000000..85f44d3f51
--- /dev/null
+++ b/plugins/catalog/src/components/CatalogTable/defaultCatalogTableColumnsFunc.tsx
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2023 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { TableColumn } from '@backstage/core-components';
+import { columnFactories } from './columns';
+import { CatalogTableColumnsFunc, CatalogTableRow } from './types';
+
+// The defaultCatalogTableColumnsFunc symbol is not directly exported, but through the
+// CatalogTable.defaultColumnsFunc field.
+/** @public */
+export const defaultCatalogTableColumnsFunc: CatalogTableColumnsFunc = ({
+ filters,
+ entities,
+}) => {
+ const showTypeColumn = filters.type === undefined;
+
+ return [
+ columnFactories.createTitleColumn({ hidden: true }),
+ columnFactories.createNameColumn({ defaultKind: filters.kind?.value }),
+ ...createEntitySpecificColumns(),
+ columnFactories.createMetadataDescriptionColumn(),
+ columnFactories.createTagsColumn(),
+ ];
+
+ function createEntitySpecificColumns(): TableColumn[] {
+ const baseColumns = [
+ columnFactories.createSystemColumn(),
+ columnFactories.createOwnerColumn(),
+ columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
+ columnFactories.createSpecLifecycleColumn(),
+ ];
+ switch (filters.kind?.value) {
+ case 'user':
+ return [];
+ case 'domain':
+ case 'system':
+ return [columnFactories.createOwnerColumn()];
+ case 'group':
+ case 'template':
+ return [
+ columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
+ ];
+ case 'location':
+ return [
+ columnFactories.createSpecTypeColumn({ hidden: !showTypeColumn }),
+ columnFactories.createSpecTargetsColumn(),
+ ];
+ default:
+ return entities.every(entity => entity.metadata.namespace === 'default')
+ ? baseColumns
+ : [...baseColumns, columnFactories.createNamespaceColumn()];
+ }
+ }
+};