aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/issues
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-11 14:40:32 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-11 14:40:32 +0200
commitd10d21c9f178d5ccad5884695a2975c970c875c8 (patch)
tree3a26e0927d8c05286eeaf04ca0fca42592b03e5c /server/sonar-web/src/main/js/apps/issues
parentd68eabbdec9d5c6744a89aab66b7d2d30e122829 (diff)
downloadsonarqube-d10d21c9f178d5ccad5884695a2975c970c875c8.tar.gz
sonarqube-d10d21c9f178d5ccad5884695a2975c970c875c8.zip
SONAR-6285 show filters on the issues home page
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/controller.js7
-rw-r--r--server/sonar-web/src/main/js/apps/issues/filters-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/templates/issues-filters.hbs28
-rw-r--r--server/sonar-web/src/main/js/apps/issues/templates/issues-workspace-home.hbs93
-rw-r--r--server/sonar-web/src/main/js/apps/issues/workspace-home-view.js159
5 files changed, 41 insertions, 248 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/controller.js b/server/sonar-web/src/main/js/apps/issues/controller.js
index a35311fa576..a201496f8b8 100644
--- a/server/sonar-web/src/main/js/apps/issues/controller.js
+++ b/server/sonar-web/src/main/js/apps/issues/controller.js
@@ -90,7 +90,7 @@ define([
fetchFilters: function () {
var that = this;
return $.when(
- that.options.app.filters.fetch(),
+ that.options.app.filters.fetch({ reset: true }),
$.get(baseUrl + '/api/issue_filters/app', function (r) {
that.options.app.state.set({
canBulkChange: r.canBulkChange,
@@ -237,7 +237,10 @@ define([
this.options.app.layout.workspaceComponentViewerRegion.reset();
key.setScope('home');
this.options.app.issuesView.unbindScrollEvents();
- this.options.app.homeView = new HomeView({ app: this.options.app });
+ this.options.app.homeView = new HomeView({
+ app: this.options.app,
+ collection: this.options.app.filters
+ });
this.options.app.layout.workspaceHomeRegion.show(this.options.app.homeView);
return this.options.app.layout.showHomePage();
},
diff --git a/server/sonar-web/src/main/js/apps/issues/filters-view.js b/server/sonar-web/src/main/js/apps/issues/filters-view.js
index d219c1e0fd4..c3ea67bd434 100644
--- a/server/sonar-web/src/main/js/apps/issues/filters-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/filters-view.js
@@ -20,7 +20,7 @@ define([
var that = this;
this.listenTo(options.app.state, 'change:filter', this.render);
this.listenTo(options.app.state, 'change:changed', this.render);
- this.listenTo(options.app.filters, 'all', this.render);
+ this.listenTo(options.app.filters, 'reset', this.render);
window.onSaveAs = window.onCopy = window.onEdit = function (id) {
$('#modal').dialog('close');
return that.options.app.controller.fetchFilters().done(function () {
diff --git a/server/sonar-web/src/main/js/apps/issues/templates/issues-filters.hbs b/server/sonar-web/src/main/js/apps/issues/templates/issues-filters.hbs
index c3ffd012a3a..74cd306ce3e 100644
--- a/server/sonar-web/src/main/js/apps/issues/templates/issues-filters.hbs
+++ b/server/sonar-web/src/main/js/apps/issues/templates/issues-filters.hbs
@@ -1,29 +1,27 @@
{{#unless state.isContext}}
<h1 class="page-title dropdown">
- {{#if state.canManageFilters}}
- <a class="search-navigator-filters-show-list dropdown-toggle" data-toggle="dropdown">
- <i class="icon-list"></i><span class="issues-filters-name">{{> "_issues-filter-name"}}</span>
- </a>
- <ul class="dropdown-menu">
- {{#each items}}
+ <a class="search-navigator-filters-show-list dropdown-toggle" data-toggle="dropdown">
+ <i class="icon-list"></i><span class="issues-filters-name">{{> "_issues-filter-name"}}</span>
+ </a>
+ <ul class="dropdown-menu">
+ {{#each items}}
+ {{#ifCanUseFilter query}}
<li>
<a class="search-navigator-filters-button search-navigator-filters-filter js-filter" data-id="{{id}}">
{{name}}
</a>
</li>
- {{/each}}
- {{#notEmpty items}}
- <li class="divider"></li>
- {{/notEmpty}}
+ {{/ifCanUseFilter}}
+ {{/each}}
+ {{#if state.canManageFilters}}
+ <li class="divider"></li>
<li>
<a class="search-navigator-filters-manage" href="{{link "/issues/manage"}}">{{t "manage"}}</a>
</li>
- </ul>
- {{#if filter.description}}
- <div class="search-navigator-filters-description">{{filter.description}}</div>
{{/if}}
- {{else}}
- <span class="search-navigator-filters-name">{{t "issues"}}</span>
+ </ul>
+ {{#if filter.description}}
+ <div class="search-navigator-filters-description">{{filter.description}}</div>
{{/if}}
</h1>
diff --git a/server/sonar-web/src/main/js/apps/issues/templates/issues-workspace-home.hbs b/server/sonar-web/src/main/js/apps/issues/templates/issues-workspace-home.hbs
index 6c903b7faf9..0057630ed6a 100644
--- a/server/sonar-web/src/main/js/apps/issues/templates/issues-workspace-home.hbs
+++ b/server/sonar-web/src/main/js/apps/issues/templates/issues-workspace-home.hbs
@@ -1,77 +1,26 @@
-<div class="spacer-top spacer-bottom">
- <div class="columns">
- <div class="column-half {{#unless user}}column-one{{/unless}}">
- <h3 class="text-center">{{t "issues.home.recent_issues"}}</h3>
- <p class="note text-center">({{t "issues.home.over_last_week"}})</p>
+<div class="issues-workspace-home-inner">
+ <div>
+ <h2 class="big-spacer-bottom">Start From Filters:</h2>
- <div class="spacer-top text-center js-barchart" data-height="75" data-width="300"></div>
- <h4 class="spacer-top spacer-bottom text-center">{{t "issues.home.projects"}}</h4>
- <table class="data zebra spacer-top">
- {{#each projects}}
- <tr>
- <td>{{qualifierIcon "TRK"}}&nbsp;<a href="{{issuesHomeLink "projectUuids" val}}">{{label}}</a></td>
- <td class="thin text-right">+{{numberShort count}}</td>
- </tr>
- {{/each}}
- </table>
- <h4 class="spacer-top spacer-bottom text-center">{{t "issues.home.authors"}}</h4>
- <table class="data zebra spacer-top">
- {{#each authors}}
- <tr>
- <td><a href="{{issuesHomeLink "authors" val}}">{{val}}</a></td>
- <td class="thin text-right">+{{numberShort count}}</td>
- </tr>
- {{/each}}
- </table>
- <h4 class="spacer-top spacer-bottom text-center">{{t "issues.home.tags"}}</h4>
- <ul class="list-inline">
- {{#each tags}}
- <li><a class="link-no-underline" style="font-size: {{size}}px;" data-toggle="tooltip" data-placement="bottom"
- href="{{issuesHomeLink "tags" val}}"
- title="+{{numberShort count}}">{{val}}</a></li>
- {{/each}}
- </ul>
- </div>
+ <ul>
+ {{#each items}}
+ {{#ifCanUseFilter query}}
+ <li class="text-left spacer-bottom">
+ <i class="icon-favorite little-spacer-right" {{#unless favorite}}style="visibility: hidden;"{{/unless}}></i>
- {{#if user}}
- <div class="column-half">
- <h3 class="text-center">{{t "issues.home.my_recent_issues"}}</h3>
- <p class="note text-center">({{t "issues.home.over_last_week"}})</p>
+ <a href="#id={{id}}">{{name}}</a>
- <div class="spacer-top text-center js-my-barchart" data-height="75" data-width="300"></div>
- {{#notEmpty myProjects}}
- <h4 class="spacer-top spacer-bottom text-center">{{t "issues.home.projects"}}</h4>
- <table class="data zebra spacer-top">
- {{#each myProjects}}
- <tr>
- <td>{{qualifierIcon "TRK"}}&nbsp;<a href="{{myIssuesHomeLink "projectUuids" val}}">{{label}}</a></td>
- <td class="thin text-right">+{{numberShort count}}</td>
- </tr>
- {{/each}}
- </table>
- {{/notEmpty}}
- {{#notEmpty myTags}}
- <h4 class="spacer-top spacer-bottom text-center">{{t "issues.home.tags"}}</h4>
- <ul class="list-inline">
- {{#each myTags}}
- <li><a class="link-no-underline" style="font-size: {{size}}px;" data-toggle="tooltip" data-placement="bottom"
- href="{{myIssuesHomeLink "tags" val}}"
- title="+{{numberShort count}}">{{val}}</a></li>
- {{/each}}
- </ul>
- {{/notEmpty}}
- {{#notEmpty filters}}
- <h3 class="spacer-bottom text-center" style="padding-top: 12px; margin-top: 20px; border-top: 1px solid #efefef;">
- {{t "issues.home.my_filters"}}</h3>
- <ul class="list-inline">
- {{#each filters}}
- <li>
- <a href="{{issueFilterHomeLink id}}">{{name}}</a>
- </li>
- {{/each}}
- </ul>
- {{/notEmpty}}
- </div>
- {{/if}}
+ {{#if shared}}
+ <span class="note nowrap">[{{t "issue_filter.shared"}}]</span>
+ {{/if}}
+ </li>
+ {{/ifCanUseFilter}}
+ {{/each}}
+ </ul>
+ </div>
+
+ <div class="big-spacer-top">
+ or make a
+ <a href="#resolved=false" class="button spacer-left">New Search</a>
</div>
</div>
diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js
index 942e86e4ba7..aff1c52366f 100644
--- a/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js
@@ -2,169 +2,12 @@ define([
'./templates'
], function () {
- var $ = jQuery;
-
- Handlebars.registerHelper('issuesHomeLink', function (property, value) {
- return baseUrl + '/issues/search#resolved=false|createdInLast=1w|' +
- property + '=' + (encodeURIComponent(value));
- });
-
- Handlebars.registerHelper('myIssuesHomeLink', function (property, value) {
- return baseUrl + '/issues/search#resolved=false|createdInLast=1w|assignees=__me__|' +
- property + '=' + (encodeURIComponent(value));
- });
-
Handlebars.registerHelper('issueFilterHomeLink', function (id) {
return baseUrl + '/issues/search#id=' + id;
});
return Marionette.ItemView.extend({
- template: Templates['issues-workspace-home'],
-
- modelEvents: {
- 'change': 'render'
- },
-
- events: {
- 'click .js-barchart rect': 'selectBar',
- 'click .js-my-barchart rect': 'selectMyBar'
- },
-
- initialize: function () {
- this.model = new Backbone.Model();
- this.requestIssues();
- this.requestMyIssues();
- },
-
- _getProjects: function (r) {
- var projectFacet = _.findWhere(r.facets, { property: 'projectUuids' });
- if (projectFacet != null) {
- var values = _.head(projectFacet.values, 3);
- values.forEach(function (v) {
- var project = _.findWhere(r.components, { uuid: v.val });
- v.label = project.longName;
- });
- return values;
- }
- },
-
- _getAuthors: function (r) {
- var authorFacet = _.findWhere(r.facets, { property: 'authors' });
- if (authorFacet != null) {
- return _.head(authorFacet.values, 3);
- }
- },
-
- _getTags: function (r) {
- var MIN_SIZE = 10,
- MAX_SIZE = 24,
- tagFacet = _.findWhere(r.facets, { property: 'tags' });
- if (tagFacet != null) {
- var values = _.head(tagFacet.values, 10),
- minCount = _.min(values, function (v) {
- return v.count;
- }).count,
- maxCount = _.max(values, function (v) {
- return v.count;
- }).count,
- scale = d3.scale.linear().domain([minCount, maxCount]).range([MIN_SIZE, MAX_SIZE]);
- values.forEach(function (v) {
- v.size = scale(v.count);
- });
- return values;
- }
- },
-
- requestIssues: function () {
- var that = this;
- var url = baseUrl + '/api/issues/search',
- options = {
- resolved: false,
- createdInLast: '1w',
- ps: 1,
- facets: 'createdAt,projectUuids,authors,tags'
- };
- return $.get(url, options).done(function (r) {
- var createdAt = _.findWhere(r.facets, { property: 'createdAt' });
- that.model.set({
- createdAt: createdAt != null ? createdAt.values : null,
- projects: that._getProjects(r),
- authors: that._getAuthors(r),
- tags: that._getTags(r)
- });
- });
- },
-
- requestMyIssues: function () {
- var that = this;
- var url = baseUrl + '/api/issues/search',
- options = {
- resolved: false,
- createdInLast: '1w',
- assignees: '__me__',
- ps: 1,
- facets: 'createdAt,projectUuids,authors,tags'
- };
- return $.get(url, options).done(function (r) {
- var createdAt = _.findWhere(r.facets, { property: 'createdAt' });
- return that.model.set({
- myCreatedAt: createdAt != null ? createdAt.values : null,
- myProjects: that._getProjects(r),
- myTags: that._getTags(r)
- });
- });
- },
-
- _addFormattedValues: function (values) {
- return values.map(function (v) {
- var text = window.formatMeasure(v.count, 'SHORT_INT');
- return _.extend(v, { text: text });
- });
- },
-
- onRender: function () {
- var values = this.model.get('createdAt'),
- myValues = this.model.get('myCreatedAt');
- if (values != null) {
- this.$('.js-barchart').barchart(this._addFormattedValues(values));
- }
- if (myValues != null) {
- this.$('.js-my-barchart').barchart(this._addFormattedValues(myValues));
- }
- this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
- },
-
- onDestroy: function () {
- this.$('[data-toggle="tooltip"]').tooltip('destroy');
- },
-
- selectBar: function (e) {
- var periodStart = $(e.currentTarget).data('period-start'),
- periodEnd = $(e.currentTarget).data('period-end');
- this.options.app.state.setQuery({
- resolved: false,
- createdAfter: periodStart,
- createdBefore: periodEnd
- });
- },
-
- selectMyBar: function (e) {
- var periodStart = $(e.currentTarget).data('period-start'),
- periodEnd = $(e.currentTarget).data('period-end');
- this.options.app.state.setQuery({
- resolved: false,
- assignees: '__me__',
- createdAfter: periodStart,
- createdBefore: periodEnd
- });
- },
-
- serializeData: function () {
- return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- user: window.SS.user,
- filters: _.sortBy(this.options.app.filters.toJSON(), 'name')
- });
- }
+ template: Templates['issues-workspace-home']
});
});