aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/issue/actions.js
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-04-04 17:14:00 +0200
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-04-13 12:21:37 +0200
commitd665528c8751ead9ca93e3d18dd8600fac92834b (patch)
treec0b20b3df0dc4b199a0c59b08354555f33268d3e /server/sonar-web/src/main/js/components/issue/actions.js
parent1ff5bd2cb76894f7c184c9df9ff729112ba5a246 (diff)
downloadsonarqube-d665528c8751ead9ca93e3d18dd8600fac92834b.tar.gz
sonarqube-d665528c8751ead9ca93e3d18dd8600fac92834b.zip
SONAR-9063 Rework issue box
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.js52
1 files changed, 52 insertions, 0 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
new file mode 100644
index 00000000000..a0631c17001
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/issue/actions.js
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * 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';
+
+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
+ )
+ ])
+ );
+ },
+ error => {
+ onFail(dispatch)(error);
+ if (oldIssue && newIssue) {
+ dispatch(receiveIssues([oldIssue]));
+ }
+ }
+ );
+ };