]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8661 Display organization in the search
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Jan 2017 10:18:43 +0000 (11:18 +0100)
committerStas Vilchik <stas-vilchik@users.noreply.github.com>
Tue, 24 Jan 2017 08:25:53 +0000 (09:25 +0100)
server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js
server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js
server/sonar-web/src/main/js/app/components/nav/global/SearchView.js
server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs

index cbaa9fb25202c5023fe8b2f635a2992cc40dc6b8..303a45c6cc15a325bc78c1fff7259f56b869e2fe 100644 (file)
@@ -56,7 +56,12 @@ export default React.createClass({
     const { breadcrumbs } = this.props.component;
     const { qualifier } = breadcrumbs[breadcrumbs.length - 1];
     if (['TRK', 'VW', 'DEV'].indexOf(qualifier) !== -1) {
-      RecentHistory.add(this.props.component.key, this.props.component.name, qualifier.toLowerCase());
+      RecentHistory.add(
+          this.props.component.key,
+          this.props.component.name,
+          qualifier.toLowerCase(),
+          this.props.component.organization
+      );
     }
   },
 
index d5bb1b2d5872aa88e9280273dec26292a3a7750c..56ac275736f4cfba0adb6e91a569cc493fa8786a 100644 (file)
@@ -24,7 +24,8 @@ const HISTORY_LIMIT = 10;
 type History = Array<{
   key: string,
   name: string,
-  icon: string
+  icon: string,
+  organization?: string
 }>;
 
 export default class RecentHistory {
@@ -51,9 +52,9 @@ export default class RecentHistory {
     localStorage.removeItem(STORAGE_KEY);
   }
 
-  static add (componentKey: string, componentName: string, icon: string): void {
+  static add (componentKey: string, componentName: string, icon: string, organization?: string): void {
     const sonarHistory = RecentHistory.get();
-    const newEntry = { key: componentKey, name: componentName, icon };
+    const newEntry = { key: componentKey, name: componentName, icon, organization };
     let newHistory = sonarHistory.filter(entry => entry.key !== newEntry.key);
     newHistory.unshift(newEntry);
     newHistory = newHistory.slice(0, HISTORY_LIMIT);
index 156266ff1325759c4d0c212c6951cc68ad59df14..070d80e993c4eac435d491cc639fd5c3e0a5cfdc 100644 (file)
@@ -31,6 +31,7 @@ import { translate } from '../../../../helpers/l10n';
 import { isUserAdmin } from '../../../../helpers/users';
 import { getFavorites } from '../../../../api/favorites';
 import { getSuggestions } from '../../../../api/components';
+import { getOrganization, areThereCustomOrganizations } from '../../../../store/organizations/utils';
 
 type Finding = {
   name: string,
@@ -174,11 +175,17 @@ export default Marionette.LayoutView.extend({
 
   resetResultsToDefault () {
     const recentHistory = RecentHistory.get();
+    const customOrganizations = areThereCustomOrganizations();
     const history = recentHistory.map((historyItem, index) => {
       const url = window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) +
           window.dashboardParameters(true);
+      const showOrganization = customOrganizations && historyItem.organization != null &&
+          historyItem.icon.toUpperCase() === 'TRK';
+      // $FlowFixMe flow doesn't check the above condition on `historyItem.organization != null`
+      const organization = showOrganization ? getOrganization(historyItem.organization) : null;
       return {
         url,
+        organization,
         name: historyItem.name,
         q: historyItem.icon,
         extra: index === 0 ? translate('browsed_recently') : null
@@ -202,12 +209,17 @@ export default Marionette.LayoutView.extend({
         return;
       }
 
+      const customOrganizations = areThereCustomOrganizations();
+
       const collection = [];
       r.results.forEach(({ items, q }) => {
         items.forEach((item, index) => {
+          const showOrganization = customOrganizations && item.organization != null && q === 'TRK';
+          const organization = showOrganization ? getOrganization(item.organization) : null;
           collection.push({
             ...item,
             q,
+            organization,
             extra: index === 0 ? translate('qualifiers', q) : null,
             url: window.baseUrl + '/dashboard?id=' + encodeURIComponent(item.key)
           });
index 25128ddfc2050630ba2e36cf4e8f4dcae109af82..890643d9237ef55e8d09db7514ee28d64ee57f43 100644 (file)
       {{name}}
     {{/eq}}
   {{/eq}}
+
+  {{#if organization}}
+    <div class="pull-right nowrap note">
+      {{organization.name}}
+    </div>
+  {{/if}}
 </a>