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.

BitbucketServerForm.tsx 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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 { Link } from 'design-system';
  21. import * as React from 'react';
  22. import { FormattedMessage } from 'react-intl';
  23. import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
  24. import { useDocUrl } from '../../../../helpers/docs';
  25. import { translate } from '../../../../helpers/l10n';
  26. import { AlmKeys, BitbucketServerBindingDefinition } from '../../../../types/alm-settings';
  27. import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
  28. export interface BitbucketServerFormProps {
  29. formData: BitbucketServerBindingDefinition;
  30. onFieldChange: (fieldId: keyof BitbucketServerBindingDefinition, value: string) => void;
  31. }
  32. export default function BitbucketServerForm(props: BitbucketServerFormProps) {
  33. const { formData } = props;
  34. const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.BitbucketServer]);
  35. return (
  36. <>
  37. <AlmBindingDefinitionFormField
  38. autoFocus
  39. help={translate('settings.almintegration.form.name.bitbucket.help')}
  40. id="name.bitbucket"
  41. maxLength={200}
  42. onFieldChange={props.onFieldChange}
  43. propKey="key"
  44. value={formData.key || ''}
  45. />
  46. <AlmBindingDefinitionFormField
  47. help={
  48. <>
  49. {translate('settings.almintegration.form.url.bitbucket.help')}
  50. <br />
  51. <br />
  52. {translate('settings.almintegration.form.url.pat_warning')}
  53. </>
  54. }
  55. id="url.bitbucket"
  56. maxLength={2000}
  57. onFieldChange={props.onFieldChange}
  58. propKey="url"
  59. value={formData.url || ''}
  60. />
  61. <AlmBindingDefinitionFormField
  62. id="personal_access_token"
  63. help={
  64. <FormattedMessage
  65. defaultMessage={translate(
  66. 'settings.almintegration.form.personal_access_token.bitbucket.help',
  67. )}
  68. id="settings.almintegration.form.personal_access_token.bitbucket.help"
  69. values={{
  70. pat: (
  71. <Link
  72. to="https://confluence.atlassian.com/bitbucketserver0515/personal-access-tokens-961275199.html"
  73. target="_blank"
  74. >
  75. {translate(
  76. 'settings.almintegration.form.personal_access_token.bitbucket.help.url',
  77. )}
  78. </Link>
  79. ),
  80. permission: <strong>Read</strong>,
  81. doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
  82. }}
  83. />
  84. }
  85. isTextArea
  86. onFieldChange={props.onFieldChange}
  87. overwriteOnly={Boolean(formData.key)}
  88. propKey="personalAccessToken"
  89. value={formData.personalAccessToken || ''}
  90. maxLength={2000}
  91. isSecret
  92. />
  93. </>
  94. );
  95. }