currentUser: CurrentUser,
fetchIssues: (query: RawQuery) => Promise<*>,
location: { pathname: string, query: RawQuery },
- onRequestFail: Error => void,
organization?: { key: string },
router: {
push: ({ pathname: string, query?: RawQuery }) => void,
fetchFirstIssues() {
this.setState({ checked: [], loading: true });
- return this.fetchIssues({}, true).then(({ facets, issues, paging, ...other }) => {
- if (this.mounted) {
- const openIssue = this.getOpenIssue(this.props, issues);
- this.setState({
- facets: parseFacets(facets),
- loading: false,
- issues,
- openIssue,
- paging,
- referencedComponents: keyBy(other.components, 'uuid'),
- referencedLanguages: keyBy(other.languages, 'key'),
- referencedRules: keyBy(other.rules, 'key'),
- referencedUsers: keyBy(other.users, 'login'),
- selected:
- issues.length > 0 ? (openIssue != null ? openIssue.key : issues[0].key) : undefined,
- selectedFlowIndex: null,
- selectedLocationIndex: null
- });
+ return this.fetchIssues({}, true).then(
+ ({ facets, issues, paging, ...other }) => {
+ if (this.mounted) {
+ const openIssue = this.getOpenIssue(this.props, issues);
+ this.setState({
+ facets: parseFacets(facets),
+ loading: false,
+ issues,
+ openIssue,
+ paging,
+ referencedComponents: keyBy(other.components, 'uuid'),
+ referencedLanguages: keyBy(other.languages, 'key'),
+ referencedRules: keyBy(other.rules, 'key'),
+ referencedUsers: keyBy(other.users, 'login'),
+ selected:
+ issues.length > 0 ? (openIssue != null ? openIssue.key : issues[0].key) : undefined,
+ selectedFlowIndex: null,
+ selectedLocationIndex: null
+ });
+ }
+ return issues;
+ },
+ () => {
+ if (this.mounted) {
+ this.setState({ loading: false });
+ }
+ return Promise.reject();
}
- return issues;
- });
+ );
}
fetchIssuesPage = (p /*: number */) => {
const p = paging.pageIndex + 1;
this.setState({ loading: true });
- this.fetchIssuesPage(p).then(response => {
- if (this.mounted) {
- this.setState(state => ({
- loading: false,
- issues: [...state.issues, ...response.issues],
- paging: response.paging
- }));
+ this.fetchIssuesPage(p).then(
+ response => {
+ if (this.mounted) {
+ this.setState(state => ({
+ loading: false,
+ issues: [...state.issues, ...response.issues],
+ paging: response.paging
+ }));
+ }
+ },
+ () => {
+ if (this.mounted) {
+ this.setState({ loading: false });
+ }
}
- });
+ );
};
fetchIssuesForComponent = (component /*: string */, from /*: number */, to /*: number */) => {
}
this.setState({ loading: true });
- return this.fetchIssuesUntil(paging.pageIndex + 1, done).then(response => {
- const nextIssues = [...issues, ...response.issues];
-
- this.setState({
- issues: nextIssues,
- loading: false,
- paging: response.paging
- });
- return nextIssues.filter(isSameComponent);
- });
+ return this.fetchIssuesUntil(paging.pageIndex + 1, done).then(
+ response => {
+ const nextIssues = [...issues, ...response.issues];
+ if (this.mounted) {
+ this.setState({
+ issues: nextIssues,
+ loading: false,
+ paging: response.paging
+ });
+ }
+ return nextIssues.filter(isSameComponent);
+ },
+ () => {
+ if (this.mounted) {
+ this.setState({ loading: false });
+ }
+ }
+ );
};
fetchFacet = (facet /*: string */) => {
fetchIssues={bulkChange === 'all' ? this.fetchIssues : this.getCheckedIssues}
onClose={this.closeBulkChange}
onDone={this.handleBulkChangeDone}
- onRequestFail={this.props.onRequestFail}
organization={this.props.organization}
/>}
</div>
/*:: import type { Dispatch } from 'redux'; */
import { uniq } from 'lodash';
import App from './App';
-import { onFail } from '../../../store/rootActions';
+import throwGlobalError from '../../../app/utils/throwGlobalError';
import { getComponent, getCurrentUser } from '../../../store/rootReducer';
import { getOrganizations } from '../../../api/organizations';
import { receiveOrganizations } from '../../../store/organizations/duck';
const organizationKeys = uniq(issues.map(issue => issue.organization));
return getOrganizations(organizationKeys).then(
response => dispatch(receiveOrganizations(response.organizations)),
- onFail(dispatch)
+ throwGlobalError
);
};
return { ...response, issues: parsedIssues };
})
.then(response => dispatch(fetchIssueOrganizations(response.issues)).then(() => response))
- .catch(onFail(dispatch));
+ .catch(throwGlobalError);
-const onRequestFail = (error /*: Error */) => (dispatch /*: Dispatch<*> */) =>
- onFail(dispatch)(error);
-
-const mapDispatchToProps = { fetchIssues, onRequestFail };
+const mapDispatchToProps = { fetchIssues };
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(App));