@reltio/components 1.4.915 → 1.4.916

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.
Files changed (31) hide show
  1. package/cjs/components/SideIconPanel/SideButtonsPanel.d.ts +3 -3
  2. package/cjs/components/SideIconPanel/SideButtonsPanel.js +3 -3
  3. package/cjs/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.d.ts +3 -2
  4. package/cjs/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.js +6 -5
  5. package/cjs/components/attributes/AttributesView/index.js +1 -1
  6. package/cjs/components/history/HistoryTree/HistoryTree.js +11 -1
  7. package/cjs/components/history/hooks/useHistory.d.ts +1 -0
  8. package/cjs/components/history/hooks/useHistory.js +7 -2
  9. package/cjs/components/history/hooks/useHistoryDiff.d.ts +2 -0
  10. package/cjs/components/history/hooks/useHistoryDiff.js +62 -0
  11. package/cjs/components/history/hooks/useHistoryWithTotal.d.ts +1 -0
  12. package/cjs/components/history/hooks/useHistoryWithTotal.js +1 -1
  13. package/cjs/components/history/index.d.ts +1 -0
  14. package/cjs/components/history/index.js +3 -1
  15. package/cjs/contexts/HistoryAppearanceContext/index.js +3 -1
  16. package/esm/components/SideIconPanel/SideButtonsPanel.d.ts +3 -3
  17. package/esm/components/SideIconPanel/SideButtonsPanel.js +3 -3
  18. package/esm/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.d.ts +3 -2
  19. package/esm/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.js +6 -5
  20. package/esm/components/attributes/AttributesView/index.js +1 -1
  21. package/esm/components/history/HistoryTree/HistoryTree.js +12 -2
  22. package/esm/components/history/hooks/useHistory.d.ts +1 -0
  23. package/esm/components/history/hooks/useHistory.js +7 -2
  24. package/esm/components/history/hooks/useHistoryDiff.d.ts +2 -0
  25. package/esm/components/history/hooks/useHistoryDiff.js +39 -0
  26. package/esm/components/history/hooks/useHistoryWithTotal.d.ts +1 -0
  27. package/esm/components/history/hooks/useHistoryWithTotal.js +1 -1
  28. package/esm/components/history/index.d.ts +1 -0
  29. package/esm/components/history/index.js +1 -0
  30. package/esm/contexts/HistoryAppearanceContext/index.js +3 -1
  31. package/package.json +3 -3
@@ -3,11 +3,11 @@ declare type Props = {
3
3
  buttonsProps: {
4
4
  icon: ElementType;
5
5
  tooltipTitle: string;
6
- id: string;
6
+ id: number;
7
7
  }[];
8
- activeIndex: number;
8
+ activeIndexId: number;
9
9
  className?: string;
10
- onButtonClick: (index: number) => void;
10
+ onButtonClick: (id: number) => void;
11
11
  };
12
12
  export declare const SideButtonsPanel: VFC<Props>;
13
13
  export {};
@@ -31,12 +31,12 @@ var classnames_1 = __importDefault(require("classnames"));
31
31
  var SmallIconButton_1 = require("../SmallIconButton");
32
32
  var styles_1 = require("./styles");
