@reltio/components 1.4.1725 → 1.4.1726
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/cjs/components/history/ContributorsPanel/ContributorItem.js +1 -1
- package/cjs/components/history/ContributorsPanel/ContributorsPanel.js +3 -4
- package/cjs/components/history/HistoryGraph/HistoryGraph.js +13 -10
- package/cjs/components/history/HistoryGraph/helpers.d.ts +2 -0
- package/cjs/components/history/HistoryGraph/helpers.js +12 -3
- package/cjs/components/history/HistoryRow/HistoryRow.d.ts +2 -2
- package/cjs/components/history/HistoryRow/HistoryRow.js +3 -2
- package/cjs/components/history/hooks/historyHelpers.d.ts +6 -0
- package/cjs/components/history/hooks/historyHelpers.js +58 -0
- package/cjs/components/history/hooks/useHistory.js +1 -0
- package/cjs/components/history/hooks/useHistoryTree.d.ts +1 -1
- package/cjs/components/history/hooks/useHistoryTree.js +64 -141
- package/esm/components/history/ContributorsPanel/ContributorItem.js +1 -1
- package/esm/components/history/ContributorsPanel/ContributorsPanel.js +3 -4
- package/esm/components/history/HistoryGraph/HistoryGraph.js +14 -11
- package/esm/components/history/HistoryGraph/helpers.d.ts +2 -0
- package/esm/components/history/HistoryGraph/helpers.js +9 -1
- package/esm/components/history/HistoryRow/HistoryRow.d.ts +2 -2
- package/esm/components/history/HistoryRow/HistoryRow.js +3 -2
- package/esm/components/history/hooks/historyHelpers.d.ts +6 -0
- package/esm/components/history/hooks/historyHelpers.js +52 -0
- package/esm/components/history/hooks/useHistory.js +1 -0
- package/esm/components/history/hooks/useHistoryTree.d.ts +1 -1
- package/esm/components/history/hooks/useHistoryTree.js +56 -133
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ var ContributorItem = function (_a) {
|
|
|
12
12
|
var value = _a.value, _c = _a.isSelected, isSelected = _c === void 0 ? true : _c, onClick = _a.onClick;
|
|
13
13
|
var color = (0, mdm_sdk_1.getContributorColor)(value);
|
|
14
14
|
var styles = (0, styles_1.useContributorStyles)({ color: color });
|
|
15
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.icon, (_b = {},
|
|
15
|
+
return (react_1.default.createElement("div", { "data-reltio-id": "reltio-contributor-item", "data-reltio-contributor": value, className: (0, classnames_1.default)(styles.icon, (_b = {},
|
|
16
16
|
_b[styles.inactive] = !isSelected,
|
|
17
17
|
_b[styles.active] = isSelected,
|
|
18
18
|
_b[styles.clickable] = !!onClick,
|
|
@@ -28,9 +28,8 @@ var ContributorsPanel = function (_a) {
|
|
|
28
28
|
onSelectValues(__spreadArray(__spreadArray([], (selectedValues || []), true), [value], false));
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.root, className) },
|
|
32
|
-
react_1.default.createElement(ContributorItem_1.default, { value: entityUri }),
|
|
33
|
-
(
|
|
34
|
-
values.map(function (value) { return (react_1.default.createElement(ContributorItem_1.default, { key: value, value: value, isSelected: selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(value), onClick: function () { return handleClick(value); } })); })));
|
|
31
|
+
return (react_1.default.createElement("div", { "data-reltio-id": "reltio-contributors-panel", className: (0, classnames_1.default)(styles.root, className) },
|
|
32
|
+
react_1.default.createElement(ContributorItem_1.default, { key: entityUri, value: entityUri }), values === null || values === void 0 ? void 0 :
|
|
33
|
+
values.map(function (value) { return (react_1.default.createElement(ContributorItem_1.default, { key: value, value: value, isSelected: selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(value), onClick: function () { return handleClick(value); } })); })));
|
|
35
34
|
};
|
|
36
35
|
exports.default = ContributorsPanel;
|
|
@@ -45,13 +45,15 @@ var HistoryGraph = function (_a) {
|
|
|
45
45
|
var rowPositions = [ROW_MARGIN];
|
|
46
46
|
var _b = rows.reduce(function (acc, _a, i) {
|
|
47
47
|
var uri = _a.uri, height = _a.height, uris = _a.uris, type = _a.type, fakeType = _a.fakeType, index = _a.index, timestamp = _a.timestamp, label = _a.label;
|
|
48
|
-
var
|
|
48
|
+
var historyLane = historyLanes[uri];
|
|
49
|
+
var x = historyLane.index * COL_WIDTH + COL_MARGIN;
|
|
49
50
|
var y = rowPositions[i];
|
|
50
51
|
rowPositions.push(y + height);
|
|
51
52
|
var hasFakeType = (0, helpers_1.isFakeHistoryType)(fakeType);
|
|
52
53
|
var circleUri = hasFakeType ? uris[0] : uri;
|
|
53
54
|
var isCollapsed = !(uris === null || uris === void 0 ? void 0 : uris.some(function (uri) { return historyLanes[uri]; }));
|
|
54
|
-
|
|
55
|
+
var shouldShowLine = fakeType === types_1.HistoryChangeTypes.FAKE_NAVIGATE_PROFILE && historyLane.index !== 0;
|
|
56
|
+
acc.circles.push(react_1.default.createElement(exports.HistoryCircleWithTooltip, { tooltipTitle: label, tooltipPlacement: "top", onMouseOver: onHistoryCircleMouseOver ? function () { return onHistoryCircleMouseOver(uri, timestamp, index); } : undefined, key: "circle-".concat(circleUri, "-").concat(i), x: x, y: y, color: (0, mdm_sdk_1.getContributorColor)(circleUri), isDashed: hasFakeType, isCollapsed: isCollapsed, showCollapseIcon: !!uris, showLine: shouldShowLine }));
|
|
55
57
|
acc.rowLines.push(react_1.default.createElement("rect", { key: "".concat(circleUri, "-").concat(index), x: x, y: y - ROW_HEIGHT / 2, width: '100%', height: ROW_HEIGHT, fill: (0, mdm_sdk_1.getContributorColor)(circleUri), opacity: 0.06 }));
|
|
56
58
|
var isUpRight = type === types_1.HistoryChangeTypes.ENTITIES_SPLITTED;
|
|
57
59
|
uris === null || uris === void 0 ? void 0 : uris.forEach(function (contributorUri) {
|
|
@@ -62,7 +64,7 @@ var HistoryGraph = function (_a) {
|
|
|
62
64
|
var toX = contributorLane.index * COL_WIDTH + COL_MARGIN;
|
|
63
65
|
var toY = isUpRight ? y - rowHeight : y + rowHeight;
|
|
64
66
|
if (x !== toX)
|
|
65
|
-
acc.links.push(react_1.default.createElement(HistoryLink_1.default, { key: "link-".concat(contributorUri, "-").concat(index), x: x, y: y, toX: toX, toY: toY, isDashed:
|
|
67
|
+
acc.links.push(react_1.default.createElement(HistoryLink_1.default, { key: "link-".concat(contributorUri, "-").concat(index), x: x, y: y, toX: toX, toY: toY, isDashed: hasFakeType, color: (0, mdm_sdk_1.getContributorColor)(contributorUri) }));
|
|
66
68
|
});
|
|
67
69
|
return acc;
|
|
68
70
|
}, { links: [], circles: [], rowLines: [] }), links = _b.links, rowLines = _b.rowLines, circles = _b.circles;
|
|
@@ -74,25 +76,26 @@ var HistoryGraph = function (_a) {
|
|
|
74
76
|
contributorLane.lifeTime.forEach(function (_a, i) {
|
|
75
77
|
var _b;
|
|
76
78
|
var start = _a.start, end = _a.end;
|
|
77
|
-
if (((_b = rows[end === null || end === void 0 ? void 0 : end.index]) === null || _b === void 0 ? void 0 : _b.type) === types_1.HistoryChangeTypes.ENTITIES_SPLITTED)
|
|
79
|
+
if (((_b = rows[end === null || end === void 0 ? void 0 : end.index]) === null || _b === void 0 ? void 0 : _b.type) === types_1.HistoryChangeTypes.ENTITIES_SPLITTED) {
|
|
80
|
+
if ((end === null || end === void 0 ? void 0 : end.index) && contributorLane.index === 0) {
|
|
81
|
+
links.unshift(react_1.default.createElement("path", { key: "line-".concat(contributorUri, "-").concat(i), d: "M".concat(x, " ").concat(rowPositions[0], " L").concat(x, " ").concat(rowPositions[end.index - 1]), stroke: (0, mdm_sdk_1.getContributorColor)(contributorUri), strokeWidth: 2 }));
|
|
82
|
+
}
|
|
78
83
|
return;
|
|
84
|
+
}
|
|
79
85
|
var startIndex = (start === null || start === void 0 ? void 0 : start.type) === types_1.HistoryChangeTypes.ENTITIES_SPLITTED ? (start === null || start === void 0 ? void 0 : start.index) - 1 : start === null || start === void 0 ? void 0 : start.index;
|
|
80
|
-
var endIndex = (
|
|
81
|
-
(end === null || end === void 0 ? void 0 : end.type) === types_1.HistoryChangeTypes.ENTITIES_MERGED
|
|
82
|
-
? (end === null || end === void 0 ? void 0 : end.index) + 1
|
|
83
|
-
: end === null || end === void 0 ? void 0 : end.index;
|
|
86
|
+
var endIndex = (0, helpers_1.findEndIndex)(end);
|
|
84
87
|
var startY = rowPositions[startIndex] || rowPositions[rowPositions.length - 2];
|
|
85
88
|
var endY = rowPositions[endIndex] || ROW_MARGIN;
|
|
86
89
|
if (startY <= endY)
|
|
87
90
|
return;
|
|
88
91
|
var color = (0, mdm_sdk_1.getContributorColor)(contributorUri);
|
|
89
|
-
if (!end && contributorLane.index > 0) {
|
|
92
|
+
if (!end && endIndex === undefined && contributorLane.index > 0) {
|
|
90
93
|
circles.push(react_1.default.createElement(HistoryCircle_1.default, { key: "initCircle-".concat(contributorUri, "-").concat(i), x: x, y: endY, color: color, showLine: true }));
|
|
91
94
|
}
|
|
92
95
|
links.unshift(react_1.default.createElement("path", { key: "line-".concat(contributorUri, "-").concat(i), d: "M".concat(x, " ").concat(startY, " L").concat(x, " ").concat(endY), stroke: color, strokeWidth: 2 }));
|
|
93
96
|
});
|
|
94
97
|
});
|
|
95
|
-
return (react_1.default.createElement("svg", { className: "chart", width: width, height: height },
|
|
98
|
+
return (react_1.default.createElement("svg", { "data-reltio-id": "reltio-history-graph", className: "chart", width: width, height: height },
|
|
96
99
|
react_1.default.createElement("g", { id: "rowLines" }, rowLines),
|
|
97
100
|
react_1.default.createElement("g", { id: "links" }, links),
|
|
98
101
|
react_1.default.createElement("g", { id: "circles" }, circles)));
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { HistoryRowData } from '../types';
|
|
1
2
|
export declare const getHistoryLinkCurve: (x: number, y: number, toX: number, toY: number) => string;
|
|
2
3
|
export declare const isFakeHistoryType: (type: string) => boolean;
|
|
4
|
+
export declare const findEndIndex: (end: HistoryRowData) => number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFakeHistoryType = exports.getHistoryLinkCurve = void 0;
|
|
4
|
-
var
|
|
3
|
+
exports.findEndIndex = exports.isFakeHistoryType = exports.getHistoryLinkCurve = void 0;
|
|
4
|
+
var types_1 = require("../types");
|
|
5
5
|
var getHistoryLinkCurve = function (x, y, toX, toY) {
|
|
6
6
|
var isUp = y > toY;
|
|
7
7
|
var isLeft = x < toX;
|
|
@@ -13,6 +13,15 @@ var getHistoryLinkCurve = function (x, y, toX, toY) {
|
|
|
13
13
|
};
|
|
14
14
|
exports.getHistoryLinkCurve = getHistoryLinkCurve;
|
|
15
15
|
var isFakeHistoryType = function (type) {
|
|
16
|
-
return type ===
|
|
16
|
+
return type === types_1.HistoryChangeTypes.FAKE_FILTERED_INCOMING || type === types_1.HistoryChangeTypes.FAKE_FILTERED_OUTGOING;
|
|
17
17
|
};
|
|
18
18
|
exports.isFakeHistoryType = isFakeHistoryType;
|
|
19
|
+
var findEndIndex = function (end) {
|
|
20
|
+
var _a = end || {}, endIndex = _a.index, endType = _a.type;
|
|
21
|
+
if (endIndex === undefined)
|
|
22
|
+
return;
|
|
23
|
+
return endType === types_1.HistoryChangeTypes.ENTITIES_MERGED_MANUALLY || endType === types_1.HistoryChangeTypes.ENTITIES_MERGED
|
|
24
|
+
? endIndex + 1
|
|
25
|
+
: endIndex;
|
|
26
|
+
};
|
|
27
|
+
exports.findEndIndex = findEndIndex;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { HistoryRowData } from '../types';
|
|
3
3
|
type Props = {
|
|
4
|
-
change:
|
|
4
|
+
change: HistoryRowData;
|
|
5
5
|
isCurrent?: boolean;
|
|
6
6
|
isSelected: boolean;
|
|
7
7
|
onClick: () => void;
|
|
@@ -13,8 +13,9 @@ var styles_1 = require("./styles");
|
|
|
13
13
|
var HistoryRow = function (_a) {
|
|
14
14
|
var _b;
|
|
15
15
|
var change = _a.change, isCurrent = _a.isCurrent, isSelected = _a.isSelected, onClick = _a.onClick;
|
|
16
|
-
var uri = change.uri, type = change.type, matchGroups = change.matchGroups, user = change.user, timestamp = change.timestamp;
|
|
17
|
-
var
|
|
16
|
+
var uri = change.uri, type = change.type, matchGroups = change.matchGroups, user = change.user, timestamp = change.timestamp, fakeType = change.fakeType, uris = change.uris;
|
|
17
|
+
var colorUri = fakeType && uris ? uris[0] : uri;
|
|
18
|
+
var color = (0, mdm_sdk_1.getContributorColor)(colorUri);
|
|
18
19
|
var styles = (0, styles_1.useStyles)({ color: color });
|
|
19
20
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.historyRow, (_b = {}, _b[styles.selected] = isSelected, _b)), onClick: onClick },
|
|
20
21
|
react_1.default.createElement("div", { className: styles.rowHeader },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HistoryChange } from '@reltio/mdm-sdk';
|
|
2
|
+
import { HistoryLife } from '../types';
|
|
3
|
+
export declare const checkChange: any;
|
|
4
|
+
export declare const startNewLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
5
|
+
export declare const updateLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
6
|
+
export declare const endLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.endLife = exports.updateLife = exports.startNewLife = exports.checkChange = void 0;
|
|
4
|
+
var ramda_1 = require("ramda");
|
|
5
|
+
var types_1 = require("../types");
|
|
6
|
+
exports.checkChange = (0, ramda_1.curry)(function (involvedUris, checkInUris, change) {
|
|
7
|
+
var uri = change.uri, type = change.type, uris = change.uris;
|
|
8
|
+
if (involvedUris) {
|
|
9
|
+
if (Array.isArray(involvedUris)) {
|
|
10
|
+
if (type !== types_1.HistoryChangeTypes.ENTITY_LOST_MERGE)
|
|
11
|
+
return null;
|
|
12
|
+
if (involvedUris.includes(uri)) {
|
|
13
|
+
return change;
|
|
14
|
+
}
|
|
15
|
+
else if (checkInUris && uris) {
|
|
16
|
+
return involvedUris.some(function (involvedUri) { return uris.includes(involvedUri); }) ? change : null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (uri === involvedUris || (checkInUris && (uris === null || uris === void 0 ? void 0 : uris.includes(involvedUris))))
|
|
21
|
+
return change;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
});
|
|
26
|
+
var startNewLife = function (lifeTime, change) {
|
|
27
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
28
|
+
if (currentLife &&
|
|
29
|
+
(!currentLife.start ||
|
|
30
|
+
(currentLife.start.type === types_1.HistoryChangeTypes.ENTITY_CREATED &&
|
|
31
|
+
change.type === types_1.HistoryChangeTypes.ENTITIES_SPLITTED))) {
|
|
32
|
+
currentLife.start = change;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
lifeTime.push({ start: change, end: null });
|
|
36
|
+
};
|
|
37
|
+
exports.startNewLife = startNewLife;
|
|
38
|
+
var updateLife = function (lifeTime, change) {
|
|
39
|
+
var shouldAddNewLife = true;
|
|
40
|
+
if (lifeTime.length) {
|
|
41
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
42
|
+
shouldAddNewLife = !((!currentLife.start || currentLife.start.timestamp < change.timestamp) &&
|
|
43
|
+
(!currentLife.end || currentLife.end.timestamp > change.timestamp));
|
|
44
|
+
}
|
|
45
|
+
if (shouldAddNewLife) {
|
|
46
|
+
lifeTime.push({ start: null, end: null });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.updateLife = updateLife;
|
|
50
|
+
var endLife = function (lifeTime, change) {
|
|
51
|
+
if (lifeTime.length) {
|
|
52
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
53
|
+
if (!currentLife.start)
|
|
54
|
+
currentLife.start = change;
|
|
55
|
+
}
|
|
56
|
+
lifeTime.push({ start: null, end: change });
|
|
57
|
+
};
|
|
58
|
+
exports.endLife = endLife;
|
|
@@ -82,6 +82,7 @@ var useHistory = function (_a) {
|
|
|
82
82
|
if (entityUri && enabled) {
|
|
83
83
|
loadHistoricUris();
|
|
84
84
|
setHistoryPage(0);
|
|
85
|
+
setHistoryWithTotal(null);
|
|
85
86
|
}
|
|
86
87
|
}, [entityUri, entity === null || entity === void 0 ? void 0 : entity.updatedTime, enabled]);
|
|
87
88
|
var loadMore = (0, react_1.useCallback)(function (offset) {
|
|
@@ -10,43 +10,33 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
23
|
exports.useHistoryTree = void 0;
|
|
15
24
|
var react_1 = require("react");
|
|
16
25
|
var ramda_1 = require("ramda");
|
|
17
|
-
var types_1 = require("
|
|
26
|
+
var types_1 = require("../types");
|
|
27
|
+
var historyHelpers_1 = require("./historyHelpers");
|
|
18
28
|
var useHistoryTree = function (_a) {
|
|
19
29
|
var entityUri = _a.entityUri, historyChanges = _a.historyChanges, selectedUris = _a.selectedUris;
|
|
20
30
|
return (0, react_1.useMemo)(function () {
|
|
21
31
|
var _a;
|
|
22
32
|
var historyLanes = (_a = {}, _a[entityUri] = { index: 0, lifeTime: [] }, _a);
|
|
23
33
|
var rows = [{ user: '', timestamp: 0, uri: entityUri }];
|
|
24
|
-
var
|
|
25
|
-
var _a;
|
|
26
|
-
var uri = change.uri || entityUri;
|
|
27
|
-
if (involvedUris) {
|
|
28
|
-
if (Array.isArray(involvedUris)) {
|
|
29
|
-
if (change.type !== types_1.HistoryChangeTypes.ENTITY_LOST_MERGE)
|
|
30
|
-
return null;
|
|
31
|
-
if (involvedUris.includes(uri)) {
|
|
32
|
-
return change;
|
|
33
|
-
}
|
|
34
|
-
else if (checkInUris && change.uris) {
|
|
35
|
-
return involvedUris.some(function (involvedUri) { return change.uris.includes(involvedUri); }) ? change : null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (uri === involvedUris || (checkInUris && ((_a = change.uris) === null || _a === void 0 ? void 0 : _a.includes(involvedUris))))
|
|
40
|
-
return change;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
});
|
|
34
|
+
var normalizedHistoryChanges = historyChanges === null || historyChanges === void 0 ? void 0 : historyChanges.map(function (change) { return (__assign(__assign({}, change), { uri: change.uri || entityUri })); });
|
|
45
35
|
var findNextChange = function (index, involvedUris, checkInUris) {
|
|
46
|
-
return (0, ramda_1.pipe)((0, ramda_1.drop)(index + 1), (0, ramda_1.find)(checkChange(involvedUris, checkInUris)))(
|
|
36
|
+
return (0, ramda_1.pipe)((0, ramda_1.drop)(index + 1), (0, ramda_1.find)((0, historyHelpers_1.checkChange)(involvedUris, checkInUris)))(normalizedHistoryChanges);
|
|
47
37
|
};
|
|
48
38
|
var findPreviousChange = function (index, uri) {
|
|
49
|
-
return (0, ramda_1.pipe)((0, ramda_1.slice)(index + 1, Infinity), (0, ramda_1.find)(checkChange(uri, false)))(rows);
|
|
39
|
+
return (0, ramda_1.pipe)((0, ramda_1.slice)(index + 1, Infinity), (0, ramda_1.find)((0, historyHelpers_1.checkChange)(uri, false)))(rows);
|
|
50
40
|
};
|
|
51
41
|
var checkLaneUri = function (uri) {
|
|
52
42
|
if (!historyLanes[uri] && (!selectedUris || selectedUris.includes(uri))) {
|
|
@@ -57,60 +47,30 @@ var useHistoryTree = function (_a) {
|
|
|
57
47
|
}
|
|
58
48
|
return historyLanes[uri];
|
|
59
49
|
};
|
|
60
|
-
var startNewLife = function (lifeTime, change) {
|
|
61
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
62
|
-
if (currentLife &&
|
|
63
|
-
(!currentLife.start ||
|
|
64
|
-
(currentLife.start.type === types_1.HistoryChangeTypes.ENTITY_CREATED &&
|
|
65
|
-
change.type === types_1.HistoryChangeTypes.ENTITIES_SPLITTED))) {
|
|
66
|
-
currentLife.start = change;
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
lifeTime.push({ start: change, end: null });
|
|
70
|
-
};
|
|
71
|
-
var updateLife = function (lifeTime, change) {
|
|
72
|
-
var shouldAddNewLife = true;
|
|
73
|
-
if (lifeTime.length) {
|
|
74
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
75
|
-
shouldAddNewLife = !((!currentLife.start || currentLife.start.timestamp < change.timestamp) &&
|
|
76
|
-
(!currentLife.end || currentLife.end.timestamp > change.timestamp));
|
|
77
|
-
}
|
|
78
|
-
if (shouldAddNewLife) {
|
|
79
|
-
lifeTime.push({ start: null, end: null });
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var endLife = function (lifeTime, change) {
|
|
83
|
-
if (lifeTime.length) {
|
|
84
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
85
|
-
if (!currentLife.start)
|
|
86
|
-
currentLife.start = change;
|
|
87
|
-
}
|
|
88
|
-
lifeTime.push({ start: null, end: change });
|
|
89
|
-
};
|
|
90
50
|
var checkLifeTime = function (lifeTime, change) {
|
|
91
51
|
var _a, _b;
|
|
92
52
|
switch (change.type) {
|
|
93
53
|
case types_1.HistoryChangeTypes.ENTITY_CREATED:
|
|
94
|
-
startNewLife(lifeTime, change);
|
|
54
|
+
(0, historyHelpers_1.startNewLife)(lifeTime, change);
|
|
95
55
|
break;
|
|
96
56
|
case types_1.HistoryChangeTypes.ENTITIES_MERGED_ON_THE_FLY:
|
|
97
57
|
case types_1.HistoryChangeTypes.ENTITY_CHANGED:
|
|
98
|
-
updateLife(lifeTime, change);
|
|
58
|
+
(0, historyHelpers_1.updateLife)(lifeTime, change);
|
|
99
59
|
break;
|
|
100
60
|
case types_1.HistoryChangeTypes.ENTITY_LOST_MERGE:
|
|
101
61
|
case types_1.HistoryChangeTypes.ENTITY_REMOVED:
|
|
102
|
-
endLife(lifeTime, change);
|
|
62
|
+
(0, historyHelpers_1.endLife)(lifeTime, change);
|
|
103
63
|
break;
|
|
104
64
|
case types_1.HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
105
|
-
updateLife(lifeTime, change);
|
|
65
|
+
(0, historyHelpers_1.updateLife)(lifeTime, change);
|
|
106
66
|
(_a = change.uris) === null || _a === void 0 ? void 0 : _a.forEach(function (uri) {
|
|
107
67
|
var relatedLane = historyLanes[uri];
|
|
108
68
|
if (!relatedLane)
|
|
109
69
|
return;
|
|
110
70
|
var lifeTimeLength = relatedLane.lifeTime.length;
|
|
111
71
|
lifeTimeLength
|
|
112
|
-
? startNewLife(relatedLane.lifeTime, change)
|
|
113
|
-
: endLife(relatedLane.lifeTime, change);
|
|
72
|
+
? (0, historyHelpers_1.startNewLife)(relatedLane.lifeTime, change)
|
|
73
|
+
: (0, historyHelpers_1.endLife)(relatedLane.lifeTime, change);
|
|
114
74
|
rows.push({
|
|
115
75
|
uri: uri,
|
|
116
76
|
user: change.user,
|
|
@@ -124,28 +84,32 @@ var useHistoryTree = function (_a) {
|
|
|
124
84
|
break;
|
|
125
85
|
case types_1.HistoryChangeTypes.ENTITIES_MERGED:
|
|
126
86
|
case types_1.HistoryChangeTypes.ENTITIES_MERGED_MANUALLY:
|
|
127
|
-
updateLife(lifeTime, change);
|
|
87
|
+
(0, historyHelpers_1.updateLife)(lifeTime, change);
|
|
128
88
|
(_b = change.uris) === null || _b === void 0 ? void 0 : _b.forEach(function (uri) {
|
|
129
89
|
var relatedLane = historyLanes[uri];
|
|
130
90
|
if (relatedLane)
|
|
131
|
-
endLife(relatedLane.lifeTime, change);
|
|
91
|
+
(0, historyHelpers_1.endLife)(relatedLane.lifeTime, change);
|
|
132
92
|
});
|
|
133
93
|
break;
|
|
134
94
|
}
|
|
135
95
|
};
|
|
136
96
|
var postProcessChanges = [];
|
|
137
|
-
|
|
138
|
-
var
|
|
97
|
+
normalizedHistoryChanges === null || normalizedHistoryChanges === void 0 ? void 0 : normalizedHistoryChanges.forEach(function (change, index) {
|
|
98
|
+
var uri = change.uri, uris = change.uris, timestamp = change.timestamp;
|
|
139
99
|
switch (change.type) {
|
|
140
100
|
case types_1.HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
141
|
-
if (!findNextChange(index,
|
|
101
|
+
if (!findNextChange(index, uri, false)) {
|
|
142
102
|
return;
|
|
143
103
|
}
|
|
144
104
|
else {
|
|
145
|
-
var
|
|
146
|
-
var involvedUris = change.uris ? [change.uris, uri] : [uri];
|
|
105
|
+
var involvedUris = uris ? __spreadArray(__spreadArray([], uris, true), [uri], false) : [uri];
|
|
147
106
|
var lostMergeChange = findNextChange(index, involvedUris, true);
|
|
148
|
-
|
|
107
|
+
var isLostMerge = !uri || uri === (lostMergeChange === null || lostMergeChange === void 0 ? void 0 : lostMergeChange.uri);
|
|
108
|
+
var lastChange = rows[rows.length - 1];
|
|
109
|
+
var isAlreadyUnmerged = lastChange.type === types_1.HistoryChangeTypes.ENTITIES_SPLITTED &&
|
|
110
|
+
(uris === null || uris === void 0 ? void 0 : uris.includes(lastChange.uri)) &&
|
|
111
|
+
lastChange.timestamp === timestamp;
|
|
112
|
+
if (isLostMerge || isAlreadyUnmerged)
|
|
149
113
|
return;
|
|
150
114
|
}
|
|
151
115
|
break;
|
|
@@ -155,71 +119,50 @@ var useHistoryTree = function (_a) {
|
|
|
155
119
|
case types_1.HistoryChangeTypes.RELATIONSHIP_CHANGED:
|
|
156
120
|
return;
|
|
157
121
|
}
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
if (!checkLaneUri(uri))
|
|
161
|
-
addPostProcess = true;
|
|
162
|
-
});
|
|
163
|
-
var contributorLane = checkLaneUri(change.uri || entityUri);
|
|
164
|
-
if (!contributorLane)
|
|
165
|
-
return;
|
|
122
|
+
var contributorLane = checkLaneUri(uri);
|
|
123
|
+
uris === null || uris === void 0 ? void 0 : uris.forEach(function (uri) { return checkLaneUri(uri); });
|
|
166
124
|
var rowChange = __assign({}, change);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
125
|
+
if (contributorLane) {
|
|
126
|
+
checkLifeTime(contributorLane.lifeTime, rowChange);
|
|
127
|
+
rows.push(rowChange);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
if (uris)
|
|
131
|
+
postProcessChanges.push(rowChange);
|
|
132
|
+
}
|
|
171
133
|
});
|
|
172
134
|
postProcessChanges.forEach(function (postChange) {
|
|
173
135
|
postChange.uris.forEach(function (postUri) {
|
|
174
|
-
if (historyLanes[postUri])
|
|
136
|
+
if (!historyLanes[postUri])
|
|
175
137
|
return;
|
|
176
|
-
|
|
177
|
-
var uri =
|
|
178
|
-
if (
|
|
138
|
+
normalizedHistoryChanges.forEach(function (change) {
|
|
139
|
+
var uri = change.uri, uris = change.uris, type = change.type, timestamp = change.timestamp;
|
|
140
|
+
if (timestamp !== postChange.timestamp || type !== postChange.type)
|
|
179
141
|
return;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
switch (type) {
|
|
186
|
-
case types_1.HistoryChangeTypes.ENTITIES_MERGED:
|
|
187
|
-
case types_1.HistoryChangeTypes.ENTITIES_MERGED_MANUALLY:
|
|
188
|
-
fakeType = types_1.HistoryChangeTypes.FAKE_FILTERED_INCOMING;
|
|
189
|
-
break;
|
|
190
|
-
case types_1.HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
191
|
-
fakeType = types_1.HistoryChangeTypes.FAKE_FILTERED_OUTGOING;
|
|
192
|
-
break;
|
|
193
|
-
default:
|
|
142
|
+
var fakeChange;
|
|
143
|
+
switch (type) {
|
|
144
|
+
case types_1.HistoryChangeTypes.ENTITIES_MERGED:
|
|
145
|
+
case types_1.HistoryChangeTypes.ENTITIES_MERGED_MANUALLY:
|
|
146
|
+
if (!(uris === null || uris === void 0 ? void 0 : uris.includes(postUri)))
|
|
194
147
|
return;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
uri
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
if (!(0, ramda_1.isNil)(extendLife.startIndex)) {
|
|
212
|
-
contributorLane.lifeTime[extendLife.startIndex].start = fakeChange;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
rows.splice(rows.indexOf(postChange), 0, fakeChange);
|
|
216
|
-
});
|
|
148
|
+
fakeChange = { fakeType: types_1.HistoryChangeTypes.FAKE_FILTERED_INCOMING, uri: postUri };
|
|
149
|
+
break;
|
|
150
|
+
case types_1.HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
151
|
+
if (uri !== postUri || !uris)
|
|
152
|
+
return;
|
|
153
|
+
fakeChange = { fakeType: types_1.HistoryChangeTypes.FAKE_FILTERED_OUTGOING, uri: uri };
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
var fakeRowIndex = rows.findIndex(function (row, i) { return i !== 0 && row.timestamp < timestamp; });
|
|
159
|
+
var fakeRow = __assign(__assign(__assign({}, postChange), fakeChange), { uris: [postChange.uri] });
|
|
160
|
+
rows.splice(fakeRowIndex, 0, fakeRow);
|
|
217
161
|
});
|
|
218
162
|
});
|
|
219
163
|
});
|
|
220
164
|
rows.forEach(function (row, i) {
|
|
221
165
|
row.index = i;
|
|
222
|
-
row.uri = row.uri || entityUri;
|
|
223
166
|
});
|
|
224
167
|
return {
|
|
225
168
|
historyData: { historyLanes: historyLanes, rows: rows },
|
|
@@ -228,23 +171,3 @@ var useHistoryTree = function (_a) {
|
|
|
228
171
|
}, [entityUri, historyChanges, selectedUris]);
|
|
229
172
|
};
|
|
230
173
|
exports.useHistoryTree = useHistoryTree;
|
|
231
|
-
var findClosestLife = function (lifeTime, timestamp) {
|
|
232
|
-
return lifeTime.reduce(function (acc, _a, i) {
|
|
233
|
-
var start = _a.start, end = _a.end;
|
|
234
|
-
if (start) {
|
|
235
|
-
var d = timestamp - start.timestamp;
|
|
236
|
-
if ((0, ramda_1.isNil)(acc.startDistance) || (Math.abs(acc.startDistance) > Math.abs(d) && d > 0)) {
|
|
237
|
-
acc.startIndex = i;
|
|
238
|
-
acc.startDistance = d;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (end) {
|
|
242
|
-
var d = timestamp - end.timestamp;
|
|
243
|
-
if ((0, ramda_1.isNil)(acc.endDistance) || (Math.abs(acc.endDistance) > Math.abs(d) && d < 0)) {
|
|
244
|
-
acc.endIndex = i;
|
|
245
|
-
acc.endDistance = d;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return acc;
|
|
249
|
-
}, { startIndex: null, endIndex: null, startDistance: null, endDistance: null });
|
|
250
|
-
};
|
|
@@ -7,7 +7,7 @@ var ContributorItem = function (_a) {
|
|
|
7
7
|
var value = _a.value, _c = _a.isSelected, isSelected = _c === void 0 ? true : _c, onClick = _a.onClick;
|
|
8
8
|
var color = getContributorColor(value);
|
|
9
9
|
var styles = useContributorStyles({ color: color });
|
|
10
|
-
return (React.createElement("div", { className: classnames(styles.icon, (_b = {},
|
|
10
|
+
return (React.createElement("div", { "data-reltio-id": "reltio-contributor-item", "data-reltio-contributor": value, className: classnames(styles.icon, (_b = {},
|
|
11
11
|
_b[styles.inactive] = !isSelected,
|
|
12
12
|
_b[styles.active] = isSelected,
|
|
13
13
|
_b[styles.clickable] = !!onClick,
|
|
@@ -23,9 +23,8 @@ var ContributorsPanel = function (_a) {
|
|
|
23
23
|
onSelectValues(__spreadArray(__spreadArray([], (selectedValues || []), true), [value], false));
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
return (React.createElement("div", { className: classnames(styles.root, className) },
|
|
27
|
-
React.createElement(ContributorItem, { value: entityUri }),
|
|
28
|
-
(
|
|
29
|
-
values.map(function (value) { return (React.createElement(ContributorItem, { key: value, value: value, isSelected: selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(value), onClick: function () { return handleClick(value); } })); })));
|
|
26
|
+
return (React.createElement("div", { "data-reltio-id": "reltio-contributors-panel", className: classnames(styles.root, className) },
|
|
27
|
+
React.createElement(ContributorItem, { key: entityUri, value: entityUri }), values === null || values === void 0 ? void 0 :
|
|
28
|
+
values.map(function (value) { return (React.createElement(ContributorItem, { key: value, value: value, isSelected: selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.includes(value), onClick: function () { return handleClick(value); } })); })));
|
|
30
29
|
};
|
|
31
30
|
export default ContributorsPanel;
|
|
@@ -3,7 +3,7 @@ import { getContributorColor } from '@reltio/mdm-sdk';
|
|
|
3
3
|
import HistoryLink from './HistoryLink';
|
|
4
4
|
import HistoryCircle from './HistoryCircle';
|
|
5
5
|
import { HistoryChangeTypes } from '../types';
|
|
6
|
-
import { isFakeHistoryType } from './helpers';
|
|
6
|
+
import { isFakeHistoryType, findEndIndex } from './helpers';
|
|
7
7
|
import { withTooltip } from '../../../HOCs';
|
|
8
8
|
var COL_WIDTH = 16;
|
|
9
9
|
var COL_MARGIN = 24;
|
|
@@ -16,13 +16,15 @@ var HistoryGraph = function (_a) {
|
|
|
16
16
|
var rowPositions = [ROW_MARGIN];
|
|
17
17
|
var _b = rows.reduce(function (acc, _a, i) {
|
|
18
18
|
var uri = _a.uri, height = _a.height, uris = _a.uris, type = _a.type, fakeType = _a.fakeType, index = _a.index, timestamp = _a.timestamp, label = _a.label;
|
|
19
|
-
var
|
|
19
|
+
var historyLane = historyLanes[uri];
|
|
20
|
+
var x = historyLane.index * COL_WIDTH + COL_MARGIN;
|
|
20
21
|
var y = rowPositions[i];
|
|
21
22
|
rowPositions.push(y + height);
|
|
22
23
|
var hasFakeType = isFakeHistoryType(fakeType);
|
|
23
24
|
var circleUri = hasFakeType ? uris[0] : uri;
|
|
24
25
|
var isCollapsed = !(uris === null || uris === void 0 ? void 0 : uris.some(function (uri) { return historyLanes[uri]; }));
|
|
25
|
-
|
|
26
|
+
var shouldShowLine = fakeType === HistoryChangeTypes.FAKE_NAVIGATE_PROFILE && historyLane.index !== 0;
|
|
27
|
+
acc.circles.push(React.createElement(HistoryCircleWithTooltip, { tooltipTitle: label, tooltipPlacement: "top", onMouseOver: onHistoryCircleMouseOver ? function () { return onHistoryCircleMouseOver(uri, timestamp, index); } : undefined, key: "circle-".concat(circleUri, "-").concat(i), x: x, y: y, color: getContributorColor(circleUri), isDashed: hasFakeType, isCollapsed: isCollapsed, showCollapseIcon: !!uris, showLine: shouldShowLine }));
|
|
26
28
|
acc.rowLines.push(React.createElement("rect", { key: "".concat(circleUri, "-").concat(index), x: x, y: y - ROW_HEIGHT / 2, width: '100%', height: ROW_HEIGHT, fill: getContributorColor(circleUri), opacity: 0.06 }));
|
|
27
29
|
var isUpRight = type === HistoryChangeTypes.ENTITIES_SPLITTED;
|
|
28
30
|
uris === null || uris === void 0 ? void 0 : uris.forEach(function (contributorUri) {
|
|
@@ -33,7 +35,7 @@ var HistoryGraph = function (_a) {
|
|
|
33
35
|
var toX = contributorLane.index * COL_WIDTH + COL_MARGIN;
|
|
34
36
|
var toY = isUpRight ? y - rowHeight : y + rowHeight;
|
|
35
37
|
if (x !== toX)
|
|
36
|
-
acc.links.push(React.createElement(HistoryLink, { key: "link-".concat(contributorUri, "-").concat(index), x: x, y: y, toX: toX, toY: toY, isDashed:
|
|
38
|
+
acc.links.push(React.createElement(HistoryLink, { key: "link-".concat(contributorUri, "-").concat(index), x: x, y: y, toX: toX, toY: toY, isDashed: hasFakeType, color: getContributorColor(contributorUri) }));
|
|
37
39
|
});
|
|
38
40
|
return acc;
|
|
39
41
|
}, { links: [], circles: [], rowLines: [] }), links = _b.links, rowLines = _b.rowLines, circles = _b.circles;
|
|
@@ -45,25 +47,26 @@ var HistoryGraph = function (_a) {
|
|
|
45
47
|
contributorLane.lifeTime.forEach(function (_a, i) {
|
|
46
48
|
var _b;
|
|
47
49
|
var start = _a.start, end = _a.end;
|
|
48
|
-
if (((_b = rows[end === null || end === void 0 ? void 0 : end.index]) === null || _b === void 0 ? void 0 : _b.type) === HistoryChangeTypes.ENTITIES_SPLITTED)
|
|
50
|
+
if (((_b = rows[end === null || end === void 0 ? void 0 : end.index]) === null || _b === void 0 ? void 0 : _b.type) === HistoryChangeTypes.ENTITIES_SPLITTED) {
|
|
51
|
+
if ((end === null || end === void 0 ? void 0 : end.index) && contributorLane.index === 0) {
|
|
52
|
+
links.unshift(React.createElement("path", { key: "line-".concat(contributorUri, "-").concat(i), d: "M".concat(x, " ").concat(rowPositions[0], " L").concat(x, " ").concat(rowPositions[end.index - 1]), stroke: getContributorColor(contributorUri), strokeWidth: 2 }));
|
|
53
|
+
}
|
|
49
54
|
return;
|
|
55
|
+
}
|
|
50
56
|
var startIndex = (start === null || start === void 0 ? void 0 : start.type) === HistoryChangeTypes.ENTITIES_SPLITTED ? (start === null || start === void 0 ? void 0 : start.index) - 1 : start === null || start === void 0 ? void 0 : start.index;
|
|
51
|
-
var endIndex = (end
|
|
52
|
-
(end === null || end === void 0 ? void 0 : end.type) === HistoryChangeTypes.ENTITIES_MERGED
|
|
53
|
-
? (end === null || end === void 0 ? void 0 : end.index) + 1
|
|
54
|
-
: end === null || end === void 0 ? void 0 : end.index;
|
|
57
|
+
var endIndex = findEndIndex(end);
|
|
55
58
|
var startY = rowPositions[startIndex] || rowPositions[rowPositions.length - 2];
|
|
56
59
|
var endY = rowPositions[endIndex] || ROW_MARGIN;
|
|
57
60
|
if (startY <= endY)
|
|
58
61
|
return;
|
|
59
62
|
var color = getContributorColor(contributorUri);
|
|
60
|
-
if (!end && contributorLane.index > 0) {
|
|
63
|
+
if (!end && endIndex === undefined && contributorLane.index > 0) {
|
|
61
64
|
circles.push(React.createElement(HistoryCircle, { key: "initCircle-".concat(contributorUri, "-").concat(i), x: x, y: endY, color: color, showLine: true }));
|
|
62
65
|
}
|
|
63
66
|
links.unshift(React.createElement("path", { key: "line-".concat(contributorUri, "-").concat(i), d: "M".concat(x, " ").concat(startY, " L").concat(x, " ").concat(endY), stroke: color, strokeWidth: 2 }));
|
|
64
67
|
});
|
|
65
68
|
});
|
|
66
|
-
return (React.createElement("svg", { className: "chart", width: width, height: height },
|
|
69
|
+
return (React.createElement("svg", { "data-reltio-id": "reltio-history-graph", className: "chart", width: width, height: height },
|
|
67
70
|
React.createElement("g", { id: "rowLines" }, rowLines),
|
|
68
71
|
React.createElement("g", { id: "links" }, links),
|
|
69
72
|
React.createElement("g", { id: "circles" }, circles)));
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { HistoryRowData } from '../types';
|
|
1
2
|
export declare const getHistoryLinkCurve: (x: number, y: number, toX: number, toY: number) => string;
|
|
2
3
|
export declare const isFakeHistoryType: (type: string) => boolean;
|
|
4
|
+
export declare const findEndIndex: (end: HistoryRowData) => number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HistoryChangeTypes } from '../types
|
|
1
|
+
import { HistoryChangeTypes } from '../types';
|
|
2
2
|
export var getHistoryLinkCurve = function (x, y, toX, toY) {
|
|
3
3
|
var isUp = y > toY;
|
|
4
4
|
var isLeft = x < toX;
|
|
@@ -11,3 +11,11 @@ export var getHistoryLinkCurve = function (x, y, toX, toY) {
|
|
|
11
11
|
export var isFakeHistoryType = function (type) {
|
|
12
12
|
return type === HistoryChangeTypes.FAKE_FILTERED_INCOMING || type === HistoryChangeTypes.FAKE_FILTERED_OUTGOING;
|
|
13
13
|
};
|
|
14
|
+
export var findEndIndex = function (end) {
|
|
15
|
+
var _a = end || {}, endIndex = _a.index, endType = _a.type;
|
|
16
|
+
if (endIndex === undefined)
|
|
17
|
+
return;
|
|
18
|
+
return endType === HistoryChangeTypes.ENTITIES_MERGED_MANUALLY || endType === HistoryChangeTypes.ENTITIES_MERGED
|
|
19
|
+
? endIndex + 1
|
|
20
|
+
: endIndex;
|
|
21
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { HistoryRowData } from '../types';
|
|
3
3
|
type Props = {
|
|
4
|
-
change:
|
|
4
|
+
change: HistoryRowData;
|
|
5
5
|
isCurrent?: boolean;
|
|
6
6
|
isSelected: boolean;
|
|
7
7
|
onClick: () => void;
|
|
@@ -8,8 +8,9 @@ import { useStyles } from './styles';
|
|
|
8
8
|
var HistoryRow = function (_a) {
|
|
9
9
|
var _b;
|
|
10
10
|
var change = _a.change, isCurrent = _a.isCurrent, isSelected = _a.isSelected, onClick = _a.onClick;
|
|
11
|
-
var uri = change.uri, type = change.type, matchGroups = change.matchGroups, user = change.user, timestamp = change.timestamp;
|
|
12
|
-
var
|
|
11
|
+
var uri = change.uri, type = change.type, matchGroups = change.matchGroups, user = change.user, timestamp = change.timestamp, fakeType = change.fakeType, uris = change.uris;
|
|
12
|
+
var colorUri = fakeType && uris ? uris[0] : uri;
|
|
13
|
+
var color = getContributorColor(colorUri);
|
|
13
14
|
var styles = useStyles({ color: color });
|
|
14
15
|
return (React.createElement("div", { className: classnames(styles.historyRow, (_b = {}, _b[styles.selected] = isSelected, _b)), onClick: onClick },
|
|
15
16
|
React.createElement("div", { className: styles.rowHeader },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HistoryChange } from '@reltio/mdm-sdk';
|
|
2
|
+
import { HistoryLife } from '../types';
|
|
3
|
+
export declare const checkChange: any;
|
|
4
|
+
export declare const startNewLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
5
|
+
export declare const updateLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
6
|
+
export declare const endLife: (lifeTime: HistoryLife[], change: HistoryChange) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { curry } from 'ramda';
|
|
2
|
+
import { HistoryChangeTypes } from '../types';
|
|
3
|
+
export var checkChange = curry(function (involvedUris, checkInUris, change) {
|
|
4
|
+
var uri = change.uri, type = change.type, uris = change.uris;
|
|
5
|
+
if (involvedUris) {
|
|
6
|
+
if (Array.isArray(involvedUris)) {
|
|
7
|
+
if (type !== HistoryChangeTypes.ENTITY_LOST_MERGE)
|
|
8
|
+
return null;
|
|
9
|
+
if (involvedUris.includes(uri)) {
|
|
10
|
+
return change;
|
|
11
|
+
}
|
|
12
|
+
else if (checkInUris && uris) {
|
|
13
|
+
return involvedUris.some(function (involvedUri) { return uris.includes(involvedUri); }) ? change : null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
if (uri === involvedUris || (checkInUris && (uris === null || uris === void 0 ? void 0 : uris.includes(involvedUris))))
|
|
18
|
+
return change;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
});
|
|
23
|
+
export var startNewLife = function (lifeTime, change) {
|
|
24
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
25
|
+
if (currentLife &&
|
|
26
|
+
(!currentLife.start ||
|
|
27
|
+
(currentLife.start.type === HistoryChangeTypes.ENTITY_CREATED &&
|
|
28
|
+
change.type === HistoryChangeTypes.ENTITIES_SPLITTED))) {
|
|
29
|
+
currentLife.start = change;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
lifeTime.push({ start: change, end: null });
|
|
33
|
+
};
|
|
34
|
+
export var updateLife = function (lifeTime, change) {
|
|
35
|
+
var shouldAddNewLife = true;
|
|
36
|
+
if (lifeTime.length) {
|
|
37
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
38
|
+
shouldAddNewLife = !((!currentLife.start || currentLife.start.timestamp < change.timestamp) &&
|
|
39
|
+
(!currentLife.end || currentLife.end.timestamp > change.timestamp));
|
|
40
|
+
}
|
|
41
|
+
if (shouldAddNewLife) {
|
|
42
|
+
lifeTime.push({ start: null, end: null });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export var endLife = function (lifeTime, change) {
|
|
46
|
+
if (lifeTime.length) {
|
|
47
|
+
var currentLife = lifeTime[lifeTime.length - 1];
|
|
48
|
+
if (!currentLife.start)
|
|
49
|
+
currentLife.start = change;
|
|
50
|
+
}
|
|
51
|
+
lifeTime.push({ start: null, end: change });
|
|
52
|
+
};
|
|
@@ -78,6 +78,7 @@ export var useHistory = function (_a) {
|
|
|
78
78
|
if (entityUri && enabled) {
|
|
79
79
|
loadHistoricUris();
|
|
80
80
|
setHistoryPage(0);
|
|
81
|
+
setHistoryWithTotal(null);
|
|
81
82
|
}
|
|
82
83
|
}, [entityUri, entity === null || entity === void 0 ? void 0 : entity.updatedTime, enabled]);
|
|
83
84
|
var loadMore = useCallback(function (offset) {
|
|
@@ -9,38 +9,28 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { useMemo } from 'react';
|
|
13
|
-
import {
|
|
14
|
-
import { HistoryChangeTypes } from '
|
|
22
|
+
import { pipe, slice, find, drop } from 'ramda';
|
|
23
|
+
import { HistoryChangeTypes } from '../types';
|
|
24
|
+
import { checkChange, startNewLife, updateLife, endLife } from './historyHelpers';
|
|
15
25
|
export var useHistoryTree = function (_a) {
|
|
16
26
|
var entityUri = _a.entityUri, historyChanges = _a.historyChanges, selectedUris = _a.selectedUris;
|
|
17
27
|
return useMemo(function () {
|
|
18
28
|
var _a;
|
|
19
29
|
var historyLanes = (_a = {}, _a[entityUri] = { index: 0, lifeTime: [] }, _a);
|
|
20
30
|
var rows = [{ user: '', timestamp: 0, uri: entityUri }];
|
|
21
|
-
var
|
|
22
|
-
var _a;
|
|
23
|
-
var uri = change.uri || entityUri;
|
|
24
|
-
if (involvedUris) {
|
|
25
|
-
if (Array.isArray(involvedUris)) {
|
|
26
|
-
if (change.type !== HistoryChangeTypes.ENTITY_LOST_MERGE)
|
|
27
|
-
return null;
|
|
28
|
-
if (involvedUris.includes(uri)) {
|
|
29
|
-
return change;
|
|
30
|
-
}
|
|
31
|
-
else if (checkInUris && change.uris) {
|
|
32
|
-
return involvedUris.some(function (involvedUri) { return change.uris.includes(involvedUri); }) ? change : null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (uri === involvedUris || (checkInUris && ((_a = change.uris) === null || _a === void 0 ? void 0 : _a.includes(involvedUris))))
|
|
37
|
-
return change;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
});
|
|
31
|
+
var normalizedHistoryChanges = historyChanges === null || historyChanges === void 0 ? void 0 : historyChanges.map(function (change) { return (__assign(__assign({}, change), { uri: change.uri || entityUri })); });
|
|
42
32
|
var findNextChange = function (index, involvedUris, checkInUris) {
|
|
43
|
-
return pipe(drop(index + 1), find(checkChange(involvedUris, checkInUris)))(
|
|
33
|
+
return pipe(drop(index + 1), find(checkChange(involvedUris, checkInUris)))(normalizedHistoryChanges);
|
|
44
34
|
};
|
|
45
35
|
var findPreviousChange = function (index, uri) {
|
|
46
36
|
return pipe(slice(index + 1, Infinity), find(checkChange(uri, false)))(rows);
|
|
@@ -54,36 +44,6 @@ export var useHistoryTree = function (_a) {
|
|
|
54
44
|
}
|
|
55
45
|
return historyLanes[uri];
|
|
56
46
|
};
|
|
57
|
-
var startNewLife = function (lifeTime, change) {
|
|
58
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
59
|
-
if (currentLife &&
|
|
60
|
-
(!currentLife.start ||
|
|
61
|
-
(currentLife.start.type === HistoryChangeTypes.ENTITY_CREATED &&
|
|
62
|
-
change.type === HistoryChangeTypes.ENTITIES_SPLITTED))) {
|
|
63
|
-
currentLife.start = change;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
lifeTime.push({ start: change, end: null });
|
|
67
|
-
};
|
|
68
|
-
var updateLife = function (lifeTime, change) {
|
|
69
|
-
var shouldAddNewLife = true;
|
|
70
|
-
if (lifeTime.length) {
|
|
71
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
72
|
-
shouldAddNewLife = !((!currentLife.start || currentLife.start.timestamp < change.timestamp) &&
|
|
73
|
-
(!currentLife.end || currentLife.end.timestamp > change.timestamp));
|
|
74
|
-
}
|
|
75
|
-
if (shouldAddNewLife) {
|
|
76
|
-
lifeTime.push({ start: null, end: null });
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var endLife = function (lifeTime, change) {
|
|
80
|
-
if (lifeTime.length) {
|
|
81
|
-
var currentLife = lifeTime[lifeTime.length - 1];
|
|
82
|
-
if (!currentLife.start)
|
|
83
|
-
currentLife.start = change;
|
|
84
|
-
}
|
|
85
|
-
lifeTime.push({ start: null, end: change });
|
|
86
|
-
};
|
|
87
47
|
var checkLifeTime = function (lifeTime, change) {
|
|
88
48
|
var _a, _b;
|
|
89
49
|
switch (change.type) {
|
|
@@ -131,18 +91,22 @@ export var useHistoryTree = function (_a) {
|
|
|
131
91
|
}
|
|
132
92
|
};
|
|
133
93
|
var postProcessChanges = [];
|
|
134
|
-
|
|
135
|
-
var
|
|
94
|
+
normalizedHistoryChanges === null || normalizedHistoryChanges === void 0 ? void 0 : normalizedHistoryChanges.forEach(function (change, index) {
|
|
95
|
+
var uri = change.uri, uris = change.uris, timestamp = change.timestamp;
|
|
136
96
|
switch (change.type) {
|
|
137
97
|
case HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
138
|
-
if (!findNextChange(index,
|
|
98
|
+
if (!findNextChange(index, uri, false)) {
|
|
139
99
|
return;
|
|
140
100
|
}
|
|
141
101
|
else {
|
|
142
|
-
var
|
|
143
|
-
var involvedUris = change.uris ? [change.uris, uri] : [uri];
|
|
102
|
+
var involvedUris = uris ? __spreadArray(__spreadArray([], uris, true), [uri], false) : [uri];
|
|
144
103
|
var lostMergeChange = findNextChange(index, involvedUris, true);
|
|
145
|
-
|
|
104
|
+
var isLostMerge = !uri || uri === (lostMergeChange === null || lostMergeChange === void 0 ? void 0 : lostMergeChange.uri);
|
|
105
|
+
var lastChange = rows[rows.length - 1];
|
|
106
|
+
var isAlreadyUnmerged = lastChange.type === HistoryChangeTypes.ENTITIES_SPLITTED &&
|
|
107
|
+
(uris === null || uris === void 0 ? void 0 : uris.includes(lastChange.uri)) &&
|
|
108
|
+
lastChange.timestamp === timestamp;
|
|
109
|
+
if (isLostMerge || isAlreadyUnmerged)
|
|
146
110
|
return;
|
|
147
111
|
}
|
|
148
112
|
break;
|
|
@@ -152,71 +116,50 @@ export var useHistoryTree = function (_a) {
|
|
|
152
116
|
case HistoryChangeTypes.RELATIONSHIP_CHANGED:
|
|
153
117
|
return;
|
|
154
118
|
}
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
if (!checkLaneUri(uri))
|
|
158
|
-
addPostProcess = true;
|
|
159
|
-
});
|
|
160
|
-
var contributorLane = checkLaneUri(change.uri || entityUri);
|
|
161
|
-
if (!contributorLane)
|
|
162
|
-
return;
|
|
119
|
+
var contributorLane = checkLaneUri(uri);
|
|
120
|
+
uris === null || uris === void 0 ? void 0 : uris.forEach(function (uri) { return checkLaneUri(uri); });
|
|
163
121
|
var rowChange = __assign({}, change);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
122
|
+
if (contributorLane) {
|
|
123
|
+
checkLifeTime(contributorLane.lifeTime, rowChange);
|
|
124
|
+
rows.push(rowChange);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (uris)
|
|
128
|
+
postProcessChanges.push(rowChange);
|
|
129
|
+
}
|
|
168
130
|
});
|
|
169
131
|
postProcessChanges.forEach(function (postChange) {
|
|
170
132
|
postChange.uris.forEach(function (postUri) {
|
|
171
|
-
if (historyLanes[postUri])
|
|
133
|
+
if (!historyLanes[postUri])
|
|
172
134
|
return;
|
|
173
|
-
|
|
174
|
-
var uri =
|
|
175
|
-
if (
|
|
135
|
+
normalizedHistoryChanges.forEach(function (change) {
|
|
136
|
+
var uri = change.uri, uris = change.uris, type = change.type, timestamp = change.timestamp;
|
|
137
|
+
if (timestamp !== postChange.timestamp || type !== postChange.type)
|
|
176
138
|
return;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
switch (type) {
|
|
183
|
-
case HistoryChangeTypes.ENTITIES_MERGED:
|
|
184
|
-
case HistoryChangeTypes.ENTITIES_MERGED_MANUALLY:
|
|
185
|
-
fakeType = HistoryChangeTypes.FAKE_FILTERED_INCOMING;
|
|
186
|
-
break;
|
|
187
|
-
case HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
188
|
-
fakeType = HistoryChangeTypes.FAKE_FILTERED_OUTGOING;
|
|
189
|
-
break;
|
|
190
|
-
default:
|
|
139
|
+
var fakeChange;
|
|
140
|
+
switch (type) {
|
|
141
|
+
case HistoryChangeTypes.ENTITIES_MERGED:
|
|
142
|
+
case HistoryChangeTypes.ENTITIES_MERGED_MANUALLY:
|
|
143
|
+
if (!(uris === null || uris === void 0 ? void 0 : uris.includes(postUri)))
|
|
191
144
|
return;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
uri
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
if (!isNil(extendLife.startIndex)) {
|
|
209
|
-
contributorLane.lifeTime[extendLife.startIndex].start = fakeChange;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
rows.splice(rows.indexOf(postChange), 0, fakeChange);
|
|
213
|
-
});
|
|
145
|
+
fakeChange = { fakeType: HistoryChangeTypes.FAKE_FILTERED_INCOMING, uri: postUri };
|
|
146
|
+
break;
|
|
147
|
+
case HistoryChangeTypes.ENTITIES_SPLITTED:
|
|
148
|
+
if (uri !== postUri || !uris)
|
|
149
|
+
return;
|
|
150
|
+
fakeChange = { fakeType: HistoryChangeTypes.FAKE_FILTERED_OUTGOING, uri: uri };
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
var fakeRowIndex = rows.findIndex(function (row, i) { return i !== 0 && row.timestamp < timestamp; });
|
|
156
|
+
var fakeRow = __assign(__assign(__assign({}, postChange), fakeChange), { uris: [postChange.uri] });
|
|
157
|
+
rows.splice(fakeRowIndex, 0, fakeRow);
|
|
214
158
|
});
|
|
215
159
|
});
|
|
216
160
|
});
|
|
217
161
|
rows.forEach(function (row, i) {
|
|
218
162
|
row.index = i;
|
|
219
|
-
row.uri = row.uri || entityUri;
|
|
220
163
|
});
|
|
221
164
|
return {
|
|
222
165
|
historyData: { historyLanes: historyLanes, rows: rows },
|
|
@@ -224,23 +167,3 @@ export var useHistoryTree = function (_a) {
|
|
|
224
167
|
};
|
|
225
168
|
}, [entityUri, historyChanges, selectedUris]);
|
|
226
169
|
};
|
|
227
|
-
var findClosestLife = function (lifeTime, timestamp) {
|
|
228
|
-
return lifeTime.reduce(function (acc, _a, i) {
|
|
229
|
-
var start = _a.start, end = _a.end;
|
|
230
|
-
if (start) {
|
|
231
|
-
var d = timestamp - start.timestamp;
|
|
232
|
-
if (isNil(acc.startDistance) || (Math.abs(acc.startDistance) > Math.abs(d) && d > 0)) {
|
|
233
|
-
acc.startIndex = i;
|
|
234
|
-
acc.startDistance = d;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (end) {
|
|
238
|
-
var d = timestamp - end.timestamp;
|
|
239
|
-
if (isNil(acc.endDistance) || (Math.abs(acc.endDistance) > Math.abs(d) && d < 0)) {
|
|
240
|
-
acc.endIndex = i;
|
|
241
|
-
acc.endDistance = d;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return acc;
|
|
245
|
-
}, { startIndex: null, endIndex: null, startDistance: null, endDistance: null });
|
|
246
|
-
};
|