diff options
7 files changed, 240 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx index dd0670cb55f..bfade459220 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardLeak.tsx @@ -28,8 +28,9 @@ import TagsList from '../../../components/tags/TagsList'; import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContainer'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Project } from '../types'; -import { Organization } from '../../../app/types'; import { formatDuration } from '../utils'; +import { Organization } from '../../../app/types'; +import { getProjectUrl } from '../../../helpers/urls'; interface Props { height: number; @@ -97,10 +98,17 @@ export default function ProjectCardLeak({ height, organization, project }: Props </div> ) : ( <div className="boxed-group-inner"> - <div className="note project-card-not-analyzed"> - {project.analysisDate - ? translate('projects.no_new_code_period') - : translate('projects.not_analyzed')} + <div className="project-card-not-analyzed"> + <span className="note"> + {project.analysisDate + ? translate('projects.no_new_code_period') + : translate('projects.not_analyzed')} + </span> + {!project.analysisDate && ( + <Link className="button spacer-left" to={getProjectUrl(project.key)}> + {translate('projects.configure_analysis')} + </Link> + )} </div> </div> )} diff --git a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx index 859572fb80a..264ef83813c 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/ProjectCardOverall.tsx @@ -29,6 +29,7 @@ import PrivacyBadgeContainer from '../../../components/common/PrivacyBadgeContai import { translate, translateWithParameters } from '../../../helpers/l10n'; import { Project } from '../types'; import { Organization } from '../../../app/types'; +import { getProjectUrl } from '../../../helpers/urls'; interface Props { height: number; @@ -57,7 +58,7 @@ export default function ProjectCardOverall({ height, organization, project }: Pr {!organization && ( <ProjectCardOrganizationContainer organization={project.organization} /> )} - <Link to={{ pathname: '/dashboard', query: { id: project.key } }}>{project.name}</Link> + <Link to={getProjectUrl(project.key)}>{project.name}</Link> </h2> {project.analysisDate && <ProjectCardQualityGate status={measures['alert_status']} />} <div className="project-card-header-right"> @@ -90,7 +91,12 @@ export default function ProjectCardOverall({ height, organization, project }: Pr </div> ) : ( <div className="boxed-group-inner"> - <div className="note project-card-not-analyzed">{translate('projects.not_analyzed')}</div> + <div className="project-card-not-analyzed"> + <span className="note">{translate('projects.not_analyzed')}</span> + <Link className="button spacer-left" to={getProjectUrl(project.key)}> + {translate('projects.configure_analysis')} + </Link> + </div> </div> )} </div> diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx index 5a83961cca1..b83840aedde 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardLeak-test.tsx @@ -76,3 +76,15 @@ it('should display the leak measures and quality gate', () => { shallow(<ProjectCardLeak height={100} organization={undefined} project={PROJECT} />) ).toMatchSnapshot(); }); + +it('should display not analyzed yet', () => { + expect( + shallow( + <ProjectCardLeak + height={100} + organization={undefined} + project={{ ...PROJECT, analysisDate: undefined }} + /> + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx index 4ed5e6753ab..f0c2736bde7 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectCardOverall-test.tsx @@ -90,3 +90,15 @@ it('should display the overall measures and quality gate', () => { shallow(<ProjectCardOverall height={100} organization={undefined} project={PROJECT} />) ).toMatchSnapshot(); }); + +it('should display not analyzed yet', () => { + expect( + shallow( + <ProjectCardOverall + height={100} + organization={undefined} + project={{ ...PROJECT, analysisDate: undefined }} + /> + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardLeak-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardLeak-test.tsx.snap index bc672cd63b9..d3204d97486 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardLeak-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardLeak-test.tsx.snap @@ -1,5 +1,101 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`should display not analyzed yet 1`] = ` +<div + className="boxed-group project-card" + data-key="foo" + style={ + Object { + "height": 100, + } + } +> + <div + className="boxed-group-header clearfix" + > + <div + className="project-card-header" + > + <h2 + className="project-card-name" + > + <Connect(ProjectCardOrganization) + organization={ + Object { + "key": "org", + "name": "org", + } + } + /> + <Link + onlyActiveOnIndex={false} + style={Object {}} + to={ + Object { + "pathname": "/dashboard", + "query": Object { + "id": "foo", + }, + } + } + > + Foo + </Link> + </h2> + <div + className="project-card-header-right" + > + <Connect(PrivacyBadge) + className="spacer-left" + organization={ + Object { + "key": "org", + "name": "org", + } + } + qualifier="TRK" + tooltipProps={ + Object { + "projectKey": "foo", + } + } + visibility="public" + /> + </div> + </div> + </div> + <div + className="boxed-group-inner" + > + <div + className="project-card-not-analyzed" + > + <span + className="note" + > + projects.not_analyzed + </span> + <Link + className="button spacer-left" + onlyActiveOnIndex={false} + style={Object {}} + to={ + Object { + "pathname": "/dashboard", + "query": Object { + "branch": undefined, + "id": "foo", + }, + } + } + > + projects.configure_analysis + </Link> + </div> + </div> +</div> +`; + exports[`should display the leak measures and quality gate 1`] = ` <div className="boxed-group project-card" diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverall-test.tsx.snap b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverall-test.tsx.snap index 039ca9bd89c..eef7d8c0920 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverall-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectCardOverall-test.tsx.snap @@ -1,5 +1,102 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`should display not analyzed yet 1`] = ` +<div + className="boxed-group project-card" + data-key="foo" + style={ + Object { + "height": 100, + } + } +> + <div + className="boxed-group-header clearfix" + > + <div + className="project-card-header" + > + <h2 + className="project-card-name" + > + <Connect(ProjectCardOrganization) + organization={ + Object { + "key": "org", + "name": "org", + } + } + /> + <Link + onlyActiveOnIndex={false} + style={Object {}} + to={ + Object { + "pathname": "/dashboard", + "query": Object { + "branch": undefined, + "id": "foo", + }, + } + } + > + Foo + </Link> + </h2> + <div + className="project-card-header-right" + > + <Connect(PrivacyBadge) + className="spacer-left" + organization={ + Object { + "key": "org", + "name": "org", + } + } + qualifier="TRK" + tooltipProps={ + Object { + "projectKey": "foo", + } + } + visibility="public" + /> + </div> + </div> + </div> + <div + className="boxed-group-inner" + > + <div + className="project-card-not-analyzed" + > + <span + className="note" + > + projects.not_analyzed + </span> + <Link + className="button spacer-left" + onlyActiveOnIndex={false} + style={Object {}} + to={ + Object { + "pathname": "/dashboard", + "query": Object { + "branch": undefined, + "id": "foo", + }, + } + } + > + projects.configure_analysis + </Link> + </div> + </div> +</div> +`; + exports[`should display the overall measures and quality gate 1`] = ` <div className="boxed-group project-card" @@ -34,6 +131,7 @@ exports[`should display the overall measures and quality gate 1`] = ` Object { "pathname": "/dashboard", "query": Object { + "branch": undefined, "id": "foo", }, } diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index a2e9ef14fc6..13d8d40376f 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -754,6 +754,7 @@ projects.explore_projects=Explore Projects projects.not_analyzed=Project is not analyzed yet. projects.no_new_code_period=Project has no new code data yet. projects.new_code_period_x=New code: last {0} +projects.configure_analysis=Configure analysis projects.last_analysis_on_x=Last analysis: {0} projects.search=Search by project name or key projects.perspective=Perspective |