* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { connect } from 'react-redux';
+import { getGlobalSettingValue, Store } from '../../../store/rootReducer';
import { Facet, Query, ReferencedComponent, ReferencedLanguage, ReferencedRule } from '../utils';
import AssigneeFacet from './AssigneeFacet';
import AuthorFacet from './AuthorFacet';
referencedLanguages: T.Dict<ReferencedLanguage>;
referencedRules: T.Dict<ReferencedRule>;
referencedUsers: T.Dict<T.UserBase>;
+ disableDeveloperAggregatedInfo: boolean;
}
-export default class Sidebar extends React.PureComponent<Props> {
+export class Sidebar extends React.PureComponent<Props> {
renderComponentFacets() {
const { component, facets, loadingFacets, openFacets, query } = this.props;
if (!component) {
/>
)}
{this.renderComponentFacets()}
- {!this.props.myIssues && (
+ {!this.props.myIssues && !this.props.disableDeveloperAggregatedInfo && (
<AssigneeFacet
assigned={query.assigned}
assignees={query.assignees}
stats={facets.assignees}
/>
)}
- {displayAuthorFacet && (
+ {displayAuthorFacet && !this.props.disableDeveloperAggregatedInfo && (
<AuthorFacet
authors={query.authors}
component={component}
);
}
}
+
+export const mapStateToProps = (state: Store) => {
+ const disableDeveloperAggregatedInfo = getGlobalSettingValue(
+ state,
+ 'sonar.developerAggregatedInfo.disabled'
+ );
+ return {
+ disableDeveloperAggregatedInfo: disableDeveloperAggregatedInfo?.value === true.toString()
+ };
+};
+
+export default connect(mapStateToProps)(Sidebar);
import { shallow, ShallowWrapper } from 'enzyme';
import { flatten } from 'lodash';
import * as React from 'react';
+import { mockComponent } from '../../../../helpers/testMocks';
+import { getGlobalSettingValue } from '../../../../store/rootReducer';
+import { ComponentQualifier } from '../../../../types/component';
import { Query } from '../../utils';
-import Sidebar, { Props } from '../Sidebar';
+import { mapStateToProps, Sidebar } from '../Sidebar';
-jest.mock('../../../../store/rootReducer', () => ({}));
+jest.mock('../../../../store/rootReducer', () => ({ getGlobalSettingValue: jest.fn() }));
-const renderSidebar = (props?: Partial<Props>) => {
+it('should render facets for global page', () => {
+ expect(renderSidebar()).toMatchSnapshot();
+});
+
+it('should render facets for project', () => {
+ expect(renderSidebar({ component: mockComponent() })).toMatchSnapshot();
+});
+
+it('should render facets for module', () => {
+ expect(
+ renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.SubProject }) })
+ ).toMatchSnapshot();
+});
+
+it('should render facets for directory', () => {
+ expect(
+ renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.Directory }) })
+ ).toMatchSnapshot();
+});
+
+it('should render facets for developer', () => {
+ expect(
+ renderSidebar({ component: mockComponent({ qualifier: ComponentQualifier.Developper }) })
+ ).toMatchSnapshot();
+});
+
+it('should render facets when my issues are selected', () => {
+ expect(renderSidebar({ myIssues: true })).toMatchSnapshot();
+});
+
+it('should not render developer nominative facets when asked not to', () => {
+ expect(renderSidebar({ disableDeveloperAggregatedInfo: true })).toMatchSnapshot();
+});
+
+it('should init the component with the proper store value', () => {
+ mapStateToProps({} as any);
+
+ expect(getGlobalSettingValue).toHaveBeenCalledWith(
+ expect.any(Object),
+ 'sonar.developerAggregatedInfo.disabled'
+ );
+});
+
+const renderSidebar = (props?: Partial<Sidebar['props']>) => {
return flatten(
mapChildren(
- shallow(
+ shallow<Sidebar>(
<Sidebar
component={undefined}
facets={{}}
referencedLanguages={{}}
referencedRules={{}}
referencedUsers={{}}
+ disableDeveloperAggregatedInfo={false}
{...props}
/>
)
function mapChildren(wrapper: ShallowWrapper) {
return wrapper.children().map(node => {
if (typeof node.type() === 'symbol') {
- return node.children().map(node => node.name());
+ return node.children().map(n => n.name());
}
return node.name();
});
}
};
-
-const component = {
- breadcrumbs: [],
- name: 'foo',
- key: 'foo',
- organization: 'org'
-};
-
-it('should render facets for global page', () => {
- expect(renderSidebar()).toMatchSnapshot();
-});
-
-it('should render facets for project', () => {
- expect(renderSidebar({ component: { ...component, qualifier: 'TRK' } })).toMatchSnapshot();
-});
-
-it('should render facets for module', () => {
- expect(renderSidebar({ component: { ...component, qualifier: 'BRC' } })).toMatchSnapshot();
-});
-
-it('should render facets for directory', () => {
- expect(renderSidebar({ component: { ...component, qualifier: 'DIR' } })).toMatchSnapshot();
-});
-
-it('should render facets for developer', () => {
- expect(renderSidebar({ component: { ...component, qualifier: 'DEV' } })).toMatchSnapshot();
-});
-
-it('should render facets when my issues are selected', () => {
- expect(renderSidebar({ myIssues: true })).toMatchSnapshot();
-});
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should not render developer nominative facets when asked not to 1`] = `
+Array [
+ "TypeFacet",
+ "SeverityFacet",
+ "ResolutionFacet",
+ "StatusFacet",
+ "StandardFacet",
+ "InjectIntl(CreationDateFacet)",
+ "Connect(LanguageFacet)",
+ "RuleFacet",
+ "TagFacet",
+ "ProjectFacet",
+]
+`;
+
exports[`should render facets for developer 1`] = `
Array [
"TypeFacet",
import org.sonar.server.ui.WebAnalyticsLoader;
import org.sonar.server.user.UserSession;
+import static org.sonar.api.CoreProperties.DEVELOPER_AGGREGATED_INFO_DISABLED;
import static org.sonar.api.CoreProperties.RATING_GRID;
import static org.sonar.core.config.WebConstants.SONAR_LF_ENABLE_GRAVATAR;
import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL;
SONAR_LF_LOGO_WIDTH_PX,
SONAR_LF_ENABLE_GRAVATAR,
SONAR_LF_GRAVATAR_SERVER_URL,
- RATING_GRID);
+ RATING_GRID,
+ DEVELOPER_AGGREGATED_INFO_DISABLED);
private final Map<String, String> systemSettingValuesByKey;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
settings.setProperty("sonar.lf.enableGravatar", true);
settings.setProperty("sonar.updatecenter.activate", false);
settings.setProperty("sonar.technicalDebt.ratingGrid", "0.05,0.1,0.2,0.5");
+ settings.setProperty("sonar.developerAggregatedInfo.disabled", false);
// This setting should be ignored as it's not needed
settings.setProperty("sonar.defaultGroup", "sonar-users");
init();
" \"sonar.lf.enableGravatar\": \"true\"," +
" \"sonar.updatecenter.activate\": \"false\"," +
" \"sonar.technicalDebt.ratingGrid\": \"0.05,0.1,0.2,0.5\"" +
+ " \"sonar.developerAggregatedInfo.disabled\": \"false\"" +
" }" +
"}");
}
"}");
}
+ @Test
+ public void return_developer_info_disabled_setting() {
+ init();
+ settings.setProperty("sonar.developerAggregatedInfo.disabled", true);
+
+ assertJson(call()).isSimilarTo("{" +
+ " \"settings\": {" +
+ " \"sonar.developerAggregatedInfo.disabled\": \"true\"" +
+ " }" +
+ "}");
+ }
+
@Test
public void return_deprecated_logo_settings() {
init();
.build(),
// ISSUES
+ PropertyDefinition.builder(CoreProperties.DEVELOPER_AGGREGATED_INFO_DISABLED)
+ .name("Disable developer aggregated information")
+ .description("Don't show issue facets aggregating information per developer")
+ .category(CoreProperties.CATEGORY_GENERAL)
+ .subCategory(CoreProperties.SUBCATEGORY_ISSUES)
+ .onQualifiers(Qualifiers.PROJECT)
+ .type(BOOLEAN)
+ .defaultValue(Boolean.toString(false))
+ .build(),
+
PropertyDefinition.builder(CoreProperties.DEFAULT_ISSUE_ASSIGNEE)
.name("Default Assignee")
.description("New issues will be assigned to this user each time it is not possible to determine the user who is the author of the issue.")
@Test
public void all() {
List<PropertyDefinition> defs = CorePropertyDefinitions.all();
- assertThat(defs).hasSize(51);
+ assertThat(defs).hasSize(52);
}
@Test
*/
String DEFAULT_ISSUE_ASSIGNEE = "sonar.issues.defaultAssigneeLogin";
+ /**
+ * @since 8.5
+ */
+ String DEVELOPER_AGGREGATED_INFO_DISABLED = "sonar.developerAggregatedInfo.disabled";
+
/**
* @since 7.6
*/