Skip to content

Commit 24eadd6

Browse files
Merge remote-tracking branch 'origin/8.3' into 8.4
2 parents aa84e84 + 6bbba68 commit 24eadd6

File tree

7 files changed

+94
-9
lines changed

7 files changed

+94
-9
lines changed

packages/neos-ui-editors/src/Editors/AssetEditor/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export default class AssetEditor extends PureComponent {
238238
<SelectBox
239239
optionValueField="identifier"
240240
loadingLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:loading')}
241-
displaySearchBox={true}
241+
displaySearchBox={this.isFeatureEnabled('mediaBrowser')}
242242
ListPreviewElement={AssetOption}
243243
placeholder={this.props.i18nRegistry.translate(this.props.placeholder)}
244244
options={this.props.value ? this.state.options : this.state.searchOptions}
@@ -265,7 +265,7 @@ export default class AssetEditor extends PureComponent {
265265
dndType={dndTypes.MULTISELECT}
266266
optionValueField="identifier"
267267
loadingLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:loading')}
268-
displaySearchBox={true}
268+
displaySearchBox={this.isFeatureEnabled('mediaBrowser')}
269269
ListPreviewElement={AssetOption}
270270
placeholder={this.props.i18nRegistry.translate(this.props.placeholder)}
271271
options={this.state.options || []}

packages/neos-ui-editors/src/Editors/SelectBox/DataSourceBasedSelectBoxEditor.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import MultiSelectBox from '@neos-project/react-ui-components/src/MultiSelectBox
77
import {selectors} from '@neos-project/neos-ui-redux-store';
88
import {neos} from '@neos-project/neos-ui-decorators';
99
import {shouldDisplaySearchBox, searchOptions, processSelectBoxOptions} from './SelectBoxHelpers';
10+
import {createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue} from './createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue';
1011
import PreviewOption from '../../Library/PreviewOption';
1112

1213
const getDataLoaderOptionsForProps = props => ({
@@ -30,7 +31,17 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
3031
className: PropTypes.string,
3132
value: PropTypes.oneOfType([
3233
PropTypes.string,
33-
PropTypes.arrayOf(PropTypes.string)
34+
PropTypes.arrayOf(PropTypes.string),
35+
PropTypes.shape({
36+
__identity: PropTypes.string.isRequired,
37+
__type: PropTypes.string
38+
}),
39+
PropTypes.arrayOf(
40+
PropTypes.shape({
41+
__identity: PropTypes.string.isRequired,
42+
__type: PropTypes.string
43+
})
44+
)
3445
]),
3546
options: PropTypes.shape({
3647
allowEmpty: PropTypes.bool,
@@ -101,8 +112,23 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
101112
});
102113
}
103114

115+
get valueForSingleSelect() {
116+
const {value} = this.props;
117+
return createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue(value);
118+
}
119+
120+
get valueForMultiSelect() {
121+
const {value} = this.props;
122+
123+
if (Array.isArray(value)) {
124+
return value.map(createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue);
125+
}
126+
127+
return value ? [createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue(value)] : [];
128+
}
129+
104130
render() {
105-
const {commit, value, i18nRegistry, className} = this.props;
131+
const {commit, i18nRegistry, className} = this.props;
106132
const options = Object.assign({}, this.constructor.defaultOptions, this.props.options);
107133

108134
const processedSelectBoxOptions = processSelectBoxOptions(i18nRegistry, this.state.selectBoxOptions);
@@ -115,7 +141,7 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
115141
return (<MultiSelectBox
116142
className={className}
117143
options={processedSelectBoxOptions}
118-
values={value || []}
144+
values={this.valueForMultiSelect}
119145
onValuesChange={commit}
120146
loadingLabel={loadingLabel}
121147
ListPreviewElement={PreviewOption}
@@ -136,7 +162,7 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
136162
return (<SelectBox
137163
className={className}
138164
options={this.state.searchTerm ? searchOptions(this.state.searchTerm, processedSelectBoxOptions) : processedSelectBoxOptions}
139-
value={value}
165+
value={this.valueForSingleSelect}
140166
onValueChange={commit}
141167
loadingLabel={loadingLabel}
142168
ListPreviewElement={PreviewOption}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue} from './createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue';
2+
3+
describe('createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue', () => {
4+
it('accepts value of type "string" and returns a "string"', () => {
5+
const value =
6+
createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue(
7+
'I am already a valid select box value, believe it or not.'
8+
);
9+
10+
expect(value).toEqual(
11+
'I am already a valid select box value, believe it or not.'
12+
);
13+
});
14+
15+
it('accepts an object identity DTO and returns a "string"', () => {
16+
const value =
17+
createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue({
18+
__identity: 'de93b358-cb77-422e-b295-2f219bfc4dfb',
19+
__type: 'Neos\\Media\\Domain\\Model\\Tag'
20+
});
21+
22+
expect(value).toEqual('de93b358-cb77-422e-b295-2f219bfc4dfb');
23+
});
24+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @TODO I am a cry for help!
3+
*
4+
* This is an ad-hoc solution to the problem that properties of a PHP class type
5+
* (like "Neos\Media\Domain\Model\Tag" for example) may or may not be persisted
6+
* as object identity DTOs.
7+
*
8+
* The function name is intentionally kept vague to allow bugfixes to capture
9+
* more, potentially obscure cases in which the persisted property value needs
10+
* to be filtered before the select box receives it.
11+
*
12+
* A proper way to handle this would be to define precisely what kind of values
13+
* the select box editor is going to accept and simply reject everything that
14+
* violates that definition. Errors would need to be handled in way that
15+
* indicates to editors that there's a problem that an integrator needs to fix.
16+
* Furthermore the error handling should make it easy for integrators to figure
17+
* out what value has been provided to the select box and why it has been
18+
* rejected.
19+
*
20+
* That however would constitute a breaking change and that's how we end up
21+
* with with this function.
22+
*/
23+
export const createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue = (
24+
value: unknown
25+
) => {
26+
if (typeof value === 'object' && value !== null) {
27+
if (
28+
'__identity' in value &&
29+
typeof (value as Record<'__identity', any>).__identity === 'string'
30+
) {
31+
return (value as Record<'__identity', string>).__identity;
32+
}
33+
}
34+
35+
return value;
36+
};

packages/neos-ui-extensibility-webpack-adapter/scripts/helpers/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ module.exports = function (neosPackageJson) {
4545
require.resolve('babel-plugin-transform-es2015-block-scoping'),
4646
require.resolve('babel-plugin-transform-es2015-typeof-symbol'),
4747
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
48-
[require.resolve('babel-plugin-transform-regenerator'), {async: false, asyncGenerators: false}]
4948
]
5049
}
5150
}]

packages/react-ui-components/src/DropDown/style.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
position: absolute;
5050
top: 100%;
5151
left: 0;
52-
z-index: var(--zIndex-DropdownContents-Context);
52+
z-index: var(--zIndex-SecondaryInspectorElevated-DropDownContents);
5353
display: none;
5454
width: 100%;
5555
margin: 0;

packages/react-ui-components/src/SelectBox/style.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
.selectBox__contents {
3030
min-width: 160px;
3131
box-shadow: 0 5px 5px rgba(0, 0, 0, .2);
32-
z-index: var(--zIndex-SelectBoxContents);
32+
z-index: var(--zIndex-SecondaryInspectorElevated-DropDownContents);
3333
margin-top: -2px;
3434
}
3535

0 commit comments

Comments
 (0)