diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-11-07 12:43:12 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2018-11-12 10:47:55 +0100 |
commit | 1d231e6fc9895bf9db626b7f78b95576ea8af9a0 (patch) | |
tree | 6cd1a9c446c983253b5f7edaba70ac77ce3870d5 | |
parent | 37029b14d4c0e74f38f258920a229391148bb2e3 (diff) | |
download | sonarqube-1d231e6fc9895bf9db626b7f78b95576ea8af9a0.tar.gz sonarqube-1d231e6fc9895bf9db626b7f78b95576ea8af9a0.zip |
SONARCLOUD-45 Support empty array of featured projects in SC homepage
-rw-r--r-- | server/sonar-web/src/main/js/apps/about/sonarcloud/Home.tsx | 12 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/apps/about/sonarcloud/components/FeaturedProjects.tsx | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/about/sonarcloud/Home.tsx b/server/sonar-web/src/main/js/apps/about/sonarcloud/Home.tsx index 6154444ba4a..d23ad559b67 100644 --- a/server/sonar-web/src/main/js/apps/about/sonarcloud/Home.tsx +++ b/server/sonar-web/src/main/js/apps/about/sonarcloud/Home.tsx @@ -60,6 +60,8 @@ export default class Home extends React.PureComponent<{}, State> { }; render() { + const { data } = this.state; + return ( <div className="global-container"> <div className="page-wrapper"> @@ -77,10 +79,8 @@ export default class Home extends React.PureComponent<{}, State> { <EnhanceWorkflow /> <Functionality /> <Languages /> - <Stats data={this.state.data} /> - <Projects - featuredProjects={this.state.data ? this.state.data.featuredProjects : undefined} - /> + <Stats data={data} /> + <Projects featuredProjects={(data && data.featuredProjects) || []} /> </div> </div> <Footer /> @@ -313,14 +313,14 @@ function Stats({ data }: StatsProps) { } interface ProjectsProps { - featuredProjects?: FeaturedProject[]; + featuredProjects: FeaturedProject[]; } function Projects({ featuredProjects }: ProjectsProps) { return ( <div className="sc-section sc-columns"> <div className="sc-column sc-column-full"> - {featuredProjects && ( + {featuredProjects.length > 0 && ( <> <h6 className="big-spacer-bottom"> Transparency makes sense diff --git a/server/sonar-web/src/main/js/apps/about/sonarcloud/components/FeaturedProjects.tsx b/server/sonar-web/src/main/js/apps/about/sonarcloud/components/FeaturedProjects.tsx index bd1d80c2f3c..b14ef2a375a 100644 --- a/server/sonar-web/src/main/js/apps/about/sonarcloud/components/FeaturedProjects.tsx +++ b/server/sonar-web/src/main/js/apps/about/sonarcloud/components/FeaturedProjects.tsx @@ -95,6 +95,10 @@ export default class FeaturedProjects extends React.PureComponent<Props, State> orderProjectsFromProps = () => { const { projects } = this.props; + if (projects.length === 0) { + return []; + } + // Last element should be put at the begining for proper carousel animation return [projects.pop(), ...projects].map((project: FeaturedProject, id) => { return { |