]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6798 add ability to empty the CE queue
authorStas Vilchik <vilchiks@gmail.com>
Mon, 28 Sep 2015 10:05:18 +0000 (12:05 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 28 Sep 2015 10:05:34 +0000 (12:05 +0200)
server/sonar-web/src/main/js/api/ce.js
server/sonar-web/src/main/js/apps/background-tasks/main.js
server/sonar-web/src/main/js/apps/background-tasks/stats.js

index 2c019eff3b502bce4680bf022015a4779faacb09..d2bed547a4a69ca6a7df2ff6fabd26b59ab49ac2 100644 (file)
@@ -20,6 +20,11 @@ export function cancelTask (id) {
   return $.post(url, { id }).then(getTask.bind(null, id));
 }
 
+export function cancelAllTasks () {
+  let url = baseUrl + '/api/ce/cancel_all';
+  return $.post(url);
+}
+
 export function getTasksForComponent(componentId) {
   let url = baseUrl + '/api/ce/project';
   return $.get(url, { componentId });
index 71a81a66cc4d81f2af252f38f6a79bbd7060da1e..a92d1c23ba172a1d99f815831caa46d344e4ca95 100644 (file)
@@ -1,6 +1,6 @@
 import _ from 'underscore';
 import React from 'react';
-import {getQueue, getActivity, cancelTask} from '../../api/ce';
+import {getQueue, getActivity, cancelTask, cancelAllTasks} from '../../api/ce';
 import {STATUSES, CURRENTS} from './constants';
 import Header from './header';
 import Stats from './stats';
@@ -17,7 +17,6 @@ export default React.createClass({
       activity: [],
       activityTotal: 0,
       activityPage: 1,
-      pendingCount: 0,
       statusFilter: STATUSES.ALL,
       currentsFilter: CURRENTS.ALL
     };
@@ -121,11 +120,15 @@ export default React.createClass({
     });
   },
 
+  cancelPending() {
+    cancelAllTasks().then(this.requestData);
+  },
+
   render() {
     return (
         <div className="page">
           <Header/>
-          <Stats {...this.state} showFailures={this.showFailures}/>
+          <Stats {...this.state} cancelPending={this.cancelPending} showFailures={this.showFailures}/>
           <Search {...this.state} onStatusChange={this.onStatusChange} onCurrentsChange={this.onCurrentsChange}/>
           <Tasks tasks={[].concat(this.state.queue, this.state.activity)} onTaskCanceled={this.onTaskCanceled}/>
           <ListFooter count={this.state.queue.length + this.state.activity.length}
index 367dbaea3adc55022865f647052fe2e630f7011e..719b789fa7325c41e245ae8dbfcfbd0c97526220 100644 (file)
@@ -1,6 +1,11 @@
 import React from 'react';
 
 export default React.createClass({
+  onPendingCanceled(e) {
+    e.preventDefault();
+    this.props.cancelPending();
+  },
+
   onFailuresClick(e) {
     e.preventDefault();
     this.props.showFailures();
@@ -18,6 +23,23 @@ export default React.createClass({
     );
   },
 
+  renderPending() {
+    if (this.props.pendingCount == null) {
+      return null;
+    }
+    if (this.props.pendingCount > 0) {
+      return (
+          <span>
+            <span className="emphasised-measure">{this.props.pendingCount}</span> pending
+            <a onClick={this.onPendingCanceled} className="icon-delete spacer-left" title="Cancel Pending Tasks"
+               data-toggle="tooltip" href="#"></a>
+          </span>
+      );
+    } else {
+      return <span><span className="emphasised-measure">{this.props.pendingCount}</span> pending</span>;
+    }
+  },
+
   renderFailures() {
     if (this.props.failuresCount == null) {
       return null;
@@ -33,7 +55,7 @@ export default React.createClass({
     return (
         <section className="big-spacer-top big-spacer-bottom">
           <span>
-            <span className="emphasised-measure">{this.props.pendingCount}</span> pending
+            {this.renderPending()}
           </span>
           <span className="huge-spacer-left">
             {this.renderFailures()}