]> source.dussan.org Git - sonarqube.git/commitdiff
display organizations in projects facet on issues page
authorStas Vilchik <vilchiks@gmail.com>
Thu, 2 Feb 2017 10:56:15 +0000 (11:56 +0100)
committerStas Vilchik <stas-vilchik@users.noreply.github.com>
Thu, 2 Feb 2017 12:32:25 +0000 (13:32 +0100)
server/sonar-web/src/main/js/apps/issues/facets/project-facet.js
server/sonar-web/src/main/js/apps/issues/templates/facets/issues-projects-facet.hbs [new file with mode: 0644]

index da323213530548985b0fac966bdb8ace5baf307c..c5eaa70356a926ba0640953b02c5f6bd0835aa30 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import CustomValuesFacet from './custom-values-facet';
+import Template from '../templates/facets/issues-projects-facet.hbs';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
+import { areThereCustomOrganizations, getOrganization } from '../../../store/organizations/utils';
 
 export default CustomValuesFacet.extend({
+  template: Template,
 
   getUrl () {
     return window.baseUrl + '/api/components/search';
@@ -80,16 +83,21 @@ export default CustomValuesFacet.extend({
   getValuesWithLabels () {
     const values = this.model.getValues();
     const projects = this.options.app.facets.components;
+    const displayOrganizations = areThereCustomOrganizations();
     values.forEach(v => {
       const uuid = v.val;
       let label = '';
+      let organization = null;
       if (uuid) {
         const project = projects.find(p => p.uuid === uuid);
         if (project != null) {
           label = project.longName;
+          organization = displayOrganizations && project.organization ?
+              getOrganization(project.organization) : null;
         }
       }
       v.label = label;
+      v.organization = organization;
     });
     return values;
   },
diff --git a/server/sonar-web/src/main/js/apps/issues/templates/facets/issues-projects-facet.hbs b/server/sonar-web/src/main/js/apps/issues/templates/facets/issues-projects-facet.hbs
new file mode 100644 (file)
index 0000000..7693af6
--- /dev/null
@@ -0,0 +1,16 @@
+{{> "_issues-facet-header"}}
+
+<div class="search-navigator-facet-list">
+  {{#each values}}
+    <a class="facet search-navigator-facet js-facet" data-value="{{val}}" title="{{#if extra}}({{extra}}) {{/if}}{{default label val}}">
+      <span class="facet-name">{{#if organization}}{{organization.name}}<span class="slash-separator"></span>{{/if}}{{default label val}}</span>
+      <span class="facet-stat">
+        {{#eq ../state.facetMode 'count'}}{{numberShort count}}{{else}}{{formatMeasure count 'SHORT_WORK_DUR'}}{{/eq}}
+      </span>
+    </a>
+  {{/each}}
+
+  <div class="search-navigator-facet-custom-value">
+    <input type="hidden" class="js-custom-value">
+  </div>
+</div>