33
33
  var SideButtonsPanel = function (_a) {
34
- var buttonsProps = _a.buttonsProps, activeIndex = _a.activeIndex, className = _a.className, onButtonClick = _a.onButtonClick;
34
+ var buttonsProps = _a.buttonsProps, activeIndexId = _a.activeIndexId, className = _a.className, onButtonClick = _a.onButtonClick;
35
35
  var styles = styles_1.useStyles();
36
- return (react_1.default.createElement("div", { className: classnames_1.default(styles.container, className) }, buttonsProps.map(function (_a, index) {
36
+ return (react_1.default.createElement("div", { className: classnames_1.default(styles.container, className) }, buttonsProps.map(function (_a) {
37
37
  var _b;
38
38
  var id = _a.id, buttonProps = __rest(_a, ["id"]);
39
- return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, __assign({}, buttonProps, { size: "S", key: id, className: classnames_1.default((_b = {}, _b[styles.active] = activeIndex === index, _b), styles.buttonWrapper), onClick: function () { return onButtonClick(index); }, "data-reltio-id": "reltio-profile-right-side-button-" + id })));
39
+ return (react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, __assign({}, buttonProps, { size: "S", key: id, className: classnames_1.default((_b = {}, _b[styles.active] = activeIndexId === id, _b), styles.buttonWrapper), onClick: function () { return onButtonClick(id); }, "data-reltio-id": "reltio-profile-right-side-button-" + id })));
40
40
  })));
41
41
  };
42
42
  exports.SideButtonsPanel = SideButtonsPanel;
@@ -1,7 +1,8 @@
1
1
  import { ReactNode, VFC } from 'react';
2
2
  declare type HeaderProps = {
3
- mainTitle: string;
4
- secondTitle: string;
3
+ mainTitle?: string;
4
+ secondTitle?: string;
5
+ content?: ReactNode;
5
6
  rightContent?: ReactNode;
6
7
  };
7
8
  declare type Props = HeaderProps & {
@@ -12,13 +12,14 @@ var Divider_1 = __importDefault(require("@material-ui/core/Divider"));
12
12
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
13
13
  var SmallIconButton_1 = require("../../SmallIconButton");
14
14
  var SidePanelContentHeader = function (_a) {
15
- var onClose = _a.onClose, mainTitle = _a.mainTitle, secondTitle = _a.secondTitle, rightContent = _a.rightContent;
15
+ var onClose = _a.onClose, mainTitle = _a.mainTitle, secondTitle = _a.secondTitle, content = _a.content, rightContent = _a.rightContent;
16
16
  var styles = styles_1.useStyles();
17
17
  return (react_1.default.createElement("div", { className: styles.container },
18
18
  react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { size: "S", icon: Close_1.default, onClick: onClose, className: styles.icon, tooltipTitle: ui_i18n_1.default.text('Close') }),
19
- react_1.default.createElement(Typography_1.default, { variant: "h6" }, mainTitle),
20
- react_1.default.createElement(Divider_1.default, { orientation: "vertical", flexItem: true, className: styles.divider }),
21
- react_1.default.createElement(Typography_1.default, { variant: "body1", color: "textSecondary", className: styles.secondTitle }, secondTitle),
22
- rightContent));
19
+ content || (react_1.default.createElement(react_1.default.Fragment, null,
20
+ react_1.default.createElement(Typography_1.default, { variant: "h6" }, mainTitle),
21
+ react_1.default.createElement(Divider_1.default, { orientation: "vertical", flexItem: true, className: styles.divider }),
22
+ react_1.default.createElement(Typography_1.default, { variant: "body1", color: "textSecondary", className: styles.secondTitle }, secondTitle),
23
+ rightContent))));
23
24
  };
24
25
  exports.SidePanelContentHeader = SidePanelContentHeader;
@@ -9,7 +9,7 @@ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
9
9
  var AttributesView_1 = __importDefault(require("./AttributesView"));
10
10
  exports.AttributesView = AttributesView_1.default;
11
11
  var mapStateToProps = function (state, ownProps) { return ({
12
- entity: ownProps.entity || mdm_module_1.default.selectors.getEntity(state),
12
+ entity: ownProps.entity || mdm_module_1.default.selectors.getEntityWithDiff(state),
13
13
  mode: ownProps.mode || mdm_module_1.default.selectors.getMode(state)
14
14
  }); };
15
15
  exports.default = react_redux_1.connect(mapStateToProps)(AttributesView_1.default);
@@ -39,7 +39,8 @@ var react_resize_detector_1 = __importDefault(require("react-resize-detector"));
39
39
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
40
40
  var ramda_1 = require("ramda");
41
41
  var classnames_1 = __importDefault(require("classnames"));
42
- var mdm_module_1 = require("@reltio/mdm-module");
42
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
43
+ var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
43
44
  var Button_1 = __importDefault(require("@material-ui/core/Button"));
