@reltio/components 1.4.913 → 1.4.917

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 (67) hide show
  1. package/cjs/components/MergeButton/MergeButton.d.ts +1 -0
  2. package/cjs/components/MergeButton/MergeButton.js +3 -2
  3. package/cjs/components/SideIconPanel/SideButtonsPanel.d.ts +3 -3
  4. package/cjs/components/SideIconPanel/SideButtonsPanel.js +3 -3
  5. package/cjs/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.d.ts +3 -2
  6. package/cjs/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.js +6 -5
  7. package/cjs/components/attributes/AttributesView/index.js +1 -1
  8. package/cjs/components/attributes/ImageAttributesLine/ImageAttributesLine.d.ts +7 -2
  9. package/cjs/components/attributes/ImageAttributesLine/ImageAttributesLine.js +15 -1
  10. package/cjs/components/attributes/editMode/AttributesPager/AttributesPager.js +1 -1
  11. package/cjs/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.d.ts +8 -2
  12. package/cjs/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.js +5 -5
  13. package/cjs/components/attributes/editMode/SimpleAttributeEditor/selectors/helpers/parents.js +3 -1
  14. package/cjs/components/attributes/readMode/AttributesPager/AttributesPager.js +1 -1
  15. package/cjs/components/attributes/readMode/ImageAttributesLine/ImageAttributesLine.d.ts +7 -2
  16. package/cjs/components/attributes/readMode/ImageAttributesLine/ImageAttributesLine.js +2 -2
  17. package/cjs/components/history/HistoryFilterButton/HistoryFilterButton.js +7 -1
  18. package/cjs/components/history/HistoryTree/HistoryTree.js +11 -1
  19. package/cjs/components/history/hooks/useHistory.d.ts +2 -2
  20. package/cjs/components/history/hooks/useHistory.js +20 -6
  21. package/cjs/components/history/hooks/useHistoryDiff.d.ts +2 -0
  22. package/cjs/components/history/hooks/useHistoryDiff.js +62 -0
  23. package/cjs/components/history/hooks/useHistoryWithTotal.d.ts +3 -2
  24. package/cjs/components/history/hooks/useHistoryWithTotal.js +6 -6
  25. package/cjs/components/history/index.d.ts +1 -0
  26. package/cjs/components/history/index.js +3 -1
  27. package/cjs/components/history/utils/filters.d.ts +3 -0
  28. package/cjs/components/history/utils/filters.js +67 -0
  29. package/cjs/components/index.d.ts +1 -0
  30. package/cjs/components/index.js +5 -3
  31. package/cjs/contexts/HistoryAppearanceContext/index.js +3 -1
  32. package/cjs/hooks/useMergeAllRequest.d.ts +2 -1
  33. package/cjs/hooks/useMergeAllRequest.js +6 -3
  34. package/esm/components/MergeButton/MergeButton.d.ts +1 -0
  35. package/esm/components/MergeButton/MergeButton.js +3 -2
  36. package/esm/components/SideIconPanel/SideButtonsPanel.d.ts +3 -3
  37. package/esm/components/SideIconPanel/SideButtonsPanel.js +3 -3
  38. package/esm/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.d.ts +3 -2
  39. package/esm/components/SidePanel/SidePanelContentHeader/SidePanelContentHeader.js +6 -5
  40. package/esm/components/attributes/AttributesView/index.js +1 -1
  41. package/esm/components/attributes/ImageAttributesLine/ImageAttributesLine.d.ts +7 -2
  42. package/esm/components/attributes/ImageAttributesLine/ImageAttributesLine.js +15 -1
  43. package/esm/components/attributes/editMode/AttributesPager/AttributesPager.js +1 -1
  44. package/esm/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.d.ts +8 -2
  45. package/esm/components/attributes/editMode/ImageAttributesLine/ImageAttributesLine.js +6 -6
  46. package/esm/components/attributes/editMode/SimpleAttributeEditor/selectors/helpers/parents.js +3 -1
  47. package/esm/components/attributes/readMode/AttributesPager/AttributesPager.js +1 -1
  48. package/esm/components/attributes/readMode/ImageAttributesLine/ImageAttributesLine.d.ts +7 -2
  49. package/esm/components/attributes/readMode/ImageAttributesLine/ImageAttributesLine.js +2 -2
  50. package/esm/components/history/HistoryFilterButton/HistoryFilterButton.js +8 -2
  51. package/esm/components/history/HistoryTree/HistoryTree.js +12 -2
  52. package/esm/components/history/hooks/useHistory.d.ts +2 -2
  53. package/esm/components/history/hooks/useHistory.js +20 -6
  54. package/esm/components/history/hooks/useHistoryDiff.d.ts +2 -0
  55. package/esm/components/history/hooks/useHistoryDiff.js +39 -0
  56. package/esm/components/history/hooks/useHistoryWithTotal.d.ts +3 -2
  57. package/esm/components/history/hooks/useHistoryWithTotal.js +6 -6
  58. package/esm/components/history/index.d.ts +1 -0
  59. package/esm/components/history/index.js +1 -0
  60. package/esm/components/history/utils/filters.d.ts +3 -0
  61. package/esm/components/history/utils/filters.js +60 -0
  62. package/esm/components/index.d.ts +1 -0
  63. package/esm/components/index.js +1 -0
  64. package/esm/contexts/HistoryAppearanceContext/index.js +3 -1
  65. package/esm/hooks/useMergeAllRequest.d.ts +2 -1
  66. package/esm/hooks/useMergeAllRequest.js +6 -3
  67. package/package.json +3 -3
