You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Home.tsx 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import Helmet from 'react-helmet';
  22. import { connect } from 'react-redux';
  23. import { FixedNavBar, TopNavBar } from './components/NavBars';
  24. import FeaturedProjects from './components/FeaturedProjects';
  25. import Footer from './components/Footer';
  26. import { Languages } from './components/Languages';
  27. import LoginButtons from './components/LoginButtons';
  28. import Statistics from './components/Statistics';
  29. import { requestHomepageData, HomepageData, FeaturedProject } from './utils';
  30. import { getGlobalSettingValue, Store } from '../../../store/rootReducer';
  31. import { addWhitePageClass, removeWhitePageClass } from '../../../helpers/pages';
  32. import { getBaseUrl } from '../../../helpers/urls';
  33. import './new_style.css';
  34. interface Props {
  35. homePageDataUrl?: string;
  36. }
  37. interface State {
  38. data?: HomepageData;
  39. }
  40. export class Home extends React.PureComponent<Props, State> {
  41. mounted = false;
  42. state: State = {};
  43. componentDidMount() {
  44. this.mounted = true;
  45. addWhitePageClass();
  46. this.fetchData();
  47. }
  48. componentWillUnmount() {
  49. removeWhitePageClass();
  50. this.mounted = false;
  51. }
  52. fetchData = () => {
  53. const { homePageDataUrl } = this.props;
  54. if (homePageDataUrl) {
  55. requestHomepageData(homePageDataUrl).then(
  56. data => {
  57. if (this.mounted) {
  58. this.setState({ data });
  59. }
  60. },
  61. () => {
  62. /* Fail silently */
  63. }
  64. );
  65. }
  66. };
  67. render() {
  68. const { data } = this.state;
  69. return (
  70. <div className="global-container">
  71. <div className="page-wrapper">
  72. <div className="page-container sc-page">
  73. <Helmet title="SonarCloud | Clean Code, Rockstar Status">
  74. <meta
  75. content="Enhance your workflow with continuous code quality, SonarCloud automatically analyzes and decorates pull requests on GitHub, Bitbucket and Azure DevOps on major languages."
  76. name="description"
  77. />
  78. </Helmet>
  79. <FixedNavBar />
  80. <PageBackgroundHeader />
  81. <TopNavBar />
  82. <PageTitle />
  83. <EnhanceWorkflow />
  84. <Functionality />
  85. <Languages />
  86. <Stats data={data} />
  87. <Projects featuredProjects={(data && data.featuredProjects) || []} />
  88. </div>
  89. </div>
  90. <Footer />
  91. </div>
  92. );
  93. }
  94. }
  95. const mapStateToProps = (state: Store) => {
  96. const homePageDataUrl = getGlobalSettingValue(state, 'sonar.homepage.url');
  97. return {
  98. homePageDataUrl: homePageDataUrl && homePageDataUrl.value
  99. };
  100. };
  101. export default connect(mapStateToProps)(Home);
  102. function PageBackgroundHeader() {
  103. return (
  104. <div className="sc-header-background">
  105. <div className="sc-background-start" />
  106. <div className="sc-background-end" />
  107. <div className="sc-background-center">
  108. <img alt="" height="418px" src={`${getBaseUrl()}/images/sonarcloud/home-header.svg`} />
  109. </div>
  110. </div>
  111. );
  112. }
  113. function PageTitle() {
  114. return (
  115. <div className="sc-section sc-columns big-spacer-top">
  116. <div className="sc-column sc-column-half display-flex-center">
  117. <div>
  118. <h1 className="sc-title-orange big-spacer-top">Clean Code</h1>
  119. <h1 className="sc-spacer-bottom">Rockstar Status</h1>
  120. <h5 className="sc-big-spacer-bottom sc-regular-weight">
  121. Eliminate bugs and vulnerabilities.
  122. <br />
  123. Champion quality code in your projects.
  124. </h5>
  125. <div>
  126. <h6>Go ahead! Analyze your repo:</h6>
  127. <LoginButtons />
  128. <p className="sc-mention sc-regular-weight big-spacer-top">
  129. Free for Open-Source Projects
  130. </p>
  131. </div>
  132. </div>
  133. </div>
  134. <div className="sc-column sc-column-half text-right">
  135. <img
  136. alt=""
  137. src={`${getBaseUrl()}/images/sonarcloud/home-header-people.png`}
  138. width="430px"
  139. />
  140. </div>
  141. </div>
  142. );
  143. }
  144. function EnhanceWorkflow() {
  145. return (
  146. <div className="sc-section sc-columns">
  147. <div className="sc-column sc-column-full">
  148. <h3 className="sc-big-spacer-bottom">
  149. Enhance Your Workflow
  150. <br />
  151. with Continuous Code Quality
  152. </h3>
  153. <img
  154. alt=""
  155. className="sc-big-spacer-bottom"
  156. src={`${getBaseUrl()}/images/sonarcloud/home-branch.png`}
  157. srcSet={`${getBaseUrl()}/images/sonarcloud/home-branch.png 1x, ${getBaseUrl()}/images/sonarcloud/home-branch@2x.png 2x`}
  158. />
  159. <h5 className="spacer-bottom">Maximize your throughput and only release clean code</h5>
  160. <h6 className="sc-big-spacer-bottom sc-regular-weight">
  161. SonarCloud automatically analyzes branches and decorates pull requests
  162. </h6>
  163. </div>
  164. </div>
  165. );
  166. }
  167. function Functionality() {
  168. return (
  169. <div className="position-relative">
  170. <div className="sc-functionality-background">
  171. <div className="sc-background-center">
  172. <img
  173. alt=""
  174. height="300px"
  175. src={`${getBaseUrl()}/images/sonarcloud/home-grey-background.svg`}
  176. />
  177. </div>
  178. </div>
  179. <div className="sc-functionality-container">
  180. <div className="sc-section">
  181. <h3 className="sc-big-spacer-bottom text-center">
  182. Functionality
  183. <br />
  184. that Fits Your Projects
  185. </h3>
  186. <div className="sc-columns">
  187. <div className="sc-column sc-column-small big-spacer-top">
  188. <h6 className="sc-regular-weight spacer-bottom">Easy to Use</h6>
  189. <p>
  190. With just a few clicks you’re up and running right where your code lives. Immediate
  191. access to the latest features and enhancements.
  192. </p>
  193. <div className="sc-separator" />
  194. <span className="big-spacer-bottom sc-with-icon">
  195. <img
  196. alt=""
  197. className="big-spacer-right"
  198. src={`${getBaseUrl()}/images/sonarcloud/scale.svg`}
  199. />{' '}
  200. Scale on-demand as your projects grow.
  201. </span>
  202. <span className="sc-with-icon">
  203. <img
  204. alt=""
  205. className="big-spacer-right"
  206. src={`${getBaseUrl()}/images/sonarcloud/stop.svg`}
  207. />{' '}
  208. No contracts, stop/start anytime.
  209. </span>
  210. </div>
  211. <div className="sc-column sc-column-big big-spacer-top">
  212. <img
  213. alt=""
  214. className="sc-rounded-img"
  215. src={`${getBaseUrl()}/images/sonarcloud/home-easy-to-use.png`}
  216. srcSet={`${getBaseUrl()}/images/sonarcloud/home-easy-to-use.png 1x, ${getBaseUrl()}/images/sonarcloud/home-easy-to-use@2x.png 2x`}
  217. />
  218. </div>
  219. </div>
  220. <div className="sc-columns">
  221. <div className="sc-column sc-column-big">
  222. <img
  223. alt=""
  224. className="sc-rounded-img"
  225. src={`${getBaseUrl()}/images/sonarcloud/home-open-transparent.png`}
  226. srcSet={`${getBaseUrl()}/images/sonarcloud/home-open-transparent.png 1x, ${getBaseUrl()}/images/sonarcloud/home-open-transparent@2x.png 2x`}
  227. />
  228. </div>
  229. <div className="sc-column sc-column-small">
  230. <div>
  231. <h6 className="sc-regular-weight spacer-bottom">Open and Transparent</h6>
  232. <p className="big-spacer-bottom">
  233. Project dashboards keep teams and stakeholders informed on code quality and
  234. releasability.
  235. </p>
  236. <p>Display project badges and show your communities you’re all about awesome.</p>
  237. <img
  238. alt=""
  239. className="big-spacer-top"
  240. src={`${getBaseUrl()}/images/project_badges/sonarcloud-black.svg`}
  241. width="200px"
  242. />
  243. </div>
  244. </div>
  245. </div>
  246. <div className="sc-columns">
  247. <div className="sc-column sc-column-full big-spacer-bottom">
  248. <div>
  249. <h6 className="sc-regular-weight spacer-bottom">Effective Collaboration</h6>
  250. <p className="sc-with-inline-icon">
  251. Use
  252. <img
  253. alt="SonarCloud"
  254. src={`${getBaseUrl()}/images/sonarcloud/sonarcloud-logo-text-only.svg`}
  255. />
  256. with your team, share best practices and have fun writing quality code!
  257. </p>
  258. <br />
  259. <p className="sc-with-inline-icon">
  260. Connect with
  261. <img
  262. alt="SonarCloud"
  263. src={`${getBaseUrl()}/images/sonarcloud/sonarlint-logo.svg`}
  264. />
  265. and get real-time notifications in your IDE as you work.
  266. </p>
  267. <div className="big-spacer-top">
  268. <img
  269. alt=""
  270. className="big-spacer-top huge-spacer-bottom"
  271. src={`${getBaseUrl()}/images/sonarcloud/ide.svg`}
  272. width="216px"
  273. />
  274. </div>
  275. <img alt="" src={`${getBaseUrl()}/images/sonarcloud/collab.svg`} width="540px" />
  276. </div>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <div className="sc-functionality-background sc-functionality-background-bottom">
  282. <div className="sc-background-center">
  283. <img
  284. alt=""
  285. height="140px"
  286. src={`${getBaseUrl()}/images/sonarcloud/home-background-grey-bottom.svg`}
  287. />
  288. </div>
  289. </div>
  290. </div>
  291. );
  292. }
  293. interface StatsProps {
  294. data?: HomepageData;
  295. }
  296. function Stats({ data }: StatsProps) {
  297. return (
  298. <div className="sc-section sc-columns">
  299. <div className="sc-column sc-column-full">
  300. <h3>
  301. Over 3,000 Projects
  302. <br />
  303. Continuously Analyzed
  304. </h3>
  305. {data && (
  306. <Statistics
  307. statistics={[
  308. { icon: 'rules', text: 'Static analysis rules checked', value: data.rules },
  309. { icon: 'locs', text: 'Lines of code analyzed', value: data.publicLoc },
  310. {
  311. icon: 'pull-request',
  312. text: 'Pull Requests decorated/week',
  313. value: data.newPullRequests7d
  314. },
  315. {
  316. icon: 'open-source',
  317. text: 'Open-source projects inspected',
  318. value: data.publicProjects
  319. }
  320. ]}
  321. />
  322. )}
  323. </div>
  324. </div>
  325. );
  326. }
  327. interface ProjectsProps {
  328. featuredProjects: FeaturedProject[];
  329. }
  330. function Projects({ featuredProjects }: ProjectsProps) {
  331. return (
  332. <div className="sc-section sc-columns">
  333. <div className="sc-column sc-column-full">
  334. {featuredProjects.length > 0 && (
  335. <>
  336. <h6 className="big-spacer-bottom">
  337. Transparency makes sense
  338. <br />
  339. and that’s why the trend is growing.
  340. </h6>
  341. <p>
  342. Check out these open-source projects showing users
  343. <br />
  344. their commitment to quality.
  345. </p>
  346. <FeaturedProjects projects={featuredProjects} />
  347. </>
  348. )}
  349. <h6 className="spacer-bottom">
  350. Come join the fun, it’s entirely free for open-source projects!
  351. </h6>
  352. <div className="sc-spacer-bottom">
  353. <LoginButtons />
  354. </div>
  355. </div>
  356. </div>
  357. );
  358. }