@reltio/components 1.4.2183 → 1.4.2185
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/CollaborationItem/components/SendMessageArea/styles.d.ts +1 -1
- package/DateRangeEditor/styles.d.ts +1 -1
- package/DependentLookupEditor/styles.d.ts +1 -1
- package/DropDownSelector/DropDownSelector.d.ts +28 -35
- package/DropDownSelector/DropDownSelector.js +3 -20
- package/DropDownSelector/DropDownSelector.test.js +17 -0
- package/DropDownSelector/components/Menu/Menu.d.ts +16 -9
- package/DropDownSelector/components/Menu/Menu.js +2 -7
- package/DropDownSelector/styles.d.ts +1 -1
- package/EntitySelector/EntitySelector.js +24 -4
- package/EntitySelector/components/Group/Group.d.ts +18 -10
- package/EntitySelector/components/Group/Group.js +8 -9
- package/HOCs/withReactSelectMuiSkin/styles.d.ts +1 -1
- package/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/HierarchyNodeTitle/useEntityDetails.js +8 -4
- package/HierarchyNodeTitle/useEntityDetails.test.js +24 -9
- package/MetadataTypesSelector/styles.d.ts +1 -1
- package/MultiSelect/styles.d.ts +1 -1
- package/ProfileCard/components/ProfileCardPlaceholder/styles.d.ts +1 -1
- package/ReactSortableTree/components/NodeRendererDefault/NodeRendererDefault.d.ts +2 -2
- package/RelationEditor/RelationEditor.js +5 -7
- package/RelationEditor/RelationEditor.test.js +40 -0
- package/cjs/CollaborationItem/components/SendMessageArea/styles.d.ts +1 -1
- package/cjs/DateRangeEditor/styles.d.ts +1 -1
- package/cjs/DependentLookupEditor/styles.d.ts +1 -1
- package/cjs/DropDownSelector/DropDownSelector.d.ts +28 -35
- package/cjs/DropDownSelector/DropDownSelector.js +4 -21
- package/cjs/DropDownSelector/DropDownSelector.test.js +17 -0
- package/cjs/DropDownSelector/components/Menu/Menu.d.ts +16 -9
- package/cjs/DropDownSelector/components/Menu/Menu.js +2 -7
- package/cjs/DropDownSelector/styles.d.ts +1 -1
- package/cjs/EntitySelector/EntitySelector.js +23 -3
- package/cjs/EntitySelector/components/Group/Group.d.ts +18 -10
- package/cjs/EntitySelector/components/Group/Group.js +8 -9
- package/cjs/HOCs/withReactSelectMuiSkin/styles.d.ts +1 -1
- package/cjs/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/cjs/HierarchyNodeTitle/useEntityDetails.js +6 -2
- package/cjs/HierarchyNodeTitle/useEntityDetails.test.js +27 -9
- package/cjs/MetadataTypesSelector/styles.d.ts +1 -1
- package/cjs/MultiSelect/styles.d.ts +1 -1
- package/cjs/ProfileCard/components/ProfileCardPlaceholder/styles.d.ts +1 -1
- package/cjs/ReactSortableTree/components/NodeRendererDefault/NodeRendererDefault.d.ts +2 -2
- package/cjs/RelationEditor/RelationEditor.js +5 -7
- package/cjs/RelationEditor/RelationEditor.test.js +40 -0
- package/cjs/features/history/hooks/useHistorySlice.js +1 -1
- package/cjs/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/features/workflow/WorkflowComments/styles.d.ts +1 -1
- package/features/history/hooks/useHistorySlice.js +1 -1
- package/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/features/workflow/WorkflowComments/styles.d.ts +1 -1
- package/package.json +2 -2
|
@@ -183,12 +183,10 @@ var RelationEditor = function (_a) {
|
|
|
183
183
|
setModifiedEntity(newEntity);
|
|
184
184
|
}, [setModifiedEntity, onChangeEntity, mode, metadata]);
|
|
185
185
|
var errorMessage = getErrorMessage(error);
|
|
186
|
-
var
|
|
187
|
-
var _a
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
return content.entityTypes;
|
|
186
|
+
var entityTypesUris = useMemo(function () {
|
|
187
|
+
var _a;
|
|
188
|
+
var _b = config, content = _b.content, contentSecondLevel = _b.contentSecondLevel;
|
|
189
|
+
return ((_a = (contentSecondLevel && connection.parentEntityUri ? contentSecondLevel.entityTypes : content.entityTypes)) !== null && _a !== void 0 ? _a : []);
|
|
192
190
|
}, [config, connection.parentEntityUri]);
|
|
193
191
|
var isEntityHasMaskedAttrValue = pipe(values, flatten, any(isAttributeHasMaskedValue))(((_d = (_c = connection.entity) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.attributes) || {});
|
|
194
192
|
var isMasked = showMasking && isEntityHasMaskedAttrValue;
|
|
@@ -203,7 +201,7 @@ var RelationEditor = function (_a) {
|
|
|
203
201
|
React.createElement(EntitySelector, { className: classnames(styles.item, (_b = {},
|
|
204
202
|
_b[styles.dense] = errorMessage ||
|
|
205
203
|
(connection.entity && isTempUri(connection.entity.entityUri)),
|
|
206
|
-
_b)), entity: connection.entity || {}, entityTypesUris:
|
|
204
|
+
_b)), entity: connection.entity || {}, entityTypesUris: entityTypesUris, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: relationEditorAttributeTypesSelectionStrategy, isMasked: isMasked })))),
|
|
207
205
|
React.createElement(HiddenAttributesContext.Provider, { value: emptyHiddenAttributes },
|
|
208
206
|
React.createElement(EditModeAttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute }))))),
|
|
209
207
|
React.createElement("div", { className: styles.actionButtons },
|
|
@@ -48,6 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import React from 'react';
|
|
49
49
|
import { screen, render, within } from '@testing-library/react';
|
|
50
50
|
import userEvent from '@testing-library/user-event';
|
|
51
|
+
import { assocPath, pipe } from 'ramda';
|
|
51
52
|
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
|
|
52
53
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
53
54
|
import { Mode, ScreenType, ProfileViewType, typeAheadSearch, ErrorType, ActivityFilter, ErrorSource, ErrorSeverity } from '@reltio/mdm-sdk';
|
|
@@ -478,6 +479,45 @@ describe('relation editor behaviour', function () {
|
|
|
478
479
|
}
|
|
479
480
|
});
|
|
480
481
|
}); });
|
|
482
|
+
it('should hide create button when user lacks metadata permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
483
|
+
var props, user, inputs;
|
|
484
|
+
return __generator(this, function (_a) {
|
|
485
|
+
switch (_a.label) {
|
|
486
|
+
case 0:
|
|
487
|
+
props = assocPath(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST'], defaultProps);
|
|
488
|
+
user = setUp({ props: props }).user;
|
|
489
|
+
inputs = screen.getAllByRole('combobox');
|
|
490
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
491
|
+
case 1:
|
|
492
|
+
_a.sent();
|
|
493
|
+
expect(screen.queryByText('Create new Address')).not.toBeInTheDocument();
|
|
494
|
+
return [2 /*return*/];
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}); });
|
|
498
|
+
it('should hide create button for one of the entity types when user lacks metadata permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
499
|
+
var props, user, inputs;
|
|
500
|
+
return __generator(this, function (_a) {
|
|
501
|
+
switch (_a.label) {
|
|
502
|
+
case 0:
|
|
503
|
+
props = pipe(assocPath(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST']), assocPath(['config', 'content'], {
|
|
504
|
+
entityTypes: ['configuration/entityTypes/Location', 'configuration/entityTypes/HCA'],
|
|
505
|
+
outRelations: [
|
|
506
|
+
{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' },
|
|
507
|
+
{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }
|
|
508
|
+
]
|
|
509
|
+
}))(defaultProps);
|
|
510
|
+
user = setUp({ props: props }).user;
|
|
511
|
+
inputs = screen.getAllByRole('combobox');
|
|
512
|
+
return [4 /*yield*/, user.click(inputs[1])];
|
|
513
|
+
case 1:
|
|
514
|
+
_a.sent();
|
|
515
|
+
expect(screen.queryByText('Create new Address')).not.toBeInTheDocument();
|
|
516
|
+
expect(screen.getByText('Create new HCA')).toBeInTheDocument();
|
|
517
|
+
return [2 /*return*/];
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}); });
|
|
481
521
|
it('should show "create entity" button if mode is suggesting, but main entity uri is not temporary', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
482
522
|
var props, mdmValues, user, inputs;
|
|
483
523
|
return __generator(this, function (_a) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type StylesProps = {
|
|
2
2
|
isEditing?: boolean;
|
|
3
3
|
};
|
|
4
|
-
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"button" | "form" | "main" | "root" | "
|
|
4
|
+
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"button" | "form" | "main" | "root" | "avatar" | "textField" | "buttons">;
|
|
5
5
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"underline" | "uppercase" | "dropdownIndicator" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"underline" | "uppercase" | "dropdownIndicator" | "inputLabel" | "adornedEnd" | "inputRoot">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"placeholder" | "option" | "dropdownIndicator" | "
|
|
1
|
+
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"placeholder" | "option" | "dropdownIndicator" | "clearIndicator" | "isCrossedOut">;
|
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
options
|
|
1
|
+
import React, { ForwardedRef } from 'react';
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
import { PrimitiveValue } from '@reltio/mdm-sdk';
|
|
4
|
+
type Props<T> = {
|
|
5
|
+
value?: T;
|
|
6
|
+
label: string;
|
|
7
|
+
options?: T[];
|
|
8
|
+
getOptions?: (inputValue: string) => Promise<void | T[]>;
|
|
9
|
+
onChange?: (value: T) => void;
|
|
10
|
+
onCreate?: (value: PrimitiveValue, group?: string) => void;
|
|
11
|
+
onClear?: () => void;
|
|
12
|
+
createLabel?: string;
|
|
13
|
+
canCreateOption?: (id?: string) => boolean;
|
|
14
|
+
components?: {
|
|
15
|
+
Group?: React.ElementType;
|
|
16
|
+
ClearIndicator?: React.ElementType;
|
|
17
|
+
Option?: React.ElementType;
|
|
18
|
+
GroupHeading?: React.ElementType;
|
|
19
|
+
SingleValue?: React.ElementType;
|
|
20
|
+
[key: string]: React.ElementType;
|
|
21
|
+
};
|
|
22
|
+
textFieldInputRef?: ForwardedRef<HTMLInputElement>;
|
|
23
|
+
TextFieldProps?: TextFieldProps;
|
|
8
24
|
height?: number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
TextFieldProps: any;
|
|
15
|
-
classes: any;
|
|
16
|
-
}): React.JSX.Element;
|
|
17
|
-
export namespace DropDownSelector {
|
|
18
|
-
export { DropDownSelectorType as propTypes };
|
|
19
|
-
}
|
|
20
|
-
export namespace DropDownSelectorType {
|
|
21
|
-
let value: PropTypes.Requireable<object>;
|
|
22
|
-
let label: PropTypes.Validator<string>;
|
|
23
|
-
let getOptions: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
-
let options: PropTypes.Requireable<any[]>;
|
|
25
|
-
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
26
|
-
let onCreate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
let onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
-
let createLabel: PropTypes.Requireable<string>;
|
|
29
|
-
let components: PropTypes.Requireable<object>;
|
|
30
|
-
let textFieldInputRef: PropTypes.Requireable<object>;
|
|
31
|
-
let TextFieldProps: PropTypes.Requireable<object>;
|
|
32
|
-
let height: PropTypes.Requireable<number>;
|
|
33
|
-
let classes: PropTypes.Requireable<object>;
|
|
34
|
-
}
|
|
35
|
-
import React from 'react';
|
|
36
|
-
import PropTypes from 'prop-types';
|
|
25
|
+
classes?: Record<string, string>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
export declare const DropDownSelector: <T>({ value, label, options, getOptions, createLabel, height, onChange, onCreate, canCreateOption, onClear, components, textFieldInputRef, TextFieldProps, classes, ...otherProps }: Props<T>) => React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -48,9 +48,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.
|
|
51
|
+
exports.DropDownSelector = void 0;
|
|
52
52
|
var react_1 = __importStar(require("react"));
|
|
53
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
54
53
|
var classnames_1 = __importDefault(require("classnames"));
|
|
55
54
|
var ramda_1 = require("ramda");
|
|
56
55
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
@@ -63,9 +62,9 @@ var SingleValue_1 = require("./components/SingleValue");
|
|
|
63
62
|
var styles_1 = require("./styles");
|
|
64
63
|
var DropDownSelector = function (_a) {
|
|
65
64
|
var _b;
|
|
66
|
-
var value = _a.value, label = _a.label,
|
|
65
|
+
var value = _a.value, label = _a.label, options = _a.options, getOptions = _a.getOptions, createLabel = _a.createLabel, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.onChange, onChange = _d === void 0 ? ramda_1.identity : _d, onCreate = _a.onCreate, _e = _a.canCreateOption, canCreateOption = _e === void 0 ? function () { return Boolean(onCreate); } : _e, _f = _a.onClear, onClear = _f === void 0 ? ramda_1.identity : _f, _g = _a.components, components = _g === void 0 ? {} : _g, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, _h = _a.classes, classes = _h === void 0 ? {} : _h, otherProps = __rest(_a, ["value", "label", "options", "getOptions", "createLabel", "height", "onChange", "onCreate", "canCreateOption", "onClear", "components", "textFieldInputRef", "TextFieldProps", "classes"]);
|
|
67
66
|
var styles = (0, styles_1.useStyles)({ height: height });
|
|
68
|
-
var
|
|
67
|
+
var _j = (0, react_1.useState)(false), open = _j[0], setOpen = _j[1];
|
|
69
68
|
var inputRef = (0, react_1.useRef)(null);
|
|
70
69
|
var SelectComponent = getOptions ? AsyncReactSelect_1.AsyncReactSelect : ReactSelect_1.ReactSelect;
|
|
71
70
|
var showIndicatorSeparator = (0, ramda_1.prop)('ClearIndicator', components)
|
|
@@ -81,22 +80,6 @@ var DropDownSelector = function (_a) {
|
|
|
81
80
|
var overloadStylesIfNoLabel = (0, ramda_1.isEmpty)(label) ? styles_1.withoutLabelInputStyle : {};
|
|
82
81
|
var mergedStyles = __assign(__assign(__assign({}, styles_1.customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
|
|
83
82
|
var mergedClasses = __assign(__assign({}, styles), classes);
|
|
84
|
-
return (react_1.default.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: (0, ramda_1.defaultTo)(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, classes: mergedClasses, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: ReactSelectDropdownIndicator_1.ReactSelectDropdownIndicator, LoadingIndicator: EmptyStub_1.EmptyStub, SingleValue: SingleValue_1.SingleValue, Menu: Menu_1.Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', size: 'small', classes: __assign(__assign({}, (0, ramda_1.prop)('classes', TextFieldProps)), { root: (0, classnames_1.default)(styles.formControl, (0, ramda_1.path)(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, (0, ramda_1.prop)('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, (0, ramda_1.prop)('InputProps', TextFieldProps)), { classes: __assign(__assign({}, (0, ramda_1.path)(['InputProps', 'classes'], TextFieldProps)), { root: (0, classnames_1.default)(styles.filledInputRoot, (0, ramda_1.path)(['InputProps', 'classes', 'root'], TextFieldProps)), underline: (0, classnames_1.default)((_b = {}, _b[styles.filledInputUnderline] = (0, mdm_sdk_1.isEmptyValue)(value), _b), (0, ramda_1.path)(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: (0, classnames_1.default)('focused', (0, ramda_1.path)(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, (0, ramda_1.prop)('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, (0, ramda_1.path)(['InputLabelProps', 'classes'], TextFieldProps)), { root: (0, classnames_1.default)(styles.inputLabel, (0, ramda_1.path)(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: (0, classnames_1.default)('shrink', (0, ramda_1.path)(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !(0, mdm_sdk_1.isEmptyValue)(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
|
|
83
|
+
return (react_1.default.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: (0, ramda_1.defaultTo)(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, canCreateOption: canCreateOption, classes: mergedClasses, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: ReactSelectDropdownIndicator_1.ReactSelectDropdownIndicator, LoadingIndicator: EmptyStub_1.EmptyStub, SingleValue: SingleValue_1.SingleValue, Menu: Menu_1.Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', size: 'small', classes: __assign(__assign({}, (0, ramda_1.prop)('classes', TextFieldProps)), { root: (0, classnames_1.default)(styles.formControl, (0, ramda_1.path)(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, (0, ramda_1.prop)('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, (0, ramda_1.prop)('InputProps', TextFieldProps)), { classes: __assign(__assign({}, (0, ramda_1.path)(['InputProps', 'classes'], TextFieldProps)), { root: (0, classnames_1.default)(styles.filledInputRoot, (0, ramda_1.path)(['InputProps', 'classes', 'root'], TextFieldProps)), underline: (0, classnames_1.default)((_b = {}, _b[styles.filledInputUnderline] = (0, mdm_sdk_1.isEmptyValue)(value), _b), (0, ramda_1.path)(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: (0, classnames_1.default)('focused', (0, ramda_1.path)(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, (0, ramda_1.prop)('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, (0, ramda_1.path)(['InputLabelProps', 'classes'], TextFieldProps)), { root: (0, classnames_1.default)(styles.inputLabel, (0, ramda_1.path)(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: (0, classnames_1.default)('shrink', (0, ramda_1.path)(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !(0, mdm_sdk_1.isEmptyValue)(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
|
|
85
84
|
};
|
|
86
85
|
exports.DropDownSelector = DropDownSelector;
|
|
87
|
-
exports.DropDownSelectorType = {
|
|
88
|
-
value: prop_types_1.default.oneOfType([prop_types_1.default.object, prop_types_1.default.array]),
|
|
89
|
-
label: prop_types_1.default.string.isRequired,
|
|
90
|
-
getOptions: prop_types_1.default.func,
|
|
91
|
-
options: prop_types_1.default.array,
|
|
92
|
-
onChange: prop_types_1.default.func,
|
|
93
|
-
onCreate: prop_types_1.default.func,
|
|
94
|
-
onClear: prop_types_1.default.func,
|
|
95
|
-
createLabel: prop_types_1.default.string,
|
|
96
|
-
components: prop_types_1.default.object,
|
|
97
|
-
textFieldInputRef: prop_types_1.default.object,
|
|
98
|
-
TextFieldProps: prop_types_1.default.object,
|
|
99
|
-
height: prop_types_1.default.number,
|
|
100
|
-
classes: prop_types_1.default.object
|
|
101
|
-
};
|
|
102
|
-
exports.DropDownSelector.propTypes = exports.DropDownSelectorType;
|
|
@@ -53,6 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
var react_1 = __importDefault(require("react"));
|
|
54
54
|
var react_2 = require("@testing-library/react");
|
|
55
55
|
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
|
+
var test_utils_1 = require("../test-utils");
|
|
56
57
|
var DropDownSelector_1 = require("./DropDownSelector");
|
|
57
58
|
var defaultOptions = [
|
|
58
59
|
{ label: 'First option', value: 'option1' },
|
|
@@ -164,4 +165,20 @@ describe('Dropdown selector tests', function () {
|
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
167
|
}); });
|
|
168
|
+
it('should not show create button if canCreateOption is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var props, user;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
props = __assign(__assign({}, defaultProps), { canCreateOption: function () { return false; }, createLabel: 'Create new option' });
|
|
174
|
+
user = setUp(props).user;
|
|
175
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('combobox'))];
|
|
176
|
+
case 1:
|
|
177
|
+
_a.sent();
|
|
178
|
+
expect(react_2.screen.queryByText('Create new option')).not.toBeInTheDocument();
|
|
179
|
+
expect((0, test_utils_1.getMuiIconByName)('Add')).not.toBeInTheDocument();
|
|
180
|
+
return [2 /*return*/];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}); });
|
|
167
184
|
});
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
selectProps: {
|
|
4
|
+
createLabel?: string;
|
|
5
|
+
canCreateOption: () => boolean;
|
|
6
|
+
inputValue: string;
|
|
7
|
+
components?: {
|
|
8
|
+
Group?: React.ElementType;
|
|
9
|
+
[key: string]: React.ElementType;
|
|
10
|
+
};
|
|
11
|
+
onCreate: (inputValue: string) => void;
|
|
12
|
+
};
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export declare const Menu: (props: Props) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -16,22 +16,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Menu = void 0;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
20
19
|
var ramda_1 = require("ramda");
|
|
21
20
|
var Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
22
21
|
var ReactSelectMenuWithPopper_1 = require("../../../ReactSelectMenuWithPopper");
|
|
23
22
|
var styles_1 = require("./styles");
|
|
24
23
|
var Menu = function (props) {
|
|
25
|
-
var _a = props.selectProps, onCreate = _a.onCreate, createLabel = _a.createLabel, inputValue = _a.inputValue, components = _a.components, children = props.children;
|
|
24
|
+
var _a = props.selectProps, onCreate = _a.onCreate, createLabel = _a.createLabel, inputValue = _a.inputValue, components = _a.components, canCreateOption = _a.canCreateOption, children = props.children;
|
|
26
25
|
var styles = (0, styles_1.useStyles)();
|
|
27
26
|
return (react_1.default.createElement(ReactSelectMenuWithPopper_1.ReactSelectMenuWithPopper, __assign({}, props),
|
|
28
27
|
children,
|
|
29
|
-
createLabel && !(0, ramda_1.prop)('Group', components) && (react_1.default.createElement("span", { className: styles.addLabel, onClick: function () { return onCreate(inputValue); } },
|
|
28
|
+
createLabel && !(0, ramda_1.prop)('Group', components) && canCreateOption() && (react_1.default.createElement("span", { className: styles.addLabel, onClick: function () { return onCreate(inputValue); } },
|
|
30
29
|
react_1.default.createElement(Add_1.default, { className: styles.addIcon }),
|
|
31
30
|
createLabel))));
|
|
32
31
|
};
|
|
33
32
|
exports.Menu = Menu;
|
|
34
|
-
exports.Menu.propTypes = {
|
|
35
|
-
children: prop_types_1.default.element.isRequired,
|
|
36
|
-
selectProps: prop_types_1.default.object.isRequired
|
|
37
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"
|
|
1
|
+
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"dropdownIndicator" | "control" | "valueContainer" | "formControl" | "filledInputRoot" | "filledInputUnderline" | "inputLabel">;
|
|
2
2
|
export namespace customStyles {
|
|
3
3
|
function menu(baseStyles: any): any;
|
|
4
4
|
function menuList(baseStyles: any): any;
|
|
@@ -68,6 +68,18 @@ var EntitySelector = function (_a) {
|
|
|
68
68
|
var styles = (0, styles_1.useStyles)();
|
|
69
69
|
var _g = (0, react_1.useState)(''), inputValue = _g[0], setInputValue = _g[1];
|
|
70
70
|
var entityTypes = (0, react_1.useMemo)(function () { return entityTypesUris.map(function (type) { return (0, mdm_sdk_1.getEntityType)(metadata, type); }).filter(mdm_sdk_1.isAvailableEntityType); }, [entityTypesUris, metadata]);
|
|
71
|
+
var creatableEntityTypesUris = (0, react_1.useMemo)(function () {
|
|
72
|
+
return entityTypesUris.filter(function (entityTypeUri) {
|
|
73
|
+
var entityType = (0, mdm_sdk_1.getEntityType)(metadata, entityTypeUri);
|
|
74
|
+
return (0, mdm_sdk_1.checkMetadataForCreate)(mode, entityType);
|
|
75
|
+
});
|
|
76
|
+
}, [entityTypesUris, mode, metadata]);
|
|
77
|
+
var canCreateEntity = (0, react_1.useCallback)(function (entityTypeUri) {
|
|
78
|
+
if (entityTypes.length === 0) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return creatableEntityTypesUris.includes(entityTypeUri !== null && entityTypeUri !== void 0 ? entityTypeUri : entityTypes[0].uri);
|
|
82
|
+
}, [creatableEntityTypesUris, entityTypes]);
|
|
71
83
|
var options = (0, react_1.useMemo)(function () { return (__assign(__assign({}, globalSearchRequestOptions), { max: max, sendMasked: isMasked })); }, [globalSearchRequestOptions, isMasked, max]);
|
|
72
84
|
var handleCreate = onCreate
|
|
73
85
|
? function (value, entityTypeUri) {
|
|
@@ -92,8 +104,16 @@ var EntitySelector = function (_a) {
|
|
|
92
104
|
return ((0, ramda_1.isEmpty)(entityTypes) ? Promise.resolve([]) : (0, mdm_sdk_1.typeAheadSearch)(entityTypes, value, options)).then((0, helpers_1.buildEntityOptions)(entityTypes, onCreate));
|
|
93
105
|
}, [entityTypes, onCreate, options]);
|
|
94
106
|
var currentEntityType = ((0, ramda_1.isEmpty)(entity) ? entityTypes[0] : (0, mdm_sdk_1.getEntityType)(metadata, entity.entityType)) || {};
|
|
95
|
-
var createLabel = onCreate &&
|
|
96
|
-
|
|
107
|
+
var createLabel = onCreate &&
|
|
108
|
+
(inputValue
|
|
109
|
+
? ui_i18n_1.default.text('Create "${name}" as new ${entityTypeLabel}', {
|
|
110
|
+
name: inputValue,
|
|
111
|
+
entityTypeLabel: currentEntityType.label
|
|
112
|
+
})
|
|
113
|
+
: ui_i18n_1.default.text('Create new ${entityTypeLabel}', { entityTypeLabel: currentEntityType.label }));
|
|
114
|
+
var label = ui_i18n_1.default.text('Select ${entityTypeLabel}profile', {
|
|
115
|
+
entityTypeLabel: entityTypes.length === 1 ? "".concat(entityTypes[0].label, " ") : ''
|
|
116
|
+
});
|
|
97
117
|
var isTempEntity = !(0, ramda_1.isEmpty)(entity) && (0, mdm_sdk_1.isTempUri)(entity.entityUri);
|
|
98
118
|
var groupComponent = groupMode ? { Group: Group_1.Group, GroupHeading: EmptyStub_1.EmptyStub } : {};
|
|
99
119
|
var clearComponent = isTempEntity ? { ClearIndicator: ClearIndicator_1.ClearIndicator } : {};
|
|
@@ -103,7 +123,7 @@ var EntitySelector = function (_a) {
|
|
|
103
123
|
return (__assign(__assign({}, (TextFieldProps || {})), (_a = {}, _a['data-reltio-id'] = 'reltio-entity-selector', _a)));
|
|
104
124
|
}, [TextFieldProps]);
|
|
105
125
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
106
|
-
react_1.default.createElement(DropDownSelector_1.DropDownSelector, __assign({ value: !(0, ramda_1.isEmpty)(entity) ? entity : undefined, inputValue: inputValue, onInputChange: handleInputChange, getOptions: getOptions, getOptionLabel: (0, ramda_1.prop)('entityLabel'), onChange: handleChange, onCreate: handleCreate, onClear: handleClear, label: label, createLabel: createLabel, components: __assign(__assign({ Option: EntityOption_1.EntityOption, SingleValue: SingleValue_1.SingleValue }, groupComponent), clearComponent), currentEntityType: currentEntityType, isClearable: true, disableLinkClick: disableLinkClick, TextFieldProps: textFieldProps }, dropDownSelectorProps)),
|
|
126
|
+
react_1.default.createElement(DropDownSelector_1.DropDownSelector, __assign({ value: !(0, ramda_1.isEmpty)(entity) ? entity : undefined, inputValue: inputValue, onInputChange: handleInputChange, getOptions: getOptions, getOptionLabel: (0, ramda_1.prop)('entityLabel'), onChange: handleChange, onCreate: handleCreate, onClear: handleClear, label: label, createLabel: createLabel, canCreateOption: canCreateEntity, components: __assign(__assign({ Option: EntityOption_1.EntityOption, SingleValue: SingleValue_1.SingleValue }, groupComponent), clearComponent), currentEntityType: currentEntityType, isClearable: true, disableLinkClick: disableLinkClick, TextFieldProps: textFieldProps }, dropDownSelectorProps)),
|
|
107
127
|
isTempEntity && (react_1.default.createElement("div", { "data-reltio-id": "entity-creator", className: styles.creatorWrapper },
|
|
108
128
|
react_1.default.createElement(EntityCreator_1.EntityCreator, { mode: mode, attributeTypesSelectionStrategy: attributeTypesSelectionStrategy, entityType: currentEntityType, entityUri: entity.entityUri })))));
|
|
109
129
|
};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { GroupProps } from 'react-select';
|
|
3
|
+
type Props = GroupProps & {
|
|
4
|
+
data: {
|
|
5
|
+
label: string;
|
|
6
|
+
entityType: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
selectProps: {
|
|
10
|
+
inputValue: string;
|
|
11
|
+
onCreate?: (value: string, entityType: string) => void;
|
|
12
|
+
canCreateOption: (entityTypeUri: string) => boolean;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
export declare const Group: (props: Props) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -16,26 +16,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Group = void 0;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
20
19
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
21
20
|
var react_select_1 = require("react-select");
|
|
22
21
|
var Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
23
22
|
var styles_1 = require("./styles");
|
|
24
23
|
var ComponentsGroup = react_select_1.components.Group;
|
|
25
24
|
var Group = function (props) {
|
|
26
|
-
var _a = props.selectProps, inputValue = _a.inputValue, onCreate = _a.onCreate, data = props.data, children = props.children;
|
|
27
25
|
var styles = (0, styles_1.useStyles)();
|
|
26
|
+
var _a = props.selectProps, inputValue = _a.inputValue, onCreate = _a.onCreate, canCreateOption = _a.canCreateOption, data = props.data, children = props.children;
|
|
28
27
|
return (react_1.default.createElement(ComponentsGroup, __assign({}, props),
|
|
29
28
|
react_1.default.createElement("div", { className: styles.groupHeading },
|
|
30
29
|
react_1.default.createElement("span", null, data.label),
|
|
31
|
-
onCreate && (react_1.default.createElement("span", { onClick: function () { return onCreate(inputValue, data.entityType); }, className: styles.addLabel },
|
|
30
|
+
onCreate && canCreateOption(data.entityType) && (react_1.default.createElement("span", { onClick: function () { return onCreate(inputValue, data.entityType); }, className: styles.addLabel },
|
|
32
31
|
react_1.default.createElement(Add_1.default, { className: styles.addIcon }),
|
|
33
|
-
|
|
32
|
+
inputValue
|
|
33
|
+
? ui_i18n_1.default.text('Create "${name}" as new ${entityTypeLabel}', {
|
|
34
|
+
name: inputValue,
|
|
35
|
+
entityTypeLabel: data.label
|
|
36
|
+
})
|
|
37
|
+
: ui_i18n_1.default.text('Create new ${entityTypeLabel}', { entityTypeLabel: data.label })))),
|
|
34
38
|
children));
|
|
35
39
|
};
|
|
36
40
|
exports.Group = Group;
|
|
37
|
-
exports.Group.propTypes = {
|
|
38
|
-
selectProps: prop_types_1.default.object.isRequired,
|
|
39
|
-
data: prop_types_1.default.object,
|
|
40
|
-
children: prop_types_1.default.array
|
|
41
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"menu" | "placeholder" | "option" | "singleValue" | "dropdownIndicator" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"menu" | "placeholder" | "option" | "singleValue" | "dropdownIndicator" | "clearIndicator" | "control" | "groupHeading" | "multiValue" | "noOptionsMessage" | "valueContainer" | "multiValue__label" | "option--selected" | "option--item" | "valueContainer--multi">;
|
|
@@ -68,7 +68,21 @@ var defaultProps = {
|
|
|
68
68
|
entityUri: 'entities/123',
|
|
69
69
|
anchorEl: document.createElement('div')
|
|
70
70
|
};
|
|
71
|
-
var
|
|
71
|
+
var getDefaultMetadata = function (masking) {
|
|
72
|
+
if (masking === void 0) { masking = false; }
|
|
73
|
+
return ({
|
|
74
|
+
entityTypes: [
|
|
75
|
+
{
|
|
76
|
+
uri: 'configuration/entityTypes/HCP',
|
|
77
|
+
attributes: [
|
|
78
|
+
__assign({ uri: 'configuration/entityTypes/HCP/attributes/FirstName', type: 'String', name: 'FirstName', label: 'First Name' }, (masking && { masking: { regexPattern: '.*' } }))
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
relationTypes: []
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
var defaultMdmValues = { uiPath: 'http://localhost:3000/ui/sokol/', metadata: getDefaultMetadata(), showMasking: true };
|
|
72
86
|
var defaultMdmActions = { openEntity: jest.fn() };
|
|
73
87
|
var setUp = function (_a) {
|
|
74
88
|
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.mdmActions, mdmActions = _e === void 0 ? defaultMdmActions : _e;
|
|
@@ -141,6 +155,9 @@ describe('Hierarchy node title tests', function () {
|
|
|
141
155
|
}); })];
|
|
142
156
|
case 2:
|
|
143
157
|
_a.sent();
|
|
158
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
159
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
160
|
+
});
|
|
144
161
|
(0, react_2.within)(tooltip).getByAltText('fallback entity avatar');
|
|
145
162
|
(0, react_2.within)(tooltip).getByText('perfect entity');
|
|
146
163
|
(0, react_2.within)(tooltip).getByText('ID:');
|
|
@@ -153,4 +170,69 @@ describe('Hierarchy node title tests', function () {
|
|
|
153
170
|
}
|
|
154
171
|
});
|
|
155
172
|
}); });
|
|
173
|
+
it('should pass sendMasked option to getEntity if metadata has masking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var user, entityWithMasking;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
user = setUp({ mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true) }) }).user;
|
|
179
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByText('Title'))];
|
|
180
|
+
case 1:
|
|
181
|
+
_a.sent();
|
|
182
|
+
expect(react_2.screen.getByRole('tooltip')).toBeInTheDocument();
|
|
183
|
+
entityWithMasking = {
|
|
184
|
+
uri: 'entities/123',
|
|
185
|
+
label: '***t entity',
|
|
186
|
+
type: 'configuration/entityTypes/HCP'
|
|
187
|
+
};
|
|
188
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entityWithMasking)];
|
|
192
|
+
case 1:
|
|
193
|
+
_a.sent();
|
|
194
|
+
return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); })];
|
|
198
|
+
case 2:
|
|
199
|
+
_a.sent();
|
|
200
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
201
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk,sendMasked'
|
|
202
|
+
});
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}); });
|
|
207
|
+
it('should not pass sendMasked option to getEntity if metadata has masking but showMasking is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
+
var user;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
user = setUp({
|
|
213
|
+
mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true), showMasking: false })
|
|
214
|
+
}).user;
|
|
215
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByText('Title'))];
|
|
216
|
+
case 1:
|
|
217
|
+
_a.sent();
|
|
218
|
+
expect(react_2.screen.getByRole('tooltip')).toBeInTheDocument();
|
|
219
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entity)];
|
|
223
|
+
case 1:
|
|
224
|
+
_a.sent();
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}); })];
|
|
229
|
+
case 2:
|
|
230
|
+
_a.sent();
|
|
231
|
+
expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
|
|
232
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
233
|
+
});
|
|
234
|
+
return [2 /*return*/];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}); });
|
|
156
238
|
});
|
|
@@ -4,20 +4,24 @@ exports.useEntityDetails = void 0;
|
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
6
|
var useSafePromise_1 = require("../hooks/useSafePromise");
|
|
7
|
+
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
7
8
|
var useEntityDetails = function (entityUri) {
|
|
8
9
|
var _a = (0, react_1.useState)(null), entityDetails = _a[0], setEntityDetails = _a[1];
|
|
9
10
|
var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
10
11
|
var safePromise = (0, useSafePromise_1.useSafePromise)();
|
|
11
12
|
var cancelRequest = (0, react_1.useCallback)(function () { return safePromise(Promise.resolve()); }, [safePromise]);
|
|
13
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
14
|
+
var showMasking = (0, MdmModuleContext_1.useMdmShowMasking)();
|
|
15
|
+
var entityOptions = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.addGetEntityMaskingOptions)(metadata, { showMasking: showMasking, showAccess: false }); }, [metadata, showMasking]);
|
|
12
16
|
var showEntityDetails = (0, react_1.useCallback)((0, mdm_sdk_1.debounce)(function () {
|
|
13
17
|
setIsLoading(true);
|
|
14
|
-
safePromise((0, mdm_sdk_1.getEntity)(entityUri))
|
|
18
|
+
safePromise((0, mdm_sdk_1.getEntity)(entityUri, entityOptions))
|
|
15
19
|
.then(setEntityDetails)
|
|
16
20
|
.catch(function (error) {
|
|
17
21
|
console.warn('Failed to load entity', error);
|
|
18
22
|
})
|
|
19
23
|
.finally(function () { return setIsLoading(false); });
|
|
20
|
-
}, 1000), [entityUri, safePromise]);
|
|
24
|
+
}, 1000), [entityUri, safePromise, entityOptions]);
|
|
21
25
|
var hideEntityDetails = (0, react_1.useCallback)(function () {
|
|
22
26
|
cancelRequest();
|
|
23
27
|
showEntityDetails.cancel();
|