diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2019-08-27 16:04:38 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-09-24 20:21:16 +0200 |
commit | 45f8d835abdaf01287e2cf4a149b87ab2abfd156 (patch) | |
tree | 6aa2395100e943138acbbb070122c8d7fc0b962b /server/sonar-web/src/main/js/helpers/periods.ts | |
parent | 1bd13d06f1600169edb47200f6531ae6dfef66f2 (diff) | |
download | sonarqube-45f8d835abdaf01287e2cf4a149b87ab2abfd156.tar.gz sonarqube-45f8d835abdaf01287e2cf4a149b87ab2abfd156.zip |
SONAR-12415 Fix Leak title in project overview
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/periods.ts')
-rw-r--r-- | server/sonar-web/src/main/js/helpers/periods.ts | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/server/sonar-web/src/main/js/helpers/periods.ts b/server/sonar-web/src/main/js/helpers/periods.ts index 9c36b32efd7..6a9702fec7b 100644 --- a/server/sonar-web/src/main/js/helpers/periods.ts +++ b/server/sonar-web/src/main/js/helpers/periods.ts @@ -39,22 +39,33 @@ export function getPeriodLabel( return undefined; } - let parameter = period.modeParam || period.parameter; - if (period.mode === 'previous_version' && !parameter) { - return translate('overview.period.previous_version_only_date'); - } + let parameter = period.modeParam || period.parameter || ''; - if (period.mode === 'date' && parameter) { - parameter = dateFormatter(parameter); - } else if (period.mode === 'manual_baseline') { - if (!parameter) { + switch (period.mode) { + case 'SPECIFIC_ANALYSIS': parameter = dateFormatter(period.date); - } else { - return translateWithParameters('overview.period.previous_version', parameter); - } + break; + case 'PREVIOUS_VERSION': + parameter = parameter || dateFormatter(period.date); + break; + /* + * Handle legacy period modes, that predate MMF-1579 + */ + case 'previous_version': + if (!parameter) { + return translate('overview.period.previous_version_only_date'); + } + break; + case 'date': + parameter = parameter && dateFormatter(parameter); + break; + case 'manual_baseline': + parameter = parameter || dateFormatter(period.date); + break; + default: // No change in the parameter } - return translateWithParameters(`overview.period.${period.mode}`, parameter || ''); + return translateWithParameters(`overview.period.${period.mode.toLowerCase()}`, parameter); } export function getPeriodDate(period?: { date?: string }): Date | undefined { |