Skip to content

Commit 9a85580

Browse files
committed
FEATURE: Filter properties in right sidebar
1 parent f288653 commit 9a85580

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

packages/neos-ui/src/Containers/RightSideBar/Inspector/TabPanel/index.js

+15-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {PureComponent} from 'react';
22
import PropTypes from 'prop-types';
3-
import {$get, $contains} from 'plow-js';
3+
import {$get} from 'plow-js';
44
import Tabs from '@neos-project/react-ui-components/src/Tabs/';
55

66
import PropertyGroup from '../PropertyGroup/index';
@@ -16,25 +16,20 @@ export default class TabPanel extends PureComponent {
1616
renderSecondaryInspector: PropTypes.func.isRequired,
1717
node: PropTypes.object.isRequired,
1818
commit: PropTypes.func.isRequired,
19-
handleInspectorApply: PropTypes.func
20-
};
21-
22-
isPropertyEnabled = item => {
23-
const {node} = this.props;
24-
25-
if (item.type !== 'editor') {
26-
return true;
27-
}
28-
29-
if ($get('hidden', item)) {
30-
return false;
31-
}
32-
33-
return $get(['policy', 'canEdit'], node) && !$contains(item.id, 'policy.disallowedProperties', node);
19+
handleInspectorApply: PropTypes.func,
20+
isPropertyEnabled: PropTypes.func
3421
};
3522

3623
renderTabPanel = groups => {
37-
const {handlePanelToggle, handleInspectorApply, toggledPanels, renderSecondaryInspector, node, commit} = this.props;
24+
const {
25+
handlePanelToggle,
26+
handleInspectorApply,
27+
toggledPanels,
28+
renderSecondaryInspector,
29+
node,
30+
commit,
31+
isPropertyEnabled
32+
} = this.props;
3833

3934
return (
4035
<Tabs.Panel theme={{panel: style.inspectorTabPanel}}>
@@ -47,7 +42,7 @@ export default class TabPanel extends PureComponent {
4742
icon={$get('icon', group)}
4843
// Overlay default collapsed state over current state
4944
collapsed={Boolean($get($get('id', group), toggledPanels)) !== Boolean($get('collapsed', group))}
50-
items={$get('items', group).filter(this.isPropertyEnabled)}
45+
items={$get('items', group).filter(isPropertyEnabled)}
5146
renderSecondaryInspector={renderSecondaryInspector}
5247
node={node}
5348
commit={commit}
@@ -58,9 +53,9 @@ export default class TabPanel extends PureComponent {
5853
}
5954

6055
render() {
61-
const {groups} = this.props;
56+
const {groups, isPropertyEnabled} = this.props;
6257

63-
const visibleGroups = groups ? groups.filter(group => $get('items', group) && $get('items', group).some(this.isPropertyEnabled)) : [];
58+
const visibleGroups = groups ? groups.filter(group => $get('items', group) && $get('items', group).some(isPropertyEnabled)) : [];
6459

6560
return this.renderTabPanel(visibleGroups);
6661
}

packages/neos-ui/src/Containers/RightSideBar/Inspector/index.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export default class Inspector extends PureComponent {
8282
secondaryInspectorComponent: null,
8383
toggledPanels: {},
8484
viewConfiguration: null,
85-
originalViewConfiguration: null
85+
originalViewConfiguration: null,
86+
propertyFilter: null
8687
};
8788

8889
configurationIsProcessed = false;
@@ -228,22 +229,34 @@ export default class Inspector extends PureComponent {
228229
this.props.escape();
229230
}
230231

232+
handleFilter = (e) => {
233+
const {value} = e.target;
234+
this.setState({
235+
propertyFilter: value.toLowerCase()
236+
});
237+
}
238+
231239
closeSecondaryInspectorIfNeeded = () => {
232240
if (this.state.secondaryInspectorComponent) {
233241
this.props.closeSecondaryInspector();
234242
}
235243
}
236244

237245
isPropertyEnabled = item => {
238-
const {focusedNode} = this.props;
246+
const {propertyFilter} = this.state;
247+
if (propertyFilter && item.id.toLowerCase().indexOf(propertyFilter) === -1) {
248+
// console.debug('Property not matching filter', item.label, propertyFilter);
249+
return false;
250+
}
239251

240252
if (item.type !== 'editor') {
241253
return true;
242254
}
243255

256+
const {focusedNode} = this.props;
244257
if ($get('hidden', item) || ($get('isAutoCreated', focusedNode) === true && item.id === '_hidden')) {
245258
// This accounts for the fact that auto-created child nodes cannot
246-
// be hidden via the insprector (see: #2282)
259+
// be hidden via the inspector (see: #2282)
247260
return false;
248261
}
249262

@@ -358,6 +371,7 @@ export default class Inspector extends PureComponent {
358371
document.body
359372
)}
360373
<SelectedElement/>
374+
<input type="text" placeholder="Filter properties…" onChange={this.handleFilter} />
361375
<Tabs
362376
className={style.tabs}
363377
theme={{
@@ -411,6 +425,7 @@ export default class Inspector extends PureComponent {
411425
this.handlePanelToggle([$get('id', tab), ...path]);
412426
}}
413427
handleInspectorApply={this.handleApply}
428+
isPropertyEnabled={this.isPropertyEnabled}
414429
/>);
415430
})
416431
}

0 commit comments

Comments
 (0)