@redocly/theme
Version:
Shared UI components lib
58 lines • 3.5 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CatalogEntityDefaultRelations = CatalogEntityDefaultRelations;
const react_1 = __importDefault(require("react"));
const CatalogEntityCell_1 = require("../../../../components/Catalog/CatalogTableView/CatalogEntityCell");
const CatalogEntityRelationsTable_1 = require("../../../../components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable");
const CatalogEntityTypeTag_1 = require("../../../../components/Catalog/CatalogEntityTypeTag");
const CatalogEntityRelationCell_1 = require("../../../../components/Catalog/CatalogTableView/CatalogEntityRelationCell");
const CatalogLastUpdateCell_1 = require("../../../../components/Catalog/CatalogTableView/CatalogLastUpdateCell");
function CatalogEntityDefaultRelations({ entity, relations, query, searchQuery, setSearchQuery, entitiesCatalogConfig, catalogConfig, sortOption, setSortOption, handleSortClick, isColumnSorted, shouldShowLoadMore, shouldShowHeading = true, listType, }) {
return (react_1.default.createElement("div", { "data-component-name": "Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations" },
react_1.default.createElement(CatalogEntityRelationsTable_1.CatalogEntityRelationsTable, { entity: entity, catalogConfig: catalogConfig, entitiesCatalogConfig: entitiesCatalogConfig, relations: relations, query: query, searchQuery: searchQuery, setSearchQuery: setSearchQuery, heading: shouldShowHeading ? 'Related entities' : undefined, columns: getRelationsTableColumns(listType), sortOption: sortOption, setSortOption: setSortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted, shouldShowLoadMore: shouldShowLoadMore, listType: listType })));
}
function getRelationsTableColumns(listType) {
const columns = [
{
key: 'entity',
title: 'Entity',
render: (entity) => react_1.default.createElement(CatalogEntityCell_1.CatalogEntityCell, { entity: entity }),
sortable: true,
sortKey: 'title',
width: '4fr',
},
{
key: 'type',
title: 'Type',
render: (entity) => react_1.default.createElement(CatalogEntityTypeTag_1.CatalogEntityTypeTag, { entityType: entity.type }),
sortable: true,
sortKey: 'type',
width: '2fr',
},
{
key: 'relationType',
title: 'Relations',
render: (entity) => (react_1.default.createElement(CatalogEntityRelationCell_1.CatalogEntityRelationCell, { relationType: entity.relationType, relationRole: entity.relationRole })),
width: '2fr',
sortable: true,
sortKey: 'relation_type',
},
{
key: 'lastUpdate',
title: 'Last update',
render: (entity) => react_1.default.createElement(CatalogLastUpdateCell_1.CatalogLastUpdateCell, { lastModified: entity.updatedAt }),
width: '1fr',
minWidth: '112px',
sortable: true,
sortKey: 'updated_at',
},
];
if (listType === 'api-operation' || listType === 'data-schema') {
return columns.filter((column) => column.key !== 'type');
}
return columns;
}
//# sourceMappingURL=CatalogEntityDefaultRelations.js.map