@reltio/components 1.4.1861 → 1.4.1862
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/InlineSimpleAttribute/InlineSimpleAttribute.d.ts +1 -1
- package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.js +15 -4
- package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +98 -42
- package/cjs/InlineSimpleAttribute/styles.d.ts +2 -1
- package/cjs/InlineSimpleAttribute/styles.js +14 -5
- package/cjs/MaskingSwitcher/MaskingSwitcher.d.ts +2 -1
- package/cjs/MaskingSwitcher/MaskingSwitcher.js +5 -2
- package/cjs/SimpleAttribute/SimpleAttribute.js +1 -1
- package/cjs/contexts/MaskedAttributesContext/context.d.ts +18 -0
- package/cjs/contexts/MaskedAttributesContext/context.js +141 -0
- package/cjs/contexts/MaskedAttributesContext/hooks.d.ts +7 -3
- package/cjs/contexts/MaskedAttributesContext/hooks.js +18 -9
- package/cjs/contexts/MaskedAttributesContext/index.d.ts +2 -13
- package/cjs/contexts/MaskedAttributesContext/index.js +7 -104
- package/cjs/contexts/index.d.ts +1 -1
- package/cjs/contexts/index.js +2 -3
- package/cjs/hooks/useMaskedAttribute.d.ts +1 -0
- package/cjs/hooks/useMaskedAttribute.js +19 -17
- package/esm/InlineSimpleAttribute/InlineSimpleAttribute.d.ts +1 -1
- package/esm/InlineSimpleAttribute/InlineSimpleAttribute.js +15 -4
- package/esm/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +98 -42
- package/esm/InlineSimpleAttribute/styles.d.ts +2 -1
- package/esm/InlineSimpleAttribute/styles.js +14 -5
- package/esm/MaskingSwitcher/MaskingSwitcher.d.ts +2 -1
- package/esm/MaskingSwitcher/MaskingSwitcher.js +5 -2
- package/esm/SimpleAttribute/SimpleAttribute.js +1 -1
- package/esm/contexts/MaskedAttributesContext/context.d.ts +18 -0
- package/esm/contexts/MaskedAttributesContext/context.js +114 -0
- package/esm/contexts/MaskedAttributesContext/hooks.d.ts +7 -3
- package/esm/contexts/MaskedAttributesContext/hooks.js +14 -6
- package/esm/contexts/MaskedAttributesContext/index.d.ts +2 -13
- package/esm/contexts/MaskedAttributesContext/index.js +2 -79
- package/esm/contexts/index.d.ts +1 -1
- package/esm/contexts/index.js +1 -1
- package/esm/hooks/useMaskedAttribute.d.ts +1 -0
- package/esm/hooks/useMaskedAttribute.js +20 -18
- package/package.json +1 -1
|
@@ -14,5 +14,5 @@ type Props = {
|
|
|
14
14
|
onIgnore: (event: IgnoreInlineAttributeEvent) => void;
|
|
15
15
|
isEmpty: boolean;
|
|
16
16
|
};
|
|
17
|
-
export declare const InlineSimpleAttribute: ({ className, dataReltioId, attributeType, attributeValue, crosswalk, disableEdit, disableDelete, onIgnore, onEdit, onPin, onDelete, isEmpty }: Props) => JSX.Element;
|
|
17
|
+
export declare const InlineSimpleAttribute: ({ className, dataReltioId, attributeType, attributeValue: rawAttributeValue, crosswalk, disableEdit, disableDelete, onIgnore, onEdit, onPin, onDelete, isEmpty }: Props) => JSX.Element;
|
|
18
18
|
export {};
|
|
@@ -43,10 +43,16 @@ var PinButton_1 = require("../PinButton");
|
|
|
43
43
|
var CrosswalkMenuItem_1 = require("./components/CrosswalkMenuItem");
|
|
44
44
|
var useAttributeState_1 = require("../hooks/useAttributeState");
|
|
45
45
|
var CrosswalksDisplayContext_1 = require("../contexts/CrosswalksDisplayContext");
|
|
46
|
+
var useMaskedAttribute_1 = __importDefault(require("../hooks/useMaskedAttribute"));
|
|
47
|
+
var MaskingSwitcher_1 = require("../MaskingSwitcher");
|
|
46
48
|
var styles_1 = require("./styles");
|
|
47
49
|
var InlineSimpleAttribute = function (_a) {
|
|
48
|
-
var className = _a.className, dataReltioId = _a.dataReltioId, _b = _a.attributeType, attributeType = _b === void 0 ? null : _b,
|
|
50
|
+
var className = _a.className, dataReltioId = _a.dataReltioId, _b = _a.attributeType, attributeType = _b === void 0 ? null : _b, rawAttributeValue = _a.attributeValue, crosswalk = _a.crosswalk, disableEdit = _a.disableEdit, disableDelete = _a.disableDelete, onIgnore = _a.onIgnore, onEdit = _a.onEdit, onPin = _a.onPin, onDelete = _a.onDelete, isEmpty = _a.isEmpty;
|
|
49
51
|
var _c = (0, useAttributeState_1.useAttributeState)(), isReadingMode = _c.isReadingMode, isEditingMode = _c.isEditingMode, isHovered = _c.isHovered, onMouseEnter = _c.onMouseEnter, onMouseLeave = _c.onMouseLeave, setReadingMode = _c.setReadingMode, setEditingMode = _c.setEditingMode;
|
|
52
|
+
var _d = (0, useMaskedAttribute_1.default)({
|
|
53
|
+
attributeType: attributeType,
|
|
54
|
+
attributeValue: rawAttributeValue
|
|
55
|
+
}), isUnmaskingNeeded = _d.isUnmaskingNeeded, isMasked = _d.isMasked, toggleMasking = _d.toggleMasking, attributeValue = _d.attributeValue, isUnmasking = _d.isUnmasking, unmask = _d.unmask;
|
|
50
56
|
var containerRef = (0, react_1.useRef)();
|
|
51
57
|
var id = (0, mdm_sdk_1.getLastUriPart)(attributeValue.uri);
|
|
52
58
|
var crosswalkDisabled = (0, mdm_sdk_1.isCrosswalkDisabled)(crosswalk);
|
|
@@ -57,18 +63,20 @@ var InlineSimpleAttribute = function (_a) {
|
|
|
57
63
|
var hasBasicPermission = (0, mdm_sdk_1.checkBasicMetadataPermission)(mdm_sdk_1.MetadataPermissions.UPDATE, attributeType) && !disableEdit && canModifyAttribute;
|
|
58
64
|
var showPin = !isTemporary && ((!isReadingMode && hasBasicPermission) || attributeValue.pin);
|
|
59
65
|
var showIgnore = !isTemporary && ((!isReadingMode && hasBasicPermission) || attributeValue.ignored);
|
|
66
|
+
var showMaskingSwitcher = (isUnmaskingNeeded && !isTemporary && !isReadingMode) || isUnmasking;
|
|
60
67
|
(0, react_1.useEffect)(function () {
|
|
61
68
|
if (isTemporary && !isEmpty) {
|
|
62
69
|
setEditingMode();
|
|
63
70
|
}
|
|
64
71
|
}, [isEmpty]);
|
|
65
72
|
var color = (0, CrosswalksDisplayContext_1.useCrosswalkColor)(crosswalk);
|
|
66
|
-
var
|
|
73
|
+
var _e = (0, CrosswalksDisplayContext_1.useCrosswalkHighlight)(crosswalk), isHighlighted = _e.isHighlighted, isDimmed = _e.isDimmed, highlightCrosswalk = _e.highlightCrosswalk, removeHighlight = _e.removeHighlight;
|
|
67
74
|
var styles = (0, styles_1.useStyles)({
|
|
68
75
|
variant: crosswalkDisabled ? 'outlined' : 'filled',
|
|
69
76
|
opaque: !isDimmed,
|
|
70
77
|
fullyColored: isHighlighted,
|
|
71
|
-
color: isDimmed ? 'rgba(0, 0, 0, 0.12)' : color
|
|
78
|
+
color: isDimmed ? 'rgba(0, 0, 0, 0.12)' : color,
|
|
79
|
+
hasMasking: isUnmaskingNeeded
|
|
72
80
|
});
|
|
73
81
|
var actions = [
|
|
74
82
|
{
|
|
@@ -80,7 +88,9 @@ var InlineSimpleAttribute = function (_a) {
|
|
|
80
88
|
text: ui_i18n_1.default.text('Edit'),
|
|
81
89
|
icon: react_1.default.createElement(Edit_1.default, null),
|
|
82
90
|
tooltip: canEdit ? null : ui_i18n_1.default.text("You don't have permissions to edit"),
|
|
83
|
-
onClick: function () {
|
|
91
|
+
onClick: function () {
|
|
92
|
+
unmask().then(setEditingMode);
|
|
93
|
+
},
|
|
84
94
|
id: 'edit'
|
|
85
95
|
},
|
|
86
96
|
{
|
|
@@ -114,6 +124,7 @@ var InlineSimpleAttribute = function (_a) {
|
|
|
114
124
|
react_1.default.createElement("div", { className: styles.actions },
|
|
115
125
|
showPin && (react_1.default.createElement(PinButton_1.PinButton, { isPinned: attributeValue.pin, onClick: function () { return onPin({ attributeValue: attributeValue }); }, disabled: !hasBasicPermission })),
|
|
116
126
|
showIgnore && (react_1.default.createElement(IgnoreButton_1.IgnoreButton, { isIgnored: attributeValue.ignored, onClick: function () { return onIgnore({ attributeValue: attributeValue }); }, disabled: !hasBasicPermission })),
|
|
127
|
+
showMaskingSwitcher && (react_1.default.createElement(MaskingSwitcher_1.MaskingSwitcher, { className: styles.maskingControl, isMasked: isMasked, onToggleMasking: toggleMasking, isUnmasking: isUnmasking })),
|
|
117
128
|
isHovered && !(0, mdm_sdk_1.isAutoGeneratedAttribute)(attributeType) && (react_1.default.createElement(DropDownMenuButton_1.DropDownMenuButton, { MenuItemRenderer: CrosswalkMenuItem_1.CrosswalkMenuItem, menuId: "simple-attribute-additional-actions-".concat(id), buttonComponent: SmallIconButton_1.SmallIconButtonWithTooltip, buttonProps: {
|
|
118
129
|
icon: MoreVert_1.default,
|
|
119
130
|
size: 'XS',
|
|
@@ -33,6 +33,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
33
|
__setModuleDefault(result, mod);
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
36
72
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
73
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
74
|
};
|
|
@@ -315,48 +351,68 @@ describe('Inline simple attribute tests', function () {
|
|
|
315
351
|
attributeValue: value
|
|
316
352
|
});
|
|
317
353
|
});
|
|
318
|
-
it('should render InlineSimpleAttributeEditor on Edit menu item click', function () {
|
|
319
|
-
var props
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
354
|
+
it('should render InlineSimpleAttributeEditor on Edit menu item click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
355
|
+
var props, wrapper, onMouseEnter, actionItems;
|
|
356
|
+
return __generator(this, function (_a) {
|
|
357
|
+
switch (_a.label) {
|
|
358
|
+
case 0:
|
|
359
|
+
props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
|
|
360
|
+
wrapper = setUp(props);
|
|
361
|
+
onMouseEnter = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter');
|
|
362
|
+
(0, test_utils_1.act)(function () {
|
|
363
|
+
onMouseEnter();
|
|
364
|
+
});
|
|
365
|
+
wrapper.update();
|
|
366
|
+
actionItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
|
|
367
|
+
(0, test_utils_1.act)(function () {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
(_b = (_a = actionItems[1]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
370
|
+
});
|
|
371
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
372
|
+
case 1:
|
|
373
|
+
_a.sent();
|
|
374
|
+
wrapper.update();
|
|
375
|
+
expect(wrapper.find(InlineSimpleAttributeEditor_1.InlineSimpleAttributeEditor)).toHaveLength(1);
|
|
376
|
+
return [2 /*return*/];
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}); });
|
|
380
|
+
it('should call props.onEdit when call onEdit prop of InlineSimpleAttributeEditor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
381
|
+
var props, wrapper, event, actionItems, newAttributeValue;
|
|
382
|
+
return __generator(this, function (_a) {
|
|
383
|
+
switch (_a.label) {
|
|
384
|
+
case 0:
|
|
385
|
+
props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
|
|
386
|
+
wrapper = setUp(props);
|
|
387
|
+
event = {};
|
|
388
|
+
(0, test_utils_1.act)(function () {
|
|
389
|
+
var _a;
|
|
390
|
+
(_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
|
|
391
|
+
});
|
|
392
|
+
wrapper.update();
|
|
393
|
+
actionItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
|
|
394
|
+
(0, test_utils_1.act)(function () {
|
|
395
|
+
var _a, _b;
|
|
396
|
+
(_b = (_a = actionItems[1]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
397
|
+
});
|
|
398
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
399
|
+
case 1:
|
|
400
|
+
_a.sent();
|
|
401
|
+
wrapper.update();
|
|
402
|
+
newAttributeValue = {
|
|
403
|
+
uri: 'entities/123/attributes/String/123',
|
|
404
|
+
value: 'Test update'
|
|
405
|
+
};
|
|
406
|
+
wrapper.find(InlineSimpleAttributeEditor_1.InlineSimpleAttributeEditor).prop('onEdit')(newAttributeValue);
|
|
407
|
+
expect(actions.onEdit).toBeCalledWith({
|
|
408
|
+
attributeType: attributeType,
|
|
409
|
+
attributeValue: newAttributeValue,
|
|
410
|
+
crosswalk: crosswalk
|
|
411
|
+
});
|
|
412
|
+
return [2 /*return*/];
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}); });
|
|
360
416
|
it('should disable edit, pin, delete and ignore actions if it is system attribute', function () {
|
|
361
417
|
var props = __assign({ attributeValue: value, attributeType: __assign(__assign({}, attributeType), { system: true }), crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
|
|
362
418
|
var wrapper = setUp(props);
|
|
@@ -3,6 +3,7 @@ type StylesProps = {
|
|
|
3
3
|
fullyColored: boolean;
|
|
4
4
|
opaque: boolean;
|
|
5
5
|
color: string;
|
|
6
|
+
hasMasking: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"attributeValue" | "root" | "actions">;
|
|
8
|
+
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"attributeValue" | "root" | "actions" | "maskingControl">;
|
|
8
9
|
export {};
|
|
@@ -47,10 +47,19 @@ exports.useStyles = (0, styles_1.makeStyles)(function () { return ({
|
|
|
47
47
|
lineHeight: '14px',
|
|
48
48
|
width: 'calc(100% - 71px)'
|
|
49
49
|
},
|
|
50
|
-
actions: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
actions: function (_a) {
|
|
51
|
+
var hasMasking = _a.hasMasking;
|
|
52
|
+
return ({
|
|
53
|
+
display: 'flex',
|
|
54
|
+
width: "".concat(71 + (hasMasking ? 20 : 0), "px"),
|
|
55
|
+
justifyContent: 'flex-end',
|
|
56
|
+
marginRight: '4px'
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
maskingControl: {
|
|
60
|
+
flexShrink: 0,
|
|
61
|
+
marginLeft: '2px',
|
|
62
|
+
height: '20px !important', // important to override inline circular progress styles
|
|
63
|
+
width: '20px !important'
|
|
55
64
|
}
|
|
56
65
|
}); });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type MaskingSwitcherProps = {
|
|
2
|
+
className?: string;
|
|
2
3
|
isMasked: boolean;
|
|
3
4
|
isUnmasking?: boolean;
|
|
4
5
|
onToggleMasking: () => void;
|
|
5
6
|
};
|
|
6
|
-
export declare const MaskingSwitcher: ({ isMasked, isUnmasking, onToggleMasking }: MaskingSwitcherProps) => JSX.Element;
|
|
7
|
+
export declare const MaskingSwitcher: ({ className, isMasked, isUnmasking, onToggleMasking }: MaskingSwitcherProps) => JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MaskingSwitcher = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
8
9
|
var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
|
|
9
10
|
var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
|
|
10
11
|
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
@@ -13,8 +14,10 @@ var CircularProgress_1 = __importDefault(require("@mui/material/CircularProgress
|
|
|
13
14
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
14
15
|
var styles_1 = require("./styles");
|
|
15
16
|
var MaskingSwitcher = function (_a) {
|
|
16
|
-
var isMasked = _a.isMasked, isUnmasking = _a.isUnmasking, onToggleMasking = _a.onToggleMasking;
|
|
17
|
+
var className = _a.className, isMasked = _a.isMasked, isUnmasking = _a.isUnmasking, onToggleMasking = _a.onToggleMasking;
|
|
17
18
|
var styles = (0, styles_1.useStyles)();
|
|
18
|
-
|
|
19
|
+
var tooltipTitle = isMasked ? ui_i18n_1.default.text('Show') : ui_i18n_1.default.text('Hide');
|
|
20
|
+
return isUnmasking ? (react_1.default.createElement(CircularProgress_1.default, { size: 16, className: (0, classnames_1.default)(className, styles.switcherWrapper) })) : (react_1.default.createElement(Tooltip_1.default, { key: String(isMasked), title: tooltipTitle },
|
|
21
|
+
react_1.default.createElement(IconButton_1.default, { "aria-label": tooltipTitle, onClick: onToggleMasking, className: (0, classnames_1.default)(className, styles.switcherWrapper) }, isMasked ? react_1.default.createElement(Visibility_1.default, { className: styles.icon }) : react_1.default.createElement(VisibilityOff_1.default, { className: styles.icon }))));
|
|
19
22
|
};
|
|
20
23
|
exports.MaskingSwitcher = MaskingSwitcher;
|
|
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.SimpleAttribute = void 0;
|
|
30
30
|
var react_1 = __importStar(require("react"));
|
|
31
31
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
32
|
-
var MaskingSwitcher_1 = require("../MaskingSwitcher");
|
|
33
32
|
var classnames_1 = __importDefault(require("classnames"));
|
|
34
33
|
var useMaskedAttribute_1 = __importDefault(require("../hooks/useMaskedAttribute"));
|
|
35
34
|
var classnames_2 = require("../constants/classnames");
|
|
@@ -39,6 +38,7 @@ var CommentsContainer_1 = require("../CommentsContainer");
|
|
|
39
38
|
var DataTypeValue_1 = require("../DataTypeValue");
|
|
40
39
|
var PivotingTooltip_1 = require("../PivotingTooltip");
|
|
41
40
|
var styles_1 = require("./styles");
|
|
41
|
+
var MaskingSwitcher_1 = require("../MaskingSwitcher");
|
|
42
42
|
var SimpleAttribute = function (_a) {
|
|
43
43
|
var _b, _c, _d, _e, _f;
|
|
44
44
|
var className = _a.className, _g = _a.attributeType, attributeType = _g === void 0 ? null : _g, rawAttributeValue = _a.attributeValue, inlined = _a.inlined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
|
+
type UnmaskedAttributes = Record<string, {
|
|
4
|
+
attributeValue?: SimpleAttributeValue;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
isUnmasked?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
export type MaskedAttributesContextType = {
|
|
9
|
+
unmaskedAttributes: UnmaskedAttributes;
|
|
10
|
+
unmaskAttributeValue: (attributeValueUri: string) => Promise<SimpleAttributeValue>;
|
|
11
|
+
maskAttributeValue: (attributeValueUri: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const MaskedAttributesContext: import("@fluentui/react-context-selector").Context<MaskedAttributesContextType>;
|
|
14
|
+
type Props = {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const MaskedAttributesProvider: ({ children }: Props) => JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
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;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.MaskedAttributesProvider = exports.MaskedAttributesContext = void 0;
|
|
74
|
+
var react_1 = __importStar(require("react"));
|
|
75
|
+
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
76
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
77
|
+
var core_1 = require("../../core");
|
|
78
|
+
var MdmModuleContext_1 = require("../MdmModuleContext");
|
|
79
|
+
exports.MaskedAttributesContext = (0, react_context_selector_1.createContext)({
|
|
80
|
+
unmaskedAttributes: {},
|
|
81
|
+
unmaskAttributeValue: undefined,
|
|
82
|
+
maskAttributeValue: undefined
|
|
83
|
+
});
|
|
84
|
+
var MaskedAttributesProvider = function (_a) {
|
|
85
|
+
var children = _a.children;
|
|
86
|
+
var _b = (0, react_1.useState)({}), unmaskedAttributes = _b[0], setUnmaskedAttributes = _b[1];
|
|
87
|
+
var profileLastLoadedTime = (0, MdmModuleContext_1.useMdmProfileLastLoadedTime)();
|
|
88
|
+
var unmaskedAttributesRef = (0, react_1.useRef)(unmaskedAttributes);
|
|
89
|
+
//performance optimization to avoid unnecessary re-renders
|
|
90
|
+
unmaskedAttributesRef.current = unmaskedAttributes;
|
|
91
|
+
(0, react_1.useEffect)(function () {
|
|
92
|
+
setUnmaskedAttributes({});
|
|
93
|
+
}, [profileLastLoadedTime]);
|
|
94
|
+
var unmaskAttributeValue = (0, react_1.useCallback)(function (attributeValueUri) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
var unmaskedAttributes_1, unmaskedAttributeValue_1, error_1;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
_a.trys.push([0, 4, , 5]);
|
|
100
|
+
unmaskedAttributes_1 = unmaskedAttributesRef.current;
|
|
101
|
+
if (!!unmaskedAttributes_1[attributeValueUri]) return [3 /*break*/, 2];
|
|
102
|
+
setUnmaskedAttributes(function (prev) {
|
|
103
|
+
var _a;
|
|
104
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { loading: true }), _a)));
|
|
105
|
+
});
|
|
106
|
+
return [4 /*yield*/, (0, mdm_sdk_1.getUnmaskedAttributeValue)(attributeValueUri)];
|
|
107
|
+
case 1:
|
|
108
|
+
unmaskedAttributeValue_1 = _a.sent();
|
|
109
|
+
setUnmaskedAttributes(function (prev) {
|
|
110
|
+
var _a;
|
|
111
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = {
|
|
112
|
+
attributeValue: unmaskedAttributeValue_1,
|
|
113
|
+
isUnmasked: true,
|
|
114
|
+
loading: false
|
|
115
|
+
}, _a)));
|
|
116
|
+
});
|
|
117
|
+
return [2 /*return*/, unmaskedAttributeValue_1];
|
|
118
|
+
case 2:
|
|
119
|
+
setUnmaskedAttributes(function (prev) {
|
|
120
|
+
var _a;
|
|
121
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { isUnmasked: true }), _a)));
|
|
122
|
+
});
|
|
123
|
+
return [2 /*return*/, unmaskedAttributes_1[attributeValueUri].attributeValue];
|
|
124
|
+
case 3: return [3 /*break*/, 5];
|
|
125
|
+
case 4:
|
|
126
|
+
error_1 = _a.sent();
|
|
127
|
+
(0, core_1.showErrorMessage)(error_1);
|
|
128
|
+
return [2 /*return*/, null];
|
|
129
|
+
case 5: return [2 /*return*/];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); }, []);
|
|
133
|
+
var maskAttributeValue = (0, react_1.useCallback)(function (attributeValueUri) {
|
|
134
|
+
setUnmaskedAttributes(function (prev) {
|
|
135
|
+
var _a;
|
|
136
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { isUnmasked: false }), _a)));
|
|
137
|
+
});
|
|
138
|
+
}, []);
|
|
139
|
+
return (react_1.default.createElement(exports.MaskedAttributesContext.Provider, { value: { unmaskedAttributes: unmaskedAttributes, unmaskAttributeValue: unmaskAttributeValue, maskAttributeValue: maskAttributeValue } }, children));
|
|
140
|
+
};
|
|
141
|
+
exports.MaskedAttributesProvider = MaskedAttributesProvider;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const useUnmaskedAttributeValue: (attributeValueUri: string) => {
|
|
2
|
+
attributeValue?: import("@reltio/mdm-sdk").SimpleAttributeValue;
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
isUnmasked?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const useUnmaskAttributeValue: () => (attributeValueUri: string) => Promise<import("@reltio/mdm-sdk").SimpleAttributeValue>;
|
|
7
|
+
export declare const useMaskAttributeValue: () => (attributeValueUri: string) => void;
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useMaskAttributeValue = exports.useUnmaskAttributeValue = exports.useUnmaskedAttributeValue = void 0;
|
|
4
4
|
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
5
|
-
var
|
|
5
|
+
var context_1 = require("./context");
|
|
6
6
|
var useMaskedAttributesContext = function (selector) {
|
|
7
|
-
return (0, react_context_selector_1.useContextSelector)(
|
|
7
|
+
return (0, react_context_selector_1.useContextSelector)(context_1.MaskedAttributesContext, selector);
|
|
8
8
|
};
|
|
9
|
-
var useUnmaskedAttributeValue = function (
|
|
10
|
-
return useMaskedAttributesContext(function (
|
|
11
|
-
|
|
9
|
+
var useUnmaskedAttributeValue = function (attributeValueUri) {
|
|
10
|
+
return useMaskedAttributesContext(function (_a) {
|
|
11
|
+
var unmaskedAttributes = _a.unmaskedAttributes;
|
|
12
|
+
return unmaskedAttributes[attributeValueUri];
|
|
12
13
|
});
|
|
13
14
|
};
|
|
14
15
|
exports.useUnmaskedAttributeValue = useUnmaskedAttributeValue;
|
|
15
|
-
var
|
|
16
|
-
return useMaskedAttributesContext(function (
|
|
16
|
+
var useUnmaskAttributeValue = function () {
|
|
17
|
+
return useMaskedAttributesContext(function (_a) {
|
|
18
|
+
var unmaskAttributeValue = _a.unmaskAttributeValue;
|
|
19
|
+
return unmaskAttributeValue;
|
|
20
|
+
});
|
|
17
21
|
};
|
|
18
|
-
exports.
|
|
22
|
+
exports.useUnmaskAttributeValue = useUnmaskAttributeValue;
|
|
23
|
+
var useMaskAttributeValue = function () { return useMaskedAttributesContext(function (_a) {
|
|
24
|
+
var maskAttributeValue = _a.maskAttributeValue;
|
|
25
|
+
return maskAttributeValue;
|
|
26
|
+
}); };
|
|
27
|
+
exports.useMaskAttributeValue = useMaskAttributeValue;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type UnmaskedAttributesValues = Record<string, SimpleAttributeValue>;
|
|
4
|
-
export type MaskedAttributesContextType = {
|
|
5
|
-
unmaskedAttributesValues: UnmaskedAttributesValues;
|
|
6
|
-
addUnmaskedAttributeValue: (attributeValue: SimpleAttributeValue) => Promise<void>;
|
|
7
|
-
};
|
|
8
|
-
export declare const MaskedAttributesContext: import("@fluentui/react-context-selector").Context<MaskedAttributesContextType>;
|
|
9
|
-
type Props = {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
};
|
|
12
|
-
export declare const MaskedAttributesProvider: ({ children }: Props) => JSX.Element;
|
|
13
|
-
export {};
|
|
1
|
+
export { MaskedAttributesProvider } from './context';
|
|
2
|
+
export { useUnmaskedAttributeValue, useUnmaskAttributeValue, useMaskAttributeValue } from './hooks';
|