@reltio/components 1.4.2238 → 1.4.2240
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/DataTenantBadge/DataTenantBadge.js +3 -3
- package/DataTenantBadge/DataTenantBadge.test.js +3 -3
- package/DropDownSelector/DropDownSelector.d.ts +2 -1
- package/DropDownSelector/DropDownSelector.js +2 -2
- package/EntitySelector/EntitySelector.d.ts +2 -1
- package/EntitySelector/EntitySelector.js +2 -2
- package/EntityUriLink/EntityUriLink.d.ts +1 -0
- package/EntityUriLink/EntityUriLink.js +2 -2
- package/ProfileCard/ProfileCard.d.ts +2 -1
- package/ProfileCard/ProfileCard.js +2 -2
- package/ProfileCard/ProfileCard.test.js +19 -0
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.d.ts +2 -1
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.js +2 -2
- package/TenantsDropDownSelector/TenantsDropDownSelector.d.ts +2 -1
- package/TenantsDropDownSelector/TenantsDropDownSelector.js +2 -3
- package/TenantsDropDownSelector/TenantsDropDownSelector.spec.js +34 -3
- package/cjs/DataTenantBadge/DataTenantBadge.js +2 -2
- package/cjs/DataTenantBadge/DataTenantBadge.test.js +3 -3
- package/cjs/DropDownSelector/DropDownSelector.d.ts +2 -1
- package/cjs/DropDownSelector/DropDownSelector.js +2 -2
- package/cjs/EntitySelector/EntitySelector.d.ts +2 -1
- package/cjs/EntitySelector/EntitySelector.js +2 -2
- package/cjs/EntityUriLink/EntityUriLink.d.ts +1 -0
- package/cjs/EntityUriLink/EntityUriLink.js +2 -2
- package/cjs/ProfileCard/ProfileCard.d.ts +2 -1
- package/cjs/ProfileCard/ProfileCard.js +2 -2
- package/cjs/ProfileCard/ProfileCard.test.js +19 -0
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.d.ts +2 -1
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.js +2 -2
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.d.ts +2 -1
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.js +1 -2
- package/cjs/TenantsDropDownSelector/TenantsDropDownSelector.spec.js +34 -3
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/cjs/contexts/MdmModuleContext/hooks.js +6 -2
- package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/index.js +3 -2
- package/cjs/hooks/useMatchesLoader/useMatchesLoader.js +3 -1
- package/cjs/hooks/useMatchesLoader/useMatchesLoader.test.js +124 -22
- package/contexts/MdmModuleContext/context.d.ts +2 -0
- package/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/contexts/MdmModuleContext/hooks.js +3 -0
- package/contexts/MdmModuleContext/index.d.ts +1 -1
- package/contexts/MdmModuleContext/index.js +1 -1
- package/hooks/useMatchesLoader/useMatchesLoader.js +4 -2
- package/hooks/useMatchesLoader/useMatchesLoader.test.js +125 -23
- package/package.json +2 -2
|
@@ -3,14 +3,14 @@ import classnames from 'classnames';
|
|
|
3
3
|
import { propEq, toUpper, slice, pipe, defaultTo, find, propOr, startsWith, ifElse } from 'ramda';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import Tooltip from '@mui/material/Tooltip';
|
|
6
|
-
import {
|
|
6
|
+
import { useMdmDataTenantsWithIdBuilder } from '../contexts/MdmModuleContext';
|
|
7
7
|
import { useStyles } from './styles';
|
|
8
8
|
var addDataTenantPrefix = function (label) { return "DT:".concat(slice(0, 1, label)); };
|
|
9
9
|
export var DataTenantBadge = function (_a) {
|
|
10
10
|
var dataTenantId = _a.dataTenantId, className = _a.className;
|
|
11
11
|
var styles = useStyles({ dataTenantId: dataTenantId });
|
|
12
|
-
var
|
|
13
|
-
var dataTenant = pipe(defaultTo([]), find(propEq('id', dataTenantId)))(
|
|
12
|
+
var dataTenantsWithIdBuilder = useMdmDataTenantsWithIdBuilder();
|
|
13
|
+
var dataTenant = pipe(defaultTo([]), find(propEq('id', dataTenantId)))(dataTenantsWithIdBuilder);
|
|
14
14
|
var label = pipe(propOr('', 'label'), toUpper, ifElse(startsWith('DT:'), slice(0, 4), addDataTenantPrefix))(dataTenant);
|
|
15
15
|
var content = (React.createElement("div", { className: classnames(styles.root, className) },
|
|
16
16
|
React.createElement(Typography, { variant: "body2" }, label)));
|
|
@@ -30,7 +30,7 @@ var defaultDataTenants = [
|
|
|
30
30
|
}
|
|
31
31
|
];
|
|
32
32
|
var defaultMdmValues = {
|
|
33
|
-
|
|
33
|
+
dataTenantsWithIdBuilder: defaultDataTenants
|
|
34
34
|
};
|
|
35
35
|
var setUp = function (props, mdmValues) {
|
|
36
36
|
if (mdmValues === void 0) { mdmValues = defaultMdmValues; }
|
|
@@ -40,7 +40,7 @@ var setUp = function (props, mdmValues) {
|
|
|
40
40
|
};
|
|
41
41
|
return render(React.createElement(DataTenantBadge, __assign({}, props)), { wrapper: Providers });
|
|
42
42
|
};
|
|
43
|
-
describe('
|
|
43
|
+
describe('DataTenantBadge tests', function () {
|
|
44
44
|
it('should pass className to root element correctly', function () {
|
|
45
45
|
setUp({ dataTenantId: 'uitest3', className: 'dataTenantBadge' });
|
|
46
46
|
expect(screen.getByLabelText('DT:TEST')).toHaveClass('dataTenantBadge');
|
|
@@ -50,7 +50,7 @@ describe('DataTenantBage tests', function () {
|
|
|
50
50
|
screen.getByText('DT:T');
|
|
51
51
|
});
|
|
52
52
|
it('should render correct label if dataTenants is not exists', function () {
|
|
53
|
-
var mdmValues = {
|
|
53
|
+
var mdmValues = { dataTenantsWithIdBuilder: [] };
|
|
54
54
|
setUp({ dataTenantId: 'uitest3' }, mdmValues);
|
|
55
55
|
screen.getByText('DT:');
|
|
56
56
|
});
|
|
@@ -23,7 +23,8 @@ type Props<T> = {
|
|
|
23
23
|
TextFieldProps?: TextFieldProps;
|
|
24
24
|
height?: number;
|
|
25
25
|
classes?: Record<string, string>;
|
|
26
|
+
required?: boolean;
|
|
26
27
|
[key: string]: unknown;
|
|
27
28
|
};
|
|
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 declare const DropDownSelector: <T>({ value, label, options, getOptions, createLabel, height, onChange, onCreate, canCreateOption, onClear, components, textFieldInputRef, TextFieldProps, classes, required, ...otherProps }: Props<T>) => React.JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -33,7 +33,7 @@ import { SingleValue } from './components/SingleValue';
|
|
|
33
33
|
import { useStyles, customStyles, overloadMenuListStyle, withoutLabelInputStyle } from './styles';
|
|
34
34
|
export var DropDownSelector = function (_a) {
|
|
35
35
|
var _b;
|
|
36
|
-
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 ? identity : _d, onCreate = _a.onCreate, _e = _a.canCreateOption, canCreateOption = _e === void 0 ? function () { return Boolean(onCreate); } : _e, _f = _a.onClear, onClear = _f === void 0 ? 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"]);
|
|
36
|
+
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 ? identity : _d, onCreate = _a.onCreate, _e = _a.canCreateOption, canCreateOption = _e === void 0 ? function () { return Boolean(onCreate); } : _e, _f = _a.onClear, onClear = _f === void 0 ? identity : _f, _g = _a.components, components = _g === void 0 ? {} : _g, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, _h = _a.classes, classes = _h === void 0 ? {} : _h, required = _a.required, otherProps = __rest(_a, ["value", "label", "options", "getOptions", "createLabel", "height", "onChange", "onCreate", "canCreateOption", "onClear", "components", "textFieldInputRef", "TextFieldProps", "classes", "required"]);
|
|
37
37
|
var styles = useStyles({ height: height });
|
|
38
38
|
var _j = useState(false), open = _j[0], setOpen = _j[1];
|
|
39
39
|
var inputRef = useRef(null);
|
|
@@ -51,5 +51,5 @@ export var DropDownSelector = function (_a) {
|
|
|
51
51
|
var overloadStylesIfNoLabel = isEmpty(label) ? withoutLabelInputStyle : {};
|
|
52
52
|
var mergedStyles = __assign(__assign(__assign({}, customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
|
|
53
53
|
var mergedClasses = __assign(__assign({}, styles), classes);
|
|
54
|
-
return (React.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: 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, LoadingIndicator: EmptyStub, SingleValue: SingleValue, Menu: Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', size: 'small', classes: __assign(__assign({}, prop('classes', TextFieldProps)), { root: classnames(styles.formControl, path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputProps', 'classes'], TextFieldProps)), { root: classnames(styles.filledInputRoot, path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames((_b = {}, _b[styles.filledInputUnderline] = isEmptyValue(value), _b), path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames('focused', path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames(styles.inputLabel, path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames('shrink', path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
|
|
54
|
+
return (React.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: 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, LoadingIndicator: EmptyStub, SingleValue: SingleValue, Menu: Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', size: 'small', required: required, classes: __assign(__assign({}, prop('classes', TextFieldProps)), { root: classnames(styles.formControl, path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputProps', 'classes'], TextFieldProps)), { root: classnames(styles.filledInputRoot, path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames((_b = {}, _b[styles.filledInputUnderline] = isEmptyValue(value), _b), path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames('focused', path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames(styles.inputLabel, path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames('shrink', path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
|
|
55
55
|
};
|
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
height?: number;
|
|
19
19
|
isDisabled?: boolean;
|
|
20
20
|
isMasked?: boolean;
|
|
21
|
+
required?: boolean;
|
|
21
22
|
};
|
|
22
|
-
export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, isMasked, ...otherProps }: Props) => React.JSX.Element;
|
|
23
|
+
export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, isMasked, required, ...otherProps }: Props) => React.JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -35,7 +35,7 @@ import { buildEntityOptions } from './helpers';
|
|
|
35
35
|
import { useStyles } from './styles';
|
|
36
36
|
var DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION = 20;
|
|
37
37
|
export var EntitySelector = function (_a) {
|
|
38
|
-
var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, _f = _a.isMasked, isMasked = _f === void 0 ? false : _f, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick", "isMasked"]);
|
|
38
|
+
var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, _f = _a.isMasked, isMasked = _f === void 0 ? false : _f, required = _a.required, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick", "isMasked", "required"]);
|
|
39
39
|
var styles = useStyles();
|
|
40
40
|
var _g = useState(''), inputValue = _g[0], setInputValue = _g[1];
|
|
41
41
|
var entityTypes = useMemo(function () { return entityTypesUris.map(function (type) { return getEntityType(metadata, type); }).filter(isAvailableEntityType); }, [entityTypesUris, metadata]);
|
|
@@ -94,7 +94,7 @@ export var EntitySelector = function (_a) {
|
|
|
94
94
|
return (__assign(__assign({}, (TextFieldProps || {})), (_a = {}, _a['data-reltio-id'] = 'reltio-entity-selector', _a)));
|
|
95
95
|
}, [TextFieldProps]);
|
|
96
96
|
return (React.createElement(React.Fragment, null,
|
|
97
|
-
React.createElement(DropDownSelector, __assign({ key: entityTypesUris.join(','), value: !isEmpty(entity) ? entity : undefined, inputValue: inputValue, onInputChange: handleInputChange, getOptions: getOptions, getOptionLabel: prop('entityLabel'), onChange: handleChange, onCreate: handleCreate, onClear: handleClear, label: label, createLabel: createLabel, canCreateOption: canCreateEntity, components: __assign(__assign({ Option: EntityOption, SingleValue: SingleValue }, groupComponent), clearComponent), currentEntityType: currentEntityType, isClearable: true, disableLinkClick: disableLinkClick, TextFieldProps: textFieldProps }, dropDownSelectorProps)),
|
|
97
|
+
React.createElement(DropDownSelector, __assign({ key: entityTypesUris.join(','), value: !isEmpty(entity) ? entity : undefined, inputValue: inputValue, onInputChange: handleInputChange, getOptions: getOptions, getOptionLabel: prop('entityLabel'), onChange: handleChange, onCreate: handleCreate, onClear: handleClear, label: label, createLabel: createLabel, canCreateOption: canCreateEntity, components: __assign(__assign({ Option: EntityOption, SingleValue: SingleValue }, groupComponent), clearComponent), currentEntityType: currentEntityType, isClearable: true, disableLinkClick: disableLinkClick, TextFieldProps: textFieldProps, required: required }, dropDownSelectorProps)),
|
|
98
98
|
isTempEntity && (React.createElement("div", { "data-reltio-id": "entity-creator", className: styles.creatorWrapper },
|
|
99
99
|
React.createElement(EntityCreator, { mode: mode, attributeTypesSelectionStrategy: attributeTypesSelectionStrategy, entityType: currentEntityType, entityUri: entity.entityUri })))));
|
|
100
100
|
};
|
|
@@ -25,7 +25,7 @@ import { useMdmUiPath, useMdmAction } from '../contexts/MdmModuleContext';
|
|
|
25
25
|
import { UrlGeneratorsContext } from '../contexts/UrlGeneratorsContext';
|
|
26
26
|
import { isControlOrCommandPressed } from '../helpers/events';
|
|
27
27
|
export var EntityUriLink = forwardRef(function (_a, ref) {
|
|
28
|
-
var value = _a.value, children = _a.children, screen = _a.screen, className = _a.className, _b = _a.shouldOpenInNewTab, shouldOpenInNewTab = _b === void 0 ? false : _b, otherProps = __rest(_a, ["value", "children", "screen", "className", "shouldOpenInNewTab"]);
|
|
28
|
+
var value = _a.value, children = _a.children, screen = _a.screen, className = _a.className, _b = _a.shouldOpenInNewTab, shouldOpenInNewTab = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, otherProps = __rest(_a, ["value", "children", "screen", "className", "shouldOpenInNewTab", "disabled"]);
|
|
29
29
|
var generateEntityUrl = useContext(UrlGeneratorsContext).generateEntityUrl;
|
|
30
30
|
var uiPath = useMdmUiPath();
|
|
31
31
|
var openEntity = useMdmAction('openEntity');
|
|
@@ -36,6 +36,6 @@ export var EntityUriLink = forwardRef(function (_a, ref) {
|
|
|
36
36
|
}
|
|
37
37
|
e.stopPropagation();
|
|
38
38
|
}, [openEntity, screen, value]);
|
|
39
|
-
return value ? (React.createElement("a", __assign({ ref: ref, href: generateEntityUrl({ uiPath: uiPath, uri: value, screen: screen }), onClick: shouldOpenInNewTab ? undefined : handleClick, target: shouldOpenInNewTab ? '_blank' : '_self', rel: "noreferrer", className: className }, otherProps), children))
|
|
39
|
+
return disabled || !value ? (React.createElement("span", __assign({ ref: ref, className: className }, otherProps), children)) : (React.createElement("a", __assign({ ref: ref, href: generateEntityUrl({ uiPath: uiPath, uri: value, screen: screen }), onClick: shouldOpenInNewTab ? undefined : handleClick, target: shouldOpenInNewTab ? '_blank' : '_self', rel: "noreferrer", className: className }, otherProps), children));
|
|
40
40
|
});
|
|
41
41
|
EntityUriLink.displayName = 'EntityUriLink';
|
|
@@ -8,6 +8,7 @@ type Props = {
|
|
|
8
8
|
container?: string;
|
|
9
9
|
};
|
|
10
10
|
variant?: 'loading' | 'normal';
|
|
11
|
+
disableEntityLink?: boolean;
|
|
11
12
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
12
|
-
declare const _default: React.MemoExoticComponent<({ entity, classes, variant, ...otherProps }: Props) => React.JSX.Element>;
|
|
13
|
+
declare const _default: React.MemoExoticComponent<({ entity, classes, variant, disableEntityLink, ...otherProps }: Props) => React.JSX.Element>;
|
|
13
14
|
export default _default;
|
|
@@ -26,9 +26,9 @@ import { ProfileCardContent } from './components/ProfileCardContent';
|
|
|
26
26
|
import { ProfileCardPlaceholder } from './components/ProfileCardPlaceholder';
|
|
27
27
|
import { useStyles } from './styles';
|
|
28
28
|
var ProfileCard = function (_a) {
|
|
29
|
-
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.variant, variant = _c === void 0 ? 'normal' : _c, otherProps = __rest(_a, ["entity", "classes", "variant"]);
|
|
29
|
+
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.variant, variant = _c === void 0 ? 'normal' : _c, _d = _a.disableEntityLink, disableEntityLink = _d === void 0 ? false : _d, otherProps = __rest(_a, ["entity", "classes", "variant", "disableEntityLink"]);
|
|
30
30
|
var styles = useStyles();
|
|
31
31
|
var containerClass = classes.container;
|
|
32
|
-
return (React.createElement("div", __assign({ className: classnames(styles.container, containerClass) }, otherProps), variant === 'normal' ? (React.createElement(ProfileCardContent, { entity: entity, classes: classes })) : (React.createElement(ProfileCardPlaceholder, null))));
|
|
32
|
+
return (React.createElement("div", __assign({ className: classnames(styles.container, containerClass) }, otherProps), variant === 'normal' ? (React.createElement(ProfileCardContent, { entity: entity, classes: classes, disableEntityLink: disableEntityLink })) : (React.createElement(ProfileCardPlaceholder, null))));
|
|
33
33
|
};
|
|
34
34
|
export default memo(ProfileCard);
|
|
@@ -112,4 +112,23 @@ describe('Profile card tests', function () {
|
|
|
112
112
|
screen.getByTestId('profile-card-placeholder-avatar');
|
|
113
113
|
screen.getByTestId('profile-card-placeholder-info');
|
|
114
114
|
});
|
|
115
|
+
it('should render two ProfileCards: one from IdentityBuilder (no link) and one normal (with link)', function () {
|
|
116
|
+
var entityWithDataTenant = __assign(__assign({}, defaultEntity), { uri: 'entities/dt-456', label: 'IdentityBuilder match', dataTenant: 'tenant-with-id-builder' });
|
|
117
|
+
var Providers = function (_a) {
|
|
118
|
+
var children = _a.children;
|
|
119
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
|
|
120
|
+
};
|
|
121
|
+
render(React.createElement(React.Fragment, null,
|
|
122
|
+
React.createElement(ProfileCard, { entity: entityWithDataTenant, disableEntityLink: true, "data-reltio-id": "profile-id-builder" }),
|
|
123
|
+
React.createElement(ProfileCard, { entity: defaultEntity, disableEntityLink: false, "data-reltio-id": "profile-normal" })), { wrapper: Providers });
|
|
124
|
+
// IdentityBuilder: the label is visible as text only, no link
|
|
125
|
+
var idBuilderCard = screen.getByTestId('profile-id-builder');
|
|
126
|
+
expect(idBuilderCard).toHaveTextContent('IdentityBuilder match');
|
|
127
|
+
expect(idBuilderCard.querySelector('a[href]')).not.toBeInTheDocument();
|
|
128
|
+
// Normal: a label is a link
|
|
129
|
+
var normalCard = screen.getByTestId('profile-normal');
|
|
130
|
+
expect(normalCard).toHaveTextContent('Main label');
|
|
131
|
+
expect(normalCard.querySelector('a[href]')).toBeInTheDocument();
|
|
132
|
+
expect(screen.getByRole('link', { name: 'Main label' })).toHaveAttribute('href', 'https://reltio.com/nui#p~com.reltio.plugins.entity.default.DefaultPerspective_e~entities/123');
|
|
133
|
+
});
|
|
115
134
|
});
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
label?: string;
|
|
7
7
|
secondaryLabel?: string;
|
|
8
8
|
};
|
|
9
|
+
disableEntityLink?: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare const ProfileCardContent: ({ entity, classes }: Props) => React.JSX.Element;
|
|
11
|
+
export declare const ProfileCardContent: ({ entity, classes, disableEntityLink }: Props) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -8,7 +8,7 @@ import { ExpandedValueTooltip } from '../../../ExpandedValueTooltip';
|
|
|
8
8
|
import { EntityTypeBadge } from '../../../EntityTypeBadge';
|
|
9
9
|
import { useStyles } from './styles';
|
|
10
10
|
export var ProfileCardContent = function (_a) {
|
|
11
|
-
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b;
|
|
11
|
+
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.disableEntityLink, disableEntityLink = _c === void 0 ? false : _c;
|
|
12
12
|
var styles = useStyles();
|
|
13
13
|
var secondaryLabelClass = classes.secondaryLabel, labelClass = classes.label;
|
|
14
14
|
var label = getLabel(entity.label);
|
|
@@ -19,7 +19,7 @@ export var ProfileCardContent = function (_a) {
|
|
|
19
19
|
return (React.createElement(React.Fragment, null,
|
|
20
20
|
React.createElement(EntityAvatar, { entity: entity, imageClassName: styles.image }),
|
|
21
21
|
React.createElement("div", { className: styles.info },
|
|
22
|
-
React.createElement(EntityUriLink, { value: getEntityUriForLink(entity), className: styles.link },
|
|
22
|
+
React.createElement(EntityUriLink, { value: getEntityUriForLink(entity), className: styles.link, disabled: disableEntityLink },
|
|
23
23
|
React.createElement(ExpandedValueTooltip, { value: label, placement: "top", showOnExceededHeight: true },
|
|
24
24
|
React.createElement("div", { className: classnames(styles.label, labelClass) }, label))),
|
|
25
25
|
secondaryLabel && (React.createElement(ExpandedValueTooltip, { value: secondaryLabel, placement: "top", showOnExceededHeight: true },
|
|
@@ -4,6 +4,7 @@ type Props = {
|
|
|
4
4
|
selectedTenant: DataTenant;
|
|
5
5
|
entityTypeUri: string;
|
|
6
6
|
onChangeTenant: (tenant: DataTenant) => void;
|
|
7
|
+
dataTenants: DataTenant[];
|
|
7
8
|
};
|
|
8
|
-
export declare const TenantsDropDownSelector: ({ entityTypeUri, onChangeTenant, selectedTenant }: Props) => React.JSX.Element;
|
|
9
|
+
export declare const TenantsDropDownSelector: ({ entityTypeUri, onChangeTenant, selectedTenant, dataTenants }: Props) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -5,12 +5,11 @@ import { isAvailableTenantForEntityType, isEmptyValue } from '@reltio/mdm-sdk';
|
|
|
5
5
|
import { DropDownMenuButton } from '../DropDownMenuButton';
|
|
6
6
|
import { TenantIcon } from '../TenantIcon';
|
|
7
7
|
import { TenantMenuItem } from './components/TenantMenuItem';
|
|
8
|
-
import {
|
|
8
|
+
import { useMdmTenantObject } from '../contexts/MdmModuleContext';
|
|
9
9
|
import { useStyles } from './styles';
|
|
10
10
|
export var TenantsDropDownSelector = function (_a) {
|
|
11
|
-
var entityTypeUri = _a.entityTypeUri, onChangeTenant = _a.onChangeTenant, selectedTenant = _a.selectedTenant;
|
|
11
|
+
var entityTypeUri = _a.entityTypeUri, onChangeTenant = _a.onChangeTenant, selectedTenant = _a.selectedTenant, dataTenants = _a.dataTenants;
|
|
12
12
|
var styles = useStyles();
|
|
13
|
-
var dataTenants = useMdmDataTenants();
|
|
14
13
|
var customerTenant = useMdmTenantObject();
|
|
15
14
|
var menuItems = useMemo(function () {
|
|
16
15
|
return pipe(defaultTo([]), filter(isAvailableTenantForEntityType(entityTypeUri)), map(function (dataTenant) { return ({
|
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import React from 'react';
|
|
49
58
|
import { render, screen, within } from '@testing-library/react';
|
|
50
59
|
import userEvent from '@testing-library/user-event';
|
|
@@ -55,14 +64,19 @@ var defaultDataTenants = [
|
|
|
55
64
|
{ id: 'tenantId2', name: 'secondTenantName' },
|
|
56
65
|
{ id: 'tenantId3', name: 'thirdTenantName', label: 'Third tenant name' }
|
|
57
66
|
];
|
|
67
|
+
var defaultDataTenantsWithIdBuilder = __spreadArray(__spreadArray([], defaultDataTenants, true), [
|
|
68
|
+
{ id: 'tenantId4', name: 'idBuilderTenant', idBuilderSubscription: true }
|
|
69
|
+
], false);
|
|
58
70
|
var defaultMdmValues = {
|
|
59
71
|
dataTenants: defaultDataTenants,
|
|
72
|
+
dataTenantsWithIdBuilder: defaultDataTenantsWithIdBuilder,
|
|
60
73
|
tenant: tenantObject
|
|
61
74
|
};
|
|
62
75
|
var defaultProps = {
|
|
63
76
|
onChangeTenant: jest.fn(),
|
|
64
77
|
entityTypeUri: 'entityTypeUris',
|
|
65
|
-
selectedTenant: tenantObject
|
|
78
|
+
selectedTenant: tenantObject,
|
|
79
|
+
dataTenants: defaultDataTenantsWithIdBuilder
|
|
66
80
|
};
|
|
67
81
|
var setUp = function (_a) {
|
|
68
82
|
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
|
|
@@ -75,8 +89,8 @@ var setUp = function (_a) {
|
|
|
75
89
|
};
|
|
76
90
|
describe('TenantsDropDownSelector test', function () {
|
|
77
91
|
it('should render nothing if dataTenants is empty', function () {
|
|
78
|
-
var
|
|
79
|
-
var container = setUp({
|
|
92
|
+
var props = __assign(__assign({}, defaultProps), { dataTenants: [] });
|
|
93
|
+
var container = setUp({ props: props }).container;
|
|
80
94
|
expect(container).toBeEmptyDOMElement();
|
|
81
95
|
});
|
|
82
96
|
it('should render nothing if onChangeTenant is undefined', function () {
|
|
@@ -125,4 +139,21 @@ describe('TenantsDropDownSelector test', function () {
|
|
|
125
139
|
}
|
|
126
140
|
});
|
|
127
141
|
}); });
|
|
142
|
+
it('should use dataTenants passed via props', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
143
|
+
var user, button, menuItems;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
user = setUp().user;
|
|
148
|
+
button = screen.getByText('T');
|
|
149
|
+
return [4 /*yield*/, user.click(button)];
|
|
150
|
+
case 1:
|
|
151
|
+
_a.sent();
|
|
152
|
+
menuItems = screen.getAllByRole('menuitem');
|
|
153
|
+
expect(menuItems).toHaveLength(4); // 1 customer tenant + 3 data tenants (including idBuilder in defaultDataTenantsWithIdBuilder)
|
|
154
|
+
within(menuItems[3]).getByText('idBuilderTenant');
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); });
|
|
128
159
|
});
|
|
@@ -15,8 +15,8 @@ var addDataTenantPrefix = function (label) { return "DT:".concat((0, ramda_1.sli
|
|
|
15
15
|
var DataTenantBadge = function (_a) {
|
|
16
16
|
var dataTenantId = _a.dataTenantId, className = _a.className;
|
|
17
17
|
var styles = (0, styles_1.useStyles)({ dataTenantId: dataTenantId });
|
|
18
|
-
var
|
|
19
|
-
var dataTenant = (0, ramda_1.pipe)((0, ramda_1.defaultTo)([]), (0, ramda_1.find)((0, ramda_1.propEq)('id', dataTenantId)))(
|
|
18
|
+
var dataTenantsWithIdBuilder = (0, MdmModuleContext_1.useMdmDataTenantsWithIdBuilder)();
|
|
19
|
+
var dataTenant = (0, ramda_1.pipe)((0, ramda_1.defaultTo)([]), (0, ramda_1.find)((0, ramda_1.propEq)('id', dataTenantId)))(dataTenantsWithIdBuilder);
|
|
20
20
|
var label = (0, ramda_1.pipe)((0, ramda_1.propOr)('', 'label'), ramda_1.toUpper, (0, ramda_1.ifElse)((0, ramda_1.startsWith)('DT:'), (0, ramda_1.slice)(0, 4), addDataTenantPrefix))(dataTenant);
|
|
21
21
|
var content = (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.root, className) },
|
|
22
22
|
react_1.default.createElement(Typography_1.default, { variant: "body2" }, label)));
|
|
@@ -35,7 +35,7 @@ var defaultDataTenants = [
|
|
|
35
35
|
}
|
|
36
36
|
];
|
|
37
37
|
var defaultMdmValues = {
|
|
38
|
-
|
|
38
|
+
dataTenantsWithIdBuilder: defaultDataTenants
|
|
39
39
|
};
|
|
40
40
|
var setUp = function (props, mdmValues) {
|
|
41
41
|
if (mdmValues === void 0) { mdmValues = defaultMdmValues; }
|
|
@@ -45,7 +45,7 @@ var setUp = function (props, mdmValues) {
|
|
|
45
45
|
};
|
|
46
46
|
return (0, react_2.render)(react_1.default.createElement(DataTenantBadge_1.DataTenantBadge, __assign({}, props)), { wrapper: Providers });
|
|
47
47
|
};
|
|
48
|
-
describe('
|
|
48
|
+
describe('DataTenantBadge tests', function () {
|
|
49
49
|
it('should pass className to root element correctly', function () {
|
|
50
50
|
setUp({ dataTenantId: 'uitest3', className: 'dataTenantBadge' });
|
|
51
51
|
expect(react_2.screen.getByLabelText('DT:TEST')).toHaveClass('dataTenantBadge');
|
|
@@ -55,7 +55,7 @@ describe('DataTenantBage tests', function () {
|
|
|
55
55
|
react_2.screen.getByText('DT:T');
|
|
56
56
|
});
|
|
57
57
|
it('should render correct label if dataTenants is not exists', function () {
|
|
58
|
-
var mdmValues = {
|
|
58
|
+
var mdmValues = { dataTenantsWithIdBuilder: [] };
|
|
59
59
|
setUp({ dataTenantId: 'uitest3' }, mdmValues);
|
|
60
60
|
react_2.screen.getByText('DT:');
|
|
61
61
|
});
|
|
@@ -23,7 +23,8 @@ type Props<T> = {
|
|
|
23
23
|
TextFieldProps?: TextFieldProps;
|
|
24
24
|
height?: number;
|
|
25
25
|
classes?: Record<string, string>;
|
|
26
|
+
required?: boolean;
|
|
26
27
|
[key: string]: unknown;
|
|
27
28
|
};
|
|
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 declare const DropDownSelector: <T>({ value, label, options, getOptions, createLabel, height, onChange, onCreate, canCreateOption, onClear, components, textFieldInputRef, TextFieldProps, classes, required, ...otherProps }: Props<T>) => React.JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -62,7 +62,7 @@ var SingleValue_1 = require("./components/SingleValue");
|
|
|
62
62
|
var styles_1 = require("./styles");
|
|
63
63
|
var DropDownSelector = function (_a) {
|
|
64
64
|
var _b;
|
|
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"]);
|
|
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, required = _a.required, otherProps = __rest(_a, ["value", "label", "options", "getOptions", "createLabel", "height", "onChange", "onCreate", "canCreateOption", "onClear", "components", "textFieldInputRef", "TextFieldProps", "classes", "required"]);
|
|
66
66
|
var styles = (0, styles_1.useStyles)({ height: height });
|
|
67
67
|
var _j = (0, react_1.useState)(false), open = _j[0], setOpen = _j[1];
|
|
68
68
|
var inputRef = (0, react_1.useRef)(null);
|
|
@@ -80,6 +80,6 @@ var DropDownSelector = function (_a) {
|
|
|
80
80
|
var overloadStylesIfNoLabel = (0, ramda_1.isEmpty)(label) ? styles_1.withoutLabelInputStyle : {};
|
|
81
81
|
var mergedStyles = __assign(__assign(__assign({}, styles_1.customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
|
|
82
82
|
var mergedClasses = __assign(__assign({}, styles), classes);
|
|
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); } })));
|
|
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', required: required, 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); } })));
|
|
84
84
|
};
|
|
85
85
|
exports.DropDownSelector = DropDownSelector;
|
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
height?: number;
|
|
19
19
|
isDisabled?: boolean;
|
|
20
20
|
isMasked?: boolean;
|
|
21
|
+
required?: boolean;
|
|
21
22
|
};
|
|
22
|
-
export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, isMasked, ...otherProps }: Props) => React.JSX.Element;
|
|
23
|
+
export declare const EntitySelector: ({ entity, entityTypesUris, mode, max, onChange, onCreate, metadata, globalSearchRequestOptions, attributeTypesSelectionStrategy, disableLinkClick, isMasked, required, ...otherProps }: Props) => React.JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -64,7 +64,7 @@ var helpers_1 = require("./helpers");
|
|
|
64
64
|
var styles_1 = require("./styles");
|
|
65
65
|
var DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION = 20;
|
|
66
66
|
var EntitySelector = function (_a) {
|
|
67
|
-
var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, _f = _a.isMasked, isMasked = _f === void 0 ? false : _f, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick", "isMasked"]);
|
|
67
|
+
var _b = _a.entity, entity = _b === void 0 ? {} : _b, _c = _a.entityTypesUris, entityTypesUris = _c === void 0 ? [] : _c, mode = _a.mode, _d = _a.max, max = _d === void 0 ? DEFAULT_MAX_TYPEAHEAD_SEARCH_OPTION : _d, onChange = _a.onChange, onCreate = _a.onCreate, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, attributeTypesSelectionStrategy = _a.attributeTypesSelectionStrategy, _e = _a.disableLinkClick, disableLinkClick = _e === void 0 ? false : _e, _f = _a.isMasked, isMasked = _f === void 0 ? false : _f, required = _a.required, otherProps = __rest(_a, ["entity", "entityTypesUris", "mode", "max", "onChange", "onCreate", "metadata", "globalSearchRequestOptions", "attributeTypesSelectionStrategy", "disableLinkClick", "isMasked", "required"]);
|
|
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]);
|
|
@@ -123,7 +123,7 @@ var EntitySelector = function (_a) {
|
|
|
123
123
|
return (__assign(__assign({}, (TextFieldProps || {})), (_a = {}, _a['data-reltio-id'] = 'reltio-entity-selector', _a)));
|
|
124
124
|
}, [TextFieldProps]);
|
|
125
125
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
126
|
-
react_1.default.createElement(DropDownSelector_1.DropDownSelector, __assign({ key: entityTypesUris.join(','), 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)),
|
|
126
|
+
react_1.default.createElement(DropDownSelector_1.DropDownSelector, __assign({ key: entityTypesUris.join(','), 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, required: required }, dropDownSelectorProps)),
|
|
127
127
|
isTempEntity && (react_1.default.createElement("div", { "data-reltio-id": "entity-creator", className: styles.creatorWrapper },
|
|
128
128
|
react_1.default.createElement(EntityCreator_1.EntityCreator, { mode: mode, attributeTypesSelectionStrategy: attributeTypesSelectionStrategy, entityType: currentEntityType, entityUri: entity.entityUri })))));
|
|
129
129
|
};
|
|
@@ -51,7 +51,7 @@ var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
|
51
51
|
var UrlGeneratorsContext_1 = require("../contexts/UrlGeneratorsContext");
|
|
52
52
|
var events_1 = require("../helpers/events");
|
|
53
53
|
exports.EntityUriLink = (0, react_1.forwardRef)(function (_a, ref) {
|
|
54
|
-
var value = _a.value, children = _a.children, screen = _a.screen, className = _a.className, _b = _a.shouldOpenInNewTab, shouldOpenInNewTab = _b === void 0 ? false : _b, otherProps = __rest(_a, ["value", "children", "screen", "className", "shouldOpenInNewTab"]);
|
|
54
|
+
var value = _a.value, children = _a.children, screen = _a.screen, className = _a.className, _b = _a.shouldOpenInNewTab, shouldOpenInNewTab = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, otherProps = __rest(_a, ["value", "children", "screen", "className", "shouldOpenInNewTab", "disabled"]);
|
|
55
55
|
var generateEntityUrl = (0, react_1.useContext)(UrlGeneratorsContext_1.UrlGeneratorsContext).generateEntityUrl;
|
|
56
56
|
var uiPath = (0, MdmModuleContext_1.useMdmUiPath)();
|
|
57
57
|
var openEntity = (0, MdmModuleContext_1.useMdmAction)('openEntity');
|
|
@@ -62,6 +62,6 @@ exports.EntityUriLink = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
62
62
|
}
|
|
63
63
|
e.stopPropagation();
|
|
64
64
|
}, [openEntity, screen, value]);
|
|
65
|
-
return value ? (react_1.default.createElement("a", __assign({ ref: ref, href: generateEntityUrl({ uiPath: uiPath, uri: value, screen: screen }), onClick: shouldOpenInNewTab ? undefined : handleClick, target: shouldOpenInNewTab ? '_blank' : '_self', rel: "noreferrer", className: className }, otherProps), children))
|
|
65
|
+
return disabled || !value ? (react_1.default.createElement("span", __assign({ ref: ref, className: className }, otherProps), children)) : (react_1.default.createElement("a", __assign({ ref: ref, href: generateEntityUrl({ uiPath: uiPath, uri: value, screen: screen }), onClick: shouldOpenInNewTab ? undefined : handleClick, target: shouldOpenInNewTab ? '_blank' : '_self', rel: "noreferrer", className: className }, otherProps), children));
|
|
66
66
|
});
|
|
67
67
|
exports.EntityUriLink.displayName = 'EntityUriLink';
|
|
@@ -8,6 +8,7 @@ type Props = {
|
|
|
8
8
|
container?: string;
|
|
9
9
|
};
|
|
10
10
|
variant?: 'loading' | 'normal';
|
|
11
|
+
disableEntityLink?: boolean;
|
|
11
12
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
12
|
-
declare const _default: React.MemoExoticComponent<({ entity, classes, variant, ...otherProps }: Props) => React.JSX.Element>;
|
|
13
|
+
declare const _default: React.MemoExoticComponent<({ entity, classes, variant, disableEntityLink, ...otherProps }: Props) => React.JSX.Element>;
|
|
13
14
|
export default _default;
|
|
@@ -54,9 +54,9 @@ var ProfileCardContent_1 = require("./components/ProfileCardContent");
|
|
|
54
54
|
var ProfileCardPlaceholder_1 = require("./components/ProfileCardPlaceholder");
|
|
55
55
|
var styles_1 = require("./styles");
|
|
56
56
|
var ProfileCard = function (_a) {
|
|
57
|
-
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.variant, variant = _c === void 0 ? 'normal' : _c, otherProps = __rest(_a, ["entity", "classes", "variant"]);
|
|
57
|
+
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.variant, variant = _c === void 0 ? 'normal' : _c, _d = _a.disableEntityLink, disableEntityLink = _d === void 0 ? false : _d, otherProps = __rest(_a, ["entity", "classes", "variant", "disableEntityLink"]);
|
|
58
58
|
var styles = (0, styles_1.useStyles)();
|
|
59
59
|
var containerClass = classes.container;
|
|
60
|
-
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)(styles.container, containerClass) }, otherProps), variant === 'normal' ? (react_1.default.createElement(ProfileCardContent_1.ProfileCardContent, { entity: entity, classes: classes })) : (react_1.default.createElement(ProfileCardPlaceholder_1.ProfileCardPlaceholder, null))));
|
|
60
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)(styles.container, containerClass) }, otherProps), variant === 'normal' ? (react_1.default.createElement(ProfileCardContent_1.ProfileCardContent, { entity: entity, classes: classes, disableEntityLink: disableEntityLink })) : (react_1.default.createElement(ProfileCardPlaceholder_1.ProfileCardPlaceholder, null))));
|
|
61
61
|
};
|
|
62
62
|
exports.default = (0, react_1.memo)(ProfileCard);
|
|
@@ -117,4 +117,23 @@ describe('Profile card tests', function () {
|
|
|
117
117
|
react_2.screen.getByTestId('profile-card-placeholder-avatar');
|
|
118
118
|
react_2.screen.getByTestId('profile-card-placeholder-info');
|
|
119
119
|
});
|
|
120
|
+
it('should render two ProfileCards: one from IdentityBuilder (no link) and one normal (with link)', function () {
|
|
121
|
+
var entityWithDataTenant = __assign(__assign({}, defaultEntity), { uri: 'entities/dt-456', label: 'IdentityBuilder match', dataTenant: 'tenant-with-id-builder' });
|
|
122
|
+
var Providers = function (_a) {
|
|
123
|
+
var children = _a.children;
|
|
124
|
+
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children));
|
|
125
|
+
};
|
|
126
|
+
(0, react_2.render)(react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
|
+
react_1.default.createElement(ProfileCard_1.default, { entity: entityWithDataTenant, disableEntityLink: true, "data-reltio-id": "profile-id-builder" }),
|
|
128
|
+
react_1.default.createElement(ProfileCard_1.default, { entity: defaultEntity, disableEntityLink: false, "data-reltio-id": "profile-normal" })), { wrapper: Providers });
|
|
129
|
+
// IdentityBuilder: the label is visible as text only, no link
|
|
130
|
+
var idBuilderCard = react_2.screen.getByTestId('profile-id-builder');
|
|
131
|
+
expect(idBuilderCard).toHaveTextContent('IdentityBuilder match');
|
|
132
|
+
expect(idBuilderCard.querySelector('a[href]')).not.toBeInTheDocument();
|
|
133
|
+
// Normal: a label is a link
|
|
134
|
+
var normalCard = react_2.screen.getByTestId('profile-normal');
|
|
135
|
+
expect(normalCard).toHaveTextContent('Main label');
|
|
136
|
+
expect(normalCard.querySelector('a[href]')).toBeInTheDocument();
|
|
137
|
+
expect(react_2.screen.getByRole('link', { name: 'Main label' })).toHaveAttribute('href', 'https://reltio.com/nui#p~com.reltio.plugins.entity.default.DefaultPerspective_e~entities/123');
|
|
138
|
+
});
|
|
120
139
|
});
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
label?: string;
|
|
7
7
|
secondaryLabel?: string;
|
|
8
8
|
};
|
|
9
|
+
disableEntityLink?: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare const ProfileCardContent: ({ entity, classes }: Props) => React.JSX.Element;
|
|
11
|
+
export declare const ProfileCardContent: ({ entity, classes, disableEntityLink }: Props) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -37,7 +37,7 @@ var ExpandedValueTooltip_1 = require("../../../ExpandedValueTooltip");
|
|
|
37
37
|
var EntityTypeBadge_1 = require("../../../EntityTypeBadge");
|
|
38
38
|
var styles_1 = require("./styles");
|
|
39
39
|
var ProfileCardContent = function (_a) {
|
|
40
|
-
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b;
|
|
40
|
+
var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.disableEntityLink, disableEntityLink = _c === void 0 ? false : _c;
|
|
41
41
|
var styles = (0, styles_1.useStyles)();
|
|
42
42
|
var secondaryLabelClass = classes.secondaryLabel, labelClass = classes.label;
|
|
43
43
|
var label = (0, mdm_sdk_1.getLabel)(entity.label);
|
|
@@ -48,7 +48,7 @@ var ProfileCardContent = function (_a) {
|
|
|
48
48
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
49
49
|
react_1.default.createElement(EntityAvatar_1.EntityAvatar, { entity: entity, imageClassName: styles.image }),
|
|
50
50
|
react_1.default.createElement("div", { className: styles.info },
|
|
51
|
-
react_1.default.createElement(EntityUriLink_1.EntityUriLink, { value: (0, mdm_sdk_1.getEntityUriForLink)(entity), className: styles.link },
|
|
51
|
+
react_1.default.createElement(EntityUriLink_1.EntityUriLink, { value: (0, mdm_sdk_1.getEntityUriForLink)(entity), className: styles.link, disabled: disableEntityLink },
|
|
52
52
|
react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: label, placement: "top", showOnExceededHeight: true },
|
|
53
53
|
react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.label, labelClass) }, label))),
|
|
54
54
|
secondaryLabel && (react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: secondaryLabel, placement: "top", showOnExceededHeight: true },
|
|
@@ -4,6 +4,7 @@ type Props = {
|
|
|
4
4
|
selectedTenant: DataTenant;
|
|
5
5
|
entityTypeUri: string;
|
|
6
6
|
onChangeTenant: (tenant: DataTenant) => void;
|
|
7
|
+
dataTenants: DataTenant[];
|
|
7
8
|
};
|
|
8
|
-
export declare const TenantsDropDownSelector: ({ entityTypeUri, onChangeTenant, selectedTenant }: Props) => React.JSX.Element;
|
|
9
|
+
export declare const TenantsDropDownSelector: ({ entityTypeUri, onChangeTenant, selectedTenant, dataTenants }: Props) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -37,9 +37,8 @@ var TenantMenuItem_1 = require("./components/TenantMenuItem");
|
|
|
37
37
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
38
38
|
var styles_1 = require("./styles");
|
|
39
39
|
var TenantsDropDownSelector = function (_a) {
|
|
40
|
-
var entityTypeUri = _a.entityTypeUri, onChangeTenant = _a.onChangeTenant, selectedTenant = _a.selectedTenant;
|
|
40
|
+
var entityTypeUri = _a.entityTypeUri, onChangeTenant = _a.onChangeTenant, selectedTenant = _a.selectedTenant, dataTenants = _a.dataTenants;
|
|
41
41
|
var styles = (0, styles_1.useStyles)();
|
|
42
|
-
var dataTenants = (0, MdmModuleContext_1.useMdmDataTenants)();
|
|
43
42
|
var customerTenant = (0, MdmModuleContext_1.useMdmTenantObject)();
|
|
44
43
|
var menuItems = (0, react_1.useMemo)(function () {
|
|
45
44
|
return (0, ramda_1.pipe)((0, ramda_1.defaultTo)([]), (0, ramda_1.filter)((0, mdm_sdk_1.isAvailableTenantForEntityType)(entityTypeUri)), (0, ramda_1.map)(function (dataTenant) { return ({
|