@reltio/components 1.4.1849 → 1.4.1851

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 (81) hide show
  1. package/cjs/EditModeAttributesList/EditModeAttributesList.js +6 -3
  2. package/cjs/EditModeAttributesView/EditModeAttributesView.test.js +218 -24
  3. package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.js +4 -1
  4. package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.js +1 -9
  5. package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +113 -104
  6. package/cjs/SaveSegmentDialog/SaveSegmentDialog.d.ts +8 -0
  7. package/cjs/SaveSegmentDialog/SaveSegmentDialog.js +129 -0
  8. package/cjs/SaveSegmentDialog/SaveSegmentDialog.test.d.ts +1 -0
  9. package/cjs/SaveSegmentDialog/SaveSegmentDialog.test.js +214 -0
  10. package/cjs/SaveSegmentDialog/index.d.ts +1 -0
  11. package/cjs/SaveSegmentDialog/index.js +5 -0
  12. package/cjs/SaveSegmentDialog/styles.d.ts +1 -0
  13. package/cjs/SaveSegmentDialog/styles.js +15 -0
  14. package/cjs/contexts/MdmModuleContext/context.d.ts +6 -0
  15. package/cjs/contexts/MdmModuleContext/hooks.d.ts +4 -1
  16. package/cjs/contexts/MdmModuleContext/hooks.js +5 -1
  17. package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
  18. package/cjs/contexts/MdmModuleContext/index.js +2 -1
  19. package/cjs/hooks/index.d.ts +1 -0
  20. package/cjs/hooks/index.js +3 -1
  21. package/cjs/hooks/useHiddenAttributes/helpers.d.ts +7 -0
  22. package/cjs/hooks/useHiddenAttributes/helpers.js +22 -0
  23. package/cjs/hooks/useHiddenAttributes/useChangedAttributes.d.ts +2 -0
  24. package/cjs/hooks/useHiddenAttributes/useChangedAttributes.js +37 -0
  25. package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.d.ts +1 -0
  26. package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.js +61 -0
  27. package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.test.d.ts +1 -0
  28. package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.test.js +370 -0
  29. package/cjs/hooks/useSavedSearchesRequest/index.d.ts +1 -0
  30. package/cjs/hooks/useSavedSearchesRequest/index.js +5 -0
  31. package/cjs/hooks/useSavedSearchesRequest/requests.d.ts +6 -0
  32. package/cjs/hooks/useSavedSearchesRequest/requests.js +72 -0
  33. package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +76 -0
  34. package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +255 -0
  35. package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.d.ts +1 -0
  36. package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.js +743 -0
  37. package/cjs/index.d.ts +1 -0
  38. package/cjs/index.js +3 -1
  39. package/esm/EditModeAttributesList/EditModeAttributesList.js +6 -3
  40. package/esm/EditModeAttributesView/EditModeAttributesView.test.js +219 -25
  41. package/esm/ReadOnlyAttributesList/ReadOnlyAttributesList.js +4 -1
  42. package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.js +2 -10
  43. package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +114 -105
  44. package/esm/SaveSegmentDialog/SaveSegmentDialog.d.ts +8 -0
  45. package/esm/SaveSegmentDialog/SaveSegmentDialog.js +99 -0
  46. package/esm/SaveSegmentDialog/SaveSegmentDialog.test.d.ts +1 -0
  47. package/esm/SaveSegmentDialog/SaveSegmentDialog.test.js +209 -0
  48. package/esm/SaveSegmentDialog/index.d.ts +1 -0
  49. package/esm/SaveSegmentDialog/index.js +1 -0
  50. package/esm/SaveSegmentDialog/styles.d.ts +1 -0
  51. package/esm/SaveSegmentDialog/styles.js +12 -0
  52. package/esm/contexts/MdmModuleContext/context.d.ts +6 -0
  53. package/esm/contexts/MdmModuleContext/hooks.d.ts +4 -1
  54. package/esm/contexts/MdmModuleContext/hooks.js +3 -0
  55. package/esm/contexts/MdmModuleContext/index.d.ts +1 -1
  56. package/esm/contexts/MdmModuleContext/index.js +1 -1
  57. package/esm/hooks/index.d.ts +1 -0
  58. package/esm/hooks/index.js +1 -0
  59. package/esm/hooks/useHiddenAttributes/helpers.d.ts +7 -0
  60. package/esm/hooks/useHiddenAttributes/helpers.js +17 -0
  61. package/esm/hooks/useHiddenAttributes/useChangedAttributes.d.ts +2 -0
  62. package/esm/hooks/useHiddenAttributes/useChangedAttributes.js +33 -0
  63. package/esm/hooks/useHiddenAttributes/useHiddenAttributes.d.ts +1 -0
  64. package/esm/hooks/useHiddenAttributes/useHiddenAttributes.js +57 -0
  65. package/esm/hooks/useHiddenAttributes/useHiddenAttributes.test.d.ts +1 -0
  66. package/esm/hooks/useHiddenAttributes/useHiddenAttributes.test.js +368 -0
  67. package/esm/hooks/useSavedSearchesRequest/index.d.ts +1 -0
  68. package/esm/hooks/useSavedSearchesRequest/index.js +1 -0
  69. package/esm/hooks/useSavedSearchesRequest/requests.d.ts +6 -0
  70. package/esm/hooks/useSavedSearchesRequest/requests.js +68 -0
  71. package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +76 -0
  72. package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +251 -0
  73. package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.d.ts +1 -0
  74. package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.js +738 -0
  75. package/esm/index.d.ts +1 -0
  76. package/esm/index.js +1 -0
  77. package/package.json +2 -2
  78. package/cjs/hooks/useSavedSearchesRequest.d.ts +0 -23
  79. package/cjs/hooks/useSavedSearchesRequest.js +0 -224
  80. package/esm/hooks/useSavedSearchesRequest.d.ts +0 -23
  81. package/esm/hooks/useSavedSearchesRequest.js +0 -220
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
49
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
50
  if (ar || !(i in from)) {
@@ -21,6 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
21
57
  import React from 'react';
22
58
  import { shallow } from 'enzyme';
23
59
  import { render, screen } from '@testing-library/react';
60
+ import userEvent from '@testing-library/user-event';
24
61
  import { EntityAttrTypes } from '@reltio/mdm-sdk';
25
62
  import Typography from '@mui/material/Typography';
26
63
  import { ReadOnlyAttributesView } from './ReadOnlyAttributesView';
@@ -28,8 +65,8 @@ import { BasicView } from '../BasicView';
28
65
  import { ReadOnlyAttributesList } from '../ReadOnlyAttributesList';
29
66
  import { FacetViewHeader } from '../FacetViewHeader';
30
67
  import { PivotingAttributeContext } from '../contexts/PivotingAttributeContext';
31
- import { useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
32
- jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn() })); });
68
+ import { useMdmHiddenAttributes, useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
69
+ jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn(), useMdmHiddenAttributes: jest.fn() })); });
33
70
  describe('ReadOnlyAttributesView tests', function () {
34
71
  var metadata = {
35
72
  entityTypes: [
@@ -203,8 +240,8 @@ describe('ReadOnlyAttributesView tests', function () {
203
240
  var provider = component.find(PivotingAttributeContext.Provider);
204
241
  expect(provider.prop('value')).toEqual(pivotingAttributes);
205
242
  });
206
- describe('dynamic rules', function () {
207
- var metadataWithDynamicRules = {
243
+ describe('rule based attributes', function () {
244
+ var metadata = {
208
245
  entityTypes: [
209
246
  {
210
247
  uri: 'configuration/entityTypes/HCP',
@@ -228,93 +265,38 @@ describe('ReadOnlyAttributesView tests', function () {
228
265
  name: 'Category4',
229
266
  type: 'String',
230
267
  uri: 'configuration/entityTypes/HCP/attributes/Category4'
231
- }
232
- ],
233
- ruleBasedAttributes: [
234
- {
235
- uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule1',
236
- label: 'Dynamic Rule 1',
237
- description: 'Dynamic Attributes Rule 1',
238
- name: 'DynamicRule1',
239
- type: 'Dynamic',
240
- controlFunction: {
241
- expression: "listEquals(attributes.Category1.value, 'category1_value1') and listEquals(attributes.Category2.value, 'category2_value1', 'category2_value2')",
242
- showAttributeURI: [
243
- 'configuration/entityTypes/HCP/attributes/Category3',
244
- 'configuration/entityTypes/HCP/attributes/Category4'
245
- ]
246
- }
247
- },
248
- {
249
- uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule2',
250
- label: 'Dynamic Rule 2',
251
- description: 'Dynamic Attributes Rule 2',
252
- name: 'DynamicRule2',
253
- type: 'Dynamic',
254
- controlFunction: {
255
- expression: "listEquals(attributes.Category1.value, 'category1_value1')",
256
- showAttributeURI: ['configuration/entityTypes/HCP/attributes/Category2']
257
- }
258
268
  },
259
269
  {
260
- uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule3',
261
- label: 'Dynamic Rule 3',
262
- description: 'Dynamic Attributes Rule 3',
263
- name: 'DynamicRule3',
264
- type: 'Dynamic',
265
- controlFunction: {
266
- expression: "listEquals(attributes.Category1.value, 'category1_value2')",
267
- showAttributeURI: ['configuration/entityTypes/HCP/attributes/Category4']
268
- }
270
+ name: 'Nested1',
271
+ label: 'Nested1',
272
+ type: 'Nested',
273
+ uri: 'configuration/entityTypes/HCP/attributes/Nested1',
274
+ attributes: [
275
+ {
276
+ name: 'NestedCategory1',
277
+ type: 'String',
278
+ uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory1'
279
+ },
280
+ {
281
+ name: 'NestedCategory2',
282
+ type: 'String',
283
+ uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
284
+ }
285
+ ]
269
286
  }
270
287
  ]
271
288
  }
272
289
  ]
273
290
  };
274
291
  var setUp = function (props) {
275
- return render(React.createElement(ReadOnlyAttributesView, __assign({}, props)));
292
+ var user = userEvent.setup();
293
+ return __assign(__assign({}, render(React.createElement(ReadOnlyAttributesView, __assign({}, props)))), { user: user });
276
294
  };
277
295
  beforeAll(function () {
278
- useMdmMetadata.mockReturnValue(metadataWithDynamicRules);
279
- });
280
- it('should hide attributes which does not fit dynamic rules', function () {
281
- var entity = {
282
- type: 'configuration/entityTypes/HCP',
283
- uri: 'entities/uri_e',
284
- attributes: {
285
- Category1: [
286
- {
287
- uri: 'entities/uri_e/attributes/uri1',
288
- value: 'category1_value1_diff'
289
- }
290
- ],
291
- Category2: [
292
- {
293
- uri: 'entities/uri_e/attributes/uri2',
294
- value: 'category2_value1_diff'
295
- }
296
- ],
297
- Category3: [
298
- {
299
- uri: 'entities/uri_e/attributes/uri3',
300
- value: 'category3_value1'
301
- }
302
- ],
303
- Category4: [
304
- {
305
- uri: 'entities/uri_e/attributes/uri4',
306
- value: 'category4_value1'
307
- }
308
- ]
309
- }
310
- };
311
- setUp({ entity: entity });
312
- expect(screen.getByText('category1_value1_diff')).toBeInTheDocument();
313
- expect(screen.queryByText('category2_value1_diff')).not.toBeInTheDocument();
314
- expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
315
- expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
296
+ useMdmMetadata.mockReturnValue(metadata);
297
+ useMdmHiddenAttributes.mockReturnValue([]);
316
298
  });
317
- it('should show attributes which fits dynamic rules', function () {
299
+ it('should hide attributes', function () {
318
300
  var entity = {
319
301
  type: 'configuration/entityTypes/HCP',
320
302
  uri: 'entities/uri_e',
@@ -345,34 +327,61 @@ describe('ReadOnlyAttributesView tests', function () {
345
327
  ]
346
328
  }
347
329
  };
330
+ useMdmHiddenAttributes.mockReturnValue([
331
+ 'configuration/entityTypes/HCP/attributes/Category2',
332
+ 'configuration/entityTypes/HCP/attributes/Category3',
333
+ 'configuration/entityTypes/HCP/attributes/Category4'
334
+ ]);
348
335
  setUp({ entity: entity });
349
336
  expect(screen.getByText('category1_value1')).toBeInTheDocument();
350
- expect(screen.getByText('category2_value1')).toBeInTheDocument();
351
- expect(screen.getByText('category3_value1')).toBeInTheDocument();
352
- expect(screen.getByText('category4_value1')).toBeInTheDocument();
337
+ expect(screen.queryByText('category2_value1')).not.toBeInTheDocument();
338
+ expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
339
+ expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
353
340
  });
354
- it('should show attributes if at least one rule allows to show the attribute from showAttributeURI', function () {
355
- var entity = {
356
- type: 'configuration/entityTypes/HCP',
357
- uri: 'entities/uri_e',
358
- attributes: {
359
- Category1: [
360
- {
361
- uri: 'entities/uri_e/attributes/uri1',
362
- value: 'category1_value2'
363
- }
364
- ],
365
- Category4: [
366
- {
367
- uri: 'entities/uri_e/attributes/uri4',
368
- value: 'category4_value1'
369
- }
370
- ]
341
+ it('should hide nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
342
+ var entity, user;
343
+ return __generator(this, function (_a) {
344
+ switch (_a.label) {
345
+ case 0:
346
+ entity = {
347
+ type: 'configuration/entityTypes/HCP',
348
+ uri: 'entities/uri_e',
349
+ attributes: {
350
+ Nested1: [
351
+ {
352
+ uri: 'entities/uri_e/attributes/nesteduri1',
353
+ value: {
354
+ NestedCategory1: [
355
+ {
356
+ ov: true,
357
+ uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi1',
358
+ value: 'nested_category1_value'
359
+ }
360
+ ],
361
+ NestedCategory2: [
362
+ {
363
+ ov: true,
364
+ uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi2',
365
+ value: 'nested_category2_value1'
366
+ }
367
+ ]
368
+ }
369
+ }
370
+ ]
371
+ }
372
+ };
373
+ useMdmHiddenAttributes.mockReturnValue([
374
+ 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
375
+ ]);
376
+ user = setUp({ entity: entity }).user;
377
+ return [4 /*yield*/, user.click(screen.getByTestId('arrow-expand-button'))];
378
+ case 1:
379
+ _a.sent();
380
+ expect(screen.getByText('nested_category1_value')).toBeInTheDocument();
381
+ expect(screen.queryByText('nested_category2_value1')).not.toBeInTheDocument();
382
+ return [2 /*return*/];
371
383
  }
372
- };
373
- setUp({ entity: entity });
374
- expect(screen.getByText('category1_value2')).toBeInTheDocument();
375
- expect(screen.getByText('category4_value1')).toBeInTheDocument();
376
- });
384
+ });
385
+ }); });
377
386
  });
378
387
  });
@@ -0,0 +1,8 @@
1
+ type Props = {
2
+ isOpen: boolean;
3
+ isSaving: boolean;
4
+ onClose: () => void;
5
+ onSave: (name: string, description: string, isPublic: boolean) => void;
6
+ };
7
+ export declare const SaveSegmentDialog: ({ isOpen, isSaving, onClose, onSave }: Props) => JSX.Element;
8
+ export {};
@@ -0,0 +1,99 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import React, { useCallback, useEffect, useState } from 'react';
38
+ import i18n from 'ui-i18n';
39
+ import Dialog from '@mui/material/Dialog';
40
+ import DialogTitle from '@mui/material/DialogTitle';
41
+ import DialogContent from '@mui/material/DialogContent';
42
+ import DialogActions from '@mui/material/DialogActions';
43
+ import Button from '@mui/material/Button';
44
+ import { DropDownEditor } from '../DropDownEditor';
45
+ import { TextEditor } from '../TextEditor';
46
+ import { useStyles } from './styles';
47
+ var SharingOption;
48
+ (function (SharingOption) {
49
+ SharingOption["Public"] = "public";
50
+ SharingOption["Private"] = "private";
51
+ })(SharingOption || (SharingOption = {}));
52
+ var SHARING_OPTIONS = [
53
+ { label: i18n.text('Only me'), value: SharingOption.Private },
54
+ { label: i18n.text('All users'), value: SharingOption.Public }
55
+ ];
56
+ export var SaveSegmentDialog = function (_a) {
57
+ var isOpen = _a.isOpen, isSaving = _a.isSaving, onClose = _a.onClose, onSave = _a.onSave;
58
+ var styles = useStyles();
59
+ var _b = useState(''), name = _b[0], setName = _b[1];
60
+ var _c = useState(''), description = _c[0], setDescription = _c[1];
61
+ var _d = useState(SharingOption.Private), share = _d[0], setShare = _d[1];
62
+ var isValid = name.trim() !== '';
63
+ var handleChangeName = useCallback(function (event) {
64
+ setName(event.target.value);
65
+ }, []);
66
+ var handleChangeDescription = useCallback(function (event) {
67
+ setDescription(event.target.value);
68
+ }, []);
69
+ var handleChangeShareWith = useCallback(function (newValue) {
70
+ setShare(newValue);
71
+ }, []);
72
+ var handleSave = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
73
+ return __generator(this, function (_a) {
74
+ onSave(name, description, share === SharingOption.Public);
75
+ return [2 /*return*/];
76
+ });
77
+ }); }, [onSave, name, description, share]);
78
+ useEffect(function () {
79
+ if (isOpen) {
80
+ setName('');
81
+ setDescription('');
82
+ setShare(SharingOption.Private);
83
+ }
84
+ }, [isOpen]);
85
+ return (React.createElement(Dialog, { onClose: onClose, open: isOpen, PaperProps: { classes: { root: styles.root } } },
86
+ React.createElement(DialogTitle, null, i18n.text('Save segment')),
87
+ React.createElement(DialogContent, { className: styles.dialogContent },
88
+ React.createElement(TextEditor, { label: i18n.text('Name'), required: true, variant: "filled", onInput: handleChangeName, value: name, size: "small", autoFocus: true }),
89
+ React.createElement(TextEditor, { label: i18n.text('Description (optional)'), multiline: true, variant: "filled", value: description, onInput: handleChangeDescription, size: "small", rows: 5 }),
90
+ React.createElement(DropDownEditor, { entries: SHARING_OPTIONS, TextFieldProps: {
91
+ required: true,
92
+ label: i18n.text('Share with'),
93
+ variant: 'filled',
94
+ size: 'small'
95
+ }, value: share, onChange: handleChangeShareWith })),
96
+ React.createElement(DialogActions, null,
97
+ React.createElement(Button, { onClick: onClose }, i18n.text('Cancel')),
98
+ React.createElement(Button, { color: "primary", onClick: handleSave, disabled: isSaving || !isValid }, i18n.text('Save')))));
99
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,209 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import React from 'react';
49
+ import { render, screen } from '@testing-library/react';
50
+ import userEvent from '@testing-library/user-event';
51
+ import { SaveSegmentDialog } from '../SaveSegmentDialog';
52
+ var defaultProps = {
53
+ isOpen: true,
54
+ isSaving: false,
55
+ onClose: jest.fn(),
56
+ onSave: jest.fn()
57
+ };
58
+ var setUp = function (props) {
59
+ if (props === void 0) { props = defaultProps; }
60
+ var user = userEvent.setup();
61
+ var result = render(React.createElement(SaveSegmentDialog, __assign({}, props)));
62
+ var rerender = function (props) { return result.rerender(React.createElement(SaveSegmentDialog, __assign({}, defaultProps, props))); };
63
+ return __assign(__assign({}, result), { user: user, rerender: rerender });
64
+ };
65
+ describe('SaveSegmentDialog tests', function () {
66
+ beforeEach(function () {
67
+ jest.clearAllMocks();
68
+ });
69
+ it('should not render dialog if isOpen prop is false', function () { return __awaiter(void 0, void 0, void 0, function () {
70
+ var props, container;
71
+ return __generator(this, function (_a) {
72
+ props = __assign(__assign({}, defaultProps), { isOpen: false });
73
+ container = setUp(props).container;
74
+ expect(container).toBeEmptyDOMElement();
75
+ return [2 /*return*/];
76
+ });
77
+ }); });
78
+ it('should render main parts correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
79
+ return __generator(this, function (_a) {
80
+ setUp();
81
+ expect(screen.getByText('Save segment')).toBeInTheDocument();
82
+ expect(screen.getByText('Name')).toBeInTheDocument();
83
+ expect(screen.getByText('Description (optional)')).toBeInTheDocument();
84
+ expect(screen.getByText('Share with')).toBeInTheDocument();
85
+ expect(screen.getByText('Cancel')).toBeInTheDocument();
86
+ expect(screen.getByText('Save')).toBeInTheDocument();
87
+ return [2 /*return*/];
88
+ });
89
+ }); });
90
+ it('should clear all fields on close dialog', function () { return __awaiter(void 0, void 0, void 0, function () {
91
+ var _a, user, rerender;
92
+ return __generator(this, function (_b) {
93
+ switch (_b.label) {
94
+ case 0:
95
+ _a = setUp(), user = _a.user, rerender = _a.rerender;
96
+ return [4 /*yield*/, user.click(screen.getByText('Name'))];
97
+ case 1:
98
+ _b.sent();
99
+ return [4 /*yield*/, user.keyboard('test name')];
100
+ case 2:
101
+ _b.sent();
102
+ return [4 /*yield*/, user.click(screen.getByText('Description (optional)'))];
103
+ case 3:
104
+ _b.sent();
105
+ return [4 /*yield*/, user.keyboard('test description')];
106
+ case 4:
107
+ _b.sent();
108
+ return [4 /*yield*/, user.click(screen.getByText('Only me'))];
109
+ case 5:
110
+ _b.sent();
111
+ return [4 /*yield*/, user.click(screen.getByText('All users'))];
112
+ case 6:
113
+ _b.sent();
114
+ rerender({ isOpen: false });
115
+ rerender({ isOpen: true });
116
+ expect(screen.queryByText('test name')).not.toBeInTheDocument();
117
+ expect(screen.queryByText('test description')).not.toBeInTheDocument();
118
+ screen.getByText('Only me');
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ }); });
123
+ it('should disable "Save" button in case of name field is empty', function () { return __awaiter(void 0, void 0, void 0, function () {
124
+ var user;
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0:
128
+ user = setUp().user;
129
+ expect(screen.getByText('Save')).toBeDisabled();
130
+ return [4 /*yield*/, user.click(screen.getByText('Name'))];
131
+ case 1:
132
+ _a.sent();
133
+ return [4 /*yield*/, user.keyboard(' ')];
134
+ case 2:
135
+ _a.sent();
136
+ expect(screen.getByText('Save')).toBeDisabled();
137
+ return [4 /*yield*/, user.keyboard('test')];
138
+ case 3:
139
+ _a.sent();
140
+ expect(screen.getByText('Save')).toBeEnabled();
141
+ return [2 /*return*/];
142
+ }
143
+ });
144
+ }); });
145
+ it('should disable "Save" button in case of isSaving prop is true', function () { return __awaiter(void 0, void 0, void 0, function () {
146
+ var props, user;
147
+ return __generator(this, function (_a) {
148
+ switch (_a.label) {
149
+ case 0:
150
+ props = __assign(__assign({}, defaultProps), { isSaving: true });
151
+ user = setUp(props).user;
152
+ return [4 /*yield*/, user.click(screen.getByText('Name'))];
153
+ case 1:
154
+ _a.sent();
155
+ return [4 /*yield*/, user.keyboard('test')];
156
+ case 2:
157
+ _a.sent();
158
+ expect(screen.getByText('Save')).toBeDisabled();
159
+ return [2 /*return*/];
160
+ }
161
+ });
162
+ }); });
163
+ it('should call onSave callback with correct props on "Save" button click', function () { return __awaiter(void 0, void 0, void 0, function () {
164
+ var user;
165
+ return __generator(this, function (_a) {
166
+ switch (_a.label) {
167
+ case 0:
168
+ user = setUp().user;
169
+ return [4 /*yield*/, user.click(screen.getByText('Name'))];
170
+ case 1:
171
+ _a.sent();
172
+ return [4 /*yield*/, user.keyboard('test name')];
173
+ case 2:
174
+ _a.sent();
175
+ return [4 /*yield*/, user.click(screen.getByText('Description (optional)'))];
176
+ case 3:
177
+ _a.sent();
178
+ return [4 /*yield*/, user.keyboard('test description')];
179
+ case 4:
180
+ _a.sent();
181
+ return [4 /*yield*/, user.click(screen.getByText('Only me'))];
182
+ case 5:
183
+ _a.sent();
184
+ return [4 /*yield*/, user.click(screen.getByText('All users'))];
185
+ case 6:
186
+ _a.sent();
187
+ return [4 /*yield*/, user.click(screen.getByText('Save'))];
188
+ case 7:
189
+ _a.sent();
190
+ expect(defaultProps.onSave).toHaveBeenCalledWith('test name', 'test description', true);
191
+ return [2 /*return*/];
192
+ }
193
+ });
194
+ }); });
195
+ it('should call onClose callback on "Cancel" button click', function () { return __awaiter(void 0, void 0, void 0, function () {
196
+ var user;
197
+ return __generator(this, function (_a) {
198
+ switch (_a.label) {
199
+ case 0:
200
+ user = setUp().user;
201
+ return [4 /*yield*/, user.click(screen.getByText('Cancel'))];
202
+ case 1:
203
+ _a.sent();
204
+ expect(defaultProps.onClose).toHaveBeenCalled();
205
+ return [2 /*return*/];
206
+ }
207
+ });
208
+ }); });
209
+ });
@@ -0,0 +1 @@
1
+ export { SaveSegmentDialog } from './SaveSegmentDialog';
@@ -0,0 +1 @@
1
+ export { SaveSegmentDialog } from './SaveSegmentDialog';
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"root" | "dialogContent">;
@@ -0,0 +1,12 @@
1
+ import { makeStyles } from '@mui/styles';
2
+ export var useStyles = makeStyles({
3
+ root: {
4
+ minWidth: '600px',
5
+ minHeight: '280px'
6
+ },
7
+ dialogContent: {
8
+ display: 'flex',
9
+ flexDirection: 'column',
10
+ gap: '20px'
11
+ }
12
+ });
@@ -32,6 +32,7 @@ export type MdmModuleValuesContextProps = Partial<{
32
32
  mode: Mode;
33
33
  isViewMode: boolean;
34
34
  isEditableMode: boolean;
35
+ hiddenAttributes: string[];
35
36
  historyDiff: HistoryDiff;
36
37
  historyMode: HistoryMode;
37
38
  historySlice: HistorySlice;
@@ -114,6 +115,8 @@ export type MdmModuleActionsContextProps = Partial<{
114
115
  errorsSet: (payload: AttributeError[]) => void;
115
116
  addRelation: (id: string, connection: Connection) => void;
116
117
  editRelation: (id: string, connection: Connection) => void;
118
+ updateHiddenAttributes: (uri: string, hiddenAttributes: string[]) => void;
119
+ resetHiddenAttributes: (uri: string) => void;
117
120
  }>;
118
121
  export type MdmModuleListenersContextProps = Partial<{
119
122
  expandInvalidRelatonsListener: (callback: () => void) => (action: any) => void;
@@ -180,6 +183,8 @@ export declare const MdmModuleActionsContext: import("@fluentui/react-context-se
180
183
  errorsSet: (payload: AttributeError[]) => void;
181
184
  addRelation: (id: string, connection: Connection) => void;
182
185
  editRelation: (id: string, connection: Connection) => void;
186
+ updateHiddenAttributes: (uri: string, hiddenAttributes: string[]) => void;
187
+ resetHiddenAttributes: (uri: string) => void;
183
188
  }>>;
184
189
  export declare const MdmModuleValuesContext: import("@fluentui/react-context-selector").Context<Partial<{
185
190
  autoCloseInterval: number;
@@ -213,6 +218,7 @@ export declare const MdmModuleValuesContext: import("@fluentui/react-context-sel
213
218
  mode: Mode;
214
219
  isViewMode: boolean;
215
220
  isEditableMode: boolean;
221
+ hiddenAttributes: string[];
216
222
  historyDiff: HistoryDiff;
217
223
  historyMode: HistoryMode;
218
224
  historySlice: HistorySlice;