From 8a173aa3175c846291b8b56f2cfd84ab0e782627 Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Mon, 29 May 2017 12:18:58 +0200 Subject: SONAR-9254 Move projects facets sorting to the topbar of the projects page --- .../sonar-web/src/main/js/apps/projects/utils.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'server/sonar-web/src/main/js/apps/projects/utils.js') diff --git a/server/sonar-web/src/main/js/apps/projects/utils.js b/server/sonar-web/src/main/js/apps/projects/utils.js index a81d6258c14..ab4d157c3a2 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.js +++ b/server/sonar-web/src/main/js/apps/projects/utils.js @@ -47,6 +47,42 @@ export const saveAll = () => save(LOCALSTORAGE_ALL); export const saveFavorite = () => save(LOCALSTORAGE_FAVORITE); +export const SORTING_METRICS = [ + { value: 'name' }, + { value: 'reliability' }, + { value: 'security' }, + { value: 'maintainability' }, + { value: 'coverage' }, + { value: 'duplications' }, + { value: 'size' } +]; + +export const SORTING_LEAK_METRICS = [ + { value: 'name' }, + { value: 'new_reliability', complement: 'on_new_code' }, + { value: 'new_security', complement: 'on_new_code' }, + { value: 'new_maintainability', complement: 'on_new_code' }, + { value: 'new_coverage', complement: 'on_new_code' }, + { value: 'new_duplications', complement: 'on_new_lines' }, + { value: 'new_lines' } +]; + +export const SORTING_SWITCH = { + name: 'name', + reliability: 'new_reliability', + security: 'new_security', + maintainability: 'new_maintainability', + coverage: 'new_coverage', + duplications: 'new_duplications', + size: 'new_lines', + new_reliability: 'reliability', + new_security: 'security', + new_maintainability: 'maintainability', + new_coverage: 'coverage', + new_duplications: 'duplications', + new_lines: 'size' +}; + export const VIEWS = ['overall', 'leak']; export const VISUALIZATIONS = [ @@ -61,3 +97,8 @@ export const VISUALIZATIONS = [ export const localizeSorting = (sort?: string) => { return translate('projects.sort', sort || 'name'); }; + +export const parseSorting = (sort: string): { sortValue: string, sortDesc: boolean } => { + const desc = sort[0] === '-'; + return { sortValue: desc ? sort.substr(1) : sort, sortDesc: desc }; +}; -- cgit v1.2.3