aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2021-08-26 16:24:36 +0200
committersonartech <sonartech@sonarsource.com>2021-08-26 20:04:29 +0000
commit680aed78d5a58249ae56ca36b5f495bb579bce1a (patch)
treef0e4b70fdbf7019d8c1e50c0910f6403d60444ae /server/sonar-web
parent5e216710672e237ce18e43c0c8fe82faacaacd3b (diff)
downloadsonarqube-680aed78d5a58249ae56ca36b5f495bb579bce1a.tar.gz
sonarqube-680aed78d5a58249ae56ca36b5f495bb579bce1a.zip
SONAR-15313 drop endpoints from WebAPI deprecated since 7.X
Co-authored-by: Lukasz Jarocki <lukasz.jarocki@sonarsource.com> Co-authored-by: Philippe Perrin <philippe.perrin@sonarsource.com> Co-authored-by: MikeBirnstiehl <michael.birnstiehl@sonarsource.com>
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/api/issues.ts3
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/App.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/ListItem.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/AuthorFacet.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/AuthorFacet-test.tsx58
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/AuthorFacet-test.tsx.snap26
-rw-r--r--server/sonar-web/src/main/js/apps/issues/utils.ts27
-rw-r--r--server/sonar-web/src/main/js/types/types.d.ts1
9 files changed, 104 insertions, 42 deletions
diff --git a/server/sonar-web/src/main/js/api/issues.ts b/server/sonar-web/src/main/js/api/issues.ts
index b590509351d..f1c5ff3b74b 100644
--- a/server/sonar-web/src/main/js/api/issues.ts
+++ b/server/sonar-web/src/main/js/api/issues.ts
@@ -25,13 +25,12 @@ import { IssueResponse, RawIssuesResponse } from '../types/issues';
type FacetName =
| 'assigned_to_me'
| 'assignees'
- | 'authors'
+ | 'author'
| 'createdAt'
| 'cwe'
| 'directories'
| 'files'
| 'languages'
- | 'modules'
| 'owaspTop10'
| 'projects'
| 'reporters'
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 a3d1cae7da1..376072c762a 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
@@ -68,7 +68,6 @@ import {
areMyIssuesSelected,
areQueriesEqual,
getOpen,
- mapFacet,
parseFacets,
parseQuery,
Query,
@@ -408,7 +407,6 @@ export default class App extends React.PureComponent<Props, State> {
const facets = requestFacets
? Object.keys(openFacets)
.filter(facet => facet !== STANDARDS)
- .map(mapFacet)
.join(',')
: undefined;
@@ -590,7 +588,7 @@ export default class App extends React.PureComponent<Props, State> {
};
fetchFacet = (facet: string) => {
- return this.fetchIssues({ ps: 1, facets: mapFacet(facet) }, false).then(
+ return this.fetchIssues({ ps: 1, facets: facet }, false).then(
({ facets, ...other }) => {
if (this.mounted) {
this.setState(state => ({
@@ -689,7 +687,7 @@ export default class App extends React.PureComponent<Props, State> {
const parameters = {
...getBranchLikeQuery(this.props.branchLike),
componentKeys: component && component.key,
- facets: mapFacet(property),
+ facets: property,
s: 'FILE_LINE',
...serializeQuery({ ...query, ...changes }),
ps: 1
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 ec7b2fb4397..1115f06c456 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
@@ -78,11 +78,6 @@ export default class ListItem extends React.PureComponent<Props> {
case 'project':
onFilterChange({ ...issuesReset, projects: [issue.projectKey] });
break;
- case 'module':
- if (issue.subProjectUuid) {
- onFilterChange({ ...issuesReset, modules: [issue.subProjectUuid] });
- }
- break;
case 'file':
onFilterChange({ ...issuesReset, files: [issue.componentUuid] });
}
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 465395d1b79..2dd7db0f760 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
@@ -35,7 +35,7 @@ interface Props {
open: boolean;
query: Query;
stats: T.Dict<number> | undefined;
- authors: string[];
+ author: string[];
}
const SEARCH_SIZE = 100;
@@ -56,8 +56,8 @@ export default class AuthorFacet extends React.PureComponent<Props> {
}).then(authors => ({ maxResults: authors.length === SEARCH_SIZE, results: authors }));
};
- loadSearchResultCount = (authors: string[]) => {
- return this.props.loadSearchResultCount('authors', { authors });
+ loadSearchResultCount = (author: string[]) => {
+ return this.props.loadSearchResultCount('author', { author });
};
renderSearchResult = (author: string, term: string) => {
@@ -77,13 +77,13 @@ export default class AuthorFacet extends React.PureComponent<Props> {
onSearch={this.handleSearch}
onToggle={this.props.onToggle}
open={this.props.open}
- property="authors"
- query={omit(this.props.query, 'authors')}
+ property="author"
+ query={omit(this.props.query, 'author')}
renderFacetItem={this.identity}
renderSearchResult={this.renderSearchResult}
searchPlaceholder={translate('search.search_for_authors')}
stats={this.props.stats}
- values={this.props.authors}
+ values={this.props.author}
/>
);
}
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 9a3fb12ed75..51cfb8fea75 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
@@ -256,15 +256,15 @@ export class Sidebar extends React.PureComponent<Props> {
)}
{displayAuthorFacet && !this.props.disableDeveloperAggregatedInfo && (
<AuthorFacet
- authors={query.authors}
+ author={query.author}
component={component}
- fetching={this.props.loadingFacets.authors === true}
+ fetching={this.props.loadingFacets.author === true}
loadSearchResultCount={this.props.loadSearchResultCount}
onChange={this.props.onFilterChange}
onToggle={this.props.onFacetToggle}
- open={!!openFacets.authors}
+ open={!!openFacets.author}
query={query}
- stats={facets.authors}
+ stats={facets.author}
/>
)}
</>
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/AuthorFacet-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/AuthorFacet-test.tsx
new file mode 100644
index 00000000000..336182e6a29
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/AuthorFacet-test.tsx
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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 ListStyleFacet from '../../../../components/facet/ListStyleFacet';
+import { mockComponent } from '../../../../helpers/testMocks';
+import { Query } from '../../utils';
+import AuthorFacet from '../AuthorFacet';
+
+it('should render correctly', () => {
+ const wrapper = shallowRender();
+ expect(wrapper).toMatchSnapshot();
+});
+
+it('should notify of search result count correctly', () => {
+ const loadSearchResultCount = jest.fn();
+
+ const wrapper = shallowRender({ loadSearchResultCount });
+
+ wrapper.find(ListStyleFacet).props().loadSearchResultCount!(['1', '2']);
+
+ expect(loadSearchResultCount).toHaveBeenCalled();
+});
+
+function shallowRender(props: Partial<AuthorFacet['props']> = {}) {
+ return shallow<AuthorFacet>(
+ <AuthorFacet
+ component={mockComponent()}
+ fetching={false}
+ loadSearchResultCount={jest.fn()}
+ onChange={jest.fn()}
+ onToggle={jest.fn()}
+ open={true}
+ query={{} as Query}
+ stats={{}}
+ author={[]}
+ {...props}
+ />
+ );
+}
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/AuthorFacet-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/AuthorFacet-test.tsx.snap
new file mode 100644
index 00000000000..82c0a7d2538
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/AuthorFacet-test.tsx.snap
@@ -0,0 +1,26 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<ListStyleFacet
+ facetHeader="issues.facet.authors"
+ fetching={false}
+ getFacetItemText={[Function]}
+ getSearchResultKey={[Function]}
+ getSearchResultText={[Function]}
+ loadSearchResultCount={[Function]}
+ maxInitialItems={15}
+ maxItems={100}
+ minSearchLength={2}
+ onChange={[MockFunction]}
+ onSearch={[Function]}
+ onToggle={[MockFunction]}
+ open={true}
+ property="author"
+ query={Object {}}
+ renderFacetItem={[Function]}
+ renderSearchResult={[Function]}
+ searchPlaceholder="search.search_for_authors"
+ stats={Object {}}
+ values={Array []}
+/>
+`;
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 68097880f43..f28e8944a2b 100644
--- a/server/sonar-web/src/main/js/apps/issues/utils.ts
+++ b/server/sonar-web/src/main/js/apps/issues/utils.ts
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { isArray } from 'lodash';
import { searchUsers } from '../../api/users';
import { formatMeasure } from '../../helpers/measures';
import {
@@ -32,13 +33,14 @@ import {
} from '../../helpers/query';
import { scrollToElement } from '../../helpers/scrolling';
import { get, save } from '../../helpers/storage';
+import { isDefined } from '../../helpers/types';
import { Facet, RawFacet } from '../../types/issues';
import { SecurityStandard, StandardType } from '../../types/security';
export interface Query {
assigned: boolean;
assignees: string[];
- authors: string[];
+ author: string[];
createdAfter: Date | undefined;
createdAt: string;
createdBefore: Date | undefined;
@@ -48,7 +50,6 @@ export interface Query {
files: string[];
issues: string[];
languages: string[];
- modules: string[];
owaspTop10: string[];
projects: string[];
resolutions: string[];
@@ -81,7 +82,7 @@ export function parseQuery(query: T.RawQuery): Query {
return {
assigned: parseAsBoolean(query.assigned),
assignees: parseAsArray(query.assignees, parseAsString),
- authors: parseAsArray(query.authors, parseAsString),
+ author: isArray(query.author) ? query.author : [query.author].filter(isDefined),
createdAfter: parseAsDate(query.createdAfter),
createdAt: parseAsString(query.createdAt),
createdBefore: parseAsDate(query.createdBefore),
@@ -91,7 +92,6 @@ export function parseQuery(query: T.RawQuery): Query {
files: parseAsArray(query.files, parseAsString),
issues: parseAsArray(query.issues, parseAsString),
languages: parseAsArray(query.languages, parseAsString),
- modules: parseAsArray(query.moduleUuids, parseAsString),
owaspTop10: parseAsArray(query.owaspTop10, parseAsString),
projects: parseAsArray(query.projects, parseAsString),
resolutions: parseAsArray(query.resolutions, parseAsString),
@@ -119,7 +119,7 @@ export function serializeQuery(query: Query): T.RawQuery {
const filter = {
assigned: query.assigned ? undefined : 'false',
assignees: serializeStringArray(query.assignees),
- authors: serializeStringArray(query.authors),
+ author: query.author,
createdAfter: serializeDateShort(query.createdAfter),
createdAt: serializeString(query.createdAt),
createdBefore: serializeDateShort(query.createdBefore),
@@ -129,7 +129,6 @@ export function serializeQuery(query: Query): T.RawQuery {
files: serializeStringArray(query.files),
issues: serializeStringArray(query.issues),
languages: serializeStringArray(query.languages),
- moduleUuids: serializeStringArray(query.modules),
owaspTop10: serializeStringArray(query.owaspTop10),
projects: serializeStringArray(query.projects),
resolutions: serializeStringArray(query.resolutions),
@@ -145,37 +144,25 @@ export function serializeQuery(query: Query): T.RawQuery {
tags: serializeStringArray(query.tags),
types: serializeStringArray(query.types)
};
+
return cleanQuery(filter);
}
export const areQueriesEqual = (a: T.RawQuery, b: T.RawQuery) =>
queriesEqual(parseQuery(a), parseQuery(b));
-export function mapFacet(facet: string) {
- const propertyMapping: T.Dict<string> = {
- modules: 'moduleUuids'
- };
- return propertyMapping[facet] || facet;
-}
-
export function parseFacets(facets: RawFacet[]): T.Dict<Facet> {
if (!facets) {
return {};
}
- // for readability purpose
- const propertyMapping: T.Dict<string> = {
- moduleUuids: 'modules'
- };
-
const result: T.Dict<Facet> = {};
facets.forEach(facet => {
const values: Facet = {};
facet.values.forEach(value => {
values[value.val] = value.count;
});
- const finalProperty = propertyMapping[facet.property] || facet.property;
- result[finalProperty] = values;
+ result[facet.property] = values;
});
return result;
}
diff --git a/server/sonar-web/src/main/js/types/types.d.ts b/server/sonar-web/src/main/js/types/types.d.ts
index 5f1b977765c..9391ec3b94b 100644
--- a/server/sonar-web/src/main/js/types/types.d.ts
+++ b/server/sonar-web/src/main/js/types/types.d.ts
@@ -360,7 +360,6 @@ declare namespace T {
status: string;
subProject?: string;
subProjectName?: string;
- subProjectUuid?: string;
tags?: string[];
textRange?: TextRange;
transitions: string[];