@reltio/sources 1.4.1585 → 1.4.1586-mui5
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/index.ts +1 -0
- package/package.json +38 -21
- package/public/bundle.js +205 -0
- package/public/bundle.js.LICENSE.txt +79 -0
- package/public/package.json +22 -0
- package/scripts/build/index.js +20 -0
- package/src/components/CrosswalkTreeView/CrosswalkTreeView.tsx +47 -0
- package/src/components/CrosswalkTreeView/__tests__/CrosswalkTreeView.spec.tsx +72 -0
- package/src/components/CrosswalkTreeView/__tests__/helpers.spec.ts +961 -0
- package/src/components/CrosswalkTreeView/helpers.ts +91 -0
- package/src/components/CrosswalkTreeView/styles.ts +10 -0
- package/src/components/EmptyState/EmptyState.tsx +20 -0
- package/src/components/EmptyState/__tests__/EmptyState.test.tsx +13 -0
- package/src/components/EmptyState/icons/EmptySources.svg +43 -0
- package/src/components/EmptyState/styles.ts +19 -0
- package/src/components/LegendTable/LegendTable.tsx +124 -0
- package/src/components/LegendTable/LegendTableRow/ContributorRow/ContributorRow.tsx +46 -0
- package/src/components/LegendTable/LegendTableRow/ContributorRow/__tests__/ContributorRow.test.tsx +103 -0
- package/src/components/LegendTable/LegendTableRow/ContributorRow/styles.ts +31 -0
- package/src/components/LegendTable/LegendTableRow/LegendTableRow.tsx +179 -0
- package/src/components/LegendTable/LegendTableRow/__tests__/LegendTableRow.test.tsx +371 -0
- package/src/components/LegendTable/LegendTableRow/styles.ts +31 -0
- package/src/components/LegendTable/__tests__/LegendTable.test.tsx +273 -0
- package/src/components/LegendTable/__tests__/helpers.test.ts +541 -0
- package/src/components/LegendTable/helpers.ts +64 -0
- package/src/components/LegendTable/styles.ts +17 -0
- package/src/components/LegendView/LegendView.tsx +201 -0
- package/src/components/LegendView/__tests__/LegendView.test.tsx +307 -0
- package/src/components/LegendView/styles.ts +51 -0
- package/src/components/RightSidePanel/RightSidePanel.tsx +25 -0
- package/src/components/RightSidePanel/__tests__/RightSidePanel.test.tsx +28 -0
- package/src/components/RightSidePanel/styles.ts +14 -0
- package/src/components/RulesestsSelector/RulesestsSelector.tsx +31 -0
- package/src/components/RulesestsSelector/RulesetOption/RulesetOption.tsx +25 -0
- package/src/components/RulesestsSelector/RulesetOption/__tests__/RulesetOption.test.tsx +25 -0
- package/src/components/RulesestsSelector/RulesetOption/styles.ts +27 -0
- package/src/components/RulesestsSelector/RulesetsMenuList/RulesetsMenuList.tsx +14 -0
- package/src/components/RulesestsSelector/__tests__/RulesetsSelector.test.tsx +91 -0
- package/src/components/RulesestsSelector/styles.ts +7 -0
- package/src/components/SankeyChart/Link.tsx +31 -0
- package/src/components/SankeyChart/MergeTooltip.tsx +37 -0
- package/src/components/SankeyChart/Node.tsx +137 -0
- package/src/components/SankeyChart/SankeyChart.tsx +103 -0
- package/src/components/SankeyChart/__tests__/Link.spec.tsx +127 -0
- package/src/components/SankeyChart/__tests__/MergeTooltip.spec.tsx +22 -0
- package/src/components/SankeyChart/__tests__/Node.spec.tsx +248 -0
- package/src/components/SankeyChart/__tests__/SankeyChart.spec.tsx +161 -0
- package/src/components/SankeyChart/__tests__/__snapshots__/SankeyChart.spec.tsx.snap +183 -0
- package/src/components/SankeyChart/sankey.ts +322 -0
- package/src/components/SankeyChart/styles.ts +41 -0
- package/src/components/SankeyChart/useSankey.tsx +44 -0
- package/src/components/SelectableTree/SelectableTree.tsx +46 -0
- package/src/components/SelectableTree/__tests__/SelectableTree.test.tsx +28 -0
- package/src/components/SelectableTree/__tests__/__snapshots__/SelectableTree.test.tsx.snap +59 -0
- package/src/components/SelectableTree/styles.ts +42 -0
- package/src/components/SourcesView/SourcesView.tsx +318 -0
- package/src/components/SourcesView/__tests__/IntegrationSourcesView.spec.tsx +199 -0
- package/src/components/SourcesView/__tests__/SourcesView.spec.tsx +903 -0
- package/src/components/SourcesView/__tests__/data/metadata.data.ts +27 -0
- package/src/components/SourcesView/__tests__/data/store.data.ts +65 -0
- package/src/components/SourcesView/icons/LegendIcon.svg +8 -0
- package/src/components/SourcesView/index.tsx +57 -0
- package/src/components/SourcesView/styles.ts +44 -0
- package/src/components/TreeActionSnackbar/TreeActionSnackbar.tsx +38 -0
- package/src/components/TreeActionSnackbar/__tests__/TreeActionSnackbar.test.tsx +38 -0
- package/src/components/TreeActionSnackbar/styles.ts +11 -0
- package/src/components/UnmergeDialog/UnmergeDialog.tsx +78 -0
- package/src/components/UnmergeDialog/__tests__/UnmergeDialog.test.tsx +124 -0
- package/src/components/UnmergeDialog/__tests__/testData.data.ts +271 -0
- package/src/components/UnmergeDialog/styles.ts +34 -0
- package/src/components/UnsubscribeDialog/UnsubscribeDialog.tsx +64 -0
- package/src/components/UnsubscribeDialog/__tests__/UnsubscribeDialog.test.tsx +59 -0
- package/src/components/UnsubscribeDialog/styles.ts +31 -0
- package/src/hooks/__tests__/useCrosswalkTree.specs.tsx +68 -0
- package/src/hooks/__tests__/useCrosswalkTreeActions.specs.ts +110 -0
- package/src/hooks/__tests__/useCrosswalksDisplay.specs.tsx +213 -0
- package/src/hooks/__tests__/useEntityWithSurvivorshipGroups.specs.ts +160 -0
- package/src/hooks/useCrosswalkTree.ts +38 -0
- package/src/hooks/useCrosswalkTreeActions.ts +83 -0
- package/src/hooks/useCrosswalksDisplay.ts +110 -0
- package/src/hooks/useEntityWithSurvivorshipGroups.tsx +51 -0
- package/src/icons/notMatch.svg +14 -0
- package/src/index.ts +1 -0
- package/src/services/errors.ts +11 -0
- package/src/types/LegendMode.ts +5 -0
- package/src/types/SankeyChartData.ts +31 -0
- package/src/types/SourcesSavedState.ts +3 -0
- package/src/types/UnmergeContributorEvent.ts +7 -0
- package/src/types/UnsubscribeContributorEvent.ts +6 -0
- package/src/types/index.ts +4 -0
- package/tsconfig.json +4 -0
- package/webpack.config.js +10 -0
- package/bundle.js +0 -2
- package/bundle.js.LICENSE.txt +0 -42
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React, {useEffect, useRef, useState} from 'react';
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
3
|
+
import {useSelector} from 'react-redux';
|
|
4
|
+
import {
|
|
5
|
+
CrosswalkEditor,
|
|
6
|
+
SourceCrosswalksRow,
|
|
7
|
+
CrosswalksByTypes,
|
|
8
|
+
CrosswalkType,
|
|
9
|
+
useCrosswalkFocus,
|
|
10
|
+
useHighlightedCrosswalks
|
|
11
|
+
} from '@reltio/components';
|
|
12
|
+
import mdm from '@reltio/mdm-module';
|
|
13
|
+
import {
|
|
14
|
+
Crosswalk,
|
|
15
|
+
DataTenant,
|
|
16
|
+
eqCrosswalks,
|
|
17
|
+
getContributorColor,
|
|
18
|
+
getDataTenantFromCrosswalks,
|
|
19
|
+
RelationCrosswalk
|
|
20
|
+
} from '@reltio/mdm-sdk';
|
|
21
|
+
import classnames from 'classnames';
|
|
22
|
+
import {chain, find, flatten, head, pipe, pluck, propOr, props, values} from 'ramda';
|
|
23
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
24
|
+
import UnmergeIcon from '../../../icons/notMatch.svg';
|
|
25
|
+
import UnsubscribeIcon from '@mui/icons-material/Delete';
|
|
26
|
+
import ContributorRow from './ContributorRow/ContributorRow';
|
|
27
|
+
|
|
28
|
+
import {useStyles} from './styles';
|
|
29
|
+
|
|
30
|
+
type Props = {
|
|
31
|
+
className?: string;
|
|
32
|
+
contributorUri: string;
|
|
33
|
+
accentContributor?: boolean;
|
|
34
|
+
crosswalksBySources: {
|
|
35
|
+
source: string;
|
|
36
|
+
crosswalksByTypes: CrosswalksByTypes;
|
|
37
|
+
}[];
|
|
38
|
+
canUnmerge: boolean;
|
|
39
|
+
disableAddCrosswalk: boolean;
|
|
40
|
+
disableEditCrosswalk: boolean;
|
|
41
|
+
disableDeleteCrosswalk: boolean;
|
|
42
|
+
disableUnmergeContributor: boolean;
|
|
43
|
+
onAdd: (event: {contributorCrosswalk: Crosswalk; crosswalk: Omit<Crosswalk, 'uri'>}) => void;
|
|
44
|
+
onDelete: (crosswalkId: string) => void;
|
|
45
|
+
onEdit: (event: {crosswalkId: string; attributeName: string; value?: string}) => void;
|
|
46
|
+
onUnmerge: () => void;
|
|
47
|
+
expandedSources?: string[];
|
|
48
|
+
onToggleSourceExpanded: (sourceUri: string) => void;
|
|
49
|
+
onUnsubscribeContributor: (event: {contributorUri: string; dataTenant: DataTenant; crosswalk: Crosswalk}) => void;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const LegendTableRow = ({
|
|
53
|
+
className,
|
|
54
|
+
contributorUri,
|
|
55
|
+
accentContributor,
|
|
56
|
+
crosswalksBySources,
|
|
57
|
+
expandedSources,
|
|
58
|
+
canUnmerge,
|
|
59
|
+
disableAddCrosswalk,
|
|
60
|
+
disableEditCrosswalk,
|
|
61
|
+
disableDeleteCrosswalk,
|
|
62
|
+
disableUnmergeContributor,
|
|
63
|
+
onUnmerge,
|
|
64
|
+
onEdit,
|
|
65
|
+
onDelete,
|
|
66
|
+
onAdd,
|
|
67
|
+
onToggleSourceExpanded,
|
|
68
|
+
onUnsubscribeContributor
|
|
69
|
+
}: Props) => {
|
|
70
|
+
const contributorColor = accentContributor ? getContributorColor(contributorUri) : 'rgba(0, 0, 0, 0.38)';
|
|
71
|
+
const styles = useStyles({contributorColor});
|
|
72
|
+
const dataTenants = useSelector(mdm.selectors.getDataTenants);
|
|
73
|
+
|
|
74
|
+
const ref = useRef(null);
|
|
75
|
+
const [scrollToCrosswalk] = useHighlightedCrosswalks();
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (accentContributor && scrollToCrosswalk) {
|
|
78
|
+
const crosswalks = pipe(
|
|
79
|
+
find(({source}) => source === scrollToCrosswalk.type),
|
|
80
|
+
propOr({}, 'crosswalksByTypes'),
|
|
81
|
+
values,
|
|
82
|
+
flatten
|
|
83
|
+
)(crosswalksBySources);
|
|
84
|
+
if (
|
|
85
|
+
crosswalks.some(
|
|
86
|
+
(crosswalk) => eqCrosswalks(scrollToCrosswalk, crosswalk) && crosswalk !== scrollToCrosswalk
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
ref?.current?.scrollIntoView({behavior: 'smooth'});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [scrollToCrosswalk]);
|
|
93
|
+
|
|
94
|
+
const [showEditor, setShowEditor] = useState(false);
|
|
95
|
+
|
|
96
|
+
const contributorCrosswalk: Crosswalk = pipe(
|
|
97
|
+
pluck('crosswalksByTypes'),
|
|
98
|
+
find((crosswalks) => crosswalks[CrosswalkType.Simple].length || crosswalks[CrosswalkType.Empty].length),
|
|
99
|
+
props([CrosswalkType.Simple, CrosswalkType.Empty]),
|
|
100
|
+
flatten,
|
|
101
|
+
head
|
|
102
|
+
)(crosswalksBySources);
|
|
103
|
+
const {toggleCrosswalkFocus, isFocused} = useCrosswalkFocus(contributorCrosswalk);
|
|
104
|
+
|
|
105
|
+
const allContributorCrosswalks: (Crosswalk | RelationCrosswalk)[] = pipe(
|
|
106
|
+
pluck('crosswalksByTypes'),
|
|
107
|
+
chain(values),
|
|
108
|
+
flatten
|
|
109
|
+
)(crosswalksBySources);
|
|
110
|
+
|
|
111
|
+
const dataTenantForExternalCrosswalk = getDataTenantFromCrosswalks(allContributorCrosswalks, dataTenants);
|
|
112
|
+
|
|
113
|
+
const unsubscribeContributor = () =>
|
|
114
|
+
onUnsubscribeContributor({
|
|
115
|
+
contributorUri,
|
|
116
|
+
dataTenant: dataTenantForExternalCrosswalk,
|
|
117
|
+
crosswalk: contributorCrosswalk
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const contributorActions = [
|
|
121
|
+
{
|
|
122
|
+
icon: AddIcon,
|
|
123
|
+
tooltipTitle: i18n.text('Add crosswalk'),
|
|
124
|
+
onClick: () => setShowEditor(true),
|
|
125
|
+
disabled: disableAddCrosswalk,
|
|
126
|
+
show: !!contributorCrosswalk
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
icon: UnmergeIcon,
|
|
130
|
+
tooltipTitle: i18n.text('Unmerge'),
|
|
131
|
+
onClick: () => onUnmerge(),
|
|
132
|
+
disabled: disableUnmergeContributor,
|
|
133
|
+
show: canUnmerge
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
icon: UnsubscribeIcon,
|
|
137
|
+
tooltipTitle: i18n.text('Unsubscribe'),
|
|
138
|
+
onClick: () => unsubscribeContributor(),
|
|
139
|
+
disabled: disableUnmergeContributor,
|
|
140
|
+
show: canUnmerge && !!dataTenantForExternalCrosswalk
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div ref={ref} className={classnames(styles.root, className)}>
|
|
146
|
+
<ContributorRow
|
|
147
|
+
contributorUri={contributorUri}
|
|
148
|
+
focusable={accentContributor && !!contributorCrosswalk}
|
|
149
|
+
isFocused={accentContributor && isFocused}
|
|
150
|
+
onToggleFocus={toggleCrosswalkFocus}
|
|
151
|
+
contributorActions={contributorActions}
|
|
152
|
+
/>
|
|
153
|
+
{crosswalksBySources.map(({source, crosswalksByTypes}) => (
|
|
154
|
+
<SourceCrosswalksRow
|
|
155
|
+
key={source}
|
|
156
|
+
source={source}
|
|
157
|
+
crosswalksByTypes={crosswalksByTypes}
|
|
158
|
+
showCrosswalkColors={!accentContributor}
|
|
159
|
+
crosswalksFocusEnabled={!accentContributor}
|
|
160
|
+
expanded={expandedSources?.includes(source)}
|
|
161
|
+
disableEditCrosswalk={disableEditCrosswalk}
|
|
162
|
+
disableDeleteCrosswalk={disableDeleteCrosswalk}
|
|
163
|
+
onEdit={onEdit}
|
|
164
|
+
onDelete={onDelete}
|
|
165
|
+
onToggleExpanded={() => onToggleSourceExpanded(source)}
|
|
166
|
+
/>
|
|
167
|
+
))}
|
|
168
|
+
{showEditor && (
|
|
169
|
+
<CrosswalkEditor
|
|
170
|
+
className={styles.editor}
|
|
171
|
+
onAdd={(crosswalk) => onAdd({contributorCrosswalk, crosswalk})}
|
|
172
|
+
onClose={() => setShowEditor(false)}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default LegendTableRow;
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as reactRedux from 'react-redux';
|
|
3
|
+
import mdmModule from '@reltio/mdm-module';
|
|
4
|
+
import {mount, shallow} from 'enzyme';
|
|
5
|
+
import {act} from 'react-dom/test-utils';
|
|
6
|
+
import * as reltioComponents from '@reltio/components';
|
|
7
|
+
import {CrosswalkEditor, SourceCrosswalksRow} from '@reltio/components';
|
|
8
|
+
|
|
9
|
+
import LegendTableRow from '../LegendTableRow';
|
|
10
|
+
import ContributorRow from '../ContributorRow/ContributorRow';
|
|
11
|
+
|
|
12
|
+
jest.mock('@reltio/components', () => ({
|
|
13
|
+
...jest.requireActual<Record<string, unknown>>('@reltio/components'),
|
|
14
|
+
useHighlightedCrosswalks: jest.fn(),
|
|
15
|
+
useCrosswalkFocus: jest.fn(),
|
|
16
|
+
SourceCrosswalksRow: () => null
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe('LegendTableRow tests', () => {
|
|
20
|
+
const props = {
|
|
21
|
+
contributorUri: 'entities/2',
|
|
22
|
+
canUnmerge: true,
|
|
23
|
+
crosswalksBySources: [
|
|
24
|
+
{
|
|
25
|
+
source: 'configuration/sources/Reltio',
|
|
26
|
+
crosswalksByTypes: {
|
|
27
|
+
empty: [],
|
|
28
|
+
simple: [
|
|
29
|
+
{
|
|
30
|
+
uri: 'entities/2/crosswalks/1',
|
|
31
|
+
value: '123',
|
|
32
|
+
type: 'configuration/sources/Reltio'
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
dependent: []
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
source: 'configuration/sources/FB',
|
|
40
|
+
crosswalksByTypes: {
|
|
41
|
+
empty: [],
|
|
42
|
+
simple: [],
|
|
43
|
+
dependent: [
|
|
44
|
+
{
|
|
45
|
+
uri: 'entities/2/crosswalks/1',
|
|
46
|
+
value: '456',
|
|
47
|
+
type: 'configuration/sources/FB'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
accentContributor: false,
|
|
54
|
+
expandedSources: ['configuration/sources/Reltio'],
|
|
55
|
+
disableAddCrosswalk: false,
|
|
56
|
+
disableEditCrosswalk: false,
|
|
57
|
+
disableDeleteCrosswalk: false,
|
|
58
|
+
onUnmerge: jest.fn(),
|
|
59
|
+
onAdd: jest.fn(),
|
|
60
|
+
onEdit: jest.fn(),
|
|
61
|
+
onDelete: jest.fn(),
|
|
62
|
+
onToggleSourceExpanded: jest.fn(),
|
|
63
|
+
onUnsubscribeContributor: jest.fn(),
|
|
64
|
+
disableUnmergeContributor: false
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const toggleCrosswalkFocus = jest.fn();
|
|
68
|
+
const useHighlightedCrosswalksMock = jest.spyOn(reltioComponents, 'useHighlightedCrosswalks').mockReturnValue([]);
|
|
69
|
+
|
|
70
|
+
beforeAll(() => {
|
|
71
|
+
jest.spyOn(reactRedux, 'useSelector').mockImplementation((selector) => selector({}));
|
|
72
|
+
jest.spyOn(mdmModule.selectors, 'getDataTenants').mockReturnValue([
|
|
73
|
+
{id: 'uitest3', label: 'DT:TEST', name: 'DT_TEST', availableEntityTypes: null},
|
|
74
|
+
{id: 'hmcyo4cu', label: 'DT:hmcyo4cu', name: 'DT_hmcyo4cu', availableEntityTypes: null}
|
|
75
|
+
]);
|
|
76
|
+
jest.spyOn(reltioComponents, 'useCrosswalkFocus').mockReturnValue({
|
|
77
|
+
isFocused: false,
|
|
78
|
+
toggleCrosswalkFocus
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should render correctly', () => {
|
|
83
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
84
|
+
const contributorRow = wrapper.find(ContributorRow);
|
|
85
|
+
expect(contributorRow.props()).toMatchObject({
|
|
86
|
+
contributorUri: props.contributorUri,
|
|
87
|
+
onToggleFocus: toggleCrosswalkFocus,
|
|
88
|
+
focusable: false,
|
|
89
|
+
isFocused: false,
|
|
90
|
+
contributorActions: [
|
|
91
|
+
{
|
|
92
|
+
tooltipTitle: 'Add crosswalk',
|
|
93
|
+
disabled: props.disableAddCrosswalk,
|
|
94
|
+
show: true
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
tooltipTitle: 'Unmerge',
|
|
98
|
+
disabled: props.disableUnmergeContributor,
|
|
99
|
+
show: props.canUnmerge
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
tooltipTitle: 'Unsubscribe',
|
|
103
|
+
disabled: props.disableUnmergeContributor,
|
|
104
|
+
show: false
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
const sourceRows = wrapper.find(SourceCrosswalksRow);
|
|
109
|
+
expect(sourceRows.length).toBe(2);
|
|
110
|
+
sourceRows.forEach((sourceRow, index) => {
|
|
111
|
+
const source = props.crosswalksBySources[index].source;
|
|
112
|
+
expect(sourceRow.props()).toMatchObject({
|
|
113
|
+
source,
|
|
114
|
+
showCrosswalkColors: true,
|
|
115
|
+
crosswalksByTypes: props.crosswalksBySources[index].crosswalksByTypes,
|
|
116
|
+
disableDeleteCrosswalk: props.disableDeleteCrosswalk,
|
|
117
|
+
disableEditCrosswalk: props.disableEditCrosswalk,
|
|
118
|
+
onEdit: props.onEdit,
|
|
119
|
+
onDelete: props.onDelete,
|
|
120
|
+
expanded: props.expandedSources.includes(source),
|
|
121
|
+
crosswalksFocusEnabled: true
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should call props.onToggleSourceExpanded on source toggle', () => {
|
|
127
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
128
|
+
wrapper.find(SourceCrosswalksRow).at(1).prop('onToggleExpanded')();
|
|
129
|
+
expect(props.onToggleSourceExpanded).toBeCalledWith('configuration/sources/FB');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should disable editing in SourceRow if props.disableEditCrosswalk = true', () => {
|
|
133
|
+
const wrapper = shallow(<LegendTableRow {...props} disableEditCrosswalk={true} />);
|
|
134
|
+
wrapper.find(SourceCrosswalksRow).forEach((sourceRow) => {
|
|
135
|
+
expect(sourceRow.prop('disableEditCrosswalk')).toBeTruthy();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should disable deleting in SourceRow if props.disableDeleteCrosswalk = true', () => {
|
|
140
|
+
const wrapper = shallow(<LegendTableRow {...props} disableDeleteCrosswalk={true} />);
|
|
141
|
+
wrapper.find(SourceCrosswalksRow).forEach((sourceRow) => {
|
|
142
|
+
expect(sourceRow.prop('disableDeleteCrosswalk')).toBeTruthy();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should not show crosswalk colors if contributor is accented', () => {
|
|
147
|
+
const wrapper = shallow(<LegendTableRow {...props} accentContributor={true} />);
|
|
148
|
+
wrapper.find(SourceCrosswalksRow).forEach((row) => {
|
|
149
|
+
expect(row.prop('showCrosswalkColors')).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should scroll to LegendTableRow if accentContributors and crosswalk is highlighted ', () => {
|
|
154
|
+
const wrapper = mount(<LegendTableRow {...props} accentContributor className={'legendTableRow'} />);
|
|
155
|
+
const node = wrapper.find('.root.legendTableRow').getDOMNode();
|
|
156
|
+
node.scrollIntoView = jest.fn();
|
|
157
|
+
expect(node.scrollIntoView).not.toBeCalled();
|
|
158
|
+
useHighlightedCrosswalksMock.mockReturnValueOnce([
|
|
159
|
+
{
|
|
160
|
+
uri: 'entities/2/crosswalks/1',
|
|
161
|
+
value: '123',
|
|
162
|
+
type: 'configuration/sources/Reltio'
|
|
163
|
+
}
|
|
164
|
+
]);
|
|
165
|
+
wrapper.setProps({});
|
|
166
|
+
expect(node.scrollIntoView).toBeCalled();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('Add action tests', () => {
|
|
170
|
+
const getButton = (wrapper) => wrapper.find(ContributorRow).prop('contributorActions')[0];
|
|
171
|
+
|
|
172
|
+
it('should not show action when contributor has no simple or empty crosswalks', () => {
|
|
173
|
+
const crosswalksBySources = [
|
|
174
|
+
{
|
|
175
|
+
source: 'configuration/sources/Reltio',
|
|
176
|
+
crosswalksByTypes: {
|
|
177
|
+
empty: [],
|
|
178
|
+
simple: [],
|
|
179
|
+
dependent: []
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
source: 'configuration/sources/FB',
|
|
184
|
+
crosswalksByTypes: {
|
|
185
|
+
empty: [],
|
|
186
|
+
simple: [],
|
|
187
|
+
dependent: [
|
|
188
|
+
{
|
|
189
|
+
uri: 'entities/2/crosswalks/1',
|
|
190
|
+
value: '456',
|
|
191
|
+
type: 'configuration/sources/FB'
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
198
|
+
expect(getButton(wrapper).show).toBeTruthy();
|
|
199
|
+
wrapper.setProps({crosswalksBySources});
|
|
200
|
+
expect(getButton(wrapper).show).toBeFalsy();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should disable action if disableAddCrosswalk = true', () => {
|
|
204
|
+
const wrapper = shallow(<LegendTableRow {...props} disableAddCrosswalk={false} />);
|
|
205
|
+
expect(getButton(wrapper).disabled).toBeFalsy();
|
|
206
|
+
wrapper.setProps({disableAddCrosswalk: true});
|
|
207
|
+
expect(getButton(wrapper).disabled).toBeTruthy();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should render CrosswalkEditor on click action', () => {
|
|
211
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
212
|
+
expect(wrapper.find(CrosswalkEditor).length).toBe(0);
|
|
213
|
+
act(() => {
|
|
214
|
+
getButton(wrapper).onClick(null);
|
|
215
|
+
});
|
|
216
|
+
expect(wrapper.find(CrosswalkEditor).length).toBe(1);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should not render CrosswalkEditor on CrosswalkEditor "onClose" prop calling', () => {
|
|
220
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
221
|
+
act(() => {
|
|
222
|
+
getButton(wrapper).onClick(null);
|
|
223
|
+
});
|
|
224
|
+
act(() => {
|
|
225
|
+
wrapper.find(CrosswalkEditor).prop('onClose')();
|
|
226
|
+
});
|
|
227
|
+
expect(wrapper.find(CrosswalkEditor).length).toBe(0);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should call "onAdd" prop of CrosswalkEditor on click action', () => {
|
|
231
|
+
const newCrosswalk = {
|
|
232
|
+
type: 'someType',
|
|
233
|
+
value: 'test'
|
|
234
|
+
};
|
|
235
|
+
const contributorCrosswalk = {
|
|
236
|
+
uri: 'entities/2/crosswalks/1',
|
|
237
|
+
value: '123',
|
|
238
|
+
type: 'configuration/sources/Reltio'
|
|
239
|
+
};
|
|
240
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
241
|
+
act(() => {
|
|
242
|
+
getButton(wrapper).onClick(null);
|
|
243
|
+
});
|
|
244
|
+
wrapper.find(CrosswalkEditor).prop('onAdd')(newCrosswalk);
|
|
245
|
+
expect(props.onAdd).toHaveBeenCalledWith({
|
|
246
|
+
crosswalk: newCrosswalk,
|
|
247
|
+
contributorCrosswalk
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe('Unmerge action tests', () => {
|
|
253
|
+
const getButton = (wrapper) => wrapper.find(ContributorRow).prop('contributorActions')[1];
|
|
254
|
+
|
|
255
|
+
it('should not show action if canUnmerge is false', () => {
|
|
256
|
+
const wrapper = shallow(<LegendTableRow {...props} canUnmerge={true} />);
|
|
257
|
+
expect(getButton(wrapper).show).toBeTruthy();
|
|
258
|
+
wrapper.setProps({canUnmerge: false});
|
|
259
|
+
expect(getButton(wrapper).show).toBeFalsy();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should disable action if disableUnmergeContributor is true', () => {
|
|
263
|
+
const wrapper = shallow(<LegendTableRow {...props} disableUnmergeContributor={false} />);
|
|
264
|
+
expect(getButton(wrapper).disabled).toBeFalsy();
|
|
265
|
+
wrapper.setProps({disableUnmergeContributor: true});
|
|
266
|
+
expect(getButton(wrapper).disabled).toBeTruthy();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('should call onUnmerge on click', () => {
|
|
270
|
+
const wrapper = shallow(<LegendTableRow {...props} />);
|
|
271
|
+
expect(props.onUnmerge).toBeCalledTimes(0);
|
|
272
|
+
getButton(wrapper).onClick(null);
|
|
273
|
+
expect(props.onUnmerge).toBeCalledTimes(1);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe('Unsubscribe action tests', () => {
|
|
278
|
+
const getButton = (wrapper) => wrapper.find(ContributorRow).prop('contributorActions')[2];
|
|
279
|
+
const crosswalksBySources = [
|
|
280
|
+
{
|
|
281
|
+
source: 'configuration/sources/Reltio',
|
|
282
|
+
crosswalksByTypes: {
|
|
283
|
+
simple: [
|
|
284
|
+
{
|
|
285
|
+
ownerType: 'entity',
|
|
286
|
+
uri: 'entities/122cdcTF/crosswalks/2AHh0FKzN',
|
|
287
|
+
type: 'configuration/sources/Reltio',
|
|
288
|
+
value: '122cdcTF',
|
|
289
|
+
reltioLoadDate: '2021-09-01T18:08:02.220Z',
|
|
290
|
+
createDate: '2019-02-07T05:25:22.305Z',
|
|
291
|
+
updateDate: '2019-02-07T05:25:22.305Z',
|
|
292
|
+
attributes: [
|
|
293
|
+
'entities/122cdcTF/attributes/Address/1Gv0Y74N',
|
|
294
|
+
'entities/122cdcTF/attributes/Name/3l7yIw69b'
|
|
295
|
+
],
|
|
296
|
+
singleAttributeUpdateDates: {}
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
empty: [],
|
|
300
|
+
dependent: [
|
|
301
|
+
{
|
|
302
|
+
ownerType: 'relation',
|
|
303
|
+
uri: 'entities/122cdcTF/crosswalks/1Gv0Y74N.3l7yIqbAx',
|
|
304
|
+
type: 'configuration/sources/Reltio',
|
|
305
|
+
value: '1Gv0Y74N',
|
|
306
|
+
createDate: '2019-07-04T10:42:51.413Z',
|
|
307
|
+
updateDate: '2019-07-04T10:42:51.413Z',
|
|
308
|
+
attributeURIs: [
|
|
309
|
+
'entities/122cdcTF/attributes/Address/1Gv0Y74N',
|
|
310
|
+
'entities/122cdcTF/attributes/Address/1Gv0Y74N/AddressType/2Ytk6Tf220'
|
|
311
|
+
],
|
|
312
|
+
crosswalkExternalInfo: {
|
|
313
|
+
dtssInfo: {
|
|
314
|
+
tenantId: 'uitest3',
|
|
315
|
+
operationId: '9701e541-2df9-4015-8e8b-edf871bd80f6',
|
|
316
|
+
updatedBy: 'alexander.kirsanov',
|
|
317
|
+
updatedTime: 1630519681682,
|
|
318
|
+
status: 'MANUAL_MERGED'
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
it('should not show action if crosswalk from another dataTenant does not exist and canUnmerge is false', () => {
|
|
328
|
+
const wrapper = shallow(<LegendTableRow {...props} canUnmerge={false} />);
|
|
329
|
+
expect(getButton(wrapper).show).toBeFalsy();
|
|
330
|
+
wrapper.setProps({crosswalksBySources});
|
|
331
|
+
expect(getButton(wrapper).show).toBeFalsy();
|
|
332
|
+
wrapper.setProps({canUnmerge: true});
|
|
333
|
+
expect(getButton(wrapper).show).toBeTruthy();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('should disable action if disableUnmergeContributor is true', () => {
|
|
337
|
+
const wrapper = shallow(<LegendTableRow {...props} disableUnmergeContributor={false} />);
|
|
338
|
+
expect(getButton(wrapper).disabled).toBeFalsy();
|
|
339
|
+
wrapper.setProps({disableUnmergeContributor: true});
|
|
340
|
+
expect(getButton(wrapper).disabled).toBeTruthy();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('should call onUnsubscribe on click and call it with correct params', () => {
|
|
344
|
+
const wrapper = shallow(<LegendTableRow {...props} crosswalksBySources={crosswalksBySources} />);
|
|
345
|
+
getButton(wrapper).onClick(null);
|
|
346
|
+
expect(props.onUnsubscribeContributor).toHaveBeenCalledWith({
|
|
347
|
+
contributorUri: props.contributorUri,
|
|
348
|
+
crosswalk: {
|
|
349
|
+
attributes: [
|
|
350
|
+
'entities/122cdcTF/attributes/Address/1Gv0Y74N',
|
|
351
|
+
'entities/122cdcTF/attributes/Name/3l7yIw69b'
|
|
352
|
+
],
|
|
353
|
+
createDate: '2019-02-07T05:25:22.305Z',
|
|
354
|
+
ownerType: 'entity',
|
|
355
|
+
reltioLoadDate: '2021-09-01T18:08:02.220Z',
|
|
356
|
+
singleAttributeUpdateDates: {},
|
|
357
|
+
type: 'configuration/sources/Reltio',
|
|
358
|
+
updateDate: '2019-02-07T05:25:22.305Z',
|
|
359
|
+
uri: 'entities/122cdcTF/crosswalks/2AHh0FKzN',
|
|
360
|
+
value: '122cdcTF'
|
|
361
|
+
},
|
|
362
|
+
dataTenant: {
|
|
363
|
+
availableEntityTypes: null,
|
|
364
|
+
id: 'uitest3',
|
|
365
|
+
label: 'DT:TEST',
|
|
366
|
+
name: 'DT_TEST'
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {makeStyles} from '@mui/styles';
|
|
2
|
+
|
|
3
|
+
type StylesProps = {
|
|
4
|
+
contributorColor: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const useStyles = makeStyles(() => ({
|
|
8
|
+
root: ({contributorColor}: StylesProps) => ({
|
|
9
|
+
fontSize: '13px',
|
|
10
|
+
position: 'relative',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column',
|
|
13
|
+
alignItems: 'stretch',
|
|
14
|
+
border: '1px solid rgba(0, 0, 0, 0.05)',
|
|
15
|
+
paddingLeft: '8px',
|
|
16
|
+
'&:before': {
|
|
17
|
+
content: '" "',
|
|
18
|
+
borderLeft: `8px solid ${contributorColor}`,
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: -1,
|
|
21
|
+
left: 0,
|
|
22
|
+
bottom: -1
|
|
23
|
+
},
|
|
24
|
+
'& > div + div': {
|
|
25
|
+
marginTop: '1px'
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
editor: {
|
|
29
|
+
padding: '0px 30px 0px 25px'
|
|
30
|
+
}
|
|
31
|
+
}));
|