@redocly/theme 0.61.0-next.1 → 0.61.0-next.3
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/CatalogEntity/CatalogEntity.js +5 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.js +9 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.d.ts +6 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.js +144 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.d.ts +8 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.js +161 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.d.ts +8 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.js +67 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.d.ts +9 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.js +212 -0
- package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +2 -25
- package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +12 -1
- package/lib/components/Catalog/CatalogEntity/ShowMoreButton.d.ts +8 -0
- package/lib/components/Catalog/CatalogEntity/ShowMoreButton.js +35 -0
- package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +2 -0
- package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +4 -1
- package/lib/components/Catalog/variables.js +112 -0
- package/lib/components/ColorModeSwitcher/ColorModeIcon.d.ts +2 -1
- package/lib/components/ColorModeSwitcher/ColorModeIcon.js +3 -2
- package/lib/components/ColorModeSwitcher/ColorModeSwitcher.js +1 -4
- package/lib/components/Menu/variables.js +1 -0
- package/lib/components/Product/utils.d.ts +1 -0
- package/lib/components/Product/utils.js +10 -0
- package/lib/components/Tooltip/Tooltip.js +2 -0
- package/lib/core/constants/catalog.d.ts +1 -0
- package/lib/core/constants/catalog.js +2 -1
- package/lib/core/constants/common.d.ts +4 -0
- package/lib/core/constants/common.js +5 -1
- package/lib/core/hooks/catalog/use-catalog-entity-details.d.ts +3 -1
- package/lib/core/hooks/catalog/use-catalog-entity-details.js +12 -5
- package/lib/core/hooks/index.d.ts +1 -0
- package/lib/core/hooks/index.js +1 -0
- package/lib/core/hooks/search/use-recent-searches.js +14 -41
- package/lib/core/hooks/use-color-switcher.d.ts +0 -1
- package/lib/core/hooks/use-color-switcher.js +19 -13
- package/lib/core/hooks/use-page-actions.js +37 -6
- package/lib/core/hooks/use-product-picker.js +12 -2
- package/lib/core/hooks/use-store.d.ts +17 -0
- package/lib/core/hooks/use-store.js +64 -0
- package/lib/core/hooks/use-telemetry-fallback.d.ts +2 -0
- package/lib/core/hooks/use-telemetry-fallback.js +2 -0
- package/lib/core/types/catalog.d.ts +33 -4
- package/lib/core/types/common.d.ts +2 -0
- package/lib/core/types/hooks.d.ts +14 -3
- package/lib/core/types/l10n.d.ts +1 -1
- package/lib/core/utils/build-revision-url.d.ts +1 -0
- package/lib/core/utils/build-revision-url.js +15 -0
- package/lib/core/utils/date.d.ts +14 -0
- package/lib/core/utils/date.js +39 -0
- package/lib/core/utils/index.d.ts +2 -0
- package/lib/core/utils/index.js +2 -0
- package/lib/core/utils/load-and-navigate.js +7 -2
- package/lib/core/utils/transform-revisions-to-version-history.d.ts +8 -0
- package/lib/core/utils/transform-revisions-to-version-history.js +110 -0
- package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.d.ts +9 -0
- package/lib/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.js +26 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/package.json +5 -5
- package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +7 -1
- package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx +12 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.tsx +147 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx +180 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityRevisionItem.tsx +93 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityVersionItem.tsx +284 -0
- package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +3 -25
- package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +15 -2
- package/src/components/Catalog/CatalogEntity/ShowMoreButton.tsx +47 -0
- package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +6 -1
- package/src/components/Catalog/variables.ts +112 -0
- package/src/components/ColorModeSwitcher/ColorModeIcon.tsx +5 -3
- package/src/components/ColorModeSwitcher/ColorModeSwitcher.tsx +2 -7
- package/src/components/Menu/variables.ts +1 -0
- package/src/components/Product/utils.ts +6 -0
- package/src/components/Tooltip/Tooltip.tsx +2 -0
- package/src/core/constants/catalog.ts +2 -0
- package/src/core/constants/common.ts +5 -0
- package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
- package/src/core/hooks/catalog/use-catalog-entity-details.ts +22 -6
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/search/use-recent-searches.ts +38 -65
- package/src/core/hooks/use-color-switcher.ts +29 -15
- package/src/core/hooks/use-page-actions.ts +63 -6
- package/src/core/hooks/use-product-picker.ts +12 -0
- package/src/core/hooks/use-store.ts +95 -0
- package/src/core/hooks/use-telemetry-fallback.ts +2 -0
- package/src/core/types/catalog.ts +38 -10
- package/src/core/types/common.ts +4 -0
- package/src/core/types/hooks.ts +23 -4
- package/src/core/types/l10n.ts +10 -0
- package/src/core/utils/build-revision-url.ts +16 -0
- package/src/core/utils/date.ts +33 -0
- package/src/core/utils/index.ts +2 -0
- package/src/core/utils/load-and-navigate.ts +6 -1
- package/src/core/utils/transform-revisions-to-version-history.ts +163 -0
- package/src/icons/NavaidMilitaryIcon/NavaidMilitaryIcon.tsx +43 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformRevisionsToVersionHistory = transformRevisionsToVersionHistory;
|
|
4
|
+
const constants_1 = require("../../core/constants");
|
|
5
|
+
const date_1 = require("./date");
|
|
6
|
+
function compareVersionsDescending(versionA, versionB) {
|
|
7
|
+
return versionB.localeCompare(versionA, undefined, { numeric: true });
|
|
8
|
+
}
|
|
9
|
+
function extractGroupComparisonData(group) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const version = group.version;
|
|
12
|
+
const isNotSpecified = version === constants_1.VERSION_NOT_SPECIFIED;
|
|
13
|
+
// Get version dates (oldest revision date for each group - the version's creation date)
|
|
14
|
+
// This ensures versions stay in their original order even when new revisions are added
|
|
15
|
+
const date = group.singleRevisionDate ||
|
|
16
|
+
(group.revisions && group.revisions.length > 0
|
|
17
|
+
? (_a = group.revisions[group.revisions.length - 1]) === null || _a === void 0 ? void 0 : _a.revisionDate
|
|
18
|
+
: undefined) ||
|
|
19
|
+
'';
|
|
20
|
+
const time = date ? new Date(date).getTime() : 0;
|
|
21
|
+
const hasCurrent = (_b = group.hasCurrentRevisionFromBackend) !== null && _b !== void 0 ? _b : false;
|
|
22
|
+
return { version, isNotSpecified, time, hasCurrent };
|
|
23
|
+
}
|
|
24
|
+
function compareVersionGroupsDescending(groupA, groupB) {
|
|
25
|
+
const { version: versionA, isNotSpecified: isNotSpecifiedA, time: timeA, hasCurrent: hasCurrentA, } = extractGroupComparisonData(groupA);
|
|
26
|
+
const { version: versionB, isNotSpecified: isNotSpecifiedB, time: timeB, hasCurrent: hasCurrentB, } = extractGroupComparisonData(groupB);
|
|
27
|
+
// First, compare by version date (oldest first, so most recent versions come first)
|
|
28
|
+
const dateComparison = timeB - timeA;
|
|
29
|
+
if (dateComparison !== 0) {
|
|
30
|
+
return dateComparison;
|
|
31
|
+
}
|
|
32
|
+
// If dates are equal, prioritize the one with isCurrent from backend
|
|
33
|
+
if (hasCurrentA !== hasCurrentB) {
|
|
34
|
+
return hasCurrentB ? 1 : -1; // hasCurrentB comes first if true
|
|
35
|
+
}
|
|
36
|
+
// If both have same isCurrent status, compare by version
|
|
37
|
+
// If both are unknown or both are real versions, compare by version
|
|
38
|
+
if (isNotSpecifiedA === isNotSpecifiedB) {
|
|
39
|
+
return compareVersionsDescending(versionA, versionB);
|
|
40
|
+
}
|
|
41
|
+
// If one is unknown and one is a real version, unknown comes last
|
|
42
|
+
return isNotSpecifiedA ? 1 : -1;
|
|
43
|
+
}
|
|
44
|
+
function transformRevisionsToVersionHistory({ revisions, currentRevisionDate, currentVersion, locale = typeof navigator !== 'undefined' ? navigator.language : 'en-US', }) {
|
|
45
|
+
const normalizedCurrentVersion = currentVersion === null ? constants_1.VERSION_NOT_SPECIFIED : currentVersion;
|
|
46
|
+
const versionMap = new Map();
|
|
47
|
+
revisions.forEach((revision) => {
|
|
48
|
+
const version = revision.version || constants_1.VERSION_NOT_SPECIFIED;
|
|
49
|
+
const versionRevisions = versionMap.get(version) || [];
|
|
50
|
+
versionRevisions.push(revision);
|
|
51
|
+
if (!versionMap.has(version)) {
|
|
52
|
+
versionMap.set(version, versionRevisions);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const versionGroups = Array.from(versionMap.entries()).map(([version, versionRevisions]) => {
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
const sortedRevisions = [...versionRevisions].sort((a, b) => {
|
|
58
|
+
const dateA = a.revision ? new Date(a.revision).getTime() : 0;
|
|
59
|
+
const dateB = b.revision ? new Date(b.revision).getTime() : 0;
|
|
60
|
+
return dateB - dateA;
|
|
61
|
+
});
|
|
62
|
+
const latestRevision = sortedRevisions[0];
|
|
63
|
+
const versionMatches = normalizedCurrentVersion === undefined || normalizedCurrentVersion === version;
|
|
64
|
+
let isCurrent;
|
|
65
|
+
if (currentRevisionDate !== undefined) {
|
|
66
|
+
// Check if revision matches AND version matches
|
|
67
|
+
const revisionMatches = sortedRevisions.some((rev) => rev.revision === currentRevisionDate);
|
|
68
|
+
isCurrent = revisionMatches && versionMatches;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// When no revision is specified, use isCurrent flag from the latest revision
|
|
72
|
+
// but only if version also matches (or no version filter is applied)
|
|
73
|
+
isCurrent = ((_a = latestRevision === null || latestRevision === void 0 ? void 0 : latestRevision.isCurrent) !== null && _a !== void 0 ? _a : false) && versionMatches;
|
|
74
|
+
}
|
|
75
|
+
// Check if any revision in this version group is the default version
|
|
76
|
+
const isDefaultVersion = sortedRevisions.some((rev) => rev.isDefaultVersion === true);
|
|
77
|
+
const revisions = sortedRevisions.length > 1
|
|
78
|
+
? sortedRevisions.map((rev, index) => {
|
|
79
|
+
var _a;
|
|
80
|
+
const revisionMatches = currentRevisionDate
|
|
81
|
+
? rev.revision === currentRevisionDate
|
|
82
|
+
: false;
|
|
83
|
+
const isActiveRevision = revisionMatches && versionMatches;
|
|
84
|
+
const isCurrentByDefault = !currentRevisionDate &&
|
|
85
|
+
normalizedCurrentVersion === undefined &&
|
|
86
|
+
index === 0 &&
|
|
87
|
+
isCurrent;
|
|
88
|
+
return {
|
|
89
|
+
name: `r.${sortedRevisions.length - index}`,
|
|
90
|
+
date: (0, date_1.toLocalizedShortDateTime)(rev.revision, locale),
|
|
91
|
+
revisionDate: rev.revision,
|
|
92
|
+
isActive: isActiveRevision || isCurrentByDefault,
|
|
93
|
+
isCurrent: (_a = rev.isCurrent) !== null && _a !== void 0 ? _a : false,
|
|
94
|
+
};
|
|
95
|
+
})
|
|
96
|
+
: undefined;
|
|
97
|
+
return {
|
|
98
|
+
version,
|
|
99
|
+
date: (0, date_1.toLocalizedShortDate)((latestRevision === null || latestRevision === void 0 ? void 0 : latestRevision.revision) || null, locale),
|
|
100
|
+
isCurrent,
|
|
101
|
+
isExpanded: isCurrent,
|
|
102
|
+
hasCurrentRevisionFromBackend: (_b = latestRevision === null || latestRevision === void 0 ? void 0 : latestRevision.isCurrent) !== null && _b !== void 0 ? _b : false,
|
|
103
|
+
isDefaultVersion,
|
|
104
|
+
revisions,
|
|
105
|
+
singleRevisionDate: sortedRevisions.length === 1 ? (_c = sortedRevisions[0]) === null || _c === void 0 ? void 0 : _c.revision : undefined,
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
return versionGroups.sort(compareVersionGroupsDescending);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=transform-revisions-to-version-history.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '../../icons/types';
|
|
3
|
+
export declare const NavaidMilitaryIcon: import("styled-components").StyledComponent<(props: IconProps) => React.JSX.Element, any, {
|
|
4
|
+
'data-component-name': string;
|
|
5
|
+
} & {
|
|
6
|
+
color?: string;
|
|
7
|
+
size?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
} & React.SVGProps<SVGSVGElement>, "data-component-name">;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NavaidMilitaryIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const utils_1 = require("../../core/utils");
|
|
10
|
+
const Icon = (props) => {
|
|
11
|
+
return (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, props),
|
|
12
|
+
react_1.default.createElement("path", { d: "M8 15C6.61553 15 5.26216 14.5895 4.11101 13.8203C2.95987 13.0511 2.06266 11.9579 1.53285 10.6788C1.00303 9.3997 0.86441 7.99224 1.13451 6.63437C1.4046 5.2765 2.07129 4.02922 3.05026 3.05026C4.02922 2.07129 5.2765 1.4046 6.63437 1.13451C7.99224 0.86441 9.3997 1.00303 10.6788 1.53285C11.9579 2.06266 13.0511 2.95987 13.8203 4.11101C14.5895 5.26216 15 6.61553 15 8C14.9979 9.85588 14.2597 11.6351 12.9474 12.9474C11.6351 14.2597 9.85588 14.9979 8 15ZM8 2C6.81332 2 5.65328 2.3519 4.66658 3.01119C3.67989 3.67047 2.91085 4.60755 2.45673 5.7039C2.0026 6.80026 1.88378 8.00666 2.11529 9.17054C2.3468 10.3344 2.91825 11.4035 3.75736 12.2426C4.59648 13.0818 5.66558 13.6532 6.82946 13.8847C7.99335 14.1162 9.19975 13.9974 10.2961 13.5433C11.3925 13.0892 12.3295 12.3201 12.9888 11.3334C13.6481 10.3467 14 9.18669 14 8C13.9982 6.40926 13.3655 4.88419 12.2406 3.75936C11.1158 2.63454 9.59075 2.00182 8 2Z", fill: "#1A1C21" }),
|
|
13
|
+
react_1.default.createElement("path", { d: "M8 12C7.20888 12 6.43552 11.7654 5.77772 11.3259C5.11993 10.8864 4.60724 10.2616 4.30449 9.53074C4.00173 8.79983 3.92252 7.99557 4.07686 7.21964C4.2312 6.44372 4.61217 5.73099 5.17158 5.17158C5.73099 4.61217 6.44372 4.2312 7.21964 4.07686C7.99557 3.92252 8.79983 4.00173 9.53074 4.30449C10.2616 4.60724 10.8864 5.11993 11.3259 5.77772C11.7654 6.43552 12 7.20888 12 8C11.9988 9.0605 11.577 10.0772 10.8271 10.8271C10.0772 11.577 9.0605 11.9988 8 12ZM8 5C7.40666 5 6.82664 5.17595 6.33329 5.50559C5.83994 5.83524 5.45543 6.30377 5.22836 6.85195C5.0013 7.40013 4.94189 8.00333 5.05765 8.58527C5.1734 9.16722 5.45913 9.70177 5.87868 10.1213C6.29824 10.5409 6.83279 10.8266 7.41473 10.9424C7.99668 11.0581 8.59988 10.9987 9.14805 10.7716C9.69623 10.5446 10.1648 10.1601 10.4944 9.66671C10.8241 9.17337 11 8.59335 11 8C10.9991 7.20463 10.6828 6.44208 10.1203 5.87966C9.55793 5.31725 8.79538 5.00089 8 5Z", fill: "#1A1C21" }),
|
|
14
|
+
react_1.default.createElement("path", { d: "M8 9C8.55229 9 9 8.55229 9 8C9 7.44772 8.55229 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55229 7.44772 9 8 9Z", fill: "#1A1C21" })));
|
|
15
|
+
};
|
|
16
|
+
exports.NavaidMilitaryIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
17
|
+
'data-component-name': 'icons/NavaidMilitaryIcon/NavaidMilitaryIcon',
|
|
18
|
+
})) `
|
|
19
|
+
path {
|
|
20
|
+
fill: ${({ color }) => (0, utils_1.getCssColorVariable)(color)};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
height: ${({ size }) => size || '16px'};
|
|
24
|
+
width: ${({ size }) => size || '16px'};
|
|
25
|
+
`;
|
|
26
|
+
//# sourceMappingURL=NavaidMilitaryIcon.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -115,6 +115,8 @@ export * from './components/Catalog/CatalogSelector';
|
|
|
115
115
|
export * from './components/Catalog/CatalogSortButton';
|
|
116
116
|
export * from './components/Catalog/CatalogTagsWithTooltip';
|
|
117
117
|
export * from './components/Catalog/CatalogViewModeToggle';
|
|
118
|
+
export * from './components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton';
|
|
119
|
+
export * from './components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar';
|
|
118
120
|
export * from './components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations';
|
|
119
121
|
export * from './components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations';
|
|
120
122
|
export * from './components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations';
|
package/lib/index.js
CHANGED
|
@@ -173,6 +173,8 @@ __exportStar(require("./components/Catalog/CatalogSelector"), exports);
|
|
|
173
173
|
__exportStar(require("./components/Catalog/CatalogSortButton"), exports);
|
|
174
174
|
__exportStar(require("./components/Catalog/CatalogTagsWithTooltip"), exports);
|
|
175
175
|
__exportStar(require("./components/Catalog/CatalogViewModeToggle"), exports);
|
|
176
|
+
__exportStar(require("./components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton"), exports);
|
|
177
|
+
__exportStar(require("./components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar"), exports);
|
|
176
178
|
__exportStar(require("./components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations"), exports);
|
|
177
179
|
__exportStar(require("./components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations"), exports);
|
|
178
180
|
__exportStar(require("./components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.61.0-next.
|
|
3
|
+
"version": "0.61.0-next.3",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@markdoc/markdoc": "0.5.2",
|
|
30
30
|
"lodash.debounce": "^4.0.8",
|
|
31
31
|
"lodash.throttle": "^4.1.1",
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
32
|
+
"react": "19.2.3",
|
|
33
|
+
"react-dom": "19.2.3",
|
|
34
34
|
"react-router-dom": "^6.21.1",
|
|
35
35
|
"styled-components": "^4.1.1 || ^5.3.11 || ^6.0.0"
|
|
36
36
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/react": "^19.2.7",
|
|
49
49
|
"@types/react-dom": "^19.2.3",
|
|
50
50
|
"@types/styled-components": "5.1.34",
|
|
51
|
-
"@vitest/coverage-v8": "
|
|
51
|
+
"@vitest/coverage-v8": "4.0.10",
|
|
52
52
|
"@vitest/ui": "3.2.4",
|
|
53
53
|
"concurrently": "7.6.0",
|
|
54
54
|
"react-router-dom": "^6.21.1",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"openapi-sampler": "1.6.2",
|
|
82
82
|
"react-calendar": "5.1.0",
|
|
83
83
|
"react-date-picker": "11.0.0",
|
|
84
|
-
"@redocly/config": "0.41.
|
|
84
|
+
"@redocly/config": "0.41.1"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { Route, Routes } from 'react-router-dom';
|
|
3
|
+
import { Route, Routes, useSearchParams } from 'react-router-dom';
|
|
4
4
|
|
|
5
5
|
import type { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config';
|
|
6
6
|
import type {
|
|
@@ -20,6 +20,7 @@ import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
|
20
20
|
import { CatalogEntitySchema } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntitySchema';
|
|
21
21
|
import { CatalogEntityMethodAndPath } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath';
|
|
22
22
|
import { CatalogEntityRelationsGraph } from '@redocly/theme/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.lazy';
|
|
23
|
+
import { CatalogEntityHistorySidebar } from '@redocly/theme';
|
|
23
24
|
|
|
24
25
|
export type CatalogEntityProps = {
|
|
25
26
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
@@ -93,6 +94,10 @@ export function CatalogEntity({
|
|
|
93
94
|
const { entity, relations, catalogConfig, entitiesCatalogConfig, relatedEntity } =
|
|
94
95
|
usePageProps<CatalogEntityPageProps>();
|
|
95
96
|
|
|
97
|
+
const [searchParams] = useSearchParams();
|
|
98
|
+
const revision = searchParams.get('revision') || undefined;
|
|
99
|
+
const version = searchParams.get('version') || undefined;
|
|
100
|
+
|
|
96
101
|
const linkToMainCatalog = `catalogs/${catalogConfig.slug}`;
|
|
97
102
|
const linkToMainCatalogLabel = translate(catalogConfig.titleTranslationKey);
|
|
98
103
|
|
|
@@ -100,6 +105,7 @@ export function CatalogEntity({
|
|
|
100
105
|
|
|
101
106
|
return (
|
|
102
107
|
<CatalogPageWrapper data-component-name="Catalog/CatalogEntity/CatalogEntity">
|
|
108
|
+
<CatalogEntityHistorySidebar entityKey={entity.key} revision={revision} version={version} />
|
|
103
109
|
<CatalogPageContent>
|
|
104
110
|
<Breadcrumbs
|
|
105
111
|
additionalBreadcrumbs={[
|
package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsGraph.tsx
CHANGED
|
@@ -32,8 +32,20 @@ export function CatalogEntityRelationsGraph({
|
|
|
32
32
|
}: CatalogEntityRelationsGraphProps): JSX.Element {
|
|
33
33
|
const { useFetchCatalogEntitiesRelations } = useThemeHooks();
|
|
34
34
|
const { activeColorMode } = useColorSwitcher();
|
|
35
|
+
|
|
36
|
+
const combinedFilter = useMemo(() => {
|
|
37
|
+
if (entity.version && entity.revision) {
|
|
38
|
+
const versionFilter = `version:"${entity.version}"`;
|
|
39
|
+
const revisionFilter = `revision:"${entity.revision}"`;
|
|
40
|
+
return `${versionFilter} AND ${revisionFilter}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return undefined;
|
|
44
|
+
}, [entity.version, entity.revision]);
|
|
45
|
+
|
|
35
46
|
const { items: allRelations } = useFetchCatalogEntitiesRelations({
|
|
36
47
|
entityKey: entity.key,
|
|
48
|
+
filter: combinedFilter,
|
|
37
49
|
});
|
|
38
50
|
|
|
39
51
|
const { nodes, edges, onNodesChange, onEdgesChange, onConnect } = useGraph({
|
package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistoryButton.tsx
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import { RecentlyViewedIcon } from '@redocly/theme/icons/RecentlyViewedIcon/RecentlyViewedIcon';
|
|
5
|
+
import { CheckmarkOutlineIcon } from '@redocly/theme/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon';
|
|
6
|
+
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
7
|
+
import { VERSION_NOT_SPECIFIED } from '@redocly/theme/core/constants';
|
|
8
|
+
|
|
9
|
+
export type CatalogHistoryButtonProps = {
|
|
10
|
+
version: string | null;
|
|
11
|
+
className?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function CatalogEntityHistoryButton({
|
|
15
|
+
version,
|
|
16
|
+
className,
|
|
17
|
+
}: CatalogHistoryButtonProps): React.ReactElement {
|
|
18
|
+
const [label, setLabel] = useState(version === VERSION_NOT_SPECIFIED ? null : version);
|
|
19
|
+
const { useTranslate } = useThemeHooks();
|
|
20
|
+
const { translate } = useTranslate();
|
|
21
|
+
|
|
22
|
+
const handleClose = useCallback(
|
|
23
|
+
(e: CustomEvent): void => {
|
|
24
|
+
setLabel(
|
|
25
|
+
e.detail.version === VERSION_NOT_SPECIFIED
|
|
26
|
+
? e.detail.revision || 'r.1'
|
|
27
|
+
: `${e.detail.version || version}, ${e.detail.revision || 'r.1'}`,
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
[version],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
window.addEventListener('portal:sidebar:close-version-history', (e) =>
|
|
35
|
+
handleClose(e as CustomEvent),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener('portal:sidebar:close-version-history', (e) =>
|
|
40
|
+
handleClose(e as CustomEvent),
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
}, [handleClose]);
|
|
44
|
+
|
|
45
|
+
const handleClick = (): void => {
|
|
46
|
+
window.dispatchEvent(new CustomEvent('portal:sidebar:open-version-history'));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<CatalogHistoryButtonWrapper
|
|
51
|
+
className={className}
|
|
52
|
+
data-component-name="Catalog/CatalogHistoryButton"
|
|
53
|
+
>
|
|
54
|
+
<Separator />
|
|
55
|
+
<HistoryItem onClick={handleClick}>
|
|
56
|
+
<HistoryIcon />
|
|
57
|
+
<HistoryContent>
|
|
58
|
+
<HistoryText>{translate('catalog.history.button.label', 'Version history')}</HistoryText>
|
|
59
|
+
{label && (
|
|
60
|
+
<VersionPill>
|
|
61
|
+
<CheckmarkIcon />
|
|
62
|
+
<span>{label}</span>
|
|
63
|
+
</VersionPill>
|
|
64
|
+
)}
|
|
65
|
+
</HistoryContent>
|
|
66
|
+
</HistoryItem>
|
|
67
|
+
</CatalogHistoryButtonWrapper>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const CatalogHistoryButtonWrapper = styled.div`
|
|
72
|
+
width: 100%;
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const Separator = styled.div`
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 1px;
|
|
78
|
+
background-color: var(--catalog-history-separator-border-color);
|
|
79
|
+
margin-bottom: var(--catalog-history-separator-margin-bottom);
|
|
80
|
+
flex-shrink: 0;
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const HistoryItem = styled.button`
|
|
84
|
+
all: unset;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
gap: var(--catalog-history-item-gap);
|
|
89
|
+
padding: var(--catalog-history-item-padding);
|
|
90
|
+
margin-bottom: var(--catalog-history-item-margin-bottom);
|
|
91
|
+
width: 100%;
|
|
92
|
+
border-radius: var(--catalog-history-item-border-radius);
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
transition: background-color 0.2s ease;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
background-color: var(--catalog-history-item-bg-color-hover);
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
const HistoryContent = styled.div`
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: space-between;
|
|
105
|
+
flex: 1;
|
|
106
|
+
gap: var(--catalog-history-item-gap);
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const HistoryText = styled.span`
|
|
110
|
+
font-family: var(--catalog-history-text-font-family);
|
|
111
|
+
font-size: var(--catalog-history-text-font-size);
|
|
112
|
+
font-weight: var(--catalog-history-text-font-weight);
|
|
113
|
+
line-height: var(--catalog-history-text-line-height);
|
|
114
|
+
color: var(--catalog-history-text-color);
|
|
115
|
+
flex: 1;
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
const HistoryIcon = styled(RecentlyViewedIcon)`
|
|
119
|
+
width: var(--catalog-history-icon-size);
|
|
120
|
+
height: var(--catalog-history-icon-size);
|
|
121
|
+
flex-shrink: 0;
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const VersionPill = styled.div`
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: var(--catalog-history-pill-gap);
|
|
128
|
+
padding: var(--catalog-history-pill-padding-vertical)
|
|
129
|
+
var(--catalog-history-pill-padding-horizontal);
|
|
130
|
+
border: 1px solid var(--catalog-history-pill-border-color);
|
|
131
|
+
border-radius: var(--catalog-history-pill-border-radius);
|
|
132
|
+
background-color: transparent;
|
|
133
|
+
flex-shrink: 0;
|
|
134
|
+
|
|
135
|
+
span {
|
|
136
|
+
font-family: var(--catalog-history-pill-font-family);
|
|
137
|
+
font-size: var(--catalog-history-pill-font-size);
|
|
138
|
+
line-height: var(--catalog-history-pill-line-height);
|
|
139
|
+
color: var(--catalog-history-pill-text-color);
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
const CheckmarkIcon = styled(CheckmarkOutlineIcon)`
|
|
144
|
+
width: var(--catalog-history-pill-icon-size);
|
|
145
|
+
height: var(--catalog-history-pill-icon-size);
|
|
146
|
+
color: var(--catalog-history-pill-icon-color);
|
|
147
|
+
`;
|
package/src/components/Catalog/CatalogEntity/CatalogEntityHistory/CatalogEntityHistorySidebar.tsx
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
6
|
+
import { useThemeHooks } from '@redocly/theme/core/hooks';
|
|
7
|
+
import { MenuContainer } from '@redocly/theme/components/Menu/MenuContainer';
|
|
8
|
+
import { transformRevisionsToVersionHistory } from '@redocly/theme/core/utils';
|
|
9
|
+
|
|
10
|
+
import { CatalogEntityVersionItem } from './CatalogEntityVersionItem';
|
|
11
|
+
|
|
12
|
+
export type CatalogHistorySidebarProps = {
|
|
13
|
+
entityKey: string;
|
|
14
|
+
revision?: string;
|
|
15
|
+
version?: string | null;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function CatalogEntityHistorySidebar({
|
|
20
|
+
entityKey,
|
|
21
|
+
revision,
|
|
22
|
+
version,
|
|
23
|
+
className,
|
|
24
|
+
}: CatalogHistorySidebarProps): React.ReactElement | null {
|
|
25
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
26
|
+
const location = useLocation();
|
|
27
|
+
const basePath = location.pathname;
|
|
28
|
+
const { useTranslate, useFetchCatalogEntityRevisions, useL10nConfig } = useThemeHooks();
|
|
29
|
+
const { translate } = useTranslate();
|
|
30
|
+
const { currentLocale } = useL10nConfig();
|
|
31
|
+
|
|
32
|
+
const { items: revisions } = useFetchCatalogEntityRevisions({ entityKey });
|
|
33
|
+
|
|
34
|
+
const versionHistoryItems = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
transformRevisionsToVersionHistory({
|
|
37
|
+
revisions,
|
|
38
|
+
currentRevisionDate: revision,
|
|
39
|
+
currentVersion: version,
|
|
40
|
+
locale: currentLocale,
|
|
41
|
+
}),
|
|
42
|
+
[revisions, revision, version, currentLocale],
|
|
43
|
+
);
|
|
44
|
+
const activeRevisionLabel = useMemo(() => {
|
|
45
|
+
const itemWithActiveRevision = versionHistoryItems.find((item) =>
|
|
46
|
+
item.revisions?.some((revision) => revision.isActive),
|
|
47
|
+
);
|
|
48
|
+
const activeRevision = itemWithActiveRevision?.revisions?.find((revision) => revision.isActive);
|
|
49
|
+
return activeRevision?.name;
|
|
50
|
+
}, [versionHistoryItems]);
|
|
51
|
+
|
|
52
|
+
const [expandedVersions, setExpandedVersions] = useState<Set<string>>(new Set());
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setExpandedVersions(
|
|
56
|
+
new Set(versionHistoryItems.filter((item) => item.isExpanded).map((item) => item.version)),
|
|
57
|
+
);
|
|
58
|
+
}, [versionHistoryItems]);
|
|
59
|
+
|
|
60
|
+
const handleOpenSidebar = useCallback(() => {
|
|
61
|
+
setIsOpen(true);
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
window.addEventListener('portal:sidebar:open-version-history', handleOpenSidebar);
|
|
66
|
+
|
|
67
|
+
return () => {
|
|
68
|
+
window.removeEventListener('portal:sidebar:open-version-history', handleOpenSidebar);
|
|
69
|
+
};
|
|
70
|
+
}, [handleOpenSidebar]);
|
|
71
|
+
|
|
72
|
+
const handleClose = (): void => {
|
|
73
|
+
window.dispatchEvent(
|
|
74
|
+
new CustomEvent('portal:sidebar:close-version-history', {
|
|
75
|
+
detail: { version, revision: activeRevisionLabel },
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
setIsOpen(false);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const toggleVersion = (version: string): void => {
|
|
82
|
+
setExpandedVersions((prev) => {
|
|
83
|
+
const newSet = new Set(prev);
|
|
84
|
+
if (newSet.has(version)) {
|
|
85
|
+
newSet.delete(version);
|
|
86
|
+
} else {
|
|
87
|
+
newSet.add(version);
|
|
88
|
+
}
|
|
89
|
+
return newSet;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (!isOpen) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<SidebarOverlay className={className} data-component-name="Catalog/CatalogHistorySidebar">
|
|
99
|
+
<SidebarHeader>
|
|
100
|
+
<HeaderTitle>{translate('catalog.history.sidebar.title', 'Version history')}</HeaderTitle>
|
|
101
|
+
<CloseButton
|
|
102
|
+
onClick={handleClose}
|
|
103
|
+
aria-label={translate('catalog.history.sidebar.close', 'Close version history')}
|
|
104
|
+
>
|
|
105
|
+
<CloseIcon size="20px" color="--catalog-history-sidebar-close-icon-color" />
|
|
106
|
+
</CloseButton>
|
|
107
|
+
</SidebarHeader>
|
|
108
|
+
|
|
109
|
+
<MenuContainer growContent>
|
|
110
|
+
<VersionList>
|
|
111
|
+
{versionHistoryItems.map((group) => (
|
|
112
|
+
<CatalogEntityVersionItem
|
|
113
|
+
key={group.version}
|
|
114
|
+
group={group}
|
|
115
|
+
basePath={basePath}
|
|
116
|
+
isExpanded={expandedVersions.has(group.version)}
|
|
117
|
+
onToggle={toggleVersion}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</VersionList>
|
|
121
|
+
</MenuContainer>
|
|
122
|
+
</SidebarOverlay>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const SidebarOverlay = styled.div`
|
|
127
|
+
position: fixed;
|
|
128
|
+
top: var(--navbar-height);
|
|
129
|
+
left: 0;
|
|
130
|
+
width: var(--sidebar-width);
|
|
131
|
+
height: calc(100vh - var(--navbar-height));
|
|
132
|
+
background-color: var(--catalog-history-sidebar-bg-color);
|
|
133
|
+
border-right: 1px solid var(--catalog-history-sidebar-border-color);
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
z-index: calc(var(--z-index-raised) - 1);
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
const SidebarHeader = styled.div`
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
justify-content: space-between;
|
|
144
|
+
padding: var(--catalog-history-sidebar-header-padding);
|
|
145
|
+
border-bottom: 1px solid var(--catalog-history-sidebar-border-color);
|
|
146
|
+
flex-shrink: 0;
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
const HeaderTitle = styled.h2`
|
|
150
|
+
margin: 0;
|
|
151
|
+
font-family: var(--catalog-history-sidebar-header-font-family);
|
|
152
|
+
font-size: var(--catalog-history-sidebar-header-font-size);
|
|
153
|
+
font-weight: var(--catalog-history-sidebar-header-font-weight);
|
|
154
|
+
line-height: var(--catalog-history-sidebar-header-line-height);
|
|
155
|
+
letter-spacing: var(--catalog-history-sidebar-header-letter-spacing);
|
|
156
|
+
color: var(--catalog-history-sidebar-header-color);
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
const CloseButton = styled.button`
|
|
160
|
+
all: unset;
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
width: var(--catalog-history-sidebar-close-button-size);
|
|
165
|
+
height: var(--catalog-history-sidebar-close-button-size);
|
|
166
|
+
cursor: pointer;
|
|
167
|
+
border-radius: var(--catalog-history-sidebar-close-button-border-radius);
|
|
168
|
+
transition: background-color 0.2s ease;
|
|
169
|
+
|
|
170
|
+
&:hover {
|
|
171
|
+
background-color: var(--catalog-history-sidebar-close-button-bg-color-hover);
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
const VersionList = styled.ul`
|
|
176
|
+
list-style: none;
|
|
177
|
+
margin: 0;
|
|
178
|
+
padding: var(--catalog-history-sidebar-content-padding);
|
|
179
|
+
margin-top: var(--catalog-history-sidebar-content-margin-top);
|
|
180
|
+
`;
|