|
@@ -1,4 +1,3 @@
|
|
-import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import styled from '@emotion/styled';
|
|
import styled from '@emotion/styled';
|
|
|
|
|
|
@@ -10,15 +9,23 @@ import {IconFlag} from 'app/icons';
|
|
import Well from 'app/components/well';
|
|
import Well from 'app/components/well';
|
|
import space from 'app/styles/space';
|
|
import space from 'app/styles/space';
|
|
import withApi from 'app/utils/withApi';
|
|
import withApi from 'app/utils/withApi';
|
|
-
|
|
|
|
-class MissingProjectMembership extends React.Component {
|
|
|
|
- static propTypes = {
|
|
|
|
- api: PropTypes.object,
|
|
|
|
- organization: PropTypes.object.isRequired,
|
|
|
|
- projectId: PropTypes.string.isRequired,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- constructor(props) {
|
|
|
|
|
|
+import {Client} from 'app/api';
|
|
|
|
+import {Organization, Project, Team} from 'app/types';
|
|
|
|
+
|
|
|
|
+type Props = {
|
|
|
|
+ api: Client;
|
|
|
|
+ organization: Organization;
|
|
|
|
+ projectId: string;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+type State = {
|
|
|
|
+ loading: boolean;
|
|
|
|
+ error: boolean;
|
|
|
|
+ project?: Project;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+class MissingProjectMembership extends React.Component<Props, State> {
|
|
|
|
+ constructor(props: Props) {
|
|
super(props);
|
|
super(props);
|
|
|
|
|
|
const {organization, projectId} = this.props;
|
|
const {organization, projectId} = this.props;
|
|
@@ -31,7 +38,7 @@ class MissingProjectMembership extends React.Component {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- joinTeam(team) {
|
|
|
|
|
|
+ joinTeam(team: Team) {
|
|
this.setState({
|
|
this.setState({
|
|
loading: true,
|
|
loading: true,
|
|
});
|
|
});
|
|
@@ -60,7 +67,7 @@ class MissingProjectMembership extends React.Component {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- renderJoinTeam(team, features) {
|
|
|
|
|
|
+ renderJoinTeam(team: Team, features: Set<string>) {
|
|
if (!team) {
|
|
if (!team) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -82,7 +89,7 @@ class MissingProjectMembership extends React.Component {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- renderExplanation(features) {
|
|
|
|
|
|
+ renderExplanation(features: Set<string>) {
|
|
if (features.has('open-membership')) {
|
|
if (features.has('open-membership')) {
|
|
return t('To view this data you must one of the following teams.');
|
|
return t('To view this data you must one of the following teams.');
|
|
} else {
|
|
} else {
|
|
@@ -92,8 +99,9 @@ class MissingProjectMembership extends React.Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- renderJoinTeams(features) {
|
|
|
|
- const {teams} = this.state.project;
|
|
|
|
|
|
+ renderJoinTeams(features: Set<string>) {
|
|
|
|
+ const teams = this.state.project?.teams ?? [];
|
|
|
|
+
|
|
if (!teams.length) {
|
|
if (!teams.length) {
|
|
return (
|
|
return (
|
|
<EmptyMessage>
|
|
<EmptyMessage>
|
|
@@ -104,7 +112,7 @@ class MissingProjectMembership extends React.Component {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- return teams.map(team => (
|
|
|
|
|
|
+ return teams.map((team: Team) => (
|
|
<p key={team.slug}>
|
|
<p key={team.slug}>
|
|
#{team.slug}: {this.renderJoinTeam(team, features)}
|
|
#{team.slug}: {this.renderJoinTeam(team, features)}
|
|
</p>
|
|
</p>
|