1
- import PropTypes from 'prop-types' ;
2
1
import React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
3
4
4
import { t } from 'app/locale' ;
5
- import { Config , Organization , User } from 'app/types' ;
5
+ import { Config , Organization } from 'app/types' ;
6
6
import Alert from 'app/components/alert' ;
7
7
import SentryTypes from 'app/sentryTypes' ;
8
8
import withConfig from 'app/utils/withConfig' ;
@@ -47,7 +47,7 @@ type DefaultProps = {
47
47
/**
48
48
* List of required access levels
49
49
*/
50
- access ? : string [ ] ;
50
+ access : string [ ] ;
51
51
} ;
52
52
53
53
const defaultProps : DefaultProps = {
@@ -62,10 +62,11 @@ type Props = {
62
62
* Current Organization
63
63
*/
64
64
organization : Organization ;
65
+
65
66
/**
66
- * User Configuration from ConfigStore
67
+ * Configuration from ConfigStore
67
68
*/
68
- configUser : User ;
69
+ config : Config ;
69
70
70
71
/**
71
72
* Children can be a node or a function as child.
@@ -77,9 +78,8 @@ type Props = {
77
78
* Component to handle access restrictions.
78
79
*/
79
80
class Access extends React . Component < Props > {
80
- static propTypes = {
81
+ static propTypes : any = {
81
82
organization : SentryTypes . Organization ,
82
- configUser : PropTypes . object ,
83
83
access : PropTypes . arrayOf ( PropTypes . string ) ,
84
84
requireAll : PropTypes . bool ,
85
85
isSuperuser : PropTypes . bool ,
@@ -92,7 +92,7 @@ class Access extends React.Component<Props> {
92
92
render ( ) {
93
93
const {
94
94
organization,
95
- configUser ,
95
+ config ,
96
96
access,
97
97
requireAll,
98
98
isSuperuser,
@@ -104,7 +104,7 @@ class Access extends React.Component<Props> {
104
104
const method = requireAll ? 'every' : 'some' ;
105
105
106
106
const hasAccess = ! access || access [ method ] ( acc => orgAccess . includes ( acc ) ) ;
107
- const hasSuperuser = ! ! configUser . isSuperuser ;
107
+ const hasSuperuser = ! ! config . user . isSuperuser ;
108
108
109
109
const renderProps : ChildRenderProps = {
110
110
hasAccess,
@@ -127,20 +127,4 @@ class Access extends React.Component<Props> {
127
127
}
128
128
}
129
129
130
- type ContainerProps = {
131
- config : Config ;
132
- organization : Organization ;
133
- } & Omit < Props , 'configUser' > ;
134
-
135
- class AccessContainer extends React . Component < ContainerProps > {
136
- static propTypes = {
137
- config : SentryTypes . Config ,
138
- } ;
139
-
140
- render ( ) {
141
- const user = this . props . config . user || { } ;
142
- return < Access configUser = { user } { ...this . props } /> ;
143
- }
144
- }
145
-
146
- export default withConfig ( withOrganization ( AccessContainer ) ) ;
130
+ export default withOrganization ( withConfig ( Access ) ) ;
0 commit comments