@@ -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
+ };
@@ -7,11 +7,12 @@ declare type Props = {
7
7
  max?: number;
8
8
  offset?: number;
9
9
  order?: string;
10
- filter?: any;
10
+ filter?: string;
11
11
  };
12
- export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, ...options }: Props) => {
12
+ export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, filter, ...options }: Props) => {
13
13
  isLoading: boolean;
14
14
  historyWithTotal: HistoryWithTotal;
15
15
  loadMore: (offset: number) => void;
16
+ loadData: () => void;
16
17
  };
17
18
  export {};
@@ -29,7 +29,7 @@ import { useCallback, useEffect, useState } from 'react';
29
29
  import { getHistoryWithTotal } from '@reltio/mdm-sdk';
30
30
  import { useSafePromise } from '../../../hooks';
31
31
  export var useHistoryWithTotal = function (_a) {
32
- var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b, historicUris = _a.historicUris, options = __rest(_a, ["entityUri", "enabled", "historicUris"]);
32
+ var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b, historicUris = _a.historicUris, filter = _a.filter, options = __rest(_a, ["entityUri", "enabled", "historicUris", "filter"]);
33
33
  var _c = useState(null), historyWithTotal = _c[0], setHistoryWithTotal = _c[1];
34
34
  var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
35
35
  var safePromise = useSafePromise();
@@ -40,7 +40,7 @@ export var useHistoryWithTotal = function (_a) {
40
40
  var loadData = useCallback(function () {
41
41
  if (entityUri && historicUris) {
42
42
  setIsLoading(true);
43
- safePromise(getHistoryWithTotal(__assign({ entityUri: entityUri, historicUris: historicUris }, options)))
43
+ safePromise(getHistoryWithTotal(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options)))
44
44
  .then(function (results) {
45
45
  setHistoryWithTotal(results);
46
46
  })
@@ -52,11 +52,11 @@ export var useHistoryWithTotal = function (_a) {
52
52
  else {
53
53
  setHistoryWithTotal(null);
54
54
  }
55
- }, [entityUri, historicUris]);
55
+ }, [entityUri, historicUris, filter]);
56
56
  var loadMore = useCallback(function (offset) {
57
57
  if (entityUri && historicUris) {
58
58
  setIsLoading(true);
59
- safePromise(getHistoryWithTotal(__assign(__assign({ entityUri: entityUri, historicUris: historicUris }, options), { offset: offset })))
59
+ safePromise(getHistoryWithTotal(__assign(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options), { offset: offset })))
60
60
  .then(function (results) {
61
61
  setHistoryWithTotal(function (prev) { return (__assign(__assign({}, prev), { changes: __spreadArray(__spreadArray([], prev === null || prev === void 0 ? void 0 : prev.changes), results.changes) })); });
62
62
  })
@@ -65,11 +65,11 @@ export var useHistoryWithTotal = function (_a) {
65
65
  setIsLoading(false);
66
66
  });
67
67
  }
68
- }, [entityUri, historicUris]);
68
+ }, [entityUri, historicUris, filter]);
69
69
  useEffect(function () {
70
70
  if (enabled) {
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';
@@ -0,0 +1,3 @@
1
+ import { DateRangeFilter } from '../../../types';
2
+ export declare const buildHistoryFilterString: any;
3
+ export declare const isDateRangeValid: (value: DateRangeFilter) => boolean;
@@ -0,0 +1,60 @@
1
+ import moment from 'moment';
2
+ import { type, pipe, defaultTo, reject, map, join, cond, equals, append, concat, chain, evolve, values, over, lensProp } from 'ramda';
3
+ import { isEmptyValue, escapeQueryValue } from '@reltio/mdm-sdk';
4
+ import { HistoryActivityType } from '../types/HistoryFilter';
5
+ import { ActivityTypes } from '../../activityLog/types/ActivityTypes';
6
+ import { DateRangeTypes } from '../../../types';
7
+ var wrapInBrackets = function (str) { return "(" + str + ")"; };
8
+ var multiValueFilter = function (filterClauseFn) { return pipe(map(filterClauseFn), join(' or ')); };
9
+ var durationToTimestamp = function (period) {
10
+ var amount = period[0], unit = period[1];
11
+ return moment().subtract(amount, unit).valueOf();
12
+ };
13
+ var convertHistoryTypes = chain(cond([
14
+ [
15
+ equals(HistoryActivityType.MERGE),
16
+ function () { return [
17
+ ActivityTypes.ENTITIES_MERGED,
18
+ ActivityTypes.ENTITIES_MERGED_MANUALLY,
19
+ ActivityTypes.ENTITIES_MERGED_ON_THE_FLY
20
+ ]; }
21
+ ],
22
+ [equals(HistoryActivityType.UNMERGE), function () { return [ActivityTypes.ENTITIES_SPLITTED]; }],
23
+ [equals(HistoryActivityType.UPDATE), function () { return [ActivityTypes.ENTITY_CHANGED]; }]
24
+ ]));
25
+ var buildActivityFilterClause = pipe(defaultTo([]), convertHistoryTypes, concat([ActivityTypes.ENTITY_CREATED, ActivityTypes.ENTITY_REMOVED, ActivityTypes.ENTITY_LOST_MERGE]), multiValueFilter(function (value) { return "equals(type, '" + value + "')"; }));
26
+ var buildUserFilterClause = function (user) { return "equals(user, '" + escapeQueryValue(user) + "')"; };
27
+ var buildAttributeFilterClause = function (attribute) { return "changes(" + escapeQueryValue(attribute.value) + ")"; };
28
+ var buildDateRangeFilterClause = function (_a) {
29
+ var type = _a.type, period = _a.period;
30
+ switch (type) {
31
+ case DateRangeTypes.WITHIN: {
32
+ return "gte(timestamp, " + durationToTimestamp(period) + ")";
33
+ }
34
+ case DateRangeTypes.AGO: {
35
+ return "lte(timestamp, " + durationToTimestamp(period) + ")";
36
+ }
37
+ case DateRangeTypes.BETWEEN: {
38
+ var start = period[0], end = period[1];
39
+ return "gte(timestamp, " + start.valueOf() + ") and lte(timestamp, " + moment(end).endOf('date').valueOf() + ")";
40
+ }
41
+ default: {
42
+ return '';
43
+ }
44
+ }
45
+ };
46
+ export var buildHistoryFilterString = pipe(defaultTo({}), reject(isEmptyValue), evolve({
47
+ users: multiValueFilter(buildUserFilterClause),
48
+ attributes: multiValueFilter(buildAttributeFilterClause),
49
+ dateRange: buildDateRangeFilterClause
50
+ }), over(lensProp('activities'), buildActivityFilterClause), values, reject(isEmptyValue), append("not equals(user, 'collaboration-service')"), map(wrapInBrackets), join(' and '));
51
+ export var isDateRangeValid = function (value) {
52
+ if (value.type === DateRangeTypes.AGO || value.type === DateRangeTypes.WITHIN) {
53
+ var _a = value.period, amount = _a[0], unit = _a[1];
54
+ return type(amount) === 'Number' && type(unit) === 'String' && amount > 0;
55
+ }
56
+ else if (value.type === DateRangeTypes.BETWEEN) {
57
+ var _b = value.period, startDate = _b[0], endDate = _b[1];
58
+ return startDate instanceof Date && endDate instanceof Date;
59
+ }
60
+ };
@@ -17,6 +17,7 @@ export { default as EditableAttribute } from './attributes/editMode/AttributesFa
17
17
  export { default as ReadOnlyAttributeValuesBlock } from './attributes/readMode/AttributeValuesBlock/AttributeValuesBlock';
18
18
  export { default as ReadOnlyAttributesList } from './attributes/readMode/AttributesList';
19
19
  export { default as ImageAttributesLine } from './attributes/readMode/ImageAttributesLine';
20
+ export { default as EditableImageAttributesLine } from './attributes/editMode/ImageAttributesLine';
20
21
  export { default as NestedAttribute } from './attributes/readMode/NestedAttribute';
21
22
  export { default as ReferenceAttribute } from './attributes/readMode/ReferenceAttribute';
22
23
  export { default as SimpleAttribute } from './attributes/readMode/SimpleAttribute';
@@ -16,6 +16,7 @@ export { default as EditableAttribute } from './attributes/editMode/AttributesFa
16
16
  export { default as ReadOnlyAttributeValuesBlock } from './attributes/readMode/AttributeValuesBlock/AttributeValuesBlock';
17
17
  export { default as ReadOnlyAttributesList } from './attributes/readMode/AttributesList';
18
18
  export { default as ImageAttributesLine } from './attributes/readMode/ImageAttributesLine';
19
+ export { default as EditableImageAttributesLine } from './attributes/editMode/ImageAttributesLine';
19
20
  export { default as NestedAttribute } from './attributes/readMode/NestedAttribute';
20
21
  export { default as ReferenceAttribute } from './attributes/readMode/ReferenceAttribute';
21
22
  export { default as SimpleAttribute } from './attributes/readMode/SimpleAttribute';
@@ -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';
@@ -4,8 +4,9 @@ declare type Props = {
4
4
  entity: Entity;
5
5
  onFinishRequest?: () => void;
6
6
  onStartRequest?: () => void;
7
+ onError?: () => void;
7
8
  };
8
- export declare const useMergeAllRequest: ({ entities, entity, onFinishRequest, onStartRequest }: Props) => {
9
+ export declare const useMergeAllRequest: ({ entities, entity, onFinishRequest, onStartRequest, onError }: Props) => {
9
10
  isPending: boolean;
10
11
  sendMergeAllRequest: () => void;
11
12
  };
@@ -2,18 +2,21 @@ import { useCallback, useState } from 'react';
2
2
  import { useSelector } from 'react-redux';
3
3
  import mdmModule from '@reltio/mdm-module';
4
4
  import { isDataTenantEntity, mergeCustomerTenantEntityWithMixedEntities, mergeDataTenantEntity } from '@reltio/mdm-sdk';
5
+ import { noop } from '../core';
5
6
  export var useMergeAllRequest = function (_a) {
6
- var entities = _a.entities, entity = _a.entity, onFinishRequest = _a.onFinishRequest, onStartRequest = _a.onStartRequest;
7
+ var entities = _a.entities, entity = _a.entity, onFinishRequest = _a.onFinishRequest, onStartRequest = _a.onStartRequest, _b = _a.onError, onError = _b === void 0 ? noop : _b;
7
8
  var tenant = useSelector(mdmModule.selectors.getTenant);
8
9
  var dtssPath = useSelector(mdmModule.selectors.getDtssPath);
9
- var _b = useState(false), isPending = _b[0], setIsPending = _b[1];
10
+ var _c = useState(false), isPending = _c[0], setIsPending = _c[1];
10
11
  var sendMergeAllRequest = useCallback(function () {
11
12
  onStartRequest === null || onStartRequest === void 0 ? void 0 : onStartRequest();
12
13
  setIsPending(true);
13
14
  var params = { dtssPath: dtssPath, customerTenant: tenant, entity: entity, entities: entities };
14
15
  (isDataTenantEntity(entity)
15
16
  ? mergeDataTenantEntity(params)
16
- : mergeCustomerTenantEntityWithMixedEntities(params)).finally(function () {
17
+ : mergeCustomerTenantEntityWithMixedEntities(params))
18
+ .catch(onError)
19
+ .finally(function () {
17
20
  onFinishRequest === null || onFinishRequest === void 0 ? void 0 : onFinishRequest();
18
21
  setIsPending(false);
19
22
  });
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.913",
3
+ "version": "1.4.917",
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.913",
11
- "@reltio/mdm-sdk": "^1.4.913",
10
+ "@reltio/mdm-module": "^1.4.917",
11
+ "@reltio/mdm-sdk": "^1.4.917",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",