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.

BitbucketTab.tsx 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 { FormattedMessage } from 'react-intl';
  22. import { Link } from 'react-router';
  23. import { Alert } from 'sonar-ui-common/components/ui/Alert';
  24. import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n';
  25. import {
  26. createBitbucketConfiguration,
  27. updateBitbucketConfiguration
  28. } from '../../../../api/alm-settings';
  29. import { AlmKeys, BitbucketBindingDefinition } from '../../../../types/alm-settings';
  30. import AlmTab from './AlmTab';
  31. import BitbucketForm from './BitbucketForm';
  32. export interface BitbucketTabProps {
  33. definitions: BitbucketBindingDefinition[];
  34. loading: boolean;
  35. multipleAlmEnabled: boolean;
  36. onDelete: (definitionKey: string) => void;
  37. onUpdateDefinitions: () => void;
  38. }
  39. export default function BitbucketTab(props: BitbucketTabProps) {
  40. const { multipleAlmEnabled, definitions, loading } = props;
  41. return (
  42. <div className="bordered">
  43. <AlmTab
  44. additionalColumnsHeaders={[translate('settings.almintegration.table.column.bitbucket.url')]}
  45. additionalColumnsKeys={['url']}
  46. additionalTableInfo={
  47. <Alert className="big-spacer-bottom width-50" variant="info">
  48. <FormattedMessage
  49. defaultMessage={translate(
  50. 'settings.almintegration.feature.alm_repo_import.disabled_if_multiple_bbs_instances'
  51. )}
  52. id="settings.almintegration.feature.alm_repo_import.disabled_if_multiple_bbs_instances"
  53. values={{
  54. feature: (
  55. <em>{translate('settings.almintegration.feature.alm_repo_import.title')}</em>
  56. )
  57. }}
  58. />
  59. </Alert>
  60. }
  61. alm={AlmKeys.Bitbucket}
  62. createConfiguration={createBitbucketConfiguration}
  63. defaultBinding={{ key: '', url: '', personalAccessToken: '' }}
  64. definitions={definitions}
  65. features={[
  66. {
  67. name: translate('settings.almintegration.feature.pr_decoration.title'),
  68. active: definitions.length > 0,
  69. description: translate('settings.almintegration.feature.pr_decoration.description'),
  70. inactiveReason: translate('settings.almintegration.feature.need_at_least_1_binding')
  71. },
  72. {
  73. name: translate('settings.almintegration.feature.alm_repo_import.title'),
  74. active: definitions.length === 1,
  75. description: translate('settings.almintegration.feature.alm_repo_import.description'),
  76. inactiveReason: translateWithParameters(
  77. 'onboarding.create_project.too_many_bbs_instances_X',
  78. definitions.length
  79. )
  80. }
  81. ]}
  82. form={childProps => <BitbucketForm {...childProps} />}
  83. help={
  84. <>
  85. <h3>{translate('onboarding.create_project.pat_help.title')}</h3>
  86. <p className="big-spacer-top">
  87. {translate('settings.almintegration.bitbucket.help_1')}
  88. </p>
  89. <ul className="big-spacer-top list-styled">
  90. <li>{translate('settings.almintegration.bitbucket.help_2')}</li>
  91. <li>{translate('settings.almintegration.bitbucket.help_3')}</li>
  92. </ul>
  93. <p className="big-spacer-top big-spacer-bottom">
  94. <Link target="_blank" to="/documentation/analysis/pr-decoration/">
  95. {translate('learn_more')}
  96. </Link>
  97. </p>
  98. </>
  99. }
  100. loading={loading}
  101. multipleAlmEnabled={multipleAlmEnabled}
  102. onDelete={props.onDelete}
  103. onUpdateDefinitions={props.onUpdateDefinitions}
  104. updateConfiguration={updateBitbucketConfiguration}
  105. />
  106. </div>
  107. );
  108. }