44
45
  var HistoryRow_1 = __importDefault(require("../HistoryRow/HistoryRow"));
45
46
  var HistoryGraph_1 = __importDefault(require("../HistoryGraph/HistoryGraph"));
@@ -50,6 +51,7 @@ var HistoryTree = function (_a) {
50
51
  var historyData = _a.historyData, isLoading = _a.isLoading, canLoadMore = _a.canLoadMore, onLoadMore = _a.onLoadMore, entityUri = _a.entityUri, historyEvent = _a.historyEvent, findPreviousChange = _a.findPreviousChange;
51
52
  var styles = styles_1.useStyles();
52
53
  var dispatch = react_redux_1.useDispatch();
54
+ var isEditableMode = react_redux_1.useSelector(mdm_module_1.default.selectors.getIsEditableMode);
53
55
  var _c = react_1.useState({ historyLanes: {}, rows: [] }), graphData = _c[0], setGraphData = _c[1];
54
56
  var _d = react_1.useState(false), isScrollable = _d[0], setIsScrollable = _d[1];
55
57
  var _e = react_1.useState(-1), selectedIndex = _e[0], setSelectedIndex = _e[1];
@@ -78,6 +80,14 @@ var HistoryTree = function (_a) {
78
80
  setIsScrollable(scrollLeft < scrollWidth - clientWidth);
79
81
  };
80
82
  var handleHistoryRowClick = function (index, change, isSelected, isCurrent) {
83
+ if (isEditableMode) {
84
+ if (window.confirm(ui_i18n_1.default.text('Are you sure you want to go in history mode? All your changes will be lost.'))) {
85
+ dispatch(mdm_module_1.profile.mode.actions.modeUpdated(mdm_sdk_1.Mode.Viewing));
86
+ }
87
+ else {
88
+ return;
89
+ }
90
+ }
81
91
  if ((isCurrent && !isSelected) || (!isCurrent && isSelected)) {
82
92
  dispatch(mdm_module_1.profile.history.actions.clearHistoryEvent());
83
93
  setSelectedIndex(0);
@@ -12,5 +12,6 @@ export declare const useHistory: ({ entityUri, enabled }: Props) => {
12
12
  historyWithTotal: import("@reltio/mdm-sdk").HistoryWithTotal;
13
13
  historyFilter: HistoryFilter;
14
14
  setHistoryFilter: import("react").Dispatch<import("react").SetStateAction<HistoryFilter>>;
15
+ reloadHistory: () => void;
15
16
  };
16
17
  export {};
@@ -21,7 +21,7 @@ var useHistory = function (_a) {
21
21
  offset: historyPage * MAX_HISTORY_ROWS,
22
22
  order: 'desc',
23
23
  showAll: true
24
- }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore;
24
+ }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore, loadData = _e.loadData;
25
25
  var canLoadMore = react_1.useMemo(function () { return (historyPage + 1) * MAX_HISTORY_ROWS <= (historyWithTotal === null || historyWithTotal === void 0 ? void 0 : historyWithTotal.total); }, [
26
26
  historyWithTotal,
27
27
  historyPage
@@ -32,6 +32,10 @@ var useHistory = function (_a) {
32
32
  loadMore((historyPage + 1) * MAX_HISTORY_ROWS);
33
33
  setHistoryPage(historyPage + 1);
34
34
  }, [loadMore, historyPage, canLoadMore]);
35
+ var reloadHistory = react_1.useCallback(function () {
36
+ loadData();
37
+ setHistoryPage(0);
38
+ }, [loadData]);
35
39
  return {
36
40
  isLoading: isHistoryLoading || isHistoricUrisLoading,
37
41
  canLoadMore: canLoadMore,
@@ -39,7 +43,8 @@ var useHistory = function (_a) {
39
43
  historicUris: historicUris,
40
44
  historyWithTotal: historyWithTotal,
41
45
  historyFilter: historyFilter,
42
- setHistoryFilter: setHistoryFilter
46
+ setHistoryFilter: setHistoryFilter,
47
+ reloadHistory: reloadHistory
43
48
  };
44
49
  };
45
50
  exports.useHistory = useHistory;
@@ -0,0 +1,2 @@
1
+ import { HistoryDiff } from '@reltio/mdm-sdk';
2
+ export declare const useHistoryDiff: () => HistoryDiff;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.useHistoryDiff = void 0;
23
+ var react_1 = require("react");
24
+ var react_redux_1 = require("react-redux");
25
+ var ramda_1 = require("ramda");
26
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
27
+ var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
28
+ var defaultHistoryDiff = {
29
+ appearance: {},
30
+ attributes: {},
31
+ roles: [],
32
+ tags: []
33
+ };
34
+ var fixRefEntity = ramda_1.evolve({
35
+ refEntity: mdm_sdk_1.wrapInArrayIfNeeded,
36
+ refRelation: mdm_sdk_1.wrapInArrayIfNeeded
37
+ });
38
+ var prepareHistorySlice = function (historySlice) {
39
+ if (historySlice) {
40
+ return ramda_1.evolve({
41
+ attributes: ramda_1.map(ramda_1.map(fixRefEntity))
42
+ })(historySlice);
43
+ }
44
+ return historySlice;
45
+ };
46
+ var useHistoryDiff = function () {
47
+ var dispatch = react_redux_1.useDispatch();
48
+ var historySlice = react_redux_1.useSelector(mdm_module_1.default.selectors.getHistorySlice);
49
+ var historyDiff = react_redux_1.useSelector(mdm_module_1.default.selectors.getHistoryDiff);
50
+ var historyMode = react_redux_1.useSelector(mdm_module_1.default.selectors.getHistoryMode);
51
+ var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity);
52
+ react_1.useEffect(function () {
53
+ if (historySlice) {
54
+ var aEntity = historySlice.aEntity, bEntity = historySlice.bEntity;
55
+ var historyManager = mdm_sdk_1.entity.HistoryManager.createHistoryManager(mdm_sdk_1.entity.AttributesDiff);
56
+ var historyDiff_1 = historyManager.computeEntityHistoryDiff(prepareHistorySlice(historyMode === mdm_module_1.HistoryMode.Current ? entity : bEntity), prepareHistorySlice(aEntity));
57
+ dispatch(mdm_module_1.profile.history.actions.setHistoryDiff(historyDiff_1));
58
+ }
59
+ }, [historySlice, historyMode, dispatch, entity]);
60
+ return historyDiff || defaultHistoryDiff;
61
+ };
62
+ exports.useHistoryDiff = useHistoryDiff;
@@ -13,5 +13,6 @@ export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, .
13
13
  isLoading: boolean;
14
14
  historyWithTotal: HistoryWithTotal;
15
15
  loadMore: (offset: number) => void;
16
+ loadData: () => void;
16
17
  };
17
18
  export {};
@@ -74,6 +74,6 @@ var useHistoryWithTotal = function (_a) {
74
74
  loadData();
75
75
  }
76
76
  }, [loadData, enabled]);
