|
@@ -2,6 +2,7 @@ import {memoize, partition, uniqBy} from 'lodash';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import React from 'react';
|
|
|
|
|
|
+import ProjectActions from 'app/actions/projectActions';
|
|
|
import SentryTypes from 'app/sentryTypes';
|
|
|
import parseLinkHeader from 'app/utils/parseLinkHeader';
|
|
|
import withApi from 'app/utils/withApi';
|
|
@@ -29,6 +30,10 @@ class Projects extends React.Component {
|
|
|
|
|
|
// Number of projects to return when not using `props.slugs`
|
|
|
limit: PropTypes.number,
|
|
|
+
|
|
|
+ // Whether to fetch all the projects in the organization of which the user
|
|
|
+ // has access to
|
|
|
+ allProjects: PropTypes.bool,
|
|
|
};
|
|
|
|
|
|
state = {
|
|
@@ -151,14 +156,14 @@ class Projects extends React.Component {
|
|
|
* results using search
|
|
|
*/
|
|
|
loadAllProjects = async () => {
|
|
|
- const {api, orgId, limit} = this.props;
|
|
|
+ const {api, orgId, limit, allProjects} = this.props;
|
|
|
|
|
|
this.setState({
|
|
|
fetching: true,
|
|
|
});
|
|
|
|
|
|
try {
|
|
|
- const {results, hasMore} = await fetchProjects(api, orgId, {limit});
|
|
|
+ const {results, hasMore} = await fetchProjects(api, orgId, {limit, allProjects});
|
|
|
|
|
|
this.setState({
|
|
|
fetching: false,
|
|
@@ -252,7 +257,7 @@ class Projects extends React.Component {
|
|
|
|
|
|
export default withProjects(withApi(Projects));
|
|
|
|
|
|
-async function fetchProjects(api, orgId, {slugs, search, limit} = {}) {
|
|
|
+async function fetchProjects(api, orgId, {slugs, search, limit, allProjects} = {}) {
|
|
|
const query = {};
|
|
|
|
|
|
if (slugs && slugs.length) {
|
|
@@ -268,6 +273,10 @@ async function fetchProjects(api, orgId, {slugs, search, limit} = {}) {
|
|
|
query.per_page = limit;
|
|
|
}
|
|
|
|
|
|
+ if (allProjects) {
|
|
|
+ query.all_projects = 1;
|
|
|
+ }
|
|
|
+
|
|
|
let hasMore = false;
|
|
|
const [results, _, xhr] = await api.requestPromise(
|
|
|
`/organizations/${orgId}/projects/`,
|
|
@@ -286,6 +295,11 @@ async function fetchProjects(api, orgId, {slugs, search, limit} = {}) {
|
|
|
(paginationObject.next.results || paginationObject.previous.results);
|
|
|
}
|
|
|
|
|
|
+ // populate the projects store if all projects were fetched
|
|
|
+ if (allProjects) {
|
|
|
+ ProjectActions.loadProjects(results);
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
results,
|
|
|
hasMore,
|