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.

RegulatoryReport.tsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 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 classNames from 'classnames';
  21. import * as React from 'react';
  22. import { getRegulatoryReportUrl } from '../../api/regulatory-report';
  23. import { isBranch } from '../../helpers/branch-like';
  24. import { translate } from '../../helpers/l10n';
  25. import { BranchLike } from '../../types/branch-like';
  26. import { Component } from '../../types/types';
  27. interface Props {
  28. component: Pick<Component, 'key' | 'name'>;
  29. branchLike?: BranchLike;
  30. }
  31. function RegulatoryReport(props: Props) {
  32. const { component, branchLike } = props;
  33. const branchName = branchLike && isBranch(branchLike) ? branchLike.name : undefined;
  34. const [downloadStarted, setDownloadStarted] = React.useState(false);
  35. return (
  36. <div className="page page-limited">
  37. <header className="page-header">
  38. <h1 className="page-title">{translate('regulatory_report.page')}</h1>
  39. </header>
  40. <div className="page-description">
  41. <p>{translate('regulatory_report.description1')}</p>
  42. <p>{translate('regulatory_report.description2')}</p>
  43. <div className="big-spacer-top">
  44. <a
  45. className={classNames('button button-primary', { disabled: downloadStarted })}
  46. download={[component.name, branchName, 'PDF Report'].filter(s => !!s).join(' - ')}
  47. onClick={() => setDownloadStarted(true)}
  48. href={getRegulatoryReportUrl(component.key, branchName)}
  49. target="_blank"
  50. rel="noopener noreferrer">
  51. {translate('download_verb')}
  52. </a>
  53. {downloadStarted && (
  54. <div className="spacer-top">
  55. <p>{translate('regulatory_page.download_start.sentence')}</p>
  56. </div>
  57. )}
  58. </div>
  59. </div>
  60. </div>
  61. );
  62. }
  63. export default RegulatoryReport;