aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/app/components/branch-status/BranchStatusContextProvider.tsx6
-rw-r--r--server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationHelper.ts17
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx38
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx24
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx6
-rw-r--r--server/sonar-web/src/main/js/components/controls/SelectList.tsx5
-rw-r--r--server/sonar-web/src/main/js/components/controls/ValidationForm.tsx7
-rw-r--r--server/sonar-web/src/main/js/components/controls/__tests__/ValidationForm-test.tsx5
12 files changed, 102 insertions, 46 deletions
diff --git a/server/sonar-web/src/main/js/app/components/branch-status/BranchStatusContextProvider.tsx b/server/sonar-web/src/main/js/app/components/branch-status/BranchStatusContextProvider.tsx
index 8ff18aefaa4..cf2d2ba3279 100644
--- a/server/sonar-web/src/main/js/app/components/branch-status/BranchStatusContextProvider.tsx
+++ b/server/sonar-web/src/main/js/app/components/branch-status/BranchStatusContextProvider.tsx
@@ -89,7 +89,11 @@ export default class BranchStatusContextProvider extends React.PureComponent<{},
<BranchStatusContext.Provider
value={{
branchStatusByComponent: this.state.branchStatusByComponent,
- fetchBranchStatus: this.fetchBranchStatus,
+ fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => {
+ this.fetchBranchStatus(branchLike, projectKey).catch(() => {
+ /* noop */
+ });
+ },
updateBranchStatus: this.updateBranchStatus,
}}
>
diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationHelper.ts b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationHelper.ts
index 1eb4396e0e3..1840a9178a9 100644
--- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationHelper.ts
+++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationHelper.ts
@@ -28,15 +28,18 @@ const LS_INDEXATION_COMPLETED_NOTIFICATION_SHOULD_BE_DISPLAYED =
export default class IndexationNotificationHelper {
private static interval?: NodeJS.Timeout;
- static startPolling(onNewStatus: (status: IndexationStatus) => void) {
+ static async startPolling(onNewStatus: (status: IndexationStatus) => void) {
this.stopPolling();
- // eslint-disable-next-line promise/catch-or-return
- this.poll(onNewStatus).then((status) => {
- if (!status.isCompleted) {
- this.interval = setInterval(() => this.poll(onNewStatus), POLLING_INTERVAL_MS);
- }
- });
+ const status = await this.poll(onNewStatus);
+
+ if (!status.isCompleted) {
+ this.interval = setInterval(() => {
+ this.poll(onNewStatus).catch(() => {
+ /* noop */
+ });
+ }, POLLING_INTERVAL_MS);
+ }
}
static stopPolling() {
diff --git a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx
index 8c8fb3fa673..a65f7c57fe1 100644
--- a/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/Azure/AzureProjectCreate.tsx
@@ -84,7 +84,11 @@ export default class AzureProjectCreate extends React.PureComponent<Props, State
componentDidUpdate(prevProps: Props) {
if (prevProps.almInstances.length === 0 && this.props.almInstances.length > 0) {
- this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () => this.fetchData());
+ this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () => {
+ this.fetchData().catch(() => {
+ /* noop */
+ });
+ });
}
}
@@ -286,7 +290,11 @@ export default class AzureProjectCreate extends React.PureComponent<Props, State
onSelectedAlmInstanceChange = (instance: AlmSettingsInstance) => {
this.setState(
{ selectedAlmInstance: instance, searchResults: undefined, searchQuery: '' },
- () => this.fetchData()
+ () => {
+ this.fetchData().catch(() => {
+ /* noop */
+ });
+ }
);
};
diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx
index dd4bf7a1c96..41adf4c9baa 100644
--- a/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketCloud/BitbucketCloudProjectCreate.tsx
@@ -78,7 +78,11 @@ export default class BitbucketCloudProjectCreate extends React.PureComponent<Pro
componentDidUpdate(prevProps: Props) {
if (prevProps.almInstances.length === 0 && this.props.almInstances.length > 0) {
- this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () => this.fetchData());
+ this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () => {
+ this.fetchData().catch(() => {
+ /* noop */
+ });
+ });
}
}
@@ -146,11 +150,17 @@ export default class BitbucketCloudProjectCreate extends React.PureComponent<Pro
projectsPaging: { pageIndex: 1, pageSize: BITBUCKET_CLOUD_PROJECTS_PAGESIZE },
searchQuery,
},
- async () => {
- await this.fetchData();
- if (this.mounted) {
- this.setState({ searching: false });
- }
+ () => {
+ this.fetchData().then(
+ () => {
+ if (this.mounted) {
+ this.setState({ searching: false });
+ }
+ },
+ () => {
+ /* noop */
+ }
+ );
}
);
};
@@ -164,11 +174,17 @@ export default class BitbucketCloudProjectCreate extends React.PureComponent<Pro
pageSize: state.projectsPaging.pageSize,
},
}),
- async () => {
- await this.fetchData(true);
- if (this.mounted) {
- this.setState({ loadingMore: false });
- }
+ () => {
+ this.fetchData(true).then(
+ () => {
+ if (this.mounted) {
+ this.setState({ loadingMore: false });
+ }
+ },
+ () => {
+ /* noop */
+ }
+ );
}
);
};
diff --git a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx
index af60cb12b31..49f19542cb1 100644
--- a/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/BitbucketServer/BitbucketProjectCreate.tsx
@@ -77,9 +77,11 @@ export default class BitbucketProjectCreate extends React.PureComponent<Props, S
componentDidUpdate(prevProps: Props) {
if (prevProps.almInstances.length === 0 && this.props.almInstances.length > 0) {
- this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () =>
- this.fetchInitialData()
- );
+ this.setState({ selectedAlmInstance: this.props.almInstances[0] }, () => {
+ this.fetchInitialData().catch(() => {
+ /* noop */
+ });
+ });
}
}
diff --git a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx
index ec40e48c34c..a07808a46ba 100644
--- a/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/Github/GitHubProjectCreate.tsx
@@ -86,9 +86,11 @@ export default class GitHubProjectCreate extends React.Component<Props, State> {
componentDidUpdate(prevProps: Props) {
if (prevProps.almInstances.length === 0 && this.props.almInstances.length > 0) {
- this.setState({ selectedAlmInstance: this.getInitialSelectedAlmInstance() }, () =>
- this.initialize()
- );
+ this.setState({ selectedAlmInstance: this.getInitialSelectedAlmInstance() }, () => {
+ this.initialize().catch(() => {
+ /* noop */
+ });
+ });
}
}
@@ -292,7 +294,11 @@ export default class GitHubProjectCreate extends React.Component<Props, State> {
onSelectedAlmInstanceChange = (instance: AlmSettingsInstance) => {
this.setState(
{ selectedAlmInstance: instance, searchQuery: '', organizations: [], repositories: [] },
- () => this.initialize()
+ () => {
+ this.initialize().catch(() => {
+ /* noop */
+ });
+ }
);
};
diff --git a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx
index 45b7aa4e8d7..cfa49099e20 100644
--- a/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/Gitlab/GitlabProjectCreate.tsx
@@ -74,7 +74,11 @@ export default class GitlabProjectCreate extends React.PureComponent<Props, Stat
componentDidUpdate(prevProps: Props) {
const { almInstances } = this.props;
if (prevProps.almInstances.length === 0 && this.props.almInstances.length > 0) {
- this.setState({ selectedAlmInstance: almInstances[0] }, () => this.fetchInitialData());
+ this.setState({ selectedAlmInstance: almInstances[0] }, () => {
+ this.fetchInitialData().catch(() => {
+ /* noop */
+ });
+ });
}
}
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx
index 57fa927316d..e679c512546 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx
+++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Template.tsx
@@ -243,18 +243,34 @@ export default class Template extends React.PureComponent<Props, State> {
};
handleSearch = (query: string) => {
- this.setState({ query }, this.requestHolders);
+ this.setState({ query }, () => {
+ this.requestHolders().catch(() => {
+ /* noop */
+ });
+ });
};
handleFilter = (filter: FilterOption) => {
- this.setState({ filter }, this.requestHolders);
+ this.setState({ filter }, () => {
+ this.requestHolders().catch(() => {
+ /* noop */
+ });
+ });
};
handleSelectPermission = (selectedPermission: string) => {
if (selectedPermission === this.state.selectedPermission) {
- this.setState({ selectedPermission: undefined }, this.requestHolders);
+ this.setState({ selectedPermission: undefined }, () => {
+ this.requestHolders().catch(() => {
+ /* noop */
+ });
+ });
} else {
- this.setState({ selectedPermission }, this.requestHolders);
+ this.setState({ selectedPermission }, () => {
+ this.requestHolders().catch(() => {
+ /* noop */
+ });
+ });
}
};
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx
index 11012335e56..74e09875f66 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BranchAnalysisList.tsx
@@ -132,7 +132,11 @@ export default class BranchAnalysisList extends React.PureComponent<Props, State
};
handleRangeChange = ({ value }: { value: number }) => {
- this.setState({ range: value }, () => this.fetchAnalyses());
+ this.setState({ range: value }, () => {
+ this.fetchAnalyses().catch(() => {
+ /* noop */
+ });
+ });
};
render() {
diff --git a/server/sonar-web/src/main/js/components/controls/SelectList.tsx b/server/sonar-web/src/main/js/components/controls/SelectList.tsx
index 549a3a04e6e..42454b8076a 100644
--- a/server/sonar-web/src/main/js/components/controls/SelectList.tsx
+++ b/server/sonar-web/src/main/js/components/controls/SelectList.tsx
@@ -108,7 +108,7 @@ export default class SelectList extends React.PureComponent<Props, State> {
loading: true,
lastSearchParams: { ...prevState.lastSearchParams, ...searchParams },
}),
- () =>
+ () => {
this.props
.onSearch({
filter: this.getFilter(),
@@ -117,7 +117,8 @@ export default class SelectList extends React.PureComponent<Props, State> {
query: this.state.lastSearchParams.query,
})
.then(this.stopLoading)
- .catch(this.stopLoading)
+ .catch(this.stopLoading);
+ }
);
changeFilter = (filter: SelectListFilter) => this.search({ filter, page: 1 });
diff --git a/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx b/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx
index 87349bc8931..18c0faeb9cb 100644
--- a/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx
+++ b/server/sonar-web/src/main/js/components/controls/ValidationForm.tsx
@@ -41,18 +41,13 @@ export default class ValidationForm<V extends FormikValues> extends React.Compon
}
handleSubmit = (data: V, { setSubmitting }: FormikHelpers<V>) => {
- const result = this.props.onSubmit(data);
const stopSubmitting = () => {
if (this.mounted) {
setSubmitting(false);
}
};
- if (result) {
- result.then(stopSubmitting, stopSubmitting);
- } else {
- stopSubmitting();
- }
+ this.props.onSubmit(data).then(stopSubmitting, stopSubmitting);
};
render() {
diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/ValidationForm-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/ValidationForm-test.tsx
index 57d8309ea03..5630a63cb4c 100644
--- a/server/sonar-web/src/main/js/components/controls/__tests__/ValidationForm-test.tsx
+++ b/server/sonar-web/src/main/js/components/controls/__tests__/ValidationForm-test.tsx
@@ -23,7 +23,7 @@ import ValidationForm from '../ValidationForm';
it('should render and submit', async () => {
const render = jest.fn();
- const onSubmit = jest.fn();
+ const onSubmit = jest.fn().mockResolvedValue(null);
const setSubmitting = jest.fn();
const wrapper = shallow(
<ValidationForm initialValues={{ foo: 'bar' }} onSubmit={onSubmit} validate={jest.fn()}>
@@ -36,9 +36,6 @@ it('should render and submit', async () => {
expect.objectContaining({ dirty: false, errors: {}, values: { foo: 'bar' } })
);
- wrapper.prop<Function>('onSubmit')({ foo: 'bar' }, { setSubmitting });
- expect(setSubmitting).toHaveBeenCalledWith(false);
-
onSubmit.mockResolvedValue(undefined).mockClear();
setSubmitting.mockClear();
wrapper.prop<Function>('onSubmit')({ foo: 'bar' }, { setSubmitting });