@reltio/components 1.4.2183 → 1.4.2184
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/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/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/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/cjs/features/workflow/WorkflowComments/styles.d.ts +1 -1
- package/features/workflow/AddWorkflowDialog/styles.d.ts +1 -1
- package/features/workflow/WorkflowComments/styles.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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 {};
|
|
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React, { useRef, useState } from 'react';
|
|
24
|
-
import PropTypes from 'prop-types';
|
|
25
24
|
import classnames from 'classnames';
|
|
26
25
|
import { defaultTo, identity, isEmpty, path, prop } from 'ramda';
|
|
27
26
|
import { isEmptyValue } from '@reltio/mdm-sdk';
|
|
@@ -34,9 +33,9 @@ import { SingleValue } from './components/SingleValue';
|
|
|
34
33
|
import { useStyles, customStyles, overloadMenuListStyle, withoutLabelInputStyle } from './styles';
|
|
35
34
|
export var DropDownSelector = function (_a) {
|
|
36
35
|
var _b;
|
|
37
|
-
var value = _a.value, label = _a.label,
|
|
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"]);
|
|
38
37
|
var styles = useStyles({ height: height });
|
|
39
|
-
var
|
|
38
|
+
var _j = useState(false), open = _j[0], setOpen = _j[1];
|
|
40
39
|
var inputRef = useRef(null);
|
|
41
40
|
var SelectComponent = getOptions ? AsyncReactSelect : ReactSelect;
|
|
42
41
|
var showIndicatorSeparator = prop('ClearIndicator', components)
|
|
@@ -52,21 +51,5 @@ export var DropDownSelector = function (_a) {
|
|
|
52
51
|
var overloadStylesIfNoLabel = isEmpty(label) ? withoutLabelInputStyle : {};
|
|
53
52
|
var mergedStyles = __assign(__assign(__assign({}, customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
|
|
54
53
|
var mergedClasses = __assign(__assign({}, styles), classes);
|
|
55
|
-
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, 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', 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); } })));
|
|
56
55
|
};
|
|
57
|
-
export var DropDownSelectorType = {
|
|
58
|
-
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
59
|
-
label: PropTypes.string.isRequired,
|
|
60
|
-
getOptions: PropTypes.func,
|
|
61
|
-
options: PropTypes.array,
|
|
62
|
-
onChange: PropTypes.func,
|
|
63
|
-
onCreate: PropTypes.func,
|
|
64
|
-
onClear: PropTypes.func,
|
|
65
|
-
createLabel: PropTypes.string,
|
|
66
|
-
components: PropTypes.object,
|
|
67
|
-
textFieldInputRef: PropTypes.object,
|
|
68
|
-
TextFieldProps: PropTypes.object,
|
|
69
|
-
height: PropTypes.number,
|
|
70
|
-
classes: PropTypes.object
|
|
71
|
-
};
|
|
72
|
-
DropDownSelector.propTypes = DropDownSelectorType;
|
|
@@ -48,6 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import React from 'react';
|
|
49
49
|
import { render, screen, within } from '@testing-library/react';
|
|
50
50
|
import userEvent from '@testing-library/user-event';
|
|
51
|
+
import { getMuiIconByName } from '../test-utils';
|
|
51
52
|
import { DropDownSelector } from './DropDownSelector';
|
|
52
53
|
var defaultOptions = [
|
|
53
54
|
{ label: 'First option', value: 'option1' },
|
|
@@ -159,4 +160,20 @@ describe('Dropdown selector tests', function () {
|
|
|
159
160
|
}
|
|
160
161
|
});
|
|
161
162
|
}); });
|
|
163
|
+
it('should not show create button if canCreateOption is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var props, user;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
props = __assign(__assign({}, defaultProps), { canCreateOption: function () { return false; }, createLabel: 'Create new option' });
|
|
169
|
+
user = setUp(props).user;
|
|
170
|
+
return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
|
|
171
|
+
case 1:
|
|
172
|
+
_a.sent();
|
|
173
|
+
expect(screen.queryByText('Create new option')).not.toBeInTheDocument();
|
|
174
|
+
expect(getMuiIconByName('Add')).not.toBeInTheDocument();
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}); });
|
|
162
179
|
});
|
|
@@ -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 {};
|
|
@@ -10,21 +10,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
14
13
|
import { prop } from 'ramda';
|
|
15
14
|
import AddIcon from '@mui/icons-material/Add';
|
|
16
15
|
import { ReactSelectMenuWithPopper } from '../../../ReactSelectMenuWithPopper';
|
|
17
16
|
import { useStyles } from './styles';
|
|
18
17
|
export var Menu = function (props) {
|
|
19
|
-
var _a = props.selectProps, onCreate = _a.onCreate, createLabel = _a.createLabel, inputValue = _a.inputValue, components = _a.components, children = props.children;
|
|
18
|
+
var _a = props.selectProps, onCreate = _a.onCreate, createLabel = _a.createLabel, inputValue = _a.inputValue, components = _a.components, canCreateOption = _a.canCreateOption, children = props.children;
|
|
20
19
|
var styles = useStyles();
|
|
21
20
|
return (React.createElement(ReactSelectMenuWithPopper, __assign({}, props),
|
|
22
21
|
children,
|
|
23
|
-
createLabel && !prop('Group', components) && (React.createElement("span", { className: styles.addLabel, onClick: function () { return onCreate(inputValue); } },
|
|
22
|
+
createLabel && !prop('Group', components) && canCreateOption() && (React.createElement("span", { className: styles.addLabel, onClick: function () { return onCreate(inputValue); } },
|
|
24
23
|
React.createElement(AddIcon, { className: styles.addIcon }),
|
|
25
24
|
createLabel))));
|
|
26
25
|
};
|
|
27
|
-
Menu.propTypes = {
|
|
28
|
-
children: PropTypes.element.isRequired,
|
|
29
|
-
selectProps: PropTypes.object.isRequired
|
|
30
|
-
};
|
|
@@ -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;
|
|
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import React, { useState, useMemo, useCallback } from 'react';
|
|
24
24
|
import i18n from 'ui-i18n';
|
|
25
25
|
import { isEmpty, prop } from 'ramda';
|
|
26
|
-
import { typeAheadSearch, getEntityType, isTempUri, isAvailableEntityType } from '@reltio/mdm-sdk';
|
|
26
|
+
import { typeAheadSearch, getEntityType, isTempUri, isAvailableEntityType, checkMetadataForCreate } from '@reltio/mdm-sdk';
|
|
27
27
|
import { EmptyStub } from '../EmptyStub';
|
|
28
28
|
import { DropDownSelector } from '../DropDownSelector';
|
|
29
29
|
import { EntityOption } from './components/EntityOption';
|
|
@@ -39,6 +39,18 @@ export var EntitySelector = function (_a) {
|
|
|
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]);
|
|
42
|
+
var creatableEntityTypesUris = useMemo(function () {
|
|
43
|
+
return entityTypesUris.filter(function (entityTypeUri) {
|
|
44
|
+
var entityType = getEntityType(metadata, entityTypeUri);
|
|
45
|
+
return checkMetadataForCreate(mode, entityType);
|
|
46
|
+
});
|
|
47
|
+
}, [entityTypesUris, mode, metadata]);
|
|
48
|
+
var canCreateEntity = useCallback(function (entityTypeUri) {
|
|
49
|
+
if (entityTypes.length === 0) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return creatableEntityTypesUris.includes(entityTypeUri !== null && entityTypeUri !== void 0 ? entityTypeUri : entityTypes[0].uri);
|
|
53
|
+
}, [creatableEntityTypesUris, entityTypes]);
|
|
42
54
|
var options = useMemo(function () { return (__assign(__assign({}, globalSearchRequestOptions), { max: max, sendMasked: isMasked })); }, [globalSearchRequestOptions, isMasked, max]);
|
|
43
55
|
var handleCreate = onCreate
|
|
44
56
|
? function (value, entityTypeUri) {
|
|
@@ -63,8 +75,16 @@ export var EntitySelector = function (_a) {
|
|
|
63
75
|
return (isEmpty(entityTypes) ? Promise.resolve([]) : typeAheadSearch(entityTypes, value, options)).then(buildEntityOptions(entityTypes, onCreate));
|
|
64
76
|
}, [entityTypes, onCreate, options]);
|
|
65
77
|
var currentEntityType = (isEmpty(entity) ? entityTypes[0] : getEntityType(metadata, entity.entityType)) || {};
|
|
66
|
-
var createLabel = onCreate &&
|
|
67
|
-
|
|
78
|
+
var createLabel = onCreate &&
|
|
79
|
+
(inputValue
|
|
80
|
+
? i18n.text('Create "${name}" as new ${entityTypeLabel}', {
|
|
81
|
+
name: inputValue,
|
|
82
|
+
entityTypeLabel: currentEntityType.label
|
|
83
|
+
})
|
|
84
|
+
: i18n.text('Create new ${entityTypeLabel}', { entityTypeLabel: currentEntityType.label }));
|
|
85
|
+
var label = i18n.text('Select ${entityTypeLabel}profile', {
|
|
86
|
+
entityTypeLabel: entityTypes.length === 1 ? "".concat(entityTypes[0].label, " ") : ''
|
|
87
|
+
});
|
|
68
88
|
var isTempEntity = !isEmpty(entity) && isTempUri(entity.entityUri);
|
|
69
89
|
var groupComponent = groupMode ? { Group: Group, GroupHeading: EmptyStub } : {};
|
|
70
90
|
var clearComponent = isTempEntity ? { ClearIndicator: ClearIndicator } : {};
|
|
@@ -74,7 +94,7 @@ export var EntitySelector = function (_a) {
|
|
|
74
94
|
return (__assign(__assign({}, (TextFieldProps || {})), (_a = {}, _a['data-reltio-id'] = 'reltio-entity-selector', _a)));
|
|
75
95
|
}, [TextFieldProps]);
|
|
76
96
|
return (React.createElement(React.Fragment, null,
|
|
77
|
-
React.createElement(DropDownSelector, __assign({ value: !isEmpty(entity) ? entity : undefined, inputValue: inputValue, onInputChange: handleInputChange, getOptions: getOptions, getOptionLabel: prop('entityLabel'), onChange: handleChange, onCreate: handleCreate, onClear: handleClear, label: label, createLabel: createLabel, components: __assign(__assign({ Option: EntityOption, SingleValue: SingleValue }, groupComponent), clearComponent), currentEntityType: currentEntityType, isClearable: true, disableLinkClick: disableLinkClick, TextFieldProps: textFieldProps }, dropDownSelectorProps)),
|
|
97
|
+
React.createElement(DropDownSelector, __assign({ 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)),
|
|
78
98
|
isTempEntity && (React.createElement("div", { "data-reltio-id": "entity-creator", className: styles.creatorWrapper },
|
|
79
99
|
React.createElement(EntityCreator, { mode: mode, attributeTypesSelectionStrategy: attributeTypesSelectionStrategy, entityType: currentEntityType, entityUri: entity.entityUri })))));
|
|
80
100
|
};
|
|
@@ -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 {};
|
|
@@ -10,25 +10,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
14
13
|
import i18n from 'ui-i18n';
|
|
15
14
|
import { components } from 'react-select';
|
|
16
15
|
import AddIcon from '@mui/icons-material/Add';
|
|
17
16
|
import { useStyles } from './styles';
|
|
18
17
|
var ComponentsGroup = components.Group;
|
|
19
18
|
export var Group = function (props) {
|
|
20
|
-
var _a = props.selectProps, inputValue = _a.inputValue, onCreate = _a.onCreate, data = props.data, children = props.children;
|
|
21
19
|
var styles = useStyles();
|
|
20
|
+
var _a = props.selectProps, inputValue = _a.inputValue, onCreate = _a.onCreate, canCreateOption = _a.canCreateOption, data = props.data, children = props.children;
|
|
22
21
|
return (React.createElement(ComponentsGroup, __assign({}, props),
|
|
23
22
|
React.createElement("div", { className: styles.groupHeading },
|
|
24
23
|
React.createElement("span", null, data.label),
|
|
25
|
-
onCreate && (React.createElement("span", { onClick: function () { return onCreate(inputValue, data.entityType); }, className: styles.addLabel },
|
|
24
|
+
onCreate && canCreateOption(data.entityType) && (React.createElement("span", { onClick: function () { return onCreate(inputValue, data.entityType); }, className: styles.addLabel },
|
|
26
25
|
React.createElement(AddIcon, { className: styles.addIcon }),
|
|
27
|
-
|
|
26
|
+
inputValue
|
|
27
|
+
? i18n.text('Create "${name}" as new ${entityTypeLabel}', {
|
|
28
|
+
name: inputValue,
|
|
29
|
+
entityTypeLabel: data.label
|
|
30
|
+
})
|
|
31
|
+
: i18n.text('Create new ${entityTypeLabel}', { entityTypeLabel: data.label })))),
|
|
28
32
|
children));
|
|
29
33
|
};
|
|
30
|
-
Group.propTypes = {
|
|
31
|
-
selectProps: PropTypes.object.isRequired,
|
|
32
|
-
data: PropTypes.object,
|
|
33
|
-
children: PropTypes.array
|
|
34
|
-
};
|
|
@@ -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">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "input" | "root" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "input" | "root" | "inputLabel" | "inputRoot" | "inputText" | "emptyInput" | "disabledInput" | "disabledPointer" | "disabledUnderline" | "popup-opened-icon">;
|
package/MultiSelect/styles.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ type PlaceholderProps = {
|
|
|
2
2
|
placeholder?: string;
|
|
3
3
|
label?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const useStyles: (props: PlaceholderProps) => import("@mui/styles").ClassNameMap<"placeholder" | "label" | "dropdownIndicator" | "
|
|
5
|
+
export declare const useStyles: (props: PlaceholderProps) => import("@mui/styles").ClassNameMap<"placeholder" | "label" | "dropdownIndicator" | "clearIndicator" | "option--selected">;
|
|
6
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"label" | "info" | "secondaryLabel" | "thirdRow" | "@keyframes keyframes-wave" | "wave"
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"label" | "info" | "secondaryLabel" | "avatar" | "thirdRow" | "@keyframes keyframes-wave" | "wave">;
|
|
@@ -42,9 +42,9 @@ export namespace NodeRendererDefault {
|
|
|
42
42
|
}
|
|
43
43
|
namespace propTypes {
|
|
44
44
|
export let node: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>;
|
|
45
|
-
let title_1: PropTypes.Requireable<NonNullable<((...args: any[]) => any)
|
|
45
|
+
let title_1: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
46
46
|
export { title_1 as title };
|
|
47
|
-
let subtitle_1: PropTypes.Requireable<NonNullable<((...args: any[]) => any)
|
|
47
|
+
let subtitle_1: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
48
48
|
export { subtitle_1 as subtitle };
|
|
49
49
|
export let path: PropTypes.Validator<NonNullable<string | number>[]>;
|
|
50
50
|
export let treeIndex: PropTypes.Validator<number>;
|
|
@@ -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">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "input" | "root" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"icon" | "input" | "root" | "inputLabel" | "inputRoot" | "inputText" | "emptyInput" | "disabledInput" | "disabledPointer" | "disabledUnderline" | "popup-opened-icon">;
|
|
@@ -2,5 +2,5 @@ type PlaceholderProps = {
|
|
|
2
2
|
placeholder?: string;
|
|
3
3
|
label?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const useStyles: (props: PlaceholderProps) => import("@mui/styles").ClassNameMap<"placeholder" | "label" | "dropdownIndicator" | "
|
|
5
|
+
export declare const useStyles: (props: PlaceholderProps) => import("@mui/styles").ClassNameMap<"placeholder" | "label" | "dropdownIndicator" | "clearIndicator" | "option--selected">;
|
|
6
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"label" | "info" | "secondaryLabel" | "thirdRow" | "@keyframes keyframes-wave" | "wave"
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"label" | "info" | "secondaryLabel" | "avatar" | "thirdRow" | "@keyframes keyframes-wave" | "wave">;
|
|
@@ -42,9 +42,9 @@ export namespace NodeRendererDefault {
|
|
|
42
42
|
}
|
|
43
43
|
namespace propTypes {
|
|
44
44
|
export let node: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>;
|
|
45
|
-
let title_1: PropTypes.Requireable<NonNullable<((...args: any[]) => any)
|
|
45
|
+
let title_1: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
46
46
|
export { title_1 as title };
|
|
47
|
-
let subtitle_1: PropTypes.Requireable<NonNullable<((...args: any[]) => any)
|
|
47
|
+
let subtitle_1: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>;
|
|
48
48
|
export { subtitle_1 as subtitle };
|
|
49
49
|
export let path: PropTypes.Validator<NonNullable<string | number>[]>;
|
|
50
50
|
export let treeIndex: PropTypes.Validator<number>;
|
|
@@ -211,12 +211,10 @@ var RelationEditor = function (_a) {
|
|
|
211
211
|
setModifiedEntity(newEntity);
|
|
212
212
|
}, [setModifiedEntity, onChangeEntity, mode, metadata]);
|
|
213
213
|
var errorMessage = (0, mdm_sdk_1.getErrorMessage)(error);
|
|
214
|
-
var
|
|
215
|
-
var _a
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
return content.entityTypes;
|
|
214
|
+
var entityTypesUris = (0, react_1.useMemo)(function () {
|
|
215
|
+
var _a;
|
|
216
|
+
var _b = config, content = _b.content, contentSecondLevel = _b.contentSecondLevel;
|
|
217
|
+
return ((_a = (contentSecondLevel && connection.parentEntityUri ? contentSecondLevel.entityTypes : content.entityTypes)) !== null && _a !== void 0 ? _a : []);
|
|
220
218
|
}, [config, connection.parentEntityUri]);
|
|
221
219
|
var isEntityHasMaskedAttrValue = (0, ramda_1.pipe)(ramda_1.values, ramda_1.flatten, (0, ramda_1.any)(mdm_sdk_1.isAttributeHasMaskedValue))(((_d = (_c = connection.entity) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.attributes) || {});
|
|
222
220
|
var isMasked = showMasking && isEntityHasMaskedAttrValue;
|
|
@@ -231,7 +229,7 @@ var RelationEditor = function (_a) {
|
|
|
231
229
|
react_1.default.createElement(EntitySelector_1.EntitySelector, { className: (0, classnames_1.default)(styles.item, (_b = {},
|
|
232
230
|
_b[styles.dense] = errorMessage ||
|
|
233
231
|
(connection.entity && (0, mdm_sdk_1.isTempUri)(connection.entity.entityUri)),
|
|
234
|
-
_b)), entity: connection.entity || {}, entityTypesUris:
|
|
232
|
+
_b)), entity: connection.entity || {}, entityTypesUris: entityTypesUris, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: mdm_sdk_1.relationEditorAttributeTypesSelectionStrategy, isMasked: isMasked })))),
|
|
235
233
|
react_1.default.createElement(HiddenAttributesContext_1.HiddenAttributesContext.Provider, { value: emptyHiddenAttributes },
|
|
236
234
|
react_1.default.createElement(EditModeAttributesList_1.EditModeAttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute }))))),
|
|
237
235
|
react_1.default.createElement("div", { className: styles.actionButtons },
|
|
@@ -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 ramda_1 = require("ramda");
|
|
56
57
|
var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
|
|
57
58
|
var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
58
59
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
@@ -483,6 +484,45 @@ describe('relation editor behaviour', function () {
|
|
|
483
484
|
}
|
|
484
485
|
});
|
|
485
486
|
}); });
|
|
487
|
+
it('should hide create button when user lacks metadata permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
488
|
+
var props, user, inputs;
|
|
489
|
+
return __generator(this, function (_a) {
|
|
490
|
+
switch (_a.label) {
|
|
491
|
+
case 0:
|
|
492
|
+
props = (0, ramda_1.assocPath)(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST'], defaultProps);
|
|
493
|
+
user = setUp({ props: props }).user;
|
|
494
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
495
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
496
|
+
case 1:
|
|
497
|
+
_a.sent();
|
|
498
|
+
expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
|
|
499
|
+
return [2 /*return*/];
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}); });
|
|
503
|
+
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 () {
|
|
504
|
+
var props, user, inputs;
|
|
505
|
+
return __generator(this, function (_a) {
|
|
506
|
+
switch (_a.label) {
|
|
507
|
+
case 0:
|
|
508
|
+
props = (0, ramda_1.pipe)((0, ramda_1.assocPath)(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST']), (0, ramda_1.assocPath)(['config', 'content'], {
|
|
509
|
+
entityTypes: ['configuration/entityTypes/Location', 'configuration/entityTypes/HCA'],
|
|
510
|
+
outRelations: [
|
|
511
|
+
{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' },
|
|
512
|
+
{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }
|
|
513
|
+
]
|
|
514
|
+
}))(defaultProps);
|
|
515
|
+
user = setUp({ props: props }).user;
|
|
516
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
517
|
+
return [4 /*yield*/, user.click(inputs[1])];
|
|
518
|
+
case 1:
|
|
519
|
+
_a.sent();
|
|
520
|
+
expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
|
|
521
|
+
expect(react_2.screen.getByText('Create new HCA')).toBeInTheDocument();
|
|
522
|
+
return [2 /*return*/];
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}); });
|
|
486
526
|
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 () {
|
|
487
527
|
var props, mdmValues, user, inputs;
|
|
488
528
|
return __generator(this, function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "asterisk" | "inputRoot" | "cancelButton" | "inputLabelRoot" | "popoverPaper" | "simpleDropDownSelector">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "filledInputRoot" | "commentsContainer" | "modeSwitcherWrapper" | "sendButton">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"content" | "title" | "footer" | "input" | "select" | "asterisk" | "inputRoot" | "cancelButton" | "inputLabelRoot" | "popoverPaper" | "simpleDropDownSelector">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "filledInputRoot" | "commentsContainer" | "modeSwitcherWrapper" | "sendButton">;
|