@reltio/components 1.4.1896 → 1.4.1897
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/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
- package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
- package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
- package/cjs/ModeSwitcherSelect/styles.d.ts +1 -1
- package/cjs/ModeSwitcherSelect/styles.js +18 -0
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +2 -1
- package/cjs/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
- package/cjs/features/history/HistoryRow/HistoryRow.js +3 -1
- package/cjs/features/history/HistoryTree/HistoryTree.js +2 -7
- package/cjs/features/history/HistoryTree/HistoryTree.specs.js +141 -223
- package/cjs/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
- package/cjs/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
- package/esm/ModeSwitcherSelect/styles.d.ts +1 -1
- package/esm/ModeSwitcherSelect/styles.js +18 -0
- package/esm/contexts/MdmModuleContext/context.d.ts +2 -0
- package/esm/contexts/MdmModuleContext/hooks.d.ts +2 -1
- package/esm/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
- package/esm/features/history/HistoryRow/HistoryRow.js +3 -1
- package/esm/features/history/HistoryTree/HistoryTree.js +2 -7
- package/esm/features/history/HistoryTree/HistoryTree.specs.js +141 -223
- package/esm/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
- package/esm/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
- package/package.json +2 -2
|
@@ -13,8 +13,9 @@ type ModeSwitcherSelectProps = {
|
|
|
13
13
|
buttonsGroup?: Button[];
|
|
14
14
|
value: string;
|
|
15
15
|
onChange?: (value: string) => void;
|
|
16
|
+
loading?: boolean;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
variant?: 'normal' | 'thin';
|
|
18
19
|
};
|
|
19
|
-
export declare const ModeSwitcherSelect: ({ optionsGroup, buttonsGroup, value, onChange, disabled, variant }: ModeSwitcherSelectProps) => JSX.Element;
|
|
20
|
+
export declare const ModeSwitcherSelect: ({ optionsGroup, buttonsGroup, value, onChange, loading, disabled, variant }: ModeSwitcherSelectProps) => JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -32,10 +32,11 @@ var MenuItem_1 = __importDefault(require("@mui/material/MenuItem"));
|
|
|
32
32
|
var Box_1 = __importDefault(require("@mui/material/Box"));
|
|
33
33
|
var Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
34
34
|
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
35
|
+
var CircularProgress_1 = __importDefault(require("@mui/material/CircularProgress"));
|
|
35
36
|
var styles_1 = require("./styles");
|
|
36
37
|
var isButton = function (value) { return 'onClick' in value; };
|
|
37
38
|
var ModeSwitcherSelect = function (_a) {
|
|
38
|
-
var _b = _a.optionsGroup, optionsGroup = _b === void 0 ? [] : _b, _c = _a.buttonsGroup, buttonsGroup = _c === void 0 ? [] : _c, value = _a.value, onChange = _a.onChange, _d = _a.
|
|
39
|
+
var _b = _a.optionsGroup, optionsGroup = _b === void 0 ? [] : _b, _c = _a.buttonsGroup, buttonsGroup = _c === void 0 ? [] : _c, value = _a.value, onChange = _a.onChange, _d = _a.loading, loading = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.variant, variant = _f === void 0 ? 'normal' : _f;
|
|
39
40
|
var styles = (0, styles_1.useStyles)();
|
|
40
41
|
var handleChange = function (e) {
|
|
41
42
|
var value = e.target.value;
|
|
@@ -66,14 +67,14 @@ var ModeSwitcherSelect = function (_a) {
|
|
|
66
67
|
react_1.default.createElement(Typography_1.default, { className: styles.menuItemDescription }, description)))));
|
|
67
68
|
});
|
|
68
69
|
};
|
|
69
|
-
return (react_1.default.createElement(Select_1.default, { classes: {
|
|
70
|
+
return (react_1.default.createElement(Select_1.default, { className: styles.select, classes: {
|
|
70
71
|
select: (0, classnames_1.default)(styles.root, styles[variant]),
|
|
71
72
|
icon: (0, classnames_1.default)(styles.arrowIcon, styles[variant]),
|
|
72
73
|
outlined: styles.outlined
|
|
73
74
|
}, value: value, onChange: handleChange, variant: "outlined", renderValue: function (value) {
|
|
74
75
|
var _a = optionsGroup.find((0, ramda_1.propEq)('value', value)) || {}, IconComponent = _a.icon, _b = _a.label, label = _b === void 0 ? value : _b;
|
|
75
76
|
return (react_1.default.createElement(Box_1.default, { className: styles.currentValue },
|
|
76
|
-
IconComponent && react_1.default.createElement(IconComponent, { className: styles.currentValueIcon }),
|
|
77
|
+
loading ? (react_1.default.createElement(CircularProgress_1.default, { size: "1em", "data-reltio-id": "mode-loading-spinner", className: styles.currentValueIcon })) : (IconComponent && react_1.default.createElement(IconComponent, { className: styles.currentValueIcon })),
|
|
77
78
|
react_1.default.createElement(Tooltip_1.default, { title: label },
|
|
78
79
|
react_1.default.createElement(Typography_1.default, { className: styles.currentValueText }, label))));
|
|
79
80
|
}, MenuProps: {
|
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
2
49
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
50
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
51
|
if (ar || !(i in from)) {
|
|
@@ -13,105 +60,201 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
60
|
};
|
|
14
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
62
|
var react_1 = __importDefault(require("react"));
|
|
16
|
-
var
|
|
17
|
-
var
|
|
63
|
+
var react_2 = require("@testing-library/react");
|
|
64
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
65
|
+
var Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
18
66
|
var Create_1 = __importDefault(require("@mui/icons-material/Create"));
|
|
19
67
|
var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
20
68
|
var Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
|
|
69
|
+
var test_utils_1 = require("../test-utils");
|
|
21
70
|
var ModeSwitcherSelect_1 = require("./ModeSwitcherSelect");
|
|
71
|
+
var optionsGroup = [
|
|
72
|
+
{
|
|
73
|
+
label: 'Editing label',
|
|
74
|
+
value: 'Editing',
|
|
75
|
+
description: 'Edit profile directly',
|
|
76
|
+
icon: Create_1.default
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: 'Suggesting label',
|
|
80
|
+
value: 'Suggesting',
|
|
81
|
+
description: 'Suggest changes and initiate a workflow review',
|
|
82
|
+
icon: Add_1.default
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Viewing label',
|
|
86
|
+
value: 'Viewing',
|
|
87
|
+
description: 'Read or print profile',
|
|
88
|
+
icon: Visibility_1.default
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
var buttonsGroup = [
|
|
92
|
+
{
|
|
93
|
+
label: 'Delete label',
|
|
94
|
+
value: 'Delete',
|
|
95
|
+
description: 'Permanently delete profile',
|
|
96
|
+
icon: Delete_1.default,
|
|
97
|
+
onClick: jest.fn()
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'Clone label',
|
|
101
|
+
value: 'Clone',
|
|
102
|
+
description: 'Clone profile',
|
|
103
|
+
icon: Create_1.default,
|
|
104
|
+
onClick: jest.fn()
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
var defaultProps = {
|
|
108
|
+
optionsGroup: optionsGroup,
|
|
109
|
+
buttonsGroup: buttonsGroup,
|
|
110
|
+
value: 'Viewing',
|
|
111
|
+
onChange: jest.fn()
|
|
112
|
+
};
|
|
113
|
+
var setUp = function (props) {
|
|
114
|
+
if (props === void 0) { props = {}; }
|
|
115
|
+
var user = user_event_1.default.setup();
|
|
116
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, __assign({}, defaultProps, props))));
|
|
117
|
+
};
|
|
22
118
|
describe('ModeSwitcherSelect tests', function () {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
label: 'Editing label',
|
|
27
|
-
value: 'Editing',
|
|
28
|
-
description: 'Edit profile directly',
|
|
29
|
-
icon: Create_1.default
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: 'Suggesting label',
|
|
33
|
-
value: 'Suggesting',
|
|
34
|
-
description: 'Suggest changes and initiate a workflow review',
|
|
35
|
-
icon: Create_1.default
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
label: 'Viewing label',
|
|
39
|
-
value: 'Viewing',
|
|
40
|
-
description: 'Read or print profile',
|
|
41
|
-
icon: Visibility_1.default
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
var buttonsGroup = [
|
|
45
|
-
{
|
|
46
|
-
label: 'Delete label',
|
|
47
|
-
value: 'Delete',
|
|
48
|
-
description: 'Permanently delete profile',
|
|
49
|
-
icon: Delete_1.default,
|
|
50
|
-
onClick: onClick
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
it('should render optionsGroups', function () {
|
|
54
|
-
var component = (0, enzyme_1.shallow)(react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { optionsGroup: optionsGroup, buttonsGroup: [], value: "Viewing" }));
|
|
55
|
-
var menuItems = component.find('.menuItem');
|
|
56
|
-
expect(menuItems.length).toBe(3);
|
|
57
|
-
menuItems.forEach(function (node, idx) {
|
|
58
|
-
expect(node.find(optionsGroup[idx].icon)).toHaveLength(1);
|
|
59
|
-
expect(node.find('.menuItemLabel').text()).toBe(optionsGroup[idx].label);
|
|
60
|
-
expect(node.find('.menuItemDescription').text()).toBe(optionsGroup[idx].description);
|
|
61
|
-
});
|
|
119
|
+
beforeEach(function () {
|
|
120
|
+
jest.clearAllMocks();
|
|
62
121
|
});
|
|
63
|
-
it('should render
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
122
|
+
it('should render optionsGroups', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var user, button, options;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
user = setUp({ buttonsGroup: [] }).user;
|
|
128
|
+
button = react_2.screen.getByText('Viewing label');
|
|
129
|
+
return [4 /*yield*/, user.click(button)];
|
|
130
|
+
case 1:
|
|
131
|
+
_a.sent();
|
|
132
|
+
options = react_2.screen.getAllByRole('option');
|
|
133
|
+
expect(options.length).toBe(3);
|
|
134
|
+
expect((0, test_utils_1.getMuiIconByName)('Create', options[0])).toBeInTheDocument();
|
|
135
|
+
expect((0, test_utils_1.getMuiIconByName)('Add', options[1])).toBeInTheDocument();
|
|
136
|
+
expect((0, test_utils_1.getMuiIconByName)('Visibility', options[2])).toBeInTheDocument();
|
|
137
|
+
options.forEach(function (item, i) {
|
|
138
|
+
(0, react_2.within)(item).getByText(optionsGroup[i].label);
|
|
139
|
+
(0, react_2.within)(item).getByText(optionsGroup[i].description);
|
|
140
|
+
});
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
72
143
|
});
|
|
73
|
-
});
|
|
74
|
-
it('should
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
144
|
+
}); });
|
|
145
|
+
it('should render optionsGroup and buttonsGroup', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var user, button, options, allOptions;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
user = setUp().user;
|
|
151
|
+
button = react_2.screen.getByText('Viewing label');
|
|
152
|
+
return [4 /*yield*/, user.click(button)];
|
|
153
|
+
case 1:
|
|
154
|
+
_a.sent();
|
|
155
|
+
options = react_2.screen.getAllByRole('option');
|
|
156
|
+
expect(options.length).toBe(5);
|
|
157
|
+
expect((0, test_utils_1.getMuiIconByName)('Create', options[0])).toBeInTheDocument();
|
|
158
|
+
expect((0, test_utils_1.getMuiIconByName)('Add', options[1])).toBeInTheDocument();
|
|
159
|
+
expect((0, test_utils_1.getMuiIconByName)('Visibility', options[2])).toBeInTheDocument();
|
|
160
|
+
expect((0, test_utils_1.getMuiIconByName)('Delete', options[3])).toBeInTheDocument();
|
|
161
|
+
expect((0, test_utils_1.getMuiIconByName)('Create', options[4])).toBeInTheDocument();
|
|
162
|
+
allOptions = __spreadArray(__spreadArray([], optionsGroup, true), buttonsGroup, true);
|
|
163
|
+
options.forEach(function (item, i) {
|
|
164
|
+
(0, react_2.within)(item).getByText(allOptions[i].label);
|
|
165
|
+
(0, react_2.within)(item).getByText(allOptions[i].description);
|
|
166
|
+
});
|
|
167
|
+
return [2 /*return*/];
|
|
96
168
|
}
|
|
97
|
-
|
|
98
|
-
|
|
169
|
+
});
|
|
170
|
+
}); });
|
|
171
|
+
it('should call onChange with correct value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
+
var user, button;
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
switch (_a.label) {
|
|
175
|
+
case 0:
|
|
176
|
+
user = setUp().user;
|
|
177
|
+
button = react_2.screen.getByText('Viewing label');
|
|
178
|
+
return [4 /*yield*/, user.click(button)];
|
|
179
|
+
case 1:
|
|
180
|
+
_a.sent();
|
|
181
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Suggesting label'))];
|
|
182
|
+
case 2:
|
|
183
|
+
_a.sent();
|
|
184
|
+
expect(defaultProps.onChange).toHaveBeenCalledWith('Suggesting');
|
|
185
|
+
return [2 /*return*/];
|
|
99
186
|
}
|
|
100
187
|
});
|
|
188
|
+
}); });
|
|
189
|
+
it('button onClick event should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
var user, button;
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
switch (_a.label) {
|
|
193
|
+
case 0:
|
|
194
|
+
user = setUp().user;
|
|
195
|
+
button = react_2.screen.getByText('Viewing label');
|
|
196
|
+
return [4 /*yield*/, user.click(button)];
|
|
197
|
+
case 1:
|
|
198
|
+
_a.sent();
|
|
199
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Delete label'))];
|
|
200
|
+
case 2:
|
|
201
|
+
_a.sent();
|
|
202
|
+
expect(defaultProps.onChange).not.toHaveBeenCalled();
|
|
203
|
+
expect(buttonsGroup[0].onClick).toHaveBeenCalled();
|
|
204
|
+
return [2 /*return*/];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}); });
|
|
208
|
+
it('should first button has .firstMenuItemButton className and options hasn`t', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
209
|
+
var user, button, options;
|
|
210
|
+
return __generator(this, function (_a) {
|
|
211
|
+
switch (_a.label) {
|
|
212
|
+
case 0:
|
|
213
|
+
user = setUp().user;
|
|
214
|
+
button = react_2.screen.getByText('Viewing label');
|
|
215
|
+
return [4 /*yield*/, user.click(button)];
|
|
216
|
+
case 1:
|
|
217
|
+
_a.sent();
|
|
218
|
+
options = react_2.screen.getAllByRole('option');
|
|
219
|
+
expect(options[2]).not.toHaveClass('firstMenuItemButton');
|
|
220
|
+
expect(options[3]).toHaveClass('firstMenuItemButton');
|
|
221
|
+
expect(options[4]).not.toHaveClass('firstMenuItemButton');
|
|
222
|
+
return [2 /*return*/];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}); });
|
|
226
|
+
it('should render current value correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
+
var user;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
user = setUp({ value: 'Suggesting' }).user;
|
|
232
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Suggesting label'))];
|
|
233
|
+
case 1:
|
|
234
|
+
_a.sent();
|
|
235
|
+
react_2.screen.getByRole('option', {
|
|
236
|
+
name: 'Suggesting label Suggest changes and initiate a workflow review',
|
|
237
|
+
selected: true
|
|
238
|
+
});
|
|
239
|
+
react_2.screen.getByRole('option', { name: 'Viewing label Read or print profile', selected: false });
|
|
240
|
+
return [2 /*return*/];
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}); });
|
|
244
|
+
it('should not crash when current value is not from options/buttons', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
245
|
+
return __generator(this, function (_a) {
|
|
246
|
+
setUp({ value: 'NonExisting' });
|
|
247
|
+
expect(react_2.screen.getByRole('button')).toHaveTextContent('NonExisting');
|
|
248
|
+
return [2 /*return*/];
|
|
249
|
+
});
|
|
250
|
+
}); });
|
|
251
|
+
it('should disable button', function () {
|
|
252
|
+
setUp({ disabled: true });
|
|
253
|
+
expect(react_2.screen.getByRole('button')).toHaveClass('Mui-disabled');
|
|
101
254
|
});
|
|
102
|
-
it('should
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
expect(renderValue().find('.currentValue')).toHaveLength(1);
|
|
107
|
-
expect(renderValue().find(Visibility_1.default)).toHaveLength(1);
|
|
108
|
-
expect(renderValue().find('.currentValueText').text()).toBe('Viewing label');
|
|
109
|
-
});
|
|
110
|
-
it('should not crash when current value is not from options/buttons', function () {
|
|
111
|
-
var component = (0, enzyme_1.shallow)(react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { optionsGroup: optionsGroup, buttonsGroup: buttonsGroup, value: "Viewing1" }));
|
|
112
|
-
var select = component.find(Select_1.default);
|
|
113
|
-
var renderValue = function () { return select.renderProp('renderValue')(select.prop('value')); };
|
|
114
|
-
expect(renderValue().find('.currentValue')).toHaveLength(1);
|
|
115
|
-
expect(renderValue().find('.currentValueText').text()).toBe('Viewing1');
|
|
255
|
+
it('should show loader instead of icon', function () {
|
|
256
|
+
setUp({ loading: true });
|
|
257
|
+
react_2.screen.getByTestId('mode-loading-spinner');
|
|
258
|
+
expect((0, test_utils_1.getMuiIconByName)('Visibility', react_2.screen.getByRole('button'))).not.toBeInTheDocument();
|
|
116
259
|
});
|
|
117
260
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"normal" | "thin" | "root" | "menuItem" | "outlined" | "currentValue" | "arrowIcon" | "currentValueIcon" | "currentValueText" | "firstMenuItemButton" | "menuItemInner" | "menuItemIcon" | "menuItemLabel" | "menuItemDescription">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"normal" | "thin" | "select" | "root" | "menuItem" | "outlined" | "currentValue" | "arrowIcon" | "currentValueIcon" | "currentValueText" | "firstMenuItemButton" | "menuItemInner" | "menuItemIcon" | "menuItemLabel" | "menuItemDescription">;
|
|
@@ -10,6 +10,8 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
10
10
|
normal: {},
|
|
11
11
|
thin: {},
|
|
12
12
|
root: {
|
|
13
|
+
display: 'inline-flex',
|
|
14
|
+
alignItems: 'center',
|
|
13
15
|
maxWidth: CALCULATED_MAX_WIDTH_SELECT,
|
|
14
16
|
'&$outlined': {
|
|
15
17
|
minHeight: '1.1876em'
|
|
@@ -23,6 +25,16 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
23
25
|
paddingBottom: '6px'
|
|
24
26
|
}
|
|
25
27
|
},
|
|
28
|
+
select: {
|
|
29
|
+
'&.Mui-disabled': {
|
|
30
|
+
'& .MuiOutlinedInput-notchedOutline': {
|
|
31
|
+
borderColor: theme.palette.text.disabled
|
|
32
|
+
},
|
|
33
|
+
'& $currentValueIcon, & $currentValueText': {
|
|
34
|
+
color: theme.palette.text.disabled
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
26
38
|
outlined: {
|
|
27
39
|
paddingRight: SELECT_PADDING_RIGHT,
|
|
28
40
|
paddingLeft: SELECT_PADDING_LEFT
|
|
@@ -41,6 +53,9 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
41
53
|
alignItems: 'center'
|
|
42
54
|
},
|
|
43
55
|
currentValueIcon: {
|
|
56
|
+
width: '1em',
|
|
57
|
+
height: '1em',
|
|
58
|
+
display: 'inline-block',
|
|
44
59
|
fontSize: '18px',
|
|
45
60
|
marginRight: '8px',
|
|
46
61
|
color: theme.palette.text.secondary
|
|
@@ -66,6 +81,9 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
66
81
|
alignItems: 'flex-start'
|
|
67
82
|
},
|
|
68
83
|
menuItemIcon: {
|
|
84
|
+
width: '1em',
|
|
85
|
+
height: '1em',
|
|
86
|
+
display: 'inline-block',
|
|
69
87
|
fontSize: '18px',
|
|
70
88
|
color: theme.palette.text.secondary,
|
|
71
89
|
marginRight: '9px'
|
|
@@ -93,6 +93,7 @@ export type MdmModuleActionsContextProps = Partial<{
|
|
|
93
93
|
errorSet: (payload: string) => void;
|
|
94
94
|
setHistoryMode: (payload: HistoryMode) => void;
|
|
95
95
|
modeUpdated: (payload: Mode) => void;
|
|
96
|
+
modeUpdateRequested: (payload: Mode) => void;
|
|
96
97
|
setHistoryEvent: (payload: HistoryEvent) => void;
|
|
97
98
|
clearHistoryEvent: () => void;
|
|
98
99
|
clearHistoryDiff: () => void;
|
|
@@ -162,6 +163,7 @@ export declare const MdmModuleActionsContext: import("@fluentui/react-context-se
|
|
|
162
163
|
errorSet: (payload: string) => void;
|
|
163
164
|
setHistoryMode: (payload: HistoryMode) => void;
|
|
164
165
|
modeUpdated: (payload: Mode) => void;
|
|
166
|
+
modeUpdateRequested: (payload: Mode) => void;
|
|
165
167
|
setHistoryEvent: (payload: HistoryEvent) => void;
|
|
166
168
|
clearHistoryEvent: () => void;
|
|
167
169
|
clearHistoryDiff: () => void;
|
|
@@ -71,7 +71,7 @@ export declare const useMdmDependentLookupEditorContext: (attributeValue: Simple
|
|
|
71
71
|
};
|
|
72
72
|
export declare const useMdmGlobalSearchRequestOptions: (omittingFields?: string[]) => import("@reltio/mdm-sdk").GlobalSearchRequestOptions;
|
|
73
73
|
export declare const useMdmAuthoringItemsByEntityType: (entityTypeUri: string) => import("@reltio/mdm-sdk").AuthoringItem[];
|
|
74
|
-
export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent" | "openConsoleApp" | "addAttributes" | "modifyAttribute" | "removeAttribute" | "entityDeleted" | "entityCreated" | "errorDeactivated" | "requestNextPageOfAttributeValues" | "openEntity" | "setDefaultProfilePicForModifiedEntity" | "setDefaultProfilePicForEntity" | "dependentLookupsEditorTouched" | "openPivotingPerspective" | "lookupsLoaded" | "lookupsForTypeResolved" | "errorSet" | "setHistoryMode" | "modeUpdated" | "setHistoryEvent" | "clearHistoryEvent" | "clearHistoryDiff" | "setHistoryDiff" | "setHistorySlice" | "updateSearchNavigationDataFields" | "openPerspective" | "entityDeletionFinished" | "loadEntity" | "updateSearchNavigationDataOnMerge" | "lookupsListResolved" | "relationsLoaded" | "setInitialInfo" | "setRelationType" | "closeRelationEditor" | "openRelationEditor" | "setRelationEntity" | "errorsSet" | "addRelation" | "editRelation" | "updateHiddenAttributes" | "resetHiddenAttributes" | "updateControlAttributes">(action: T) => Partial<{
|
|
74
|
+
export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent" | "openConsoleApp" | "addAttributes" | "modifyAttribute" | "removeAttribute" | "entityDeleted" | "entityCreated" | "errorDeactivated" | "requestNextPageOfAttributeValues" | "openEntity" | "setDefaultProfilePicForModifiedEntity" | "setDefaultProfilePicForEntity" | "dependentLookupsEditorTouched" | "openPivotingPerspective" | "lookupsLoaded" | "lookupsForTypeResolved" | "errorSet" | "setHistoryMode" | "modeUpdated" | "modeUpdateRequested" | "setHistoryEvent" | "clearHistoryEvent" | "clearHistoryDiff" | "setHistoryDiff" | "setHistorySlice" | "updateSearchNavigationDataFields" | "openPerspective" | "entityDeletionFinished" | "loadEntity" | "updateSearchNavigationDataOnMerge" | "lookupsListResolved" | "relationsLoaded" | "setInitialInfo" | "setRelationType" | "closeRelationEditor" | "openRelationEditor" | "setRelationEntity" | "errorsSet" | "addRelation" | "editRelation" | "updateHiddenAttributes" | "resetHiddenAttributes" | "updateControlAttributes">(action: T) => Partial<{
|
|
75
75
|
openSearch: (payload: import("@reltio/mdm-sdk").SearchState) => void;
|
|
76
76
|
openHistoryEvent: (payload: {
|
|
77
77
|
entityUri: string;
|
|
@@ -108,6 +108,7 @@ export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent"
|
|
|
108
108
|
errorSet: (payload: string) => void;
|
|
109
109
|
setHistoryMode: (payload: import("@reltio/mdm-sdk").HistoryMode) => void;
|
|
110
110
|
modeUpdated: (payload: import("@reltio/mdm-sdk").Mode) => void;
|
|
111
|
+
modeUpdateRequested: (payload: import("@reltio/mdm-sdk").Mode) => void;
|
|
111
112
|
setHistoryEvent: (payload: import("@reltio/mdm-sdk").HistoryEvent) => void;
|
|
112
113
|
clearHistoryEvent: () => void;
|
|
113
114
|
clearHistoryDiff: () => void;
|
|
@@ -51,7 +51,7 @@ var constants_1 = require("./constants");
|
|
|
51
51
|
exports.HistoryCircle = (0, react_1.forwardRef)(function (_a, ref) {
|
|
52
52
|
var x = _a.x, y = _a.y, color = _a.color, isDashed = _a.isDashed, isCollapsed = _a.isCollapsed, showCollapseIcon = _a.showCollapseIcon, showLine = _a.showLine, otherProps = __rest(_a, ["x", "y", "color", "isDashed", "isCollapsed", "showCollapseIcon", "showLine"]);
|
|
53
53
|
var radius = showCollapseIcon ? constants_1.BUMP_RADIUS * 2 : constants_1.BUMP_RADIUS;
|
|
54
|
-
return (react_1.default.createElement("g", __assign({}, otherProps, { ref: ref }),
|
|
54
|
+
return (react_1.default.createElement("g", __assign({ "data-reltio-id": "history-circle" }, otherProps, { ref: ref }),
|
|
55
55
|
showLine && (react_1.default.createElement("rect", { id: "line", x: x - radius - constants_1.LINE_MARGIN, y: y - radius - constants_1.LINE_MARGIN, width: radius * 2 + constants_1.LINE_MARGIN * 2, height: 2, fill: color })),
|
|
56
56
|
react_1.default.createElement("circle", { cx: x, cy: y, r: radius, fill: isDashed ? '#fff' : color, stroke: color, strokeDasharray: isDashed ? '1,1' : undefined, strokeWidth: 2 }),
|
|
57
57
|
showCollapseIcon && (react_1.default.createElement("g", { id: "icon" },
|
|
@@ -18,7 +18,9 @@ var HistoryRow = function (_a) {
|
|
|
18
18
|
var colorUri = fakeType && uris ? uris[0] : uri;
|
|
19
19
|
var color = (0, mdm_sdk_1.getContributorColor)(colorUri);
|
|
20
20
|
var styles = (0, styles_1.useStyles)({ color: color });
|
|
21
|
-
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.historyRow, (_b = {},
|
|
21
|
+
return (react_1.default.createElement("div", { "data-reltio-id": "history-row", className: (0, classnames_1.default)(styles.historyRow, (_b = {},
|
|
22
|
+
_b[styles.selected] = isSelected,
|
|
23
|
+
_b)), onClick: onClick },
|
|
22
24
|
react_1.default.createElement("div", { className: styles.rowHeader },
|
|
23
25
|
react_1.default.createElement("div", { className: styles.badge }),
|
|
24
26
|
react_1.default.createElement(Typography_1.default, { className: (0, classnames_1.default)(styles.title, { bold: isCurrent }) }, isCurrent ? ui_i18n_1.default.text('Current view') : (0, activity_log_1.getActivityLabel)(type)),
|
|
@@ -59,7 +59,7 @@ var HistoryTree = function (_a) {
|
|
|
59
59
|
var _e = (0, react_1.useState)(-1), selectedIndex = _e[0], setSelectedIndex = _e[1];
|
|
60
60
|
var setHistoryEvent = (0, MdmModuleContext_1.useMdmAction)('setHistoryEvent');
|
|
61
61
|
var clearHistoryEvent = (0, MdmModuleContext_1.useMdmAction)('clearHistoryEvent');
|
|
62
|
-
var
|
|
62
|
+
var modeUpdateRequested = (0, MdmModuleContext_1.useMdmAction)('modeUpdateRequested');
|
|
63
63
|
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
64
64
|
var isEditableMode = (0, MdmModuleContext_1.useMdmIsEditableMode)();
|
|
65
65
|
(0, react_1.useEffect)(function () {
|
|
@@ -106,12 +106,7 @@ var HistoryTree = function (_a) {
|
|
|
106
106
|
};
|
|
107
107
|
var handleHistoryRowClick = function (index, change, isSelected, isCurrent) {
|
|
108
108
|
if (isEditableMode) {
|
|
109
|
-
|
|
110
|
-
modeUpdated(mdm_sdk_1.Mode.Viewing);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
109
|
+
modeUpdateRequested(mdm_sdk_1.Mode.Viewing);
|
|
115
110
|
}
|
|
116
111
|
if ((isCurrent && !isSelected) || (!isCurrent && isSelected)) {
|
|
117
112
|
clearHistoryEvent();
|