選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

App.tsx 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2020 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 { lazyLoadComponent } from 'sonar-ui-common/components/lazyLoadComponent';
  22. import Suggestions from '../../../app/components/embed-docs-modal/Suggestions';
  23. import { Router, withRouter } from '../../../components/hoc/withRouter';
  24. import { isPullRequest } from '../../../helpers/branch-like';
  25. import { BranchLike } from '../../../types/branch-like';
  26. import { isPortfolioLike } from '../../../types/component';
  27. import BranchOverview from '../branches/BranchOverview';
  28. const EmptyOverview = lazyLoadComponent(() => import('./EmptyOverview'));
  29. const PullRequestOverview = lazyLoadComponent(() => import('../pullRequests/PullRequestOverview'));
  30. interface Props {
  31. branchLike?: BranchLike;
  32. branchLikes: BranchLike[];
  33. component: T.Component;
  34. isInProgress?: boolean;
  35. isPending?: boolean;
  36. router: Pick<Router, 'replace'>;
  37. }
  38. export class App extends React.PureComponent<Props> {
  39. isPortfolio = () => {
  40. return isPortfolioLike(this.props.component.qualifier);
  41. };
  42. render() {
  43. const { branchLike, branchLikes, component } = this.props;
  44. if (this.isPortfolio()) {
  45. return null;
  46. }
  47. return isPullRequest(branchLike) ? (
  48. <>
  49. <Suggestions suggestions="pull_requests" />
  50. <PullRequestOverview branchLike={branchLike} component={component} />
  51. </>
  52. ) : (
  53. <>
  54. <Suggestions suggestions="overview" />
  55. {!component.analysisDate ? (
  56. <EmptyOverview
  57. branchLike={branchLike}
  58. branchLikes={branchLikes}
  59. component={component}
  60. hasAnalyses={this.props.isPending || this.props.isInProgress}
  61. />
  62. ) : (
  63. <BranchOverview branchLike={branchLike} component={component} />
  64. )}
  65. </>
  66. );
  67. }
  68. }
  69. export default withRouter(App);