Skip to content

Commit 1e569e1

Browse files
committed
remove unused var
1 parent be1ef3c commit 1e569e1

File tree

1 file changed

+59
-46
lines changed

1 file changed

+59
-46
lines changed

src/sentry/static/sentry/app/views/projects/projectContext.jsx

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import MemberListStore from 'app/stores/memberListStore';
1515
import MissingProjectMembership from 'app/components/missingProjectMembership';
1616
import OrganizationState from 'app/mixins/organizationState';
1717
import ProjectsStore from 'app/stores/projectsStore';
18-
import recreateRoute from 'app/utils/recreateRoute';
1918
import SentryTypes from 'app/sentryTypes';
2019
import withProjects from 'app/utils/withProjects';
2120

@@ -138,6 +137,7 @@ const ProjectContext = createReactClass({
138137
let {orgId, projectId, location, skipReload} = this.props;
139138
// we fetch core access/information from the global organization data
140139
let activeProject = this.identifyProject();
140+
let hasAccess = activeProject && activeProject.hasAccess;
141141

142142
this.setState(state => ({
143143
// if `skipReload` is true, then don't change loading state
@@ -146,53 +146,66 @@ const ProjectContext = createReactClass({
146146
project: activeProject,
147147
}));
148148

149-
setActiveProject(null);
150-
const projectRequest = this.api.requestPromise(`/projects/${orgId}/${projectId}/`);
151-
152-
const environmentRequest = this.api.requestPromise(this.getEnvironmentListEndpoint());
153-
154-
Promise.all([projectRequest, environmentRequest]).then(
155-
([project, envs]) => {
156-
this.setState({
157-
loading: false,
158-
project,
159-
error: false,
160-
errorType: null,
161-
});
162-
163-
// assuming here that this means the project is considered the active project
164-
setActiveProject(project);
165-
166-
// If an environment is specified in the query string, load it instead of default
167-
const queryEnv = location.query.environment;
168-
// The default environment cannot be "" (No Environment)
169-
const {defaultEnvironment} = project;
170-
const envName = typeof queryEnv === 'undefined' ? defaultEnvironment : queryEnv;
171-
loadEnvironments(envs, envName);
172-
173-
// TODO(dcramer): move member list to organization level
174-
this.api.request(this.getMemberListEndpoint(), {
175-
success: data => {
176-
MemberListStore.loadInitialData(data.filter(m => m.user).map(m => m.user));
177-
},
178-
});
179-
},
180-
resp => {
181-
let errorType = ERROR_TYPES.UNKNOWN;
182-
183-
if (resp.status === 404) {
184-
errorType = ERROR_TYPES.PROJECT_NOT_FOUND;
185-
} else if (activeProject && !activeProject.isMember) {
186-
errorType = ERROR_TYPES.MISSING_MEMBERSHIP;
149+
if (activeProject && hasAccess) {
150+
setActiveProject(null);
151+
const projectRequest = this.api.requestPromise(`/projects/${orgId}/${projectId}/`);
152+
153+
const environmentRequest = this.api.requestPromise(
154+
this.getEnvironmentListEndpoint()
155+
);
156+
157+
Promise.all([projectRequest, environmentRequest]).then(
158+
([project, envs]) => {
159+
this.setState({
160+
loading: false,
161+
project,
162+
error: false,
163+
errorType: null,
164+
});
165+
166+
// assuming here that this means the project is considered the active project
167+
setActiveProject(project);
168+
169+
// If an environment is specified in the query string, load it instead of default
170+
const queryEnv = location.query.environment;
171+
// The default environment cannot be "" (No Environment)
172+
const {defaultEnvironment} = project;
173+
const envName = typeof queryEnv === 'undefined' ? defaultEnvironment : queryEnv;
174+
loadEnvironments(envs, envName);
175+
},
176+
() => {
177+
this.setState({
178+
loading: false,
179+
error: false,
180+
errorType: ERROR_TYPES.UNKNOWN,
181+
});
187182
}
183+
);
188184

189-
this.setState({
190-
loading: false,
191-
error: true,
192-
errorType,
193-
});
194-
}
195-
);
185+
// TODO(dcramer): move member list to organization level
186+
this.api.request(this.getMemberListEndpoint(), {
187+
success: data => {
188+
MemberListStore.loadInitialData(data.filter(m => m.user).map(m => m.user));
189+
},
190+
});
191+
} else if (activeProject && !activeProject.isMember) {
192+
this.setState({
193+
loading: false,
194+
error: true,
195+
errorType: ERROR_TYPES.MISSING_MEMBERSHIP,
196+
});
197+
} else {
198+
// The request is a 404 or other error
199+
this.api.request(`/projects/${orgId}/${projectId}/`, {
200+
error: () => {
201+
this.setState({
202+
loading: false,
203+
error: true,
204+
errorType: ERROR_TYPES.PROJECT_NOT_FOUND,
205+
});
206+
},
207+
});
208+
}
196209
},
197210

198211
getEnvironmentListEndpoint() {

0 commit comments

Comments
 (0)