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
+ );
}
},
type History = Array<{
key: string,
name: string,
- icon: string
+ icon: string,
+ organization?: string
}>;
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);
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,
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
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)
});