aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/issue/actions.js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-04-03 17:56:23 +0200
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-04-13 12:21:37 +0200
commit139261bbc13192621ef795d6d45298e1d8e1b7f3 (patch)
tree7aa153b4b3fec7e8fbf3b3b4f5ed0a1a5cc69113 /server/sonar-web/src/main/js/components/issue/actions.js
parentd665528c8751ead9ca93e3d18dd8600fac92834b (diff)
downloadsonarqube-139261bbc13192621ef795d6d45298e1d8e1b7f3.tar.gz
sonarqube-139261bbc13192621ef795d6d45298e1d8e1b7f3.zip
SONAR-9064 Rework facets sidebar on the issues page
Diffstat (limited to 'server/sonar-web/src/main/js/components/issue/actions.js')
-rw-r--r--server/sonar-web/src/main/js/components/issue/actions.js60
1 files changed, 33 insertions, 27 deletions
diff --git a/server/sonar-web/src/main/js/components/issue/actions.js b/server/sonar-web/src/main/js/components/issue/actions.js
index a0631c17001..a44430520bd 100644
--- a/server/sonar-web/src/main/js/components/issue/actions.js
+++ b/server/sonar-web/src/main/js/components/issue/actions.js
@@ -18,35 +18,41 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// @flow
-import type { Dispatch } from 'redux';
-import type { Issue } from './types';
import { onFail } from '../../store/rootActions';
-import { receiveIssues } from '../../store/issues/duck';
import { parseIssueFromResponse } from '../../helpers/issues';
+import type { Issue } from './types';
-export const updateIssue = (resultPromise: Promise<*>, oldIssue?: Issue, newIssue?: Issue) =>
- (dispatch: Dispatch<*>) => {
- if (oldIssue && newIssue) {
- dispatch(receiveIssues([newIssue]));
- }
- resultPromise.then(
- response => {
- dispatch(
- receiveIssues([
- parseIssueFromResponse(
- response.issue,
- response.components,
- response.users,
- response.rules
- )
- ])
+export const updateIssue = (
+ onChange: (Issue) => void,
+ resultPromise: Promise<*>,
+ oldIssue?: Issue,
+ newIssue?: Issue
+) => {
+ const optimisticUpdate = oldIssue != null && newIssue != null;
+
+ if (optimisticUpdate) {
+ // $FlowFixMe `newIssue` is not null, because `optimisticUpdate` is true
+ onChange(newIssue);
+ }
+
+ resultPromise.then(
+ response => {
+ if (!optimisticUpdate) {
+ const issue = parseIssueFromResponse(
+ response.issue,
+ response.components,
+ response.users,
+ response.rules
);
- },
- error => {
- onFail(dispatch)(error);
- if (oldIssue && newIssue) {
- dispatch(receiveIssues([oldIssue]));
- }
+ onChange(issue);
+ }
+ },
+ error => {
+ onFail(error);
+ if (optimisticUpdate) {
+ // $FlowFixMe `oldIssue` is not null, because `optimisticUpdate` is true
+ onChange(oldIssue);
}
- );
- };
+ }
+ );
+};