aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/App.tsx70
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx46
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx15
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx21
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx10
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/ComponentBreadcrumbs-test.tsx18
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesList-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap26
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/ComponentBreadcrumbs-test.tsx.snap8
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesList-test.tsx.snap6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap12
-rw-r--r--server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueLocationsNavigator-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx28
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/ProjectFacet-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/RuleFacet-test.tsx80
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/RuleFacet-test.tsx.snap30
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.ts27
34 files changed, 189 insertions, 288 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx
index 1532651a140..93783d44945 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx
@@ -51,6 +51,13 @@ import {
} from '../../../helpers/branch-like';
import { isSonarCloud } from '../../../helpers/system';
import { BranchLike } from '../../../types/branch-like';
+import {
+ Facet,
+ FetchIssuesPromise,
+ ReferencedComponent,
+ ReferencedLanguage,
+ ReferencedRule
+} from '../../../types/issues';
import { SecurityStandard } from '../../../types/security';
import * as actions from '../actions';
import ConciseIssuesList from '../conciseIssuesList/ConciseIssuesList';
@@ -60,16 +67,11 @@ import '../styles.css';
import {
areMyIssuesSelected,
areQueriesEqual,
- Facet,
getOpen,
mapFacet,
parseFacets,
parseQuery,
Query,
- RawFacet,
- ReferencedComponent,
- ReferencedLanguage,
- ReferencedRule,
saveMyIssues,
scrollToIssue,
serializeQuery,
@@ -86,28 +88,15 @@ import NoIssues from './NoIssues';
import NoMyIssues from './NoMyIssues';
import PageActions from './PageActions';
-interface FetchIssuesPromise {
- components: ReferencedComponent[];
- effortTotal: number;
- facets: RawFacet[];
- issues: T.Issue[];
- languages: ReferencedLanguage[];
- paging: T.Paging;
- rules: ReferencedRule[];
- users: T.UserBase[];
-}
-
interface Props {
branchLike?: BranchLike;
component?: T.Component;
currentUser: T.CurrentUser;
fetchBranchStatus: (branchLike: BranchLike, projectKey: string) => Promise<void>;
- fetchIssues: (query: T.RawQuery, requestOrganizations?: boolean) => Promise<FetchIssuesPromise>;
+ fetchIssues: (query: T.RawQuery) => Promise<FetchIssuesPromise>;
location: Location;
onBranchesChange?: () => void;
- organization?: { key: string };
router: Pick<Router, 'push' | 'replace'>;
- userOrganizations: T.Organization[];
}
export interface State {
@@ -424,17 +413,12 @@ export default class App extends React.PureComponent<Props, State> {
.join(',')
: undefined;
- const organizationKey =
- (component && component.organization) ||
- (this.props.organization && this.props.organization.key);
-
const parameters: T.Dict<string | undefined> = {
...getBranchLikeQuery(this.props.branchLike),
componentKeys: component && component.key,
s: 'FILE_LINE',
...serializeQuery(query),
ps: '100',
- organization: organizationKey,
facets,
...additional
};
@@ -452,7 +436,7 @@ export default class App extends React.PureComponent<Props, State> {
Object.assign(parameters, { assignees: '__me__' });
}
- return this.props.fetchIssues(parameters, false);
+ return this.props.fetchIssues(parameters);
};
fetchFirstIssues() {
@@ -630,7 +614,9 @@ export default class App extends React.PureComponent<Props, State> {
}));
}
},
- () => {}
+ () => {
+ /* Do nothing */
+ }
);
};
@@ -701,27 +687,20 @@ export default class App extends React.PureComponent<Props, State> {
const { component } = this.props;
const { myIssues, query } = this.state;
- const organizationKey =
- (component && component.organization) ||
- (this.props.organization && this.props.organization.key);
-
const parameters = {
...getBranchLikeQuery(this.props.branchLike),
componentKeys: component && component.key,
facets: mapFacet(property),
s: 'FILE_LINE',
...serializeQuery({ ...query, ...changes }),
- ps: 1,
- organization: organizationKey
+ ps: 1
};
if (myIssues) {
Object.assign(parameters, { assignees: '__me__' });
}
- return this.props
- .fetchIssues(parameters, false)
- .then(({ facets }) => parseFacets(facets)[property]);
+ return this.props.fetchIssues(parameters).then(({ facets }) => parseFacets(facets)[property]);
};
closeFacet = (property: string) => {
@@ -918,7 +897,6 @@ export default class App extends React.PureComponent<Props, State> {
fetchIssues={checkAll ? this.fetchIssues : this.getCheckedIssues}
onClose={this.handleCloseBulkChange}
onDone={this.handleBulkChangeDone}
- organization={this.props.organization}
/>
)}
</div>
@@ -926,20 +904,9 @@ export default class App extends React.PureComponent<Props, State> {
}
renderFacets() {
- const { component, currentUser, userOrganizations, branchLike } = this.props;
+ const { component, currentUser, branchLike } = this.props;
const { query } = this.state;
- const organizationKey =
- (component && component.organization) ||
- (this.props.organization && this.props.organization.key);
-
- const userOrganization =
- !isSonarCloud() ||
- userOrganizations.find(o => {
- return o.key === organizationKey;
- });
- const hideAuthorFacet = !userOrganization;
-
return (
<div className="layout-page-filters">
{currentUser.isLoggedIn && !isSonarCloud() && (
@@ -954,14 +921,12 @@ export default class App extends React.PureComponent<Props, State> {
component={component}
createdAfterIncludesTime={this.createdAfterIncludesTime()}
facets={this.state.facets}
- hideAuthorFacet={hideAuthorFacet}
loadSearchResultCount={this.loadSearchResultCount}
loadingFacets={this.state.loadingFacets}
myIssues={this.state.myIssues}
onFacetToggle={this.handleFacetToggle}
onFilterChange={this.handleFilterChange}
openFacets={this.state.openFacets}
- organization={this.props.organization}
query={query}
referencedComponentsById={this.state.referencedComponentsById}
referencedComponentsByKey={this.state.referencedComponentsByKey}
@@ -1029,7 +994,7 @@ export default class App extends React.PureComponent<Props, State> {
}
renderList() {
- const { branchLike, component, currentUser, organization } = this.props;
+ const { branchLike, component, currentUser } = this.props;
const { issues, loading, loadingMore, openIssue, paging } = this.state;
const selectedIndex = this.getSelectedIndex();
const selectedIssue = selectedIndex !== undefined ? issues[selectedIndex] : undefined;
@@ -1063,7 +1028,6 @@ export default class App extends React.PureComponent<Props, State> {
onIssueClick={this.openIssue}
onPopupToggle={this.handlePopupToggle}
openPopup={this.state.openPopup}
- organization={organization}
selectedIssue={selectedIssue}
/>
)}
@@ -1101,7 +1065,7 @@ export default class App extends React.PureComponent<Props, State> {
{this.renderBulkChange(openIssue)}
<PageActions
- canSetHome={Boolean(!this.props.organization && !this.props.component)}
+ canSetHome={!this.props.component}
effortTotal={this.state.effortTotal}
onReload={this.handleReload}
paging={paging}
diff --git a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx
index 97f04d40be5..ba2169c52b4 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/AppContainer.tsx
@@ -17,53 +17,29 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { uniq } from 'lodash';
import { connect } from 'react-redux';
-import { Dispatch } from 'redux';
import { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
import { searchIssues } from '../../../api/issues';
-import { getOrganizations } from '../../../api/organizations';
import throwGlobalError from '../../../app/utils/throwGlobalError';
import { withRouter } from '../../../components/hoc/withRouter';
import { parseIssueFromResponse } from '../../../helpers/issues';
-import { receiveOrganizations } from '../../../store/organizations';
import { fetchBranchStatus } from '../../../store/rootActions';
-import {
- areThereCustomOrganizations,
- getCurrentUser,
- getMyOrganizations,
- Store
-} from '../../../store/rootReducer';
+import { getCurrentUser, Store } from '../../../store/rootReducer';
+import { FetchIssuesPromise } from '../../../types/issues';
const IssuesAppContainer = lazyLoadComponent(() => import('./App'), 'IssuesAppContainer');
interface StateProps {
currentUser: T.CurrentUser;
- userOrganizations: T.Organization[];
+ fetchIssues: (query: T.RawQuery) => Promise<FetchIssuesPromise>;
}
const mapStateToProps = (state: Store): StateProps => ({
currentUser: getCurrentUser(state),
- userOrganizations: getMyOrganizations(state)
+ fetchIssues
});
-const fetchIssueOrganizations = (organizationKeys: string[]) => (dispatch: Dispatch) => {
- if (!organizationKeys.length) {
- return Promise.resolve();
- }
-
- return getOrganizations({ organizations: organizationKeys.join() }).then(
- response => dispatch(receiveOrganizations(response.organizations)),
- throwGlobalError
- );
-};
-
-const fetchIssues = (query: T.RawQuery, requestOrganizations = true) => (
- // use `Function` to be able to do `dispatch(...).then(...)`
- dispatch: Function,
- getState: () => Store
-) => {
- const organizationsEnabled = areThereCustomOrganizations(getState());
+const fetchIssues = (query: T.RawQuery) => {
return searchIssues({
...query,
additionalFields: '_all',
@@ -75,22 +51,12 @@ const fetchIssues = (query: T.RawQuery, requestOrganizations = true) => (
);
return { ...response, issues: parsedIssues };
})
- .then(response => {
- const organizationKeys = uniq([
- ...response.issues.map(issue => issue.organization),
- ...(response.components || []).map(component => component.organization)
- ]);
- return organizationsEnabled && requestOrganizations
- ? dispatch(fetchIssueOrganizations(organizationKeys)).then(() => response)
- : response;
- })
.catch(throwGlobalError);
};
// have to type cast this, because of async action
const mapDispatchToProps = {
- fetchBranchStatus: fetchBranchStatus as any,
- fetchIssues: fetchIssues as any
+ fetchBranchStatus: fetchBranchStatus as any
};
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(IssuesAppContainer));
diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx
index a5c94c651a6..3bcb1606ebf 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx
@@ -56,7 +56,6 @@ interface Props {
fetchIssues: (x: {}) => Promise<{ issues: T.Issue[]; paging: T.Paging }>;
onClose: () => void;
onDone: () => void;
- organization: { key: string } | undefined;
}
interface FormFields {
@@ -64,7 +63,6 @@ interface FormFields {
assignee?: AssigneeOption;
comment?: string;
notifications?: boolean;
- organization?: string;
removeTags?: Array<{ label: string; value: string }>;
severity?: string;
transition?: string;
@@ -94,20 +92,13 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
- let organization = props.component && props.component.organization;
- if (props.organization && !organization) {
- organization = props.organization.key;
- }
- this.state = { initialTags: [], issues: [], loading: true, submitting: false, organization };
+ this.state = { initialTags: [], issues: [], loading: true, submitting: false };
}
componentDidMount() {
this.mounted = true;
- Promise.all([
- this.loadIssues(),
- searchIssueTags({ organization: this.state.organization })
- ]).then(
+ Promise.all([this.loadIssues(), searchIssueTags({})]).then(
([{ issues, paging }, tags]) => {
if (this.mounted) {
if (issues.length > MAX_PAGE_SIZE) {
@@ -178,7 +169,7 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> {
};
handleTagsSearch = (query: string) => {
- return searchIssueTags({ organization: this.state.organization, q: query }).then(tags =>
+ return searchIssueTags({ q: query }).then(tags =>
tags.map(tag => ({ label: tag, value: tag }))
);
};
diff --git a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
index 0b0cfdc2cd0..8cde7b93c53 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/ComponentBreadcrumbs.tsx
@@ -20,26 +20,12 @@
import * as React from 'react';
import QualifierIcon from 'sonar-ui-common/components/icons/QualifierIcon';
import { collapsePath, limitComponentName } from 'sonar-ui-common/helpers/path';
-import Organization from '../../../components/shared/Organization';
import { getSelectedLocation } from '../utils';
interface Props {
component?: T.Component;
- issue: Pick<
- T.Issue,
- | 'component'
- | 'componentLongName'
- | 'componentQualifier'
- | 'flows'
- | 'organization'
- | 'project'
- | 'projectName'
- | 'secondaryLocations'
- | 'subProject'
- | 'subProjectName'
- >;
+ issue: T.Issue;
link?: boolean;
- organization: { key: string } | undefined;
selectedFlowIndex?: number;
selectedLocationIndex?: number;
}
@@ -47,12 +33,9 @@ interface Props {
export default function ComponentBreadcrumbs({
component,
issue,
- organization,
selectedFlowIndex,
selectedLocationIndex
}: Props) {
- const displayOrganization =
- !organization && (!component || ['VW', 'SVW'].includes(component.qualifier));
const displayProject = !component || !['TRK', 'BRC', 'DIR'].includes(component.qualifier);
const displaySubProject = !component || !['BRC', 'DIR'].includes(component.qualifier);
@@ -63,8 +46,6 @@ export default function ComponentBreadcrumbs({
<div className="component-name text-ellipsis">
<QualifierIcon className="spacer-right" qualifier={issue.componentQualifier} />
- {displayOrganization && <Organization link={false} organizationKey={issue.organization} />}
-
{displayProject && (
<span title={issue.projectName}>
{limitComponentName(issue.projectName)}
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
index d16a1585e34..cd35d9e3328 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesList.tsx
@@ -33,7 +33,6 @@ interface Props {
onIssueClick: (issueKey: string) => void;
onPopupToggle: (issue: string, popupName: string, open?: boolean) => void;
openPopup: { issue: string; name: string } | undefined;
- organization: { key: string } | undefined;
selectedIssue: T.Issue | undefined;
}
@@ -85,7 +84,6 @@ export default class IssuesList extends React.PureComponent<Props, State> {
onFilterChange={this.props.onFilterChange}
onPopupToggle={this.props.onPopupToggle}
openPopup={openPopup && openPopup.issue === issue.key ? openPopup.name : undefined}
- organization={this.props.organization}
previousIssue={index > 0 ? issues[index - 1] : undefined}
selected={selectedIssue != null && selectedIssue.key === issue.key}
/>
diff --git a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
index 780d2bda72f..0d2ea282495 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx
@@ -34,7 +34,6 @@ interface Props {
onFilterChange: (changes: Partial<Query>) => void;
onPopupToggle: (issue: string, popupName: string, open?: boolean) => void;
openPopup: string | undefined;
- organization: { key: string } | undefined;
previousIssue: T.Issue | undefined;
selected: boolean;
}
@@ -99,11 +98,7 @@ export default class ListItem extends React.PureComponent<Props> {
<div className="issues-workspace-list-item">
{displayComponent && (
<div className="issues-workspace-list-component note">
- <ComponentBreadcrumbs
- component={component}
- issue={this.props.issue}
- organization={this.props.organization}
- />
+ <ComponentBreadcrumbs component={component} issue={this.props.issue} />
</div>
)}
<Issue
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
index 7f639106c24..11d1ab3c705 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx
@@ -71,7 +71,7 @@ const ISSUES = [
const FACETS = [{ property: 'severities', values: [{ val: 'MINOR', count: 4 }] }];
const PAGING = { pageIndex: 1, pageSize: 100, total: 4 };
-const referencedComponent = { key: 'foo-key', name: 'bar', organization: 'John', uuid: 'foo-uuid' };
+const referencedComponent = { key: 'foo-key', name: 'bar', uuid: 'foo-uuid' };
it('should render a list of issue', async () => {
const wrapper = shallowRender();
@@ -393,13 +393,12 @@ it('should handle createAfter query param with time', async () => {
wrapper.instance().fetchIssues({});
expect(fetchIssues).toBeCalledWith(
- expect.objectContaining({ createdAfter: '2020-10-21T17:21:00+0000' }),
- false
+ expect.objectContaining({ createdAfter: '2020-10-21T17:21:00+0000' })
);
});
function fetchIssuesMockFactory(keyCount = 0, lineCount = 1) {
- return jest.fn().mockImplementation(({ p }: any) =>
+ return jest.fn().mockImplementation(({ p }: { p: number }) =>
Promise.resolve({
components: [referencedComponent],
effortTotal: 1,
@@ -439,7 +438,6 @@ function shallowRender(props: Partial<App['props']> = {}) {
breadcrumbs: [],
key: 'foo',
name: 'bar',
- organization: 'John',
qualifier: 'Doe'
}}
currentUser={mockLoggedInUser()}
@@ -456,9 +454,7 @@ function shallowRender(props: Partial<App['props']> = {}) {
})}
location={mockLocation({ pathname: '/issues', query: {} })}
onBranchesChange={() => {}}
- organization={{ key: 'foo' }}
router={mockRouter()}
- userOrganizations={[]}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx
index 9fb4eb8d9b7..21c9b4dd256 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/BulkChangeModal-test.tsx
@@ -20,15 +20,16 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { searchIssueTags } from '../../../../api/issues';
import { mockIssue } from '../../../../helpers/testMocks';
import BulkChangeModal, { MAX_PAGE_SIZE } from '../BulkChangeModal';
jest.mock('../../../../api/issues', () => ({
- searchIssueTags: () => Promise.resolve([undefined, []])
+ searchIssueTags: jest.fn().mockResolvedValue([undefined, []])
}));
jest.mock('../BulkChangeModal', () => {
- const mock = require.requireActual('../BulkChangeModal');
+ const mock = jest.requireActual('../BulkChangeModal');
mock.MAX_PAGE_SIZE = 1;
return mock;
});
@@ -92,6 +93,12 @@ it('should properly handle the search for assignee', async () => {
expect(result).toMatchSnapshot();
});
+it('should properly handle the search for tags', async () => {
+ const wrapper = getWrapper([]);
+ await wrapper.instance().handleTagsSearch('query');
+ expect(searchIssueTags).toBeCalled();
+});
+
const getWrapper = (issues: T.Issue[]) => {
return shallow<BulkChangeModal>(
<BulkChangeModal
@@ -109,7 +116,6 @@ const getWrapper = (issues: T.Issue[]) => {
}
onClose={() => {}}
onDone={() => {}}
- organization={undefined}
/>
);
};
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/ComponentBreadcrumbs-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/ComponentBreadcrumbs-test.tsx
index 0b2dd2ca53f..5776b81b648 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/ComponentBreadcrumbs-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/ComponentBreadcrumbs-test.tsx
@@ -19,31 +19,25 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
+import { mockIssue } from '../../../../helpers/testMocks';
import { ComponentQualifier } from '../../../../types/component';
import ComponentBreadcrumbs from '../ComponentBreadcrumbs';
-const baseIssue = {
+const baseIssue = mockIssue(false, {
component: 'comp',
componentLongName: 'comp-name',
componentQualifier: ComponentQualifier.File,
- flows: [],
- organization: 'org',
project: 'proj',
- projectName: 'proj-name',
- secondaryLocations: []
-};
+ projectName: 'proj-name'
+});
it('renders', () => {
expect(
- shallow(
- <ComponentBreadcrumbs component={undefined} issue={baseIssue} organization={undefined} />
- )
+ shallow(<ComponentBreadcrumbs component={undefined} issue={baseIssue} />)
).toMatchSnapshot();
});
it('renders with sub-project', () => {
const issue = { ...baseIssue, subProject: 'sub-proj', subProjectName: 'sub-proj-name' };
- expect(
- shallow(<ComponentBreadcrumbs component={undefined} issue={issue} organization={undefined} />)
- ).toMatchSnapshot();
+ expect(shallow(<ComponentBreadcrumbs component={undefined} issue={issue} />)).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesList-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesList-test.tsx
index 87e6fd84be0..292d143000d 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesList-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesList-test.tsx
@@ -46,7 +46,6 @@ function shallowRender(overrides: Partial<IssuesList['props']> = {}) {
onIssueClick={jest.fn()}
onPopupToggle={jest.fn()}
openPopup={undefined}
- organization={undefined}
selectedIssue={undefined}
{...overrides}
/>
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap
index 46e089390d2..51d877ba775 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap
@@ -103,7 +103,6 @@ exports[`should switch to source view if an issue is selected 1`] = `
"breadcrumbs": Array [],
"key": "foo",
"name": "bar",
- "organization": "John",
"qualifier": "Doe",
}
}
@@ -121,11 +120,9 @@ exports[`should switch to source view if an issue is selected 1`] = `
"key": "foo",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -152,11 +149,9 @@ exports[`should switch to source view if an issue is selected 1`] = `
"key": "bar",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -233,11 +228,9 @@ exports[`should switch to source view if an issue is selected 1`] = `
"key": "third",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
@@ -283,11 +276,9 @@ exports[`should switch to source view if an issue is selected 1`] = `
"key": "fourth",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -309,11 +300,6 @@ exports[`should switch to source view if an issue is selected 1`] = `
onIssueCheck={[Function]}
onIssueClick={[Function]}
onPopupToggle={[Function]}
- organization={
- Object {
- "key": "foo",
- }
- }
selectedIssue={
Object {
"actions": Array [],
@@ -327,11 +313,9 @@ exports[`should switch to source view if an issue is selected 1`] = `
"key": "foo",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -403,11 +387,9 @@ exports[`should switch to source view if an issue is selected 2`] = `
"key": "foo",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -434,11 +416,9 @@ exports[`should switch to source view if an issue is selected 2`] = `
"key": "bar",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -515,11 +495,9 @@ exports[`should switch to source view if an issue is selected 2`] = `
"key": "third",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
@@ -565,11 +543,9 @@ exports[`should switch to source view if an issue is selected 2`] = `
"key": "fourth",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -654,11 +630,9 @@ exports[`should switch to source view if an issue is selected 2`] = `
"key": "third",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/ComponentBreadcrumbs-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/ComponentBreadcrumbs-test.tsx.snap
index 33e198ab34e..bc18b11ab3a 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/ComponentBreadcrumbs-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/ComponentBreadcrumbs-test.tsx.snap
@@ -8,10 +8,6 @@ exports[`renders 1`] = `
className="spacer-right"
qualifier="FIL"
/>
- <Connect(Organization)
- link={false}
- organizationKey="org"
- />
<span
title="proj-name"
>
@@ -36,10 +32,6 @@ exports[`renders with sub-project 1`] = `
className="spacer-right"
qualifier="FIL"
/>
- <Connect(Organization)
- link={false}
- organizationKey="org"
- />
<span
title="proj-name"
>
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesList-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesList-test.tsx.snap
index c7a30dd2379..975eb1fe1cf 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesList-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesList-test.tsx.snap
@@ -25,11 +25,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -68,11 +66,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN3",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -107,11 +103,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap
index a0bd5ab199c..fe59402ddfe 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/IssuesSourceViewer-test.tsx.snap
@@ -77,11 +77,9 @@ exports[`should render CrossComponentSourceViewer correctly 1`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
@@ -180,11 +178,9 @@ exports[`should render CrossComponentSourceViewer correctly 1`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx
index c9a124f9661..b1e7934034a 100644
--- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssue-test.tsx
@@ -32,11 +32,9 @@ const issue: T.Issue = {
fromHotspot: false,
key: '',
message: '',
- organization: '',
project: '',
projectKey: '',
projectName: '',
- projectOrganization: '',
rule: '',
ruleName: '',
secondaryLocations: [],
diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap
index 002ac690399..67deeb639ef 100644
--- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssue-test.tsx.snap
@@ -18,11 +18,9 @@ exports[`should render 1`] = `
"fromHotspot": false,
"key": "",
"message": "",
- "organization": "",
"project": "",
"projectKey": "",
"projectName": "",
- "projectOrganization": "",
"rule": "",
"ruleName": "",
"secondaryLocations": Array [],
diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap
index 4acba10db82..4eb63a1a28c 100644
--- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap
@@ -33,11 +33,9 @@ exports[`should render correctly 1`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -71,11 +69,9 @@ exports[`should render correctly 1`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -110,11 +106,9 @@ exports[`should render correctly 1`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -217,11 +211,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
@@ -324,11 +316,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
@@ -432,11 +422,9 @@ exports[`should render correctly 2`] = `
"key": "AVsae-CQS-9G3txfbFN2",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueLocationsNavigator-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueLocationsNavigator-test.tsx.snap
index d90ab990817..0434816e9e4 100644
--- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueLocationsNavigator-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueLocationsNavigator-test.tsx.snap
@@ -40,11 +40,9 @@ exports[`should render flow locations in different file 1`] = `
"key": "",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
@@ -211,11 +209,9 @@ exports[`should render taint analysis issues correctly 1`] = `
"key": "",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [],
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap
index 277d63d0309..06624417ee0 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/__snapshots__/CrossComponentSourceViewerWrapper-test.tsx.snap
@@ -111,11 +111,9 @@ exports[`should render correctly 2`] = `
"key": "1",
"line": 25,
"message": "Reduce the number of conditional operators (4) used in the expression",
- "organization": "myorg",
"project": "myproject",
"projectKey": "foo",
"projectName": "Foo",
- "projectOrganization": "org",
"rule": "javascript:S1067",
"ruleName": "foo",
"secondaryLocations": Array [
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx
index ee703c4f321..9a507b0e40e 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AssigneeFacet.tsx
@@ -24,7 +24,8 @@ import { highlightTerm } from 'sonar-ui-common/helpers/search';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
import Avatar from '../../../components/ui/Avatar';
import { isUserActive } from '../../../helpers/users';
-import { Facet, Query, searchAssignees } from '../utils';
+import { Facet } from '../../../types/issues';
+import { Query, searchAssignees } from '../utils';
interface Props {
assigned: boolean;
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx
index 96590327447..540e77a8817 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx
@@ -23,7 +23,8 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
import { highlightTerm } from 'sonar-ui-common/helpers/search';
import { searchIssueAuthors } from '../../../api/issues';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
-import { Facet, Query } from '../utils';
+import { Facet } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
component: T.Component | undefined;
@@ -32,7 +33,6 @@ interface Props {
onChange: (changes: Partial<Query>) => void;
onToggle: (property: string) => void;
open: boolean;
- organization: string | undefined;
query: Query;
stats: T.Dict<number> | undefined;
authors: string[];
@@ -50,7 +50,6 @@ export default class AuthorFacet extends React.PureComponent<Props> {
const project =
component && ['TRK', 'VW', 'APP'].includes(component.qualifier) ? component.key : undefined;
return searchIssueAuthors({
- organization: this.props.organization,
project,
ps: SEARCH_SIZE, // maximum
q: query
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx
index d00d2b91ae5..122050d76ce 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/DirectoryFacet.tsx
@@ -28,7 +28,8 @@ import ListStyleFacet from '../../../components/facet/ListStyleFacet';
import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { BranchLike } from '../../../types/branch-like';
import { TreeComponentWithPath } from '../../../types/component';
-import { Facet, Query } from '../utils';
+import { Facet } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
branchLike?: BranchLike;
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx
index cd6a0f1dee3..c37fcbd731e 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/FileFacet.tsx
@@ -29,7 +29,8 @@ import ListStyleFacet from '../../../components/facet/ListStyleFacet';
import { getBranchLikeQuery } from '../../../helpers/branch-like';
import { BranchLike } from '../../../types/branch-like';
import { TreeComponentWithPath } from '../../../types/component';
-import { Facet, Query } from '../utils';
+import { Facet } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
branchLike?: BranchLike;
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
index f9b6206999a..72e0332fa52 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
@@ -24,7 +24,8 @@ import { translate } from 'sonar-ui-common/helpers/l10n';
import { highlightTerm } from 'sonar-ui-common/helpers/search';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
import { getLanguages, Store } from '../../../store/rootReducer';
-import { Facet, Query, ReferencedLanguage } from '../utils';
+import { Facet, ReferencedLanguage } from '../../../types/issues';
+import { Query } from '../utils';
interface InstalledLanguage {
key: string;
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx
index de55ac147b3..3bb0ca3ab87 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/ProjectFacet.tsx
@@ -25,7 +25,8 @@ import { highlightTerm } from 'sonar-ui-common/helpers/search';
import { getTree, searchProjects } from '../../../api/components';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
import { ComponentQualifier } from '../../../types/component';
-import { Facet, Query, ReferencedComponent } from '../utils';
+import { Facet, ReferencedComponent } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
component: T.Component | undefined;
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx
index 5d078cba546..4f0d2d1148a 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/RuleFacet.tsx
@@ -22,7 +22,8 @@ import * as React from 'react';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { searchRules } from '../../../api/rules';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
-import { Facet, Query, ReferencedRule } from '../utils';
+import { Facet, ReferencedRule } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
fetching: boolean;
@@ -31,7 +32,6 @@ interface Props {
onChange: (changes: Partial<Query>) => void;
onToggle: (property: string) => void;
open: boolean;
- organization: string | undefined;
query: Query;
referencedRules: T.Dict<ReferencedRule>;
rules: string[];
@@ -40,11 +40,10 @@ interface Props {
export default class RuleFacet extends React.PureComponent<Props> {
handleSearch = (query: string, page = 1) => {
- const { languages, organization } = this.props;
+ const { languages } = this.props;
return searchRules({
f: 'name,langName',
languages: languages.length ? languages.join() : undefined,
- organization,
q: query,
p: page,
ps: 30,
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
index 7442fad4ca2..6797d3fb828 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
@@ -22,7 +22,13 @@ import { connect } from 'react-redux';
import { getGlobalSettingValue, Store } from '../../../store/rootReducer';
import { BranchLike } from '../../../types/branch-like';
import { ComponentQualifier } from '../../../types/component';
-import { Facet, Query, ReferencedComponent, ReferencedLanguage, ReferencedRule } from '../utils';
+import {
+ Facet,
+ ReferencedComponent,
+ ReferencedLanguage,
+ ReferencedRule
+} from '../../../types/issues';
+import { Query } from '../utils';
import AssigneeFacet from './AssigneeFacet';
import AuthorFacet from './AuthorFacet';
import CreationDateFacet from './CreationDateFacet';
@@ -44,14 +50,12 @@ export interface Props {
component: T.Component | undefined;
createdAfterIncludesTime: boolean;
facets: T.Dict<Facet | undefined>;
- hideAuthorFacet?: boolean;
loadSearchResultCount: (property: string, changes: Partial<Query>) => Promise<Facet>;
loadingFacets: T.Dict<boolean>;
myIssues: boolean;
onFacetToggle: (property: string) => void;
onFilterChange: (changes: Partial<Query>) => void;
openFacets: T.Dict<boolean>;
- organization: { key: string } | undefined;
query: Query;
referencedComponentsById: T.Dict<ReferencedComponent>;
referencedComponentsByKey: T.Dict<ReferencedComponent>;
@@ -99,22 +103,11 @@ export class Sidebar extends React.PureComponent<Props> {
}
render() {
- const {
- component,
- createdAfterIncludesTime,
- facets,
- hideAuthorFacet,
- openFacets,
- query
- } = this.props;
+ const { component, createdAfterIncludesTime, facets, openFacets, query } = this.props;
const displayProjectsFacet =
!component || !['TRK', 'BRC', 'DIR', 'DEV_PRJ'].includes(component.qualifier);
- const displayAuthorFacet = !hideAuthorFacet && (!component || component.qualifier !== 'DEV');
-
- const organizationKey =
- (component && component.organization) ||
- (this.props.organization && this.props.organization.key);
+ const displayAuthorFacet = !component || component.qualifier !== 'DEV';
return (
<>
@@ -214,7 +207,6 @@ export class Sidebar extends React.PureComponent<Props> {
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.rules}
- organization={organizationKey}
query={query}
referencedRules={this.props.referencedRules}
rules={query.rules}
@@ -227,7 +219,6 @@ export class Sidebar extends React.PureComponent<Props> {
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.tags}
- organization={organizationKey}
query={query}
stats={facets.tags}
tags={query.tags}
@@ -270,7 +261,6 @@ export class Sidebar extends React.PureComponent<Props> {
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
open={!!openFacets.authors}
- organization={organizationKey}
query={query}
stats={facets.authors}
/>
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx
index 541989aabf1..9657291c3d7 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StandardFacet.tsx
@@ -34,8 +34,9 @@ import {
renderSansTop25Category,
renderSonarSourceSecurityCategory
} from '../../../helpers/security-standard';
+import { Facet } from '../../../types/issues';
import { SecurityStandard, Standards, StandardType } from '../../../types/security';
-import { Facet, formatFacetStat, Query, STANDARDS } from '../utils';
+import { formatFacetStat, Query, STANDARDS } from '../utils';
interface Props {
cwe: string[];
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx
index a80b8af5154..16d6b93fa0a 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/TagFacet.tsx
@@ -25,7 +25,8 @@ import { highlightTerm } from 'sonar-ui-common/helpers/search';
import { searchIssueTags } from '../../../api/issues';
import { colors } from '../../../app/theme';
import ListStyleFacet from '../../../components/facet/ListStyleFacet';
-import { Facet, Query } from '../utils';
+import { Facet } from '../../../types/issues';
+import { Query } from '../utils';
interface Props {
component: T.Component | undefined;
@@ -34,7 +35,6 @@ interface Props {
onChange: (changes: Partial<Query>) => void;
onToggle: (property: string) => void;
open: boolean;
- organization: string | undefined;
query: Query;
stats: T.Dict<number> | undefined;
tags: string[];
@@ -48,7 +48,6 @@ export default class TagFacet extends React.PureComponent<Props> {
const project =
component && ['TRK', 'VW', 'APP'].includes(component.qualifier) ? component.key : undefined;
return searchIssueTags({
- organization: this.props.organization,
project,
ps: SEARCH_SIZE,
q: query
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/ProjectFacet-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/ProjectFacet-test.tsx
index bead8220531..4267fac4043 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/ProjectFacet-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/ProjectFacet-test.tsx
@@ -23,7 +23,8 @@ import * as React from 'react';
import { getTree, searchProjects } from '../../../../api/components';
import { mockComponent } from '../../../../helpers/testMocks';
import { ComponentQualifier } from '../../../../types/component';
-import { Query, ReferencedComponent } from '../../utils';
+import { ReferencedComponent } from '../../../../types/issues';
+import { Query } from '../../utils';
import ProjectFacet from '../ProjectFacet';
jest.mock('../../../../api/components', () => ({
@@ -31,7 +32,6 @@ jest.mock('../../../../api/components', () => ({
searchProjects: jest.fn().mockResolvedValue({
components: [],
facets: [],
- organizations: [],
paging: {}
})
}));
@@ -77,8 +77,8 @@ it('should handle search for projects in portfolio', async () => {
describe("ListStyleFacet's renderers", () => {
const components: ReferencedComponent[] = [
- { key: 'projectKey', name: 'First Project Name', organization: '', uuid: '141324' },
- { key: 'projectKey2', name: 'Second Project Name', organization: '', uuid: '643878' }
+ { key: 'projectKey', name: 'First Project Name', uuid: '141324' },
+ { key: 'projectKey2', name: 'Second Project Name', uuid: '643878' }
];
const referencedComponents = keyBy(components, c => c.key);
const wrapper = shallowRender({ referencedComponents });
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/RuleFacet-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/RuleFacet-test.tsx
new file mode 100644
index 00000000000..67f0c5835f6
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/RuleFacet-test.tsx
@@ -0,0 +1,80 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import { shallow } from 'enzyme';
+import * as React from 'react';
+import { searchRules } from '../../../../api/rules';
+import { mockReferencedRule } from '../../../../helpers/mocks/issues';
+import { mockRule } from '../../../../helpers/testMocks';
+import { Query } from '../../utils';
+import RuleFacet from '../RuleFacet';
+
+jest.mock('../../../../api/rules', () => ({
+ searchRules: jest.fn().mockResolvedValue({})
+}));
+
+it('should render correctly', () => {
+ expect(shallowRender()).toMatchSnapshot();
+});
+
+it('should handle search', async () => {
+ const wrapper = shallowRender();
+
+ const query = 'query';
+
+ await wrapper.instance().handleSearch(query);
+
+ expect(searchRules).toBeCalledWith(expect.objectContaining({ languages: 'js,java', q: query }));
+});
+
+describe('ListStyleFacet Renderers', () => {
+ const referencedRules = { r1: mockReferencedRule() };
+ const instance = shallowRender({ referencedRules }).instance();
+
+ it('should include renderFacetItem', () => {
+ const rule = referencedRules.r1;
+ expect(instance.getRuleName('r1')).toBe(`(${rule.langName}) ${rule.name}`);
+ expect(instance.getRuleName('nonexistent')).toBe('nonexistent');
+ });
+
+ it('should include renderSearchResult', () => {
+ const rule = mockRule();
+ expect(instance.renderSearchResult(rule)).toBe(`(${rule.langName}) ${rule.name}`);
+ expect(instance.renderSearchResult(mockRule({ langName: '' }))).toBe(rule.name);
+ });
+});
+
+function shallowRender(props: Partial<RuleFacet['props']> = {}) {
+ return shallow<RuleFacet>(
+ <RuleFacet
+ fetching={true}
+ languages={['js', 'java']}
+ loadSearchResultCount={jest.fn()}
+ onChange={jest.fn()}
+ onToggle={jest.fn()}
+ open={false}
+ query={{} as Query}
+ referencedRules={{}}
+ rules={['r1']}
+ stats={{}}
+ {...props}
+ />
+ );
+}
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx
index a72ba4cb645..a74b9ba7238 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-test.tsx
@@ -85,7 +85,6 @@ const renderSidebar = (props?: Partial<Sidebar['props']>) => {
onFacetToggle={jest.fn()}
onFilterChange={jest.fn()}
openFacets={{}}
- organization={undefined}
query={{ types: [''] } as Query}
referencedComponentsById={{}}
referencedComponentsByKey={{}}
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/RuleFacet-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/RuleFacet-test.tsx.snap
new file mode 100644
index 00000000000..bfbc8e0c0e7
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/RuleFacet-test.tsx.snap
@@ -0,0 +1,30 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<ListStyleFacet
+ facetHeader="issues.facet.rules"
+ fetching={true}
+ getFacetItemText={[Function]}
+ getSearchResultKey={[Function]}
+ getSearchResultText={[Function]}
+ loadSearchResultCount={[Function]}
+ maxInitialItems={15}
+ maxItems={100}
+ minSearchLength={2}
+ onChange={[MockFunction]}
+ onSearch={[Function]}
+ onToggle={[MockFunction]}
+ open={false}
+ property="rules"
+ query={Object {}}
+ renderFacetItem={[Function]}
+ renderSearchResult={[Function]}
+ searchPlaceholder="search.search_for_rules"
+ stats={Object {}}
+ values={
+ Array [
+ "r1",
+ ]
+ }
+/>
+`;
diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts
index a75278626fe..0e112d06186 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.ts
+++ b/server/sonar-web/src/main/js/apps/issues/utils.ts
@@ -32,6 +32,7 @@ import {
import { scrollToElement } from 'sonar-ui-common/helpers/scrolling';
import { get, save } from 'sonar-ui-common/helpers/storage';
import { searchUsers } from '../../api/users';
+import { Facet, RawFacet } from '../../types/issues';
import { SecurityStandard, StandardType } from '../../types/security';
export interface Query {
@@ -150,15 +151,6 @@ export function serializeQuery(query: Query): T.RawQuery {
export const areQueriesEqual = (a: T.RawQuery, b: T.RawQuery) =>
queriesEqual(parseQuery(a), parseQuery(b));
-export interface RawFacet {
- property: string;
- values: Array<{ val: string; count: number }>;
-}
-
-export interface Facet {
- [value: string]: number;
-}
-
export function mapFacet(facet: string) {
const propertyMapping: T.Dict<string> = {
modules: 'moduleUuids'
@@ -192,23 +184,6 @@ export function formatFacetStat(stat: number | undefined) {
return stat && formatMeasure(stat, 'SHORT_INT');
}
-export interface ReferencedComponent {
- key: string;
- name: string;
- organization: string;
- path?: string;
- uuid: string;
-}
-
-export interface ReferencedLanguage {
- name: string;
-}
-
-export interface ReferencedRule {
- langName?: string;
- name: string;
-}
-
export const searchAssignees = (
query: string,
page = 1