diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-10-25 10:24:25 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2018-10-30 12:42:02 +0100 |
commit | f97a4394b27d97de396736e36819c4ee79c6de1f (patch) | |
tree | 131b613b34a145e7f8e5aa6aa9f245f865588a42 /server/sonar-web/src | |
parent | 4e5977f1e7d6f474841bc0b0866355a626ac297a (diff) | |
download | sonarqube-f97a4394b27d97de396736e36819c4ee79c6de1f.tar.gz sonarqube-f97a4394b27d97de396736e36819c4ee79c6de1f.zip |
SONAR-11360 Display "empty project" in projects page
Diffstat (limited to 'server/sonar-web/src')
3 files changed, 15 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx index 4f833156d2f..fce96f6e707 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverallMeasures.tsx @@ -38,6 +38,11 @@ export default function ProjectCardOverallMeasures({ measures }: Props) { return null; } + const { ncloc } = measures; + if (!ncloc) { + return <div className="note">{translate('overview.project.empty')}</div>; + } + return ( <div className="project-card-measures"> <div className="project-card-measure" data-key="reliability_rating"> diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx index 51d54721b44..534b9e512d4 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverallMeasures-test.tsx @@ -70,7 +70,7 @@ it('should not render duplications', () => { expect(wrapper.find('[data-key="duplicated_lines_density"]')).toMatchSnapshot(); }); -it('should not render ncloc', () => { +it('should render empty', () => { const measures = { alert_status: 'ERROR', bugs: '17', @@ -82,8 +82,7 @@ it('should not render ncloc', () => { sqale_rating: '1.0', vulnerabilities: '0' }; - const wrapper = shallow(<ProjectCardOverallMeasures measures={measures} />); - expect(wrapper.find('[data-key="ncloc"]').length).toBe(0); + expect(shallow(<ProjectCardOverallMeasures measures={measures} />)).toMatchSnapshot(); }); it('should render ncloc correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap index 48a600f9855..cc78296268a 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverallMeasures-test.tsx.snap @@ -237,6 +237,14 @@ exports[`should render correctly with all data 1`] = ` </div> `; +exports[`should render empty 1`] = ` +<div + className="note" +> + overview.project.empty +</div> +`; + exports[`should render ncloc correctly 1`] = ` <div className="project-card-measure project-card-ncloc" |