aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-03-24 19:25:10 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-03-24 19:25:21 +0600
commitb61fbdcc459d3689d24beb618c962e727d276261 (patch)
treed366c6b2f845aa8106387a7ef8397757763649d3
parentdf9e488fe8c877931155916bb76932caeaeef897 (diff)
downloadsonarqube-b61fbdcc459d3689d24beb618c962e727d276261.tar.gz
sonarqube-b61fbdcc459d3689d24beb618c962e727d276261.zip
SONAR-5007 Improve QP filter
-rw-r--r--sonar-server/src/main/webapp/coffee/coding-rules/app.coffee2
-rw-r--r--sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee73
-rw-r--r--sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee30
-rw-r--r--sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee12
-rw-r--r--sonar-server/src/main/webapp/less/coding-rules.less7
-rw-r--r--sonar-server/src/main/webapp/less/navigator/filters.less5
-rw-r--r--sonar-server/src/main/webapp/less/variables.less3
-rw-r--r--sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs2
-rw-r--r--sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs8
9 files changed, 63 insertions, 79 deletions
diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee
index 4a05d84b735..b5029b0f577 100644
--- a/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee
+++ b/sonar-server/src/main/webapp/coffee/coding-rules/app.coffee
@@ -249,7 +249,7 @@ requirejs [
property: 'activation'
type: ActivationFilterView
enabled: false
- optional: true
+ optional: false
multiple: false
qualityProfileFilter: @qualityProfileFilter
choices:
diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
index 53709d9de95..2f3ec432cd4 100644
--- a/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
+++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
@@ -12,81 +12,13 @@ define [
ui:
- update: '.coding-rules-detail-quality-profile-update'
- severitySelect: '.coding-rules-detail-quality-profile-severity'
-
- note: '.coding-rules-detail-quality-profile-note'
- noteForm: '.coding-rules-detail-quality-profile-note-form'
- noteText: '.coding-rules-detail-quality-profile-note-text'
- noteAdd: '.coding-rules-detail-quality-profile-note-add'
- noteEdit: '.coding-rules-detail-quality-profile-note-edit'
- noteDelete: '.coding-rules-detail-quality-profile-note-delete'
- noteCancel: '.coding-rules-detail-quality-profile-note-cancel'
- noteSubmit: '.coding-rules-detail-quality-profile-note-submit'
-
-
- events:
- 'click @ui.noteAdd': 'editNote'
- 'click @ui.noteEdit': 'editNote'
- 'click @ui.noteDelete': 'deleteNote'
- 'click @ui.noteCancel': 'cancelNote'
- 'click @ui.noteSubmit': 'submitNote'
-
- 'change .coding-rules-detail-parameters select': 'enableUpdate'
- 'keyup .coding-rules-detail-parameters input': 'enableUpdate'
-
-
- editNote: ->
- @ui.note.hide()
- @ui.noteForm.show()
- @ui.noteText.focus()
-
-
- deleteNote: ->
- @ui.noteText.val ''
- @submitNote().done =>
- @model.unset 'note'
- @render()
-
-
- cancelNote: ->
- @ui.note.show()
- @ui.noteForm.hide()
-
-
- submitNote: ->
- @ui.note.html '<i class="spinner"></i>'
- @ui.noteForm.html '<i class="spinner"></i>'
- jQuery.ajax
- type: 'POST'
- url: "#{baseUrl}/api/codingrules/note"
- dataType: 'json'
- data: text: @ui.noteText.val()
- .done (r) =>
- @model.set 'note', r.note
- @render()
+ change: '.coding-rules-detail-quality-profile-change'
enableUpdate: ->
@ui.update.prop 'disabled', false
- onRender: ->
- @ui.noteForm.hide()
-
- format = (state) ->
- return state.text unless state.id
- "<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
-
- @ui.severitySelect.val @model.get 'severity'
-# @ui.severitySelect.select2
-# width: '200px'
-# minimumResultsForSearch: 999
-# formatResult: format
-# formatSelection: format
-# escapeMarkup: (m) -> m
-
-
getParent: ->
return null unless @model.get 'inherits'
@options.qualityProfiles.findWhere(key: @model.get('inherits')).toJSON()
@@ -103,5 +35,4 @@ define [
serializeData: ->
_.extend super,
parent: @getParent()
- parameters: @enhanceParameters()
- severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'] \ No newline at end of file
+ parameters: @enhanceParameters() \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee
index 8a4a11d831e..896ee64c050 100644
--- a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee
+++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/activation-filter-view.coffee
@@ -1,13 +1,41 @@
define [
+ 'navigator/filters/choice-filters'
'coding-rules/views/filters/inheritance-filter-view'
], (
+ ChoiceFilters
InheritanceFilterView
) ->
+ class DetailsActivationFilterView extends ChoiceFilters.DetailsChoiceFilterView
+
+ onCheck: (e) ->
+ id = jQuery(e.target).val()
+ selected = @options.filterView.choices.findWhere checked: true
+ unless id == selected
+ @options.filterView.choices.each (item) -> item.set 'checked', item.id == id
+ else
+ e.preventDefault()
+ @updateValue()
+ @updateLists()
+
+
+
class ActivationFilterView extends InheritanceFilterView
tooltip: 'coding_rules.filters.activation.help'
+ initialize: ->
+ super detailsView: DetailsActivationFilterView
+
+
onChangeQualityProfile: ->
qualityProfile = @qualityProfileFilter.get 'value'
- if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive() \ No newline at end of file
+ if _.isArray(qualityProfile) && qualityProfile.length == 1 then @makeActive() else @makeInactive()
+
+
+ makeActive: ->
+ @choices.each (item) -> item.set 'checked', item.id == 'active'
+ @detailsView.updateValue()
+ @detailsView.updateLists()
+ @render()
+ super \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee
index ab1c4bd0c93..eff55a9e618 100644
--- a/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee
+++ b/sonar-server/src/main/webapp/coffee/coding-rules/views/filters/quality-profile-filter-view.coffee
@@ -16,7 +16,12 @@ define [
initialize: ->
super
@choices = new QualityProfileSuggestions
- @listenTo @model, 'change:value', @updateParentQualityProfile
+ @listenTo @model, 'change:value', @onValueChange
+
+
+ onValueChange: ->
+ @updateParentQualityProfile()
+ @highlightContext()
updateParentQualityProfile: ->
@@ -27,6 +32,11 @@ define [
@model.unset 'parentQualityProfile'
+ highlightContext: ->
+ hasContext = _.isArray(@model.get('value')) && @model.get('value').length > 0
+ @$el.toggleClass 'navigator-filter-context', hasContext
+
+
createRequest: (v) ->
jQuery.ajax
url: baseUrl + '/api/qualityprofiles/show'
diff --git a/sonar-server/src/main/webapp/less/coding-rules.less b/sonar-server/src/main/webapp/less/coding-rules.less
index c5971b0e664..fb84e4f3781 100644
--- a/sonar-server/src/main/webapp/less/coding-rules.less
+++ b/sonar-server/src/main/webapp/less/coding-rules.less
@@ -36,6 +36,9 @@
.coding-rules-detail-context-actions {
margin-bottom: @navigatorPadding;
+ padding: @navigatorPadding / 2;
+ background-color: @contextBackground;
+ border: 1px solid @contextBorder;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -53,6 +56,8 @@
margin-right: @navigatorPadding;
.limited {
+ display: inline-block;
+ vertical-align: middle;
max-width: 180px;
white-space: nowrap;
overflow: hidden;
@@ -60,7 +65,7 @@
}
.limited-big {
- width: 480px;
+ max-width: 480px;
}
}
diff --git a/sonar-server/src/main/webapp/less/navigator/filters.less b/sonar-server/src/main/webapp/less/navigator/filters.less
index dc9868f1f97..fbfdf0e3b13 100644
--- a/sonar-server/src/main/webapp/less/navigator/filters.less
+++ b/sonar-server/src/main/webapp/less/navigator/filters.less
@@ -87,6 +87,11 @@
opacity: 0.5;
}
+.navigator-filter-context {
+ background-color: @contextBackground;
+ border-color: @contextBorder;
+}
+
.navigator-filter-label {
display: inline-block;
vertical-align: middle;
diff --git a/sonar-server/src/main/webapp/less/variables.less b/sonar-server/src/main/webapp/less/variables.less
index b43675bf36c..ab56248686b 100644
--- a/sonar-server/src/main/webapp/less/variables.less
+++ b/sonar-server/src/main/webapp/less/variables.less
@@ -25,7 +25,8 @@
@orange: #f90;
@highlighted: @blue;
-
+@contextBackground: lighten(@green, 40%);
+@contextBorder: lighten(@green, 20%);
/*
diff --git a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs
index b3962380591..b1633fcfaa5 100644
--- a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs
+++ b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail-quality-profile.hbs
@@ -32,7 +32,7 @@
<td class="coding-rules-detail-quality-profile-actions">
<div class="button-group">
- <button class="coding-rules-detail-quality-profile-update">{{t 'change'}}</button>
+ <button class="coding-rules-detail-quality-profile-change">{{t 'change'}}</button>
{{#if parent}}
<button class="coding-rules-detail-quality-profile-revert button-red">
{{t 'coding_rules.revert_to_parent_definition'}}
diff --git a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs
index 05b9d52bcb6..4b36a41182b 100644
--- a/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs
+++ b/sonar-server/src/main/webapp/templates/coding-rules/coding-rules-detail.hbs
@@ -1,5 +1,5 @@
{{#if contextQualityProfile}}
- <div class="coding-rules-detail-context-actions admin">
+ <div class="coding-rules-detail-context-actions">
<table class="width100">
<tbody>
<tr>
@@ -18,7 +18,11 @@
</span>
{{/each}}
- {{#if note}}<span class="coding-rules-detail-context-actions-item">{{{note.html}}}</span>{{/if}}
+ {{#if note}}
+ <span class="coding-rules-detail-context-actions-item">
+ <span class="limited limited-big">{{{note.html}}}</span>
+ </span>
+ {{/if}}
{{/with}}
{{/if}}
</td>