Skip to content

Commit 8a1a4cb

Browse files
authored
ref(ts) Remove a redundant container on Access (#15313)
This container component can be replaced by an existing HOC and an additional property read.
1 parent 74d8c76 commit 8a1a4cb

File tree

8 files changed

+1248
-1828
lines changed

8 files changed

+1248
-1828
lines changed

src/sentry/static/sentry/app/components/acl/access.tsx

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
2+
import PropTypes from 'prop-types';
33

44
import {t} from 'app/locale';
5-
import {Config, Organization, User} from 'app/types';
5+
import {Config, Organization} from 'app/types';
66
import Alert from 'app/components/alert';
77
import SentryTypes from 'app/sentryTypes';
88
import withConfig from 'app/utils/withConfig';
@@ -47,7 +47,7 @@ type DefaultProps = {
4747
/**
4848
* List of required access levels
4949
*/
50-
access?: string[];
50+
access: string[];
5151
};
5252

5353
const defaultProps: DefaultProps = {
@@ -62,10 +62,11 @@ type Props = {
6262
* Current Organization
6363
*/
6464
organization: Organization;
65+
6566
/**
66-
* User Configuration from ConfigStore
67+
* Configuration from ConfigStore
6768
*/
68-
configUser: User;
69+
config: Config;
6970

7071
/**
7172
* Children can be a node or a function as child.
@@ -77,9 +78,8 @@ type Props = {
7778
* Component to handle access restrictions.
7879
*/
7980
class Access extends React.Component<Props> {
80-
static propTypes = {
81+
static propTypes: any = {
8182
organization: SentryTypes.Organization,
82-
configUser: PropTypes.object,
8383
access: PropTypes.arrayOf(PropTypes.string),
8484
requireAll: PropTypes.bool,
8585
isSuperuser: PropTypes.bool,
@@ -92,7 +92,7 @@ class Access extends React.Component<Props> {
9292
render() {
9393
const {
9494
organization,
95-
configUser,
95+
config,
9696
access,
9797
requireAll,
9898
isSuperuser,
@@ -104,7 +104,7 @@ class Access extends React.Component<Props> {
104104
const method = requireAll ? 'every' : 'some';
105105

106106
const hasAccess = !access || access[method](acc => orgAccess.includes(acc));
107-
const hasSuperuser = !!configUser.isSuperuser;
107+
const hasSuperuser = !!config.user.isSuperuser;
108108

109109
const renderProps: ChildRenderProps = {
110110
hasAccess,
@@ -127,20 +127,4 @@ class Access extends React.Component<Props> {
127127
}
128128
}
129129

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

Comments
 (0)