@redocly/theme 0.63.0 → 0.64.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Catalog/Catalog.js +3 -32
- package/lib/components/Catalog/CatalogActionsRow.d.ts +6 -4
- package/lib/components/Catalog/CatalogActionsRow.js +49 -5
- package/lib/components/Catalog/CatalogEntities.d.ts +0 -1
- package/lib/components/Catalog/CatalogEntities.js +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +31 -25
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +1 -1
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +2 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +1 -2
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.js +2 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.d.ts +1 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +1 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +1 -2
- package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +2 -2
- package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.d.ts +1 -3
- package/lib/core/hooks/catalog/use-catalog-table-header-cell-actions.js +1 -4
- package/lib/core/types/hooks.d.ts +2 -2
- package/package.json +2 -2
- package/src/components/Catalog/Catalog.tsx +9 -43
- package/src/components/Catalog/CatalogActionsRow.tsx +25 -7
- package/src/components/Catalog/CatalogEntities.tsx +0 -3
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +39 -31
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +1 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +2 -2
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +0 -3
- package/src/components/Catalog/CatalogTableView/CatalogTableHeaderCell.tsx +0 -3
- package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +0 -3
- package/src/core/hooks/catalog/use-catalog-table-header-cell-actions.ts +0 -6
- package/src/core/types/hooks.ts +2 -1
|
@@ -48,11 +48,10 @@ const CatalogSelector_1 = require("../../components/Catalog/CatalogSelector");
|
|
|
48
48
|
const SidebarActions_1 = require("../../components/SidebarActions/SidebarActions");
|
|
49
49
|
const CounterTag_1 = require("../../components/Tags/CounterTag");
|
|
50
50
|
const FilterInput_1 = require("../../components/Filter/FilterInput");
|
|
51
|
-
const CatalogViewModeToggle_1 = require("../../components/Catalog/CatalogViewModeToggle");
|
|
52
|
-
const CatalogSortButton_1 = require("../../components/Catalog/CatalogSortButton");
|
|
53
51
|
const CatalogEntities_1 = require("../../components/Catalog/CatalogEntities");
|
|
54
52
|
const CatalogMobileTopBar_1 = require("../../components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar");
|
|
55
53
|
const CatalogMobileFiltersPanelOverlay_1 = require("../../components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay");
|
|
54
|
+
const CatalogActionsRow_1 = require("../../components/Catalog/CatalogActionsRow");
|
|
56
55
|
function getActiveFiltersCount(filters, filterTerm) {
|
|
57
56
|
const filterOptionsCount = filters.reduce((sum, filter) => {
|
|
58
57
|
if (filter.selectedOptions instanceof Set)
|
|
@@ -101,29 +100,9 @@ function Catalog(props) {
|
|
|
101
100
|
' '),
|
|
102
101
|
react_1.default.createElement(CounterTag_1.CounterTag, { borderless: true }, entitiesCounter)),
|
|
103
102
|
react_1.default.createElement(CatalogDescription, { "data-translation-key": catalogConfig === null || catalogConfig === void 0 ? void 0 : catalogConfig.descriptionTranslationKey }, translate(catalogConfig === null || catalogConfig === void 0 ? void 0 : catalogConfig.descriptionTranslationKey)),
|
|
104
|
-
react_1.default.createElement(CatalogActionsRow,
|
|
105
|
-
|
|
106
|
-
react_1.default.createElement(FilterInput_1.FilterInput, { value: searchQuery, onChange: (updatedTerm) => setSearchQuery(updatedTerm), dataTestId: "catalog-search-input" })),
|
|
107
|
-
react_1.default.createElement(CatalogControlsWrapper, null,
|
|
108
|
-
react_1.default.createElement(CatalogSortButton_1.CatalogSortButton, { onSortChange: setSortOption, currentSort: sortOption }),
|
|
109
|
-
react_1.default.createElement(CatalogViewModeToggle_1.CatalogViewModeToggle, { viewMode: viewMode, onViewModeChange: setViewMode }))),
|
|
110
|
-
react_1.default.createElement(CatalogEntities_1.CatalogEntities, { catalogConfig: catalogConfig, excludedEntities: catalogConfig === null || catalogConfig === void 0 ? void 0 : catalogConfig.excludes, filterQuery: filterQuery, entitiesTypes: entitiesTypes, sortOption: sortOption, searchQuery: searchQuery, viewMode: viewMode, setEntitiesCounter: setEntitiesCounter, initialEntitiesList: initialEntitiesList, setSortOption: setSortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted })))))));
|
|
103
|
+
react_1.default.createElement(CatalogActionsRow_1.CatalogActionsRow, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, sortOption: sortOption, setSortOption: setSortOption, viewMode: viewMode, onViewModeChange: setViewMode }),
|
|
104
|
+
react_1.default.createElement(CatalogEntities_1.CatalogEntities, { catalogConfig: catalogConfig, excludedEntities: catalogConfig === null || catalogConfig === void 0 ? void 0 : catalogConfig.excludes, filterQuery: filterQuery, entitiesTypes: entitiesTypes, sortOption: sortOption, searchQuery: searchQuery, viewMode: viewMode, setEntitiesCounter: setEntitiesCounter, initialEntitiesList: initialEntitiesList, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted })))))));
|
|
111
105
|
}
|
|
112
|
-
const CatalogActionsRow = styled_components_1.default.div `
|
|
113
|
-
display: flex;
|
|
114
|
-
align-items: center;
|
|
115
|
-
margin-bottom: var(--spacing-xl);
|
|
116
|
-
|
|
117
|
-
@media screen and (max-width: ${utils_1.breakpoints.medium}) {
|
|
118
|
-
display: none;
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
const CatalogControlsWrapper = styled_components_1.default.div `
|
|
122
|
-
display: var(--catalog-controls-wrapper-display);
|
|
123
|
-
align-items: var(--catalog-controls-wrapper-align-items);
|
|
124
|
-
margin-left: var(--catalog-controls-wrapper-margin-left);
|
|
125
|
-
gap: var(--catalog-controls-wrapper-gap);
|
|
126
|
-
`;
|
|
127
106
|
const CatalogContentWrapper = styled_components_1.default.div `
|
|
128
107
|
flex: 1;
|
|
129
108
|
min-width: 0;
|
|
@@ -216,12 +195,4 @@ const FiltersSidebar = (0, styled_components_1.default)(Sidebar_1.Sidebar) `
|
|
|
216
195
|
border: none;
|
|
217
196
|
}
|
|
218
197
|
`;
|
|
219
|
-
const CatalogSearchInputWrapper = styled_components_1.default.div `
|
|
220
|
-
display: none;
|
|
221
|
-
width: var(--catalog-search-input-wrapper-width);
|
|
222
|
-
|
|
223
|
-
@media screen and (min-width: ${utils_1.breakpoints.medium}) {
|
|
224
|
-
display: block;
|
|
225
|
-
}
|
|
226
|
-
`;
|
|
227
198
|
//# sourceMappingURL=Catalog.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSX } from 'react';
|
|
2
2
|
import { SortOption, CatalogViewMode } from '../../core/types';
|
|
3
3
|
export type CatalogActionsRowProps = {
|
|
4
4
|
searchQuery: string;
|
|
@@ -7,9 +7,11 @@ export type CatalogActionsRowProps = {
|
|
|
7
7
|
setSortOption: (option: SortOption | null) => void;
|
|
8
8
|
viewMode?: CatalogViewMode;
|
|
9
9
|
onViewModeChange?: (mode: CatalogViewMode) => void;
|
|
10
|
-
|
|
10
|
+
isDetailsPage?: boolean;
|
|
11
11
|
};
|
|
12
|
-
export declare function CatalogActionsRow({ searchQuery, setSearchQuery, sortOption, setSortOption, viewMode, onViewModeChange,
|
|
13
|
-
export declare const CatalogActionsRowWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
+
export declare function CatalogActionsRow({ searchQuery, setSearchQuery, sortOption, setSortOption, viewMode, onViewModeChange, isDetailsPage, }: CatalogActionsRowProps): JSX.Element;
|
|
13
|
+
export declare const CatalogActionsRowWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
14
|
+
isDetailsPage: boolean;
|
|
15
|
+
}, never>;
|
|
14
16
|
export declare const CatalogControlsWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
17
|
export declare const CatalogSearchInputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,21 +39,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
exports.CatalogSearchInputWrapper = exports.CatalogControlsWrapper = exports.CatalogActionsRowWrapper = void 0;
|
|
7
40
|
exports.CatalogActionsRow = CatalogActionsRow;
|
|
8
41
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const styled_components_1 =
|
|
42
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
10
43
|
const FilterInput_1 = require("../../components/Filter/FilterInput");
|
|
11
44
|
const CatalogSortButton_1 = require("../../components/Catalog/CatalogSortButton");
|
|
12
45
|
const CatalogViewModeToggle_1 = require("../../components/Catalog/CatalogViewModeToggle");
|
|
13
|
-
|
|
14
|
-
|
|
46
|
+
const core_1 = require("../../core");
|
|
47
|
+
function CatalogActionsRow({ searchQuery, setSearchQuery, sortOption, setSortOption, viewMode, onViewModeChange, isDetailsPage = false, }) {
|
|
48
|
+
return (react_1.default.createElement(exports.CatalogActionsRowWrapper, { isDetailsPage: isDetailsPage },
|
|
15
49
|
react_1.default.createElement(exports.CatalogSearchInputWrapper, null,
|
|
16
|
-
react_1.default.createElement(FilterInput_1.FilterInput, { value: searchQuery, onChange: (updatedTerm) => setSearchQuery(updatedTerm) })),
|
|
50
|
+
react_1.default.createElement(FilterInput_1.FilterInput, { value: searchQuery, onChange: (updatedTerm) => setSearchQuery(updatedTerm), dataTestId: "catalog-search-input" })),
|
|
17
51
|
react_1.default.createElement(exports.CatalogControlsWrapper, null,
|
|
18
|
-
react_1.default.createElement(CatalogSortButton_1.CatalogSortButton, { onSortChange: setSortOption, currentSort: sortOption }),
|
|
52
|
+
viewMode === 'cards' && (react_1.default.createElement(CatalogSortButton_1.CatalogSortButton, { onSortChange: setSortOption, currentSort: sortOption })),
|
|
19
53
|
viewMode && onViewModeChange && (react_1.default.createElement(CatalogViewModeToggle_1.CatalogViewModeToggle, { viewMode: viewMode, onViewModeChange: onViewModeChange })))));
|
|
20
54
|
}
|
|
21
55
|
exports.CatalogActionsRowWrapper = styled_components_1.default.div `
|
|
22
56
|
display: flex;
|
|
23
57
|
align-items: center;
|
|
58
|
+
|
|
59
|
+
margin-bottom: ${({ isDetailsPage }) => (isDetailsPage ? 'var(--spacing-sm)' : 'var(--spacing-xl)')};
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
${({ isDetailsPage }) => !isDetailsPage &&
|
|
63
|
+
(0, styled_components_1.css) `
|
|
64
|
+
@media screen and (max-width: ${core_1.breakpoints.medium}) {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
`}
|
|
24
68
|
`;
|
|
25
69
|
exports.CatalogControlsWrapper = styled_components_1.default.div `
|
|
26
70
|
display: var(--catalog-controls-wrapper-display);
|
|
@@ -11,7 +11,6 @@ export type CatalogEntitiesProps = {
|
|
|
11
11
|
setEntitiesCounter: (counter: number) => void;
|
|
12
12
|
initialEntitiesList?: BffCatalogEntityList;
|
|
13
13
|
sortOption: SortOption | null;
|
|
14
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
15
14
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
16
15
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
17
16
|
};
|
|
@@ -44,7 +44,7 @@ const LoadMore_1 = require("../../components/LoadMore/LoadMore");
|
|
|
44
44
|
const CatalogEntitiesEmptyState_1 = require("../../components/Catalog/CatalogEntitiesEmptyState");
|
|
45
45
|
const LOAD_MORE_THRESHOLD = 10;
|
|
46
46
|
function CatalogEntities(props) {
|
|
47
|
-
const { catalogConfig, excludedEntities, filterQuery, entitiesTypes, sortOption, searchQuery, viewMode, setEntitiesCounter,
|
|
47
|
+
const { catalogConfig, excludedEntities, filterQuery, entitiesTypes, sortOption, searchQuery, viewMode, setEntitiesCounter, handleSortClick, isColumnSorted, } = props;
|
|
48
48
|
const { getEntityDetailsLink } = (0, hooks_1.useCatalogEntityDetails)({
|
|
49
49
|
catalogConfig,
|
|
50
50
|
});
|
|
@@ -85,7 +85,7 @@ function CatalogEntities(props) {
|
|
|
85
85
|
return react_1.default.createElement(CatalogEntitiesEmptyState_1.CatalogEntitiesEmptyState, null);
|
|
86
86
|
}
|
|
87
87
|
return (react_1.default.createElement(CatalogHighlight_1.HighlightContext.Provider, { value: [searchQuery], "data-component-name": "Catalog/CatalogEntities" },
|
|
88
|
-
viewMode === 'cards' ? (react_1.default.createElement(CatalogCardView_1.CatalogCardView, { entities: entities, catalogConfig: catalogConfig })) : (react_1.default.createElement(CatalogTableView_1.CatalogTableView, { entities: entities, catalogConfig: catalogConfig,
|
|
88
|
+
viewMode === 'cards' ? (react_1.default.createElement(CatalogCardView_1.CatalogCardView, { entities: entities, catalogConfig: catalogConfig })) : (react_1.default.createElement(CatalogTableView_1.CatalogTableView, { entities: entities, catalogConfig: catalogConfig, currentSortOption: sortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted, onRowClick: onRowClick })),
|
|
89
89
|
shouldShowLoadMore && (react_1.default.createElement(LoadMore_1.LoadMore, { icon: react_1.default.createElement(ArrowDownIcon_1.ArrowDownIcon, { size: "var(--catalog-load-more-icon-size)" }), onClick: query.fetchNextPage, disabled: query.isFetchingNextPage, blinking: query.isFetchingNextPage, label: query.isFetchingNextPage ? 'Loading...' : 'Load More' }))));
|
|
90
90
|
}
|
|
91
91
|
//# sourceMappingURL=CatalogEntities.js.map
|
package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js
CHANGED
|
@@ -9,32 +9,38 @@ const CatalogEntityCell_1 = require("../../../../components/Catalog/CatalogTable
|
|
|
9
9
|
const CatalogEntityRelationsTable_1 = require("../../../../components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable");
|
|
10
10
|
const CatalogEntityTypeTag_1 = require("../../../../components/Catalog/CatalogEntityTypeTag");
|
|
11
11
|
const CatalogEntityRelationCell_1 = require("../../../../components/Catalog/CatalogTableView/CatalogEntityRelationCell");
|
|
12
|
-
const columns = [
|
|
13
|
-
{
|
|
14
|
-
key: 'entity',
|
|
15
|
-
title: 'Entity',
|
|
16
|
-
render: (entity) => react_1.default.createElement(CatalogEntityCell_1.CatalogEntityCell, { entity: entity }),
|
|
17
|
-
sortable: true,
|
|
18
|
-
sortKey: 'title',
|
|
19
|
-
width: '2.5fr',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
key: 'type',
|
|
23
|
-
title: 'Type',
|
|
24
|
-
render: (entity) => react_1.default.createElement(CatalogEntityTypeTag_1.CatalogEntityTypeTag, { entityType: entity.type }),
|
|
25
|
-
sortable: true,
|
|
26
|
-
sortKey: 'type',
|
|
27
|
-
width: '1fr',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
key: 'relationType',
|
|
31
|
-
title: 'Relations',
|
|
32
|
-
render: (entity) => (react_1.default.createElement(CatalogEntityRelationCell_1.CatalogEntityRelationCell, { relationType: entity.relationType, relationRole: entity.relationRole })),
|
|
33
|
-
width: '1fr',
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
12
|
function CatalogEntityDefaultRelations({ entity, relations, query, searchQuery, setSearchQuery, entitiesCatalogConfig, catalogConfig, sortOption, setSortOption, handleSortClick, isColumnSorted, shouldShowLoadMore, shouldShowHeading = true, listType, }) {
|
|
37
13
|
return (react_1.default.createElement("div", { "data-component-name": "Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations" },
|
|
38
|
-
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:
|
|
14
|
+
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 })));
|
|
15
|
+
}
|
|
16
|
+
function getRelationsTableColumns(listType) {
|
|
17
|
+
const columns = [
|
|
18
|
+
{
|
|
19
|
+
key: 'entity',
|
|
20
|
+
title: 'Entity',
|
|
21
|
+
render: (entity) => react_1.default.createElement(CatalogEntityCell_1.CatalogEntityCell, { entity: entity }),
|
|
22
|
+
sortable: true,
|
|
23
|
+
sortKey: 'title',
|
|
24
|
+
width: '2.5fr',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: 'type',
|
|
28
|
+
title: 'Type',
|
|
29
|
+
render: (entity) => react_1.default.createElement(CatalogEntityTypeTag_1.CatalogEntityTypeTag, { entityType: entity.type }),
|
|
30
|
+
sortable: true,
|
|
31
|
+
sortKey: 'type',
|
|
32
|
+
width: '1fr',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: 'relationType',
|
|
36
|
+
title: 'Relations',
|
|
37
|
+
render: (entity) => (react_1.default.createElement(CatalogEntityRelationCell_1.CatalogEntityRelationCell, { relationType: entity.relationType, relationRole: entity.relationRole })),
|
|
38
|
+
width: '1fr',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
if (listType === 'api-operation' || listType === 'data-schema') {
|
|
42
|
+
return columns.filter((column) => column.key !== 'type');
|
|
43
|
+
}
|
|
44
|
+
return columns;
|
|
39
45
|
}
|
|
40
46
|
//# sourceMappingURL=CatalogEntityDefaultRelations.js.map
|
package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js
CHANGED
|
@@ -46,7 +46,7 @@ const ENTITY_DEFAULT_FILTERS = {
|
|
|
46
46
|
};
|
|
47
47
|
function CatalogEntityRelations({ entity, entitiesCatalogConfig, initialRelations, catalogConfig, searchQuery, setSearchQuery, }) {
|
|
48
48
|
const { useCatalogSort, useFetchCatalogEntitiesRelations } = (0, hooks_1.useThemeHooks)();
|
|
49
|
-
const { sortOption, setSortOption, handleSortClick, isColumnSorted } = useCatalogSort();
|
|
49
|
+
const { sortOption, setSortOption, handleSortClick, isColumnSorted } = useCatalogSort('title');
|
|
50
50
|
const [filter, setFilter] = (0, react_1.useState)(ENTITY_DEFAULT_FILTERS[entity.type]);
|
|
51
51
|
(0, react_1.useEffect)(() => {
|
|
52
52
|
setFilter(ENTITY_DEFAULT_FILTERS[entity.key]);
|
package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js
CHANGED
|
@@ -36,8 +36,8 @@ function CatalogEntityRelationsTable({ entity, entitiesCatalogConfig, catalogCon
|
|
|
36
36
|
};
|
|
37
37
|
return (react_1.default.createElement(CatalogEntityRelationsTableWrapper, { "data-component-name": "Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable" },
|
|
38
38
|
heading && react_1.default.createElement(Heading, null, heading),
|
|
39
|
-
react_1.default.createElement(CatalogActionsRow_1.CatalogActionsRow, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, sortOption: sortOption, setSortOption: setSortOption,
|
|
40
|
-
react_1.default.createElement(CatalogEntityRelationsTableContent_1.CatalogEntityRelationsTableContent, { entitiesCatalogConfig: entitiesCatalogConfig, catalogConfig: catalogConfig, relations: relations, query: query, searchQuery: searchQuery, columns: columns,
|
|
39
|
+
react_1.default.createElement(CatalogActionsRow_1.CatalogActionsRow, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, sortOption: sortOption, setSortOption: setSortOption, viewMode: "table", isDetailsPage: true }),
|
|
40
|
+
react_1.default.createElement(CatalogEntityRelationsTableContent_1.CatalogEntityRelationsTableContent, { entitiesCatalogConfig: entitiesCatalogConfig, catalogConfig: catalogConfig, relations: relations, query: query, searchQuery: searchQuery, columns: columns, sortOption: sortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted, shouldShowLoadMore: shouldShowLoadMore, listType: listType, onRowClick: onRowClick })));
|
|
41
41
|
}
|
|
42
42
|
const CatalogEntityRelationsTableWrapper = styled_components_1.default.div `
|
|
43
43
|
min-width: 0;
|
|
@@ -14,11 +14,10 @@ export type CatalogEntityRelationsTableContentProps = {
|
|
|
14
14
|
searchQuery: string;
|
|
15
15
|
columns: CatalogColumn<BffCatalogRelatedEntity>[];
|
|
16
16
|
sortOption: SortOption | null;
|
|
17
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
18
17
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
19
18
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
20
19
|
shouldShowLoadMore: boolean;
|
|
21
20
|
listType?: ListType;
|
|
22
21
|
onRowClick: (entity: BffCatalogRelatedEntity) => void;
|
|
23
22
|
};
|
|
24
|
-
export declare function CatalogEntityRelationsTableContent({ entitiesCatalogConfig, catalogConfig, relations, query, searchQuery, columns,
|
|
23
|
+
export declare function CatalogEntityRelationsTableContent({ entitiesCatalogConfig, catalogConfig, relations, query, searchQuery, columns, sortOption, handleSortClick, isColumnSorted, shouldShowLoadMore, listType, onRowClick, }: CatalogEntityRelationsTableContentProps): JSX.Element;
|
|
@@ -11,9 +11,9 @@ const LoadMore_1 = require("../../../../components/LoadMore/LoadMore");
|
|
|
11
11
|
const CatalogTableView_1 = require("../../../../components/Catalog/CatalogTableView/CatalogTableView");
|
|
12
12
|
const CatalogHighlight_1 = require("../../../../components/Catalog/CatalogHighlight");
|
|
13
13
|
const CatalogEntitiesEmptyState_1 = require("../../../../components/Catalog/CatalogEntitiesEmptyState");
|
|
14
|
-
function CatalogEntityRelationsTableContent({ entitiesCatalogConfig, catalogConfig, relations, query, searchQuery, columns,
|
|
14
|
+
function CatalogEntityRelationsTableContent({ entitiesCatalogConfig, catalogConfig, relations, query, searchQuery, columns, sortOption, handleSortClick, isColumnSorted, shouldShowLoadMore, listType, onRowClick, }) {
|
|
15
15
|
return (react_1.default.createElement(TableContentWrapper, { "data-component-name": "Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent" },
|
|
16
|
-
react_1.default.createElement(CatalogHighlight_1.HighlightContext.Provider, { value: [searchQuery] }, relations.length > 0 ? (react_1.default.createElement(CatalogTableView_1.CatalogTableView, { entities: relations, entitiesCatalogConfig: entitiesCatalogConfig, catalogConfig: catalogConfig, columns: columns,
|
|
16
|
+
react_1.default.createElement(CatalogHighlight_1.HighlightContext.Provider, { value: [searchQuery] }, relations.length > 0 ? (react_1.default.createElement(CatalogTableView_1.CatalogTableView, { entities: relations, entitiesCatalogConfig: entitiesCatalogConfig, catalogConfig: catalogConfig, columns: columns, currentSortOption: sortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted, style: { marginTop: 0 }, onRowClick: onRowClick, contentMinWidth: TABLE_SCROLL_MIN_WIDTH_PX })) : (react_1.default.createElement(CatalogEntitiesEmptyState_1.CatalogEntitiesEmptyState, { listType: listType }))),
|
|
17
17
|
shouldShowLoadMore && (react_1.default.createElement(LoadMore_1.LoadMore, { icon: react_1.default.createElement(ArrowDownIcon_1.ArrowDownIcon, { size: "var(--catalog-load-more-icon-size)" }), onClick: query.fetchNextPage, disabled: query.isFetchingNextPage, blinking: query.isFetchingNextPage, label: query.isFetchingNextPage ? 'Loading...' : 'Load More' }))));
|
|
18
18
|
}
|
|
19
19
|
const TABLE_SCROLL_MIN_WIDTH_PX = 608;
|
|
@@ -3,9 +3,8 @@ import { SortOption } from '../../../core/types';
|
|
|
3
3
|
import { BaseEntity, CatalogColumn } from '../../../components/Catalog/CatalogTableView/CatalogTableView';
|
|
4
4
|
export type CatalogTableHeaderCellProps<T extends BaseEntity> = {
|
|
5
5
|
column: CatalogColumn<T>;
|
|
6
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
7
6
|
currentSortOption?: SortOption | null;
|
|
8
7
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
9
8
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
10
9
|
};
|
|
11
|
-
export declare const CatalogTableHeaderCell: <T extends BaseEntity>({ column, handleSortClick, isColumnSorted,
|
|
10
|
+
export declare const CatalogTableHeaderCell: <T extends BaseEntity>({ column, handleSortClick, isColumnSorted, }: CatalogTableHeaderCellProps<T>) => React.JSX.Element;
|
|
@@ -42,12 +42,11 @@ const styled_components_1 = __importStar(require("styled-components"));
|
|
|
42
42
|
const CaretDownIcon_1 = require("../../../icons/CaretDownIcon/CaretDownIcon");
|
|
43
43
|
const CaretUpIcon_1 = require("../../../icons/CaretUpIcon/CaretUpIcon");
|
|
44
44
|
const hooks_1 = require("../../../core/hooks");
|
|
45
|
-
const CatalogTableHeaderCell = ({ column, handleSortClick, isColumnSorted,
|
|
45
|
+
const CatalogTableHeaderCell = ({ column, handleSortClick, isColumnSorted, }) => {
|
|
46
46
|
const { handleCellClick, sortKey, isUpActive, isDownActive } = (0, hooks_1.useCatalogTableHeaderCellActions)({
|
|
47
47
|
column,
|
|
48
48
|
handleSortClick,
|
|
49
49
|
isColumnSorted,
|
|
50
|
-
setSortOption,
|
|
51
50
|
});
|
|
52
51
|
return (react_1.default.createElement(TableHeaderCellWrapper, { key: column.key, "data-component-name": "Catalog/CatalogTableView/CatalogTableHeaderCell", onClick: handleCellClick, "$sortable": Boolean(column.sortable && sortKey) },
|
|
53
52
|
react_1.default.createElement(HeaderContent, null,
|
|
@@ -13,7 +13,6 @@ export type CatalogTableViewProps<T extends BaseEntity> = {
|
|
|
13
13
|
entitiesCatalogConfig?: EntitiesCatalogConfig;
|
|
14
14
|
catalogConfig: CatalogEntityConfig;
|
|
15
15
|
columns?: CatalogColumn<T>[];
|
|
16
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
17
16
|
currentSortOption?: SortOption | null;
|
|
18
17
|
onRowClick?: (entity: T) => void;
|
|
19
18
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
@@ -30,4 +29,4 @@ export type CatalogColumn<T> = {
|
|
|
30
29
|
sortable?: boolean;
|
|
31
30
|
sortKey?: string;
|
|
32
31
|
};
|
|
33
|
-
export declare const CatalogTableView: <T extends BaseEntity>({ entities, entitiesCatalogConfig, catalogConfig, columns,
|
|
32
|
+
export declare const CatalogTableView: <T extends BaseEntity>({ entities, entitiesCatalogConfig, catalogConfig, columns, currentSortOption, onRowClick, handleSortClick, isColumnSorted, style, contentMinWidth, }: CatalogTableViewProps<T>) => React.JSX.Element;
|
|
@@ -61,9 +61,9 @@ const baseColumns = [
|
|
|
61
61
|
minWidth: '120px',
|
|
62
62
|
},
|
|
63
63
|
];
|
|
64
|
-
const CatalogTableView = ({ entities, entitiesCatalogConfig, catalogConfig, columns = baseColumns,
|
|
64
|
+
const CatalogTableView = ({ entities, entitiesCatalogConfig, catalogConfig, columns = baseColumns, currentSortOption, onRowClick, handleSortClick, isColumnSorted, style, contentMinWidth, }) => {
|
|
65
65
|
const tableContent = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
66
|
-
react_1.default.createElement(CatalogTableHeader, { columnsWidths: columns.map((column) => column.width || '1fr'), columnsMinWidths: columns.map((column) => column.minWidth || 'auto') }, columns.map((column) => (react_1.default.createElement(CatalogTableHeaderCell_1.CatalogTableHeaderCell, { key: column.key, column: column,
|
|
66
|
+
react_1.default.createElement(CatalogTableHeader, { columnsWidths: columns.map((column) => column.width || '1fr'), columnsMinWidths: columns.map((column) => column.minWidth || 'auto') }, columns.map((column) => (react_1.default.createElement(CatalogTableHeaderCell_1.CatalogTableHeaderCell, { key: column.key, column: column, currentSortOption: currentSortOption, handleSortClick: handleSortClick, isColumnSorted: isColumnSorted })))),
|
|
67
67
|
react_1.default.createElement(CatalogTableBody, null, entities.map((entity) => (react_1.default.createElement(CatalogTableViewRow_1.CatalogTableViewRow, { key: entity.id, entity: entity, entitiesCatalogConfig: entitiesCatalogConfig, catalogConfig: catalogConfig, columns: columns, onRowClick: onRowClick }))))));
|
|
68
68
|
return (react_1.default.createElement(CatalogTableWrapper, { "data-component-name": "Catalog/CatalogTableView", style: style }, contentMinWidth != null ? (react_1.default.createElement(CatalogTableContentInner, { "$contentMinWidth": contentMinWidth }, tableContent)) : (react_1.default.createElement(CatalogTableScrollContent, null, tableContent))));
|
|
69
69
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { BaseEntity, CatalogColumn } from '../../../components/Catalog/CatalogTableView/CatalogTableView';
|
|
2
|
-
import { SortOption } from '../../types';
|
|
3
2
|
type CatalogTableHeaderCellActionsProps<T extends BaseEntity> = {
|
|
4
3
|
column: CatalogColumn<T>;
|
|
5
4
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
6
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
7
5
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
8
6
|
};
|
|
9
|
-
export declare function useCatalogTableHeaderCellActions<T extends BaseEntity>({ column, handleSortClick,
|
|
7
|
+
export declare function useCatalogTableHeaderCellActions<T extends BaseEntity>({ column, handleSortClick, isColumnSorted, }: CatalogTableHeaderCellActionsProps<T>): {
|
|
10
8
|
handleCellClick: () => void;
|
|
11
9
|
sortKey: string | undefined;
|
|
12
10
|
isUpActive: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCatalogTableHeaderCellActions = useCatalogTableHeaderCellActions;
|
|
4
|
-
function useCatalogTableHeaderCellActions({ column, handleSortClick,
|
|
4
|
+
function useCatalogTableHeaderCellActions({ column, handleSortClick, isColumnSorted, }) {
|
|
5
5
|
const sortKey = column.sortKey;
|
|
6
6
|
const isUpActive = sortKey ? isColumnSorted(sortKey, 'desc') : false;
|
|
7
7
|
const isDownActive = sortKey ? isColumnSorted(sortKey, 'asc') : false;
|
|
@@ -11,9 +11,6 @@ function useCatalogTableHeaderCellActions({ column, handleSortClick, setSortOpti
|
|
|
11
11
|
if (isDownActive) {
|
|
12
12
|
handleSortClick(sortKey, 'desc');
|
|
13
13
|
}
|
|
14
|
-
else if (isUpActive) {
|
|
15
|
-
setSortOption(null);
|
|
16
|
-
}
|
|
17
14
|
else {
|
|
18
15
|
handleSortClick(sortKey, 'asc');
|
|
19
16
|
}
|
|
@@ -5,7 +5,7 @@ import type { Callback, TFunction as TFunc } from 'i18next';
|
|
|
5
5
|
import type { To, Location, NavigateFunction } from 'react-router-dom';
|
|
6
6
|
import type { UseQueryResult } from '@tanstack/react-query';
|
|
7
7
|
import type { CatalogConfig, ProductUiConfig } from '../../config';
|
|
8
|
-
import type { UseCatalogResponse, FilteredCatalog, UseCatalogSortResponse, UseCatalogSearchResponse, UseCatalogProps, CatalogApiParams, CatalogApiResults } from './catalog';
|
|
8
|
+
import type { UseCatalogResponse, FilteredCatalog, UseCatalogSortResponse, UseCatalogSearchResponse, UseCatalogProps, CatalogApiParams, CatalogApiResults, SortOption } from './catalog';
|
|
9
9
|
import type { UserMenuData } from './user-menu';
|
|
10
10
|
import type { ItemState } from './sidebar';
|
|
11
11
|
import type { SearchItemData, SearchFacet, SearchFilterItem, SearchFacetQuery, AiSearchConversationItem, ToolCallName, ContentSegment } from './search';
|
|
@@ -137,7 +137,7 @@ export type ThemeHooks = {
|
|
|
137
137
|
nextPage?: ResolvedNavItemWithLink;
|
|
138
138
|
} | undefined;
|
|
139
139
|
useCatalog: (props?: UseCatalogProps) => UseCatalogResponse;
|
|
140
|
-
useCatalogSort: () => UseCatalogSortResponse;
|
|
140
|
+
useCatalogSort: (defaultSortOption?: SortOption | null) => UseCatalogSortResponse;
|
|
141
141
|
useCatalogSearch: () => UseCatalogSearchResponse;
|
|
142
142
|
useFetchCatalogEntities: (params: CatalogApiParams, initialData?: BffCatalogEntityList) => CatalogApiResults<BffCatalogEntity>;
|
|
143
143
|
useFetchCatalogEntitiesRelations: (params: CatalogApiParams & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0-next.0",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"vitest": "4.0.10",
|
|
64
64
|
"vitest-when": "0.6.2",
|
|
65
65
|
"webpack": "5.105.2",
|
|
66
|
-
"@redocly/realm-asyncapi-sdk": "0.
|
|
66
|
+
"@redocly/realm-asyncapi-sdk": "0.10.0-next.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@tanstack/react-query": "5.62.3",
|
|
@@ -22,11 +22,10 @@ import { CatalogSelector } from '@redocly/theme/components/Catalog/CatalogSelect
|
|
|
22
22
|
import { SidebarActions } from '@redocly/theme/components/SidebarActions/SidebarActions';
|
|
23
23
|
import { CounterTag } from '@redocly/theme/components/Tags/CounterTag';
|
|
24
24
|
import { FilterInput } from '@redocly/theme/components/Filter/FilterInput';
|
|
25
|
-
import { CatalogViewModeToggle } from '@redocly/theme/components/Catalog/CatalogViewModeToggle';
|
|
26
|
-
import { CatalogSortButton } from '@redocly/theme/components/Catalog/CatalogSortButton';
|
|
27
25
|
import { CatalogEntities } from '@redocly/theme/components/Catalog/CatalogEntities';
|
|
28
26
|
import { CatalogMobileTopBar } from '@redocly/theme/components/Catalog/CatalogMobileTopBar/CatalogMobileTopBar';
|
|
29
27
|
import { CatalogMobileFiltersPanelOverlay } from '@redocly/theme/components/Catalog/CatalogMobileFiltersPanel/CatalogMobileFiltersPanelOverlay';
|
|
28
|
+
import { CatalogActionsRow } from '@redocly/theme/components/Catalog/CatalogActionsRow';
|
|
30
29
|
|
|
31
30
|
type CatalogFiltersWithCounts = Record<string, { value: string; count: number }[]>;
|
|
32
31
|
|
|
@@ -173,20 +172,14 @@ export function Catalog(props: CatalogProps): JSX.Element {
|
|
|
173
172
|
{translate(catalogConfig?.descriptionTranslationKey)}
|
|
174
173
|
</CatalogDescription>
|
|
175
174
|
|
|
176
|
-
<CatalogActionsRow
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<CatalogControlsWrapper>
|
|
186
|
-
<CatalogSortButton onSortChange={setSortOption} currentSort={sortOption} />
|
|
187
|
-
<CatalogViewModeToggle viewMode={viewMode} onViewModeChange={setViewMode} />
|
|
188
|
-
</CatalogControlsWrapper>
|
|
189
|
-
</CatalogActionsRow>
|
|
175
|
+
<CatalogActionsRow
|
|
176
|
+
searchQuery={searchQuery}
|
|
177
|
+
setSearchQuery={setSearchQuery}
|
|
178
|
+
sortOption={sortOption}
|
|
179
|
+
setSortOption={setSortOption}
|
|
180
|
+
viewMode={viewMode}
|
|
181
|
+
onViewModeChange={setViewMode}
|
|
182
|
+
/>
|
|
190
183
|
|
|
191
184
|
<CatalogEntities
|
|
192
185
|
catalogConfig={catalogConfig}
|
|
@@ -198,7 +191,6 @@ export function Catalog(props: CatalogProps): JSX.Element {
|
|
|
198
191
|
viewMode={viewMode}
|
|
199
192
|
setEntitiesCounter={setEntitiesCounter}
|
|
200
193
|
initialEntitiesList={initialEntitiesList}
|
|
201
|
-
setSortOption={setSortOption}
|
|
202
194
|
handleSortClick={handleSortClick}
|
|
203
195
|
isColumnSorted={isColumnSorted}
|
|
204
196
|
/>
|
|
@@ -210,23 +202,6 @@ export function Catalog(props: CatalogProps): JSX.Element {
|
|
|
210
202
|
);
|
|
211
203
|
}
|
|
212
204
|
|
|
213
|
-
const CatalogActionsRow = styled.div`
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
margin-bottom: var(--spacing-xl);
|
|
217
|
-
|
|
218
|
-
@media screen and (max-width: ${breakpoints.medium}) {
|
|
219
|
-
display: none;
|
|
220
|
-
}
|
|
221
|
-
`;
|
|
222
|
-
|
|
223
|
-
const CatalogControlsWrapper = styled.div`
|
|
224
|
-
display: var(--catalog-controls-wrapper-display);
|
|
225
|
-
align-items: var(--catalog-controls-wrapper-align-items);
|
|
226
|
-
margin-left: var(--catalog-controls-wrapper-margin-left);
|
|
227
|
-
gap: var(--catalog-controls-wrapper-gap);
|
|
228
|
-
`;
|
|
229
|
-
|
|
230
205
|
const CatalogContentWrapper = styled.div`
|
|
231
206
|
flex: 1;
|
|
232
207
|
min-width: 0;
|
|
@@ -326,12 +301,3 @@ const FiltersSidebar = styled(Sidebar)`
|
|
|
326
301
|
border: none;
|
|
327
302
|
}
|
|
328
303
|
`;
|
|
329
|
-
|
|
330
|
-
const CatalogSearchInputWrapper = styled.div`
|
|
331
|
-
display: none;
|
|
332
|
-
width: var(--catalog-search-input-wrapper-width);
|
|
333
|
-
|
|
334
|
-
@media screen and (min-width: ${breakpoints.medium}) {
|
|
335
|
-
display: block;
|
|
336
|
-
}
|
|
337
|
-
`;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { JSX } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
import { SortOption, CatalogViewMode } from '@redocly/theme/core/types';
|
|
5
5
|
import { FilterInput } from '@redocly/theme/components/Filter/FilterInput';
|
|
6
6
|
import { CatalogSortButton } from '@redocly/theme/components/Catalog/CatalogSortButton';
|
|
7
7
|
import { CatalogViewModeToggle } from '@redocly/theme/components/Catalog/CatalogViewModeToggle';
|
|
8
|
+
import { breakpoints } from '@redocly/theme/core';
|
|
8
9
|
|
|
9
10
|
export type CatalogActionsRowProps = {
|
|
10
11
|
searchQuery: string;
|
|
@@ -13,7 +14,7 @@ export type CatalogActionsRowProps = {
|
|
|
13
14
|
setSortOption: (option: SortOption | null) => void;
|
|
14
15
|
viewMode?: CatalogViewMode;
|
|
15
16
|
onViewModeChange?: (mode: CatalogViewMode) => void;
|
|
16
|
-
|
|
17
|
+
isDetailsPage?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export function CatalogActionsRow({
|
|
@@ -23,16 +24,22 @@ export function CatalogActionsRow({
|
|
|
23
24
|
setSortOption,
|
|
24
25
|
viewMode,
|
|
25
26
|
onViewModeChange,
|
|
26
|
-
|
|
27
|
+
isDetailsPage = false,
|
|
27
28
|
}: CatalogActionsRowProps): JSX.Element {
|
|
28
29
|
return (
|
|
29
|
-
<CatalogActionsRowWrapper
|
|
30
|
+
<CatalogActionsRowWrapper isDetailsPage={isDetailsPage}>
|
|
30
31
|
<CatalogSearchInputWrapper>
|
|
31
|
-
<FilterInput
|
|
32
|
+
<FilterInput
|
|
33
|
+
value={searchQuery}
|
|
34
|
+
onChange={(updatedTerm) => setSearchQuery(updatedTerm)}
|
|
35
|
+
dataTestId="catalog-search-input"
|
|
36
|
+
/>
|
|
32
37
|
</CatalogSearchInputWrapper>
|
|
33
38
|
|
|
34
39
|
<CatalogControlsWrapper>
|
|
35
|
-
|
|
40
|
+
{viewMode === 'cards' && (
|
|
41
|
+
<CatalogSortButton onSortChange={setSortOption} currentSort={sortOption} />
|
|
42
|
+
)}
|
|
36
43
|
{viewMode && onViewModeChange && (
|
|
37
44
|
<CatalogViewModeToggle viewMode={viewMode} onViewModeChange={onViewModeChange} />
|
|
38
45
|
)}
|
|
@@ -41,9 +48,20 @@ export function CatalogActionsRow({
|
|
|
41
48
|
);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
export const CatalogActionsRowWrapper = styled.div
|
|
51
|
+
export const CatalogActionsRowWrapper = styled.div<{ isDetailsPage: boolean }>`
|
|
45
52
|
display: flex;
|
|
46
53
|
align-items: center;
|
|
54
|
+
|
|
55
|
+
margin-bottom: ${({ isDetailsPage }) => (isDetailsPage ? 'var(--spacing-sm)' : 'var(--spacing-xl)')};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
${({ isDetailsPage }) =>
|
|
59
|
+
!isDetailsPage &&
|
|
60
|
+
css`
|
|
61
|
+
@media screen and (max-width: ${breakpoints.medium}) {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
`}
|
|
47
65
|
`;
|
|
48
66
|
|
|
49
67
|
export const CatalogControlsWrapper = styled.div`
|
|
@@ -25,7 +25,6 @@ export type CatalogEntitiesProps = {
|
|
|
25
25
|
setEntitiesCounter: (counter: number) => void;
|
|
26
26
|
initialEntitiesList?: BffCatalogEntityList;
|
|
27
27
|
sortOption: SortOption | null;
|
|
28
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
29
28
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
30
29
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
31
30
|
};
|
|
@@ -42,7 +41,6 @@ export function CatalogEntities(props: CatalogEntitiesProps): JSX.Element {
|
|
|
42
41
|
searchQuery,
|
|
43
42
|
viewMode,
|
|
44
43
|
setEntitiesCounter,
|
|
45
|
-
setSortOption,
|
|
46
44
|
handleSortClick,
|
|
47
45
|
isColumnSorted,
|
|
48
46
|
} = props;
|
|
@@ -109,7 +107,6 @@ export function CatalogEntities(props: CatalogEntitiesProps): JSX.Element {
|
|
|
109
107
|
<CatalogTableView<BffCatalogEntity>
|
|
110
108
|
entities={entities}
|
|
111
109
|
catalogConfig={catalogConfig}
|
|
112
|
-
setSortOption={setSortOption}
|
|
113
110
|
currentSortOption={sortOption}
|
|
114
111
|
handleSortClick={handleSortClick}
|
|
115
112
|
isColumnSorted={isColumnSorted}
|
|
@@ -14,36 +14,6 @@ import { CatalogEntityRelationsTable } from '@redocly/theme/components/Catalog/C
|
|
|
14
14
|
import { CatalogEntityTypeTag } from '@redocly/theme/components/Catalog/CatalogEntityTypeTag';
|
|
15
15
|
import { CatalogEntityRelationCell } from '@redocly/theme/components/Catalog/CatalogTableView/CatalogEntityRelationCell';
|
|
16
16
|
|
|
17
|
-
const columns: CatalogColumn<BffCatalogRelatedEntity>[] = [
|
|
18
|
-
{
|
|
19
|
-
key: 'entity',
|
|
20
|
-
title: 'Entity',
|
|
21
|
-
render: (entity) => <CatalogEntityCell entity={entity} />,
|
|
22
|
-
sortable: true,
|
|
23
|
-
sortKey: 'title',
|
|
24
|
-
width: '2.5fr',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
key: 'type',
|
|
28
|
-
title: 'Type',
|
|
29
|
-
render: (entity) => <CatalogEntityTypeTag entityType={entity.type} />,
|
|
30
|
-
sortable: true,
|
|
31
|
-
sortKey: 'type',
|
|
32
|
-
width: '1fr',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
key: 'relationType',
|
|
36
|
-
title: 'Relations',
|
|
37
|
-
render: (entity) => (
|
|
38
|
-
<CatalogEntityRelationCell
|
|
39
|
-
relationType={entity.relationType}
|
|
40
|
-
relationRole={entity.relationRole}
|
|
41
|
-
/>
|
|
42
|
-
),
|
|
43
|
-
width: '1fr',
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
|
|
47
17
|
export type CatalogEntityDefaultRelationsProps = {
|
|
48
18
|
entity: BffCatalogEntity;
|
|
49
19
|
entitiesCatalogConfig: EntitiesCatalogConfig;
|
|
@@ -91,7 +61,7 @@ export function CatalogEntityDefaultRelations({
|
|
|
91
61
|
searchQuery={searchQuery}
|
|
92
62
|
setSearchQuery={setSearchQuery}
|
|
93
63
|
heading={shouldShowHeading ? 'Related entities' : undefined}
|
|
94
|
-
columns={
|
|
64
|
+
columns={getRelationsTableColumns(listType)}
|
|
95
65
|
sortOption={sortOption}
|
|
96
66
|
setSortOption={setSortOption}
|
|
97
67
|
handleSortClick={handleSortClick}
|
|
@@ -102,3 +72,41 @@ export function CatalogEntityDefaultRelations({
|
|
|
102
72
|
</div>
|
|
103
73
|
);
|
|
104
74
|
}
|
|
75
|
+
|
|
76
|
+
function getRelationsTableColumns(listType?: ListType): CatalogColumn<BffCatalogRelatedEntity>[] {
|
|
77
|
+
const columns: CatalogColumn<BffCatalogRelatedEntity>[] = [
|
|
78
|
+
{
|
|
79
|
+
key: 'entity',
|
|
80
|
+
title: 'Entity',
|
|
81
|
+
render: (entity) => <CatalogEntityCell entity={entity} />,
|
|
82
|
+
sortable: true,
|
|
83
|
+
sortKey: 'title',
|
|
84
|
+
width: '2.5fr',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: 'type',
|
|
88
|
+
title: 'Type',
|
|
89
|
+
render: (entity) => <CatalogEntityTypeTag entityType={entity.type} />,
|
|
90
|
+
sortable: true,
|
|
91
|
+
sortKey: 'type',
|
|
92
|
+
width: '1fr',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: 'relationType',
|
|
96
|
+
title: 'Relations',
|
|
97
|
+
render: (entity) => (
|
|
98
|
+
<CatalogEntityRelationCell
|
|
99
|
+
relationType={entity.relationType}
|
|
100
|
+
relationRole={entity.relationRole}
|
|
101
|
+
/>
|
|
102
|
+
),
|
|
103
|
+
width: '1fr',
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
if (listType === 'api-operation' || listType === 'data-schema') {
|
|
108
|
+
return columns.filter((column) => column.key !== 'type');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return columns;
|
|
112
|
+
}
|
package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx
CHANGED
|
@@ -32,7 +32,7 @@ export function CatalogEntityRelations({
|
|
|
32
32
|
setSearchQuery,
|
|
33
33
|
}: CatalogEntityRelationsProps): JSX.Element | null {
|
|
34
34
|
const { useCatalogSort, useFetchCatalogEntitiesRelations } = useThemeHooks();
|
|
35
|
-
const { sortOption, setSortOption, handleSortClick, isColumnSorted } = useCatalogSort();
|
|
35
|
+
const { sortOption, setSortOption, handleSortClick, isColumnSorted } = useCatalogSort('title');
|
|
36
36
|
|
|
37
37
|
const [filter, setFilter] = useState<string | undefined>(ENTITY_DEFAULT_FILTERS[entity.type]);
|
|
38
38
|
|
package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx
CHANGED
|
@@ -86,7 +86,8 @@ export function CatalogEntityRelationsTable({
|
|
|
86
86
|
setSearchQuery={setSearchQuery}
|
|
87
87
|
sortOption={sortOption}
|
|
88
88
|
setSortOption={setSortOption}
|
|
89
|
-
|
|
89
|
+
viewMode="table"
|
|
90
|
+
isDetailsPage={true}
|
|
90
91
|
/>
|
|
91
92
|
<CatalogEntityRelationsTableContent
|
|
92
93
|
entitiesCatalogConfig={entitiesCatalogConfig}
|
|
@@ -95,7 +96,6 @@ export function CatalogEntityRelationsTable({
|
|
|
95
96
|
query={query}
|
|
96
97
|
searchQuery={searchQuery}
|
|
97
98
|
columns={columns}
|
|
98
|
-
setSortOption={setSortOption}
|
|
99
99
|
sortOption={sortOption}
|
|
100
100
|
handleSortClick={handleSortClick}
|
|
101
101
|
isColumnSorted={isColumnSorted}
|
|
@@ -25,7 +25,6 @@ export type CatalogEntityRelationsTableContentProps = {
|
|
|
25
25
|
searchQuery: string;
|
|
26
26
|
columns: CatalogColumn<BffCatalogRelatedEntity>[];
|
|
27
27
|
sortOption: SortOption | null;
|
|
28
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
29
28
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
30
29
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
31
30
|
shouldShowLoadMore: boolean;
|
|
@@ -40,7 +39,6 @@ export function CatalogEntityRelationsTableContent({
|
|
|
40
39
|
query,
|
|
41
40
|
searchQuery,
|
|
42
41
|
columns,
|
|
43
|
-
setSortOption,
|
|
44
42
|
sortOption,
|
|
45
43
|
handleSortClick,
|
|
46
44
|
isColumnSorted,
|
|
@@ -57,7 +55,6 @@ export function CatalogEntityRelationsTableContent({
|
|
|
57
55
|
entitiesCatalogConfig={entitiesCatalogConfig}
|
|
58
56
|
catalogConfig={catalogConfig}
|
|
59
57
|
columns={columns}
|
|
60
|
-
setSortOption={setSortOption}
|
|
61
58
|
currentSortOption={sortOption}
|
|
62
59
|
handleSortClick={handleSortClick}
|
|
63
60
|
isColumnSorted={isColumnSorted}
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
|
|
13
13
|
export type CatalogTableHeaderCellProps<T extends BaseEntity> = {
|
|
14
14
|
column: CatalogColumn<T>;
|
|
15
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
16
15
|
currentSortOption?: SortOption | null;
|
|
17
16
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
18
17
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
@@ -22,13 +21,11 @@ export const CatalogTableHeaderCell = <T extends BaseEntity>({
|
|
|
22
21
|
column,
|
|
23
22
|
handleSortClick,
|
|
24
23
|
isColumnSorted,
|
|
25
|
-
setSortOption,
|
|
26
24
|
}: CatalogTableHeaderCellProps<T>) => {
|
|
27
25
|
const { handleCellClick, sortKey, isUpActive, isDownActive } = useCatalogTableHeaderCellActions({
|
|
28
26
|
column,
|
|
29
27
|
handleSortClick,
|
|
30
28
|
isColumnSorted,
|
|
31
|
-
setSortOption,
|
|
32
29
|
});
|
|
33
30
|
|
|
34
31
|
return (
|
|
@@ -26,7 +26,6 @@ export type CatalogTableViewProps<T extends BaseEntity> = {
|
|
|
26
26
|
entitiesCatalogConfig?: EntitiesCatalogConfig;
|
|
27
27
|
catalogConfig: CatalogEntityConfig;
|
|
28
28
|
columns?: CatalogColumn<T>[];
|
|
29
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
30
29
|
currentSortOption?: SortOption | null;
|
|
31
30
|
onRowClick?: (entity: T) => void;
|
|
32
31
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
@@ -96,7 +95,6 @@ export const CatalogTableView = <T extends BaseEntity>({
|
|
|
96
95
|
entitiesCatalogConfig,
|
|
97
96
|
catalogConfig,
|
|
98
97
|
columns = baseColumns as CatalogColumn<BaseEntity>[],
|
|
99
|
-
setSortOption,
|
|
100
98
|
currentSortOption,
|
|
101
99
|
onRowClick,
|
|
102
100
|
handleSortClick,
|
|
@@ -114,7 +112,6 @@ export const CatalogTableView = <T extends BaseEntity>({
|
|
|
114
112
|
<CatalogTableHeaderCell<T>
|
|
115
113
|
key={column.key}
|
|
116
114
|
column={column}
|
|
117
|
-
setSortOption={setSortOption}
|
|
118
115
|
currentSortOption={currentSortOption}
|
|
119
116
|
handleSortClick={handleSortClick}
|
|
120
117
|
isColumnSorted={isColumnSorted}
|
|
@@ -3,19 +3,15 @@ import {
|
|
|
3
3
|
CatalogColumn,
|
|
4
4
|
} from '@redocly/theme/components/Catalog/CatalogTableView/CatalogTableView';
|
|
5
5
|
|
|
6
|
-
import { SortOption } from '../../types';
|
|
7
|
-
|
|
8
6
|
type CatalogTableHeaderCellActionsProps<T extends BaseEntity> = {
|
|
9
7
|
column: CatalogColumn<T>;
|
|
10
8
|
handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void;
|
|
11
|
-
setSortOption: (sortOption: SortOption | null) => void;
|
|
12
9
|
isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean;
|
|
13
10
|
};
|
|
14
11
|
|
|
15
12
|
export function useCatalogTableHeaderCellActions<T extends BaseEntity>({
|
|
16
13
|
column,
|
|
17
14
|
handleSortClick,
|
|
18
|
-
setSortOption,
|
|
19
15
|
isColumnSorted,
|
|
20
16
|
}: CatalogTableHeaderCellActionsProps<T>) {
|
|
21
17
|
const sortKey = column.sortKey;
|
|
@@ -27,8 +23,6 @@ export function useCatalogTableHeaderCellActions<T extends BaseEntity>({
|
|
|
27
23
|
|
|
28
24
|
if (isDownActive) {
|
|
29
25
|
handleSortClick(sortKey, 'desc');
|
|
30
|
-
} else if (isUpActive) {
|
|
31
|
-
setSortOption(null);
|
|
32
26
|
} else {
|
|
33
27
|
handleSortClick(sortKey, 'asc');
|
|
34
28
|
}
|
package/src/core/types/hooks.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
UseCatalogProps,
|
|
20
20
|
CatalogApiParams,
|
|
21
21
|
CatalogApiResults,
|
|
22
|
+
SortOption,
|
|
22
23
|
} from './catalog';
|
|
23
24
|
import type { UserMenuData } from './user-menu';
|
|
24
25
|
import type { ItemState } from './sidebar';
|
|
@@ -164,7 +165,7 @@ export type ThemeHooks = {
|
|
|
164
165
|
}
|
|
165
166
|
| undefined;
|
|
166
167
|
useCatalog: (props?: UseCatalogProps) => UseCatalogResponse;
|
|
167
|
-
useCatalogSort: () => UseCatalogSortResponse;
|
|
168
|
+
useCatalogSort: (defaultSortOption?: SortOption | null) => UseCatalogSortResponse;
|
|
168
169
|
useCatalogSearch: () => UseCatalogSearchResponse;
|
|
169
170
|
useFetchCatalogEntities: (
|
|
170
171
|
params: CatalogApiParams,
|