aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-28 13:49:23 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-28 15:01:53 +0200
commit9e510dfd203b2f6dc6a27c8df49d515d9f171b9a (patch)
treeb5f2d4db24200bf762559cae1aeed5332c718653 /server
parentcf8e83dba943ec2924a6a38c92ed91ae759f2cc2 (diff)
downloadsonarqube-9e510dfd203b2f6dc6a27c8df49d515d9f171b9a.tar.gz
sonarqube-9e510dfd203b2f6dc6a27c8df49d515d9f171b9a.zip
add project-level background tasks page
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/main.js34
-rw-r--r--server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx7
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb4
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/project/background_tasks.html.erb7
5 files changed, 48 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/app.js b/server/sonar-web/src/main/js/apps/background-tasks/app.js
index 260457a03c6..7a94708fcc2 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/app.js
+++ b/server/sonar-web/src/main/js/apps/background-tasks/app.js
@@ -4,6 +4,6 @@ import Main from './main';
export default {
start (options) {
var el = document.querySelector(options.el);
- React.render(<Main/>, el);
+ React.render(<Main options={options}/>, el);
}
};
diff --git a/server/sonar-web/src/main/js/apps/background-tasks/main.js b/server/sonar-web/src/main/js/apps/background-tasks/main.js
index a92d1c23ba1..0ea7eb73487 100644
--- a/server/sonar-web/src/main/js/apps/background-tasks/main.js
+++ b/server/sonar-web/src/main/js/apps/background-tasks/main.js
@@ -22,10 +22,28 @@ export default React.createClass({
};
},
+ filterQueueForComponent(queue) {
+ if (this.props.options.componentId) {
+ return queue.filter(task => {
+ return task.componentId === this.props.options.componentId
+ });
+ } else {
+ return queue;
+ }
+ },
+
componentDidMount() {
this.requestData();
},
+ getComponentFilter() {
+ if (this.props.options.componentId) {
+ return { componentId: this.props.options.componentId };
+ } else {
+ return {};
+ }
+ },
+
getCurrentFilters() {
let filters = {};
if (this.state.statusFilter !== STATUSES.ALL) {
@@ -46,10 +64,11 @@ export default React.createClass({
requestQueue() {
if (!Object.keys(this.getCurrentFilters()).length) {
getQueue().done(queue => {
+ let tasks = this.filterQueueForComponent(queue.tasks);
this.setState({
- queue: this.orderTasks(queue.tasks),
- pendingCount: this.countPending(queue.tasks),
- inProgressDuration: this.getInProgressDuration(queue.tasks)
+ queue: this.orderTasks(tasks),
+ pendingCount: this.countPending(tasks),
+ inProgressDuration: this.getInProgressDuration(tasks)
});
});
} else {
@@ -58,7 +77,10 @@ export default React.createClass({
},
requestActivity() {
- let filters = _.extend(this.getCurrentFilters(), { p: this.state.activityPage, ps: PAGE_SIZE });
+ let filters = _.extend(
+ this.getCurrentFilters(),
+ this.getComponentFilter(),
+ { p: this.state.activityPage, ps: PAGE_SIZE });
getActivity(filters).done(activity => {
let newActivity = activity.paging.pageIndex === 1 ?
activity.tasks : [].concat(this.state.activity, activity.tasks);
@@ -71,7 +93,9 @@ export default React.createClass({
},
requestFailures() {
- let filters = { ps: 1, onlyCurrents: true, status: STATUSES.FAILED };
+ let filters = _.extend(
+ this.getComponentFilter(),
+ { ps: 1, onlyCurrents: true, status: STATUSES.FAILED });
getActivity(filters).done(failures => {
this.setState({ failuresCount: failures.paging.total });
});
diff --git a/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx b/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx
index fd55fa80097..30e8f14619b 100644
--- a/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx
+++ b/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx
@@ -71,6 +71,7 @@ export default React.createClass({
{this.renderLinksLink()}
{this.renderPermissionsLink()}
{this.renderHistoryLink()}
+ {this.renderBackgroundTasksLink()}
{this.renderUpdateKeyLink()}
{this.renderDeletionLink()}
{this.renderExtensions()}
@@ -143,6 +144,12 @@ export default React.createClass({
return this.renderLink(url, window.t('project_history.page'), '/project/history');
},
+ renderBackgroundTasksLink() {
+ // TODO check permissions
+ const url = `/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`;
+ return this.renderLink(url, 'Background Tasks', '/project/background_tasks');
+ },
+
renderUpdateKeyLink() {
if (!this.props.conf.showUpdateKey) {
return null;
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
index f53883b9aa4..8601e579f68 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
@@ -225,6 +225,10 @@ class ProjectController < ApplicationController
:include => 'events', :order => 'snapshots.created_at DESC')
end
+ def background_tasks
+ @project = get_current_project(params[:id])
+ end
+
def delete_snapshot_history
@project = get_current_project(params[:id])
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/background_tasks.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/background_tasks.html.erb
new file mode 100644
index 00000000000..43ebdf92fc1
--- /dev/null
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/project/background_tasks.html.erb
@@ -0,0 +1,7 @@
+<% content_for :extra_script do %>
+ <script>
+ require(['apps/background-tasks/app'], function (App) {
+ App.start({ el: '#content', componentId: '<%= @project.uuid -%>' });
+ });
+ </script>
+<% end %>