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.

AzureForm.tsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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, AzureBindingDefinition } from '../../../../types/alm-settings';
  27. import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
  28. export interface AzureFormProps {
  29. formData: AzureBindingDefinition;
  30. onFieldChange: (fieldId: keyof AzureBindingDefinition, value: string) => void;
  31. }
  32. export default function AzureForm(props: AzureFormProps) {
  33. const { formData, onFieldChange } = props;
  34. const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.Azure]);
  35. return (
  36. <>
  37. <AlmBindingDefinitionFormField
  38. autoFocus
  39. help={translate('settings.almintegration.form.name.azure.help')}
  40. id="name.azure"
  41. onFieldChange={onFieldChange}
  42. propKey="key"
  43. value={formData.key}
  44. maxLength={200}
  45. />
  46. <AlmBindingDefinitionFormField
  47. help={
  48. <>
  49. {translate('settings.almintegration.form.url.azure.help1')}
  50. <br />
  51. <em>https://ado.your-company.com/your_collection</em>
  52. <br />
  53. <br />
  54. {translate('settings.almintegration.form.url.azure.help2')}
  55. <br />
  56. <em>https://dev.azure.com/your_organization</em>
  57. <br />
  58. <br />
  59. {translate('settings.almintegration.form.url.pat_warning')}
  60. </>
  61. }
  62. id="url.azure"
  63. maxLength={2000}
  64. onFieldChange={onFieldChange}
  65. propKey="url"
  66. value={formData.url || ''}
  67. />
  68. <AlmBindingDefinitionFormField
  69. help={
  70. <FormattedMessage
  71. defaultMessage={translate(
  72. 'settings.almintegration.form.personal_access_token.azure.help',
  73. )}
  74. id="settings.almintegration.form.personal_access_token.azure.help"
  75. values={{
  76. pat: (
  77. <Link
  78. to="https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate"
  79. target="_blank"
  80. >
  81. {translate('settings.almintegration.form.personal_access_token.azure.help.url')}
  82. </Link>
  83. ),
  84. permission: <strong>{'Code > Read & Write'}</strong>,
  85. doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
  86. }}
  87. />
  88. }
  89. id="personal_access_token"
  90. isTextArea
  91. onFieldChange={onFieldChange}
  92. overwriteOnly={Boolean(formData.key)}
  93. propKey="personalAccessToken"
  94. value={formData.personalAccessToken}
  95. maxLength={2000}
  96. isSecret
  97. />
  98. </>
  99. );
  100. }