77
- return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore };
77
+ return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore, loadData: loadData };
78
78
  };
79
79
  exports.useHistoryWithTotal = useHistoryWithTotal;
@@ -2,6 +2,7 @@ export { useHistoricUris } from './hooks/useHistoricUris';
2
2
  export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
3
  export { useHistorySlice } from './hooks/useHistorySlice';
4
4
  export { useHistory } from './hooks/useHistory';
5
+ export { useHistoryDiff } from './hooks/useHistoryDiff';
5
6
  export { default as HistoryView } from './HistoryView/HistoryView';
6
7
  export { default as HistoryHeader } from './HistoryHeader/HistoryHeader';
7
8
  export { default as ProfileBandHistory } from './ProfileBandHistory/ProfileBandHistory';
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ProfileBandHistory = exports.HistoryHeader = exports.HistoryView = exports.useHistory = exports.useHistorySlice = exports.useHistoryWithTotal = exports.useHistoricUris = void 0;
16
+ exports.ProfileBandHistory = exports.HistoryHeader = exports.HistoryView = exports.useHistoryDiff = exports.useHistory = exports.useHistorySlice = exports.useHistoryWithTotal = exports.useHistoricUris = void 0;
17
17
  var useHistoricUris_1 = require("./hooks/useHistoricUris");
