From 4712ad2d974220f42893f6509ec5f0b7a7b446b0 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 1 May 2017 17:48:42 +0200 Subject: sort issues by creation date when coming from about page (#1993) --- .../src/main/js/apps/about/components/EntryIssueTypes.js | 10 +++++++--- .../apps/about/components/EntryIssueTypesForSonarQubeDotCom.js | 10 +++++++--- server/sonar-web/src/main/js/apps/issues/components/App.js | 7 ++++++- server/sonar-web/src/main/js/apps/issues/utils.js | 6 ++++++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.js b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.js index 010c2912f5c..349dbf85bba 100644 --- a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.js +++ b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.js @@ -43,7 +43,7 @@ export default class EntryIssueTypes extends React.PureComponent { {formatMeasure(bugs, 'SHORT_INT')} @@ -56,7 +56,11 @@ export default class EntryIssueTypes extends React.PureComponent { {formatMeasure(vulnerabilities, 'SHORT_INT')} @@ -69,7 +73,7 @@ export default class EntryIssueTypes extends React.PureComponent { {formatMeasure(codeSmells, 'SHORT_INT')} diff --git a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypesForSonarQubeDotCom.js b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypesForSonarQubeDotCom.js index e2a8e7ad16c..e7ef546f2ac 100644 --- a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypesForSonarQubeDotCom.js +++ b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypesForSonarQubeDotCom.js @@ -43,7 +43,7 @@ export default class EntryIssueTypesForSonarQubeDotCom extends React.PureCompone {formatMeasure(bugs, 'SHORT_INT')} @@ -56,7 +56,11 @@ export default class EntryIssueTypesForSonarQubeDotCom extends React.PureCompone {formatMeasure(vulnerabilities, 'SHORT_INT')} @@ -69,7 +73,7 @@ export default class EntryIssueTypesForSonarQubeDotCom extends React.PureCompone {formatMeasure(codeSmells, 'SHORT_INT')} diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index 7dc673d80dd..6361d5cc85f 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -346,13 +346,18 @@ export default class App extends React.PureComponent { const parameters = { componentKeys: component && component.key, - ...serializeQuery(query), s: 'FILE_LINE', + ...serializeQuery(query), ps: 100, facets, ...additional }; + // only sorting by CREATION_DATE is allowed, so let's sort DESC + if (query.sort) { + Object.assign(parameters, { asc: 'false' }); + } + if (myIssues) { Object.assign(parameters, { assignees: '__me__' }); } diff --git a/server/sonar-web/src/main/js/apps/issues/utils.js b/server/sonar-web/src/main/js/apps/issues/utils.js index 1ad58e08816..712b00024db 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.js +++ b/server/sonar-web/src/main/js/apps/issues/utils.js @@ -42,6 +42,7 @@ export type Query = {| resolved: boolean, resolutions: Array, rules: Array, + sort: string, severities: Array, sinceLeakPeriod: boolean, statuses: Array, @@ -65,6 +66,9 @@ const parseAsStringArray = (value: ?string): Array => (value ? value.spl const parseAsFacetMode = (facetMode: string) => (facetMode === 'debt' || facetMode === 'effort' ? 'effort' : 'count'); +// allow sorting by CREATION_DATE only +const parseAsSort = (sort: string): string => (sort === 'CREATION_DATE' ? 'CREATION_DATE' : ''); + export const parseQuery = (query: RawQuery): Query => ({ assigned: parseAsBoolean(query.assigned), assignees: parseAsStringArray(query.assignees), @@ -83,6 +87,7 @@ export const parseQuery = (query: RawQuery): Query => ({ resolved: parseAsBoolean(query.resolved), resolutions: parseAsStringArray(query.resolutions), rules: parseAsStringArray(query.rules), + sort: parseAsSort(query.s), severities: parseAsStringArray(query.severities), sinceLeakPeriod: parseAsBoolean(query.sinceLeakPeriod, false), statuses: parseAsStringArray(query.statuses), @@ -116,6 +121,7 @@ export const serializeQuery = (query: Query): RawQuery => { projectUuids: serializeValue(query.projects), resolved: query.resolved ? undefined : 'false', resolutions: serializeValue(query.resolutions), + s: serializeString(query.sort), severities: serializeValue(query.severities), sinceLeakPeriod: query.sinceLeakPeriod ? 'true' : undefined, statuses: serializeValue(query.statuses), -- cgit v1.2.3