aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-01-19 11:18:43 +0100
committerStas Vilchik <stas-vilchik@users.noreply.github.com>2017-01-24 09:25:53 +0100
commit8f37914e061783a4a32445b5238e8fa37666aaef (patch)
tree67c6f6b49fb89e3411f9bfd81f69d4fd5845e882 /server/sonar-web/src/main
parentfdffb1a9e22c4fb9e97ce6f6ded76fff720a440d (diff)
downloadsonarqube-8f37914e061783a4a32445b5238e8fa37666aaef.tar.gz
sonarqube-8f37914e061783a4a32445b5238e8fa37666aaef.zip
SONAR-8661 Display organization in the search
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js7
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js7
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/global/SearchView.js12
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs6
4 files changed, 28 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js
index cbaa9fb2520..303a45c6cc1 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNav.js
@@ -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
+ );
}
},
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js b/server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js
index d5bb1b2d587..56ac275736f 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js
+++ b/server/sonar-web/src/main/js/app/components/nav/component/RecentHistory.js
@@ -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);
diff --git a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js
index 156266ff132..070d80e993c 100644
--- a/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js
+++ b/server/sonar-web/src/main/js/app/components/nav/global/SearchView.js
@@ -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)
});
diff --git a/server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs b/server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs
index 25128ddfc20..890643d9237 100644
--- a/server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs
+++ b/server/sonar-web/src/main/js/app/components/nav/templates/nav-search-item.hbs
@@ -19,4 +19,10 @@
{{name}}
{{/eq}}
{{/eq}}
+
+ {{#if organization}}
+ <div class="pull-right nowrap note">
+ {{organization.name}}
+ </div>
+ {{/if}}
</a>