1
1
import React , { PureComponent } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { $get , $contains } from 'plow-js' ;
3
+ import { $get } from 'plow-js' ;
4
4
import Tabs from '@neos-project/react-ui-components/src/Tabs/' ;
5
5
6
6
import PropertyGroup from '../PropertyGroup/index' ;
@@ -16,25 +16,20 @@ export default class TabPanel extends PureComponent {
16
16
renderSecondaryInspector : PropTypes . func . isRequired ,
17
17
node : PropTypes . object . isRequired ,
18
18
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
34
21
} ;
35
22
36
23
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 ;
38
33
39
34
return (
40
35
< Tabs . Panel theme = { { panel : style . inspectorTabPanel } } >
@@ -47,7 +42,7 @@ export default class TabPanel extends PureComponent {
47
42
icon = { $get ( 'icon' , group ) }
48
43
// Overlay default collapsed state over current state
49
44
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 ) }
51
46
renderSecondaryInspector = { renderSecondaryInspector }
52
47
node = { node }
53
48
commit = { commit }
@@ -58,9 +53,9 @@ export default class TabPanel extends PureComponent {
58
53
}
59
54
60
55
render ( ) {
61
- const { groups} = this . props ;
56
+ const { groups, isPropertyEnabled } = this . props ;
62
57
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 ) ) : [ ] ;
64
59
65
60
return this . renderTabPanel ( visibleGroups ) ;
66
61
}
0 commit comments