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.

GithubForm.tsx 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 { translate } from 'sonar-ui-common/helpers/l10n';
  22. import { GithubBindingDefinition } from '../../../../types/alm-settings';
  23. import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
  24. export interface GithubFormProps {
  25. formData: GithubBindingDefinition;
  26. hideKeyField?: boolean;
  27. onFieldChange: (fieldId: keyof GithubBindingDefinition, value: string) => void;
  28. readOnly?: boolean;
  29. }
  30. export default function GithubForm(props: GithubFormProps) {
  31. const { formData, hideKeyField, onFieldChange, readOnly } = props;
  32. return (
  33. <>
  34. {!hideKeyField && (
  35. <AlmBindingDefinitionFormField
  36. autoFocus={true}
  37. help={translate('settings.almintegration.form.name.github.help')}
  38. id="name.github"
  39. onFieldChange={onFieldChange}
  40. propKey="key"
  41. readOnly={readOnly}
  42. value={formData.key}
  43. />
  44. )}
  45. <AlmBindingDefinitionFormField
  46. help={
  47. <>
  48. {translate('settings.almintegration.form.url.github.help1')}
  49. <br />
  50. <em>https://github.company.com/api/v3</em>
  51. <br />
  52. <br />
  53. {translate('settings.almintegration.form.url.github.help2')}
  54. <br />
  55. <em>https://api.github.com/</em>
  56. </>
  57. }
  58. id="url.github"
  59. maxLength={2000}
  60. onFieldChange={onFieldChange}
  61. propKey="url"
  62. readOnly={readOnly}
  63. value={formData.url}
  64. />
  65. <AlmBindingDefinitionFormField
  66. id="app_id"
  67. maxLength={80}
  68. onFieldChange={onFieldChange}
  69. propKey="appId"
  70. readOnly={readOnly}
  71. value={formData.appId}
  72. />
  73. <AlmBindingDefinitionFormField
  74. id="private_key"
  75. isTextArea={true}
  76. onFieldChange={onFieldChange}
  77. propKey="privateKey"
  78. readOnly={readOnly}
  79. value={formData.privateKey}
  80. />
  81. </>
  82. );
  83. }