18
18
  Object.defineProperty(exports, "useHistoricUris", { enumerable: true, get: function () { return useHistoricUris_1.useHistoricUris; } });
19
19
  var useHistoryWithTotal_1 = require("./hooks/useHistoryWithTotal");
@@ -22,6 +22,8 @@ var useHistorySlice_1 = require("./hooks/useHistorySlice");
22
22
  Object.defineProperty(exports, "useHistorySlice", { enumerable: true, get: function () { return useHistorySlice_1.useHistorySlice; } });
23
23
  var useHistory_1 = require("./hooks/useHistory");
24
24
  Object.defineProperty(exports, "useHistory", { enumerable: true, get: function () { return useHistory_1.useHistory; } });
25
+ var useHistoryDiff_1 = require("./hooks/useHistoryDiff");
26
+ Object.defineProperty(exports, "useHistoryDiff", { enumerable: true, get: function () { return useHistoryDiff_1.useHistoryDiff; } });
25
27
  var HistoryView_1 = require("./HistoryView/HistoryView");
26
28
  Object.defineProperty(exports, "HistoryView", { enumerable: true, get: function () { return __importDefault(HistoryView_1).default; } });
27
29
  var HistoryHeader_1 = require("./HistoryHeader/HistoryHeader");
@@ -7,6 +7,8 @@ exports.HistoryDiffContext = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  exports.HistoryDiffContext = react_1.default.createContext({
9
9
  appearance: undefined,
10
- attributes: undefined
10
+ attributes: undefined,
11
+ roles: undefined,
12
+ tags: undefined
11
13
  });
12
14
  exports.HistoryDiffContext.displayName = 'HistoryDiffContext';
@@ -3,11 +3,11 @@ declare type Props = {
3
3
  buttonsProps: {
4
4
  icon: ElementType;
5
5
  tooltipTitle: string;
6
- id: string;
6
+ id: number;
7
7
  }[];
8
- activeIndex: number;
8
+ activeIndexId: number;
9
9
  className?: string;
10
- onButtonClick: (index: number) => void;
10
+ onButtonClick: (id: number) => void;
11
11
  };
12
12
  export declare const SideButtonsPanel: VFC<Props>;
13
13
  export {};
@@ -25,11 +25,11 @@ import classnames from 'classnames';
25
25
  import { SmallIconButtonWithTooltip } from '../SmallIconButton';
26
26
  import { useStyles } from './styles';
27
27
  export var SideButtonsPanel = function (_a) {
28
- var buttonsProps = _a.buttonsProps, activeIndex = _a.activeIndex, className = _a.className, onButtonClick = _a.onButtonClick;
28
+ var buttonsProps = _a.buttonsProps, activeIndexId = _a.activeIndexId, className = _a.className, onButtonClick = _a.onButtonClick;
29
29
  var styles = useStyles();
30
- return (React.createElement("div", { className: classnames(styles.container, className) }, buttonsProps.map(function (_a, index) {
30
+ return (React.createElement("div", { className: classnames(styles.container, className) }, buttonsProps.map(function (_a) {
31
31
  var _b;
32
32
  var id = _a.id, buttonProps = __rest(_a, ["id"]);
33
- return (React.createElement(SmallIconButtonWithTooltip, __assign({}, buttonProps, { size: "S", key: id, className: classnames((_b = {}, _b[styles.active] = activeIndex === index, _b), styles.buttonWrapper), onClick: function () { return onButtonClick(index); }, "data-reltio-id": "reltio-profile-right-side-button-" + id })));
33
+ return (React.createElement(SmallIconButtonWithTooltip, __assign({}, buttonProps, { size: "S", key: id, className: classnames((_b = {}, _b[styles.active] = activeIndexId === id, _b), styles.buttonWrapper), onClick: function () { return onButtonClick(id); }, "data-reltio-id": "reltio-profile-right-side-button-" + id })));
34
34
  })));
35
35
  };
@@ -1,7 +1,8 @@
1
1
  import { ReactNode, VFC } from 'react';
2
2
  declare type HeaderProps = {
3
- mainTitle: string;
4
- secondTitle: string;
3
+ mainTitle?: string;
4
+ secondTitle?: string;
5
+ content?: ReactNode;
5
6
  rightContent?: ReactNode;
6
7
  };
7
8
  declare type Props = HeaderProps & {
@@ -6,12 +6,13 @@ import Divider from '@material-ui/core/Divider';
6
6
  import i18n from 'ui-i18n';
7
7
  import { SmallIconButtonWithTooltip } from '../../SmallIconButton';
8
8
  export var SidePanelContentHeader = function (_a) {
9
- var onClose = _a.onClose, mainTitle = _a.mainTitle, secondTitle = _a.secondTitle, rightContent = _a.rightContent;
9
+ var onClose = _a.onClose, mainTitle = _a.mainTitle, secondTitle = _a.secondTitle, content = _a.content, rightContent = _a.rightContent;
10
10
  var styles = useStyles();
11
11
  return (React.createElement("div", { className: styles.container },
12
12
  React.createElement(SmallIconButtonWithTooltip, { size: "S", icon: CloseIcon, onClick: onClose, className: styles.icon, tooltipTitle: i18n.text('Close') }),
13
- React.createElement(Typography, { variant: "h6" }, mainTitle),
14
- React.createElement(Divider, { orientation: "vertical", flexItem: true, className: styles.divider }),
15
- React.createElement(Typography, { variant: "body1", color: "textSecondary", className: styles.secondTitle }, secondTitle),
16
- rightContent));
13
+ content || (React.createElement(React.Fragment, null,
14
+ React.createElement(Typography, { variant: "h6" }, mainTitle),
15
+ React.createElement(Divider, { orientation: "vertical", flexItem: true, className: styles.divider }),
16
+ React.createElement(Typography, { variant: "body1", color: "textSecondary", className: styles.secondTitle }, secondTitle),
17
+ rightContent))));
17
18
  };
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
2
2
  import mdm from '@reltio/mdm-module';
3
3
  import AttributesView from './AttributesView';
4
4
  var mapStateToProps = function (state, ownProps) { return ({
5
- entity: ownProps.entity || mdm.selectors.getEntity(state),
5
+ entity: ownProps.entity || mdm.selectors.getEntityWithDiff(state),
6
6
  mode: ownProps.mode || mdm.selectors.getMode(state)
7
7
  }); };
8
8
  export { AttributesView };
@@ -10,12 +10,13 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import React, { useCallback, useEffect, useRef, useState } from 'react';
13
- import { useDispatch } from 'react-redux';
13
+ import { useDispatch, useSelector } from 'react-redux';
14
14
  import ReactResizeDetector from 'react-resize-detector';
15
15
  import i18n from 'ui-i18n';
16
16
  import { isNil } from 'ramda';
17
17
  import classnames from 'classnames';
18
- import { profile } from '@reltio/mdm-module';
18
+ import { Mode } from '@reltio/mdm-sdk';
19
+ import mdm, { profile } from '@reltio/mdm-module';
19
20
  import Button from '@material-ui/core/Button';
20
21
  import HistoryRow from '../HistoryRow/HistoryRow';
21
22
  import HistoryGraph from '../HistoryGraph/HistoryGraph';
@@ -26,6 +27,7 @@ var HistoryTree = function (_a) {
26
27
  var historyData = _a.historyData, isLoading = _a.isLoading, canLoadMore = _a.canLoadMore, onLoadMore = _a.onLoadMore, entityUri = _a.entityUri, historyEvent = _a.historyEvent, findPreviousChange = _a.findPreviousChange;
27
28
  var styles = useStyles();
28
29
  var dispatch = useDispatch();
30
+ var isEditableMode = useSelector(mdm.selectors.getIsEditableMode);
29
31
  var _c = useState({ historyLanes: {}, rows: [] }), graphData = _c[0], setGraphData = _c[1];
30
32
  var _d = useState(false), isScrollable = _d[0], setIsScrollable = _d[1];
31
33
  var _e = useState(-1), selectedIndex = _e[0], setSelectedIndex = _e[1];
@@ -54,6 +56,14 @@ var HistoryTree = function (_a) {
54
56
  setIsScrollable(scrollLeft < scrollWidth - clientWidth);
55
57
  };
56
58
  var handleHistoryRowClick = function (index, change, isSelected, isCurrent) {
59
+ if (isEditableMode) {
60
+ if (window.confirm(i18n.text('Are you sure you want to go in history mode? All your changes will be lost.'))) {
61
+ dispatch(profile.mode.actions.modeUpdated(Mode.Viewing));
62
+ }
63
+ else {
64
+ return;
65
+ }
66
+ }
57
67
  if ((isCurrent && !isSelected) || (!isCurrent && isSelected)) {
58
68
  dispatch(profile.history.actions.clearHistoryEvent());
59
69
  setSelectedIndex(0);
@@ -12,5 +12,6 @@ export declare const useHistory: ({ entityUri, enabled }: Props) => {
12
12
  historyWithTotal: import("@reltio/mdm-sdk").HistoryWithTotal;
13
13
  historyFilter: HistoryFilter;
14
14
  setHistoryFilter: import("react").Dispatch<import("react").SetStateAction<HistoryFilter>>;
15
+ reloadHistory: () => void;
15
16
  };
16
17
  export {};
@@ -18,7 +18,7 @@ export var useHistory = function (_a) {
18
18
  offset: historyPage * MAX_HISTORY_ROWS,
19
19
  order: 'desc',
20
20
  showAll: true
21
- }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore;
21
+ }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore, loadData = _e.loadData;
22
22
  var canLoadMore = useMemo(function () { return (historyPage + 1) * MAX_HISTORY_ROWS <= (historyWithTotal === null || historyWithTotal === void 0 ? void 0 : historyWithTotal.total); }, [
23
23
  historyWithTotal,
24
24
  historyPage
@@ -29,6 +29,10 @@ export var useHistory = function (_a) {
29
29
  loadMore((historyPage + 1) * MAX_HISTORY_ROWS);
30
30
  setHistoryPage(historyPage + 1);
31
31
  }, [loadMore, historyPage, canLoadMore]);
32
+ var reloadHistory = useCallback(function () {
33
+ loadData();
34
+ setHistoryPage(0);
35
+ }, [loadData]);
32
36
  return {
33
37
  isLoading: isHistoryLoading || isHistoricUrisLoading,
34
38
  canLoadMore: canLoadMore,
@@ -36,6 +40,7 @@ export var useHistory = function (_a) {
36
40
  historicUris: historicUris,
37
41
  historyWithTotal: historyWithTotal,
38
42
  historyFilter: historyFilter,
39
- setHistoryFilter: setHistoryFilter
43
+ setHistoryFilter: setHistoryFilter,
44
+ reloadHistory: reloadHistory
40
45
  };
41
46
  };
@@ -0,0 +1,2 @@
1
+ import { HistoryDiff } from '@reltio/mdm-sdk';
2
+ export declare const useHistoryDiff: () => HistoryDiff;
@@ -0,0 +1,39 @@
1
+ import { useEffect } from 'react';
2
+ import { useDispatch, useSelector } from 'react-redux';
3
+ import { evolve, map } from 'ramda';
4
+ import { entity as History, wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
5
+ import mdmModule, { HistoryMode, profile } from '@reltio/mdm-module';
6
+ var defaultHistoryDiff = {
7
+ appearance: {},
8
+ attributes: {},
9
+ roles: [],
10
+ tags: []
11
+ };
12
+ var fixRefEntity = evolve({
13
+ refEntity: wrapInArrayIfNeeded,
14
+ refRelation: wrapInArrayIfNeeded
15
+ });
16
+ var prepareHistorySlice = function (historySlice) {
17
+ if (historySlice) {
18
+ return evolve({
19
+ attributes: map(map(fixRefEntity))
20
+ })(historySlice);
21
+ }
22
+ return historySlice;
23
+ };
24
+ export var useHistoryDiff = function () {
25
+ var dispatch = useDispatch();
26
+ var historySlice = useSelector(mdmModule.selectors.getHistorySlice);
27
+ var historyDiff = useSelector(mdmModule.selectors.getHistoryDiff);
28
+ var historyMode = useSelector(mdmModule.selectors.getHistoryMode);
29
+ var entity = useSelector(mdmModule.selectors.getEntity);
30
+ useEffect(function () {
31
+ if (historySlice) {
32
+ var aEntity = historySlice.aEntity, bEntity = historySlice.bEntity;
33
+ var historyManager = History.HistoryManager.createHistoryManager(History.AttributesDiff);
34
+ var historyDiff_1 = historyManager.computeEntityHistoryDiff(prepareHistorySlice(historyMode === HistoryMode.Current ? entity : bEntity), prepareHistorySlice(aEntity));
35
+ dispatch(profile.history.actions.setHistoryDiff(historyDiff_1));
36
+ }
37
+ }, [historySlice, historyMode, dispatch, entity]);
38
+ return historyDiff || defaultHistoryDiff;
39
+ };
@@ -13,5 +13,6 @@ export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, .
13
13
  isLoading: boolean;
14
14
  historyWithTotal: HistoryWithTotal;
15
15
  loadMore: (offset: number) => void;
16
+ loadData: () => void;
16
17
  };
17
18
  export {};
@@ -71,5 +71,5 @@ export var useHistoryWithTotal = function (_a) {
71
71
  loadData();
72
72
  }
73
73
  }, [loadData, enabled]);
74
- return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore };
74
+ return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore, loadData: loadData };
75
75
  };
@@ -2,6 +2,7 @@ export { useHistoricUris } from './hooks/useHistoricUris';
2
2
  export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
3
  export { useHistorySlice } from './hooks/useHistorySlice';
4
4
  export { useHistory } from './hooks/useHistory';
5
+ export { useHistoryDiff } from './hooks/useHistoryDiff';
5
6
  export { default as HistoryView } from './HistoryView/HistoryView';
6
7
  export { default as HistoryHeader } from './HistoryHeader/HistoryHeader';
7
8
  export { default as ProfileBandHistory } from './ProfileBandHistory/ProfileBandHistory';
@@ -2,6 +2,7 @@ export { useHistoricUris } from './hooks/useHistoricUris';
2
2
  export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
3
  export { useHistorySlice } from './hooks/useHistorySlice';
4
4
  export { useHistory } from './hooks/useHistory';
5
+ export { useHistoryDiff } from './hooks/useHistoryDiff';
5
6
  export { default as HistoryView } from './HistoryView/HistoryView';
6
7
  export { default as HistoryHeader } from './HistoryHeader/HistoryHeader';
7
8
  export { default as ProfileBandHistory } from './ProfileBandHistory/ProfileBandHistory';
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  export var HistoryDiffContext = React.createContext({
3
3
  appearance: undefined,
4
- attributes: undefined
4
+ attributes: undefined,
5
+ roles: undefined,
6
+ tags: undefined
5
7
  });
6
8
  HistoryDiffContext.displayName = 'HistoryDiffContext';
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.915",
3
+ "version": "1.4.916",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "^2.7.0",
10
- "@reltio/mdm-module": "^1.4.915",
11
- "@reltio/mdm-sdk": "^1.4.915",
10
+ "@reltio/mdm-module": "^1.4.916",
11
+ "@reltio/mdm-sdk": "^1.4.916",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",