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.

GithubTab.tsx 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 { createGithubConfiguration, updateGithubConfiguration } from '../../../../api/alm-settings';
  23. import { AlmKeys, GithubBindingDefinition } from '../../../../types/alm-settings';
  24. import { ALM_INTEGRATION } from '../AdditionalCategoryKeys';
  25. import CategoryDefinitionsList from '../CategoryDefinitionsList';
  26. import AlmTab from './AlmTab';
  27. import GithubForm from './GithubForm';
  28. export interface GithubTabProps {
  29. branchesEnabled: boolean;
  30. component?: T.Component;
  31. definitions: GithubBindingDefinition[];
  32. loading: boolean;
  33. multipleAlmEnabled: boolean;
  34. onDelete: (definitionKey: string) => void;
  35. onUpdateDefinitions: () => void;
  36. }
  37. export default function GithubTab(props: GithubTabProps) {
  38. const { branchesEnabled, component, multipleAlmEnabled, definitions, loading } = props;
  39. return (
  40. <div className="bordered">
  41. {branchesEnabled && (
  42. <>
  43. <AlmTab
  44. additionalColumnsHeaders={[
  45. translate('settings.almintegration.table.column.github.url'),
  46. translate('settings.almintegration.table.column.app_id')
  47. ]}
  48. additionalColumnsKeys={['appId', 'url']}
  49. alm={AlmKeys.GitHub}
  50. createConfiguration={createGithubConfiguration}
  51. defaultBinding={{ key: '', appId: '', url: '', privateKey: '' }}
  52. definitions={definitions}
  53. features={[
  54. {
  55. name: translate('settings.almintegration.feature.pr_decoration.title'),
  56. active: definitions.length > 0,
  57. description: translate('settings.almintegration.feature.pr_decoration.description'),
  58. inactiveReason: translate('settings.almintegration.feature.need_at_least_1_binding')
  59. }
  60. ]}
  61. form={childProps => <GithubForm {...childProps} />}
  62. loading={loading}
  63. multipleAlmEnabled={multipleAlmEnabled}
  64. onDelete={props.onDelete}
  65. onUpdateDefinitions={props.onUpdateDefinitions}
  66. updateConfiguration={updateGithubConfiguration}
  67. />
  68. <div className="huge-spacer-top huge-spacer-bottom bordered-top" />
  69. </>
  70. )}
  71. <div className="big-padded">
  72. <CategoryDefinitionsList
  73. category={ALM_INTEGRATION}
  74. component={component}
  75. subCategory={AlmKeys.GitHub}
  76. />
  77. </div>
  78. </div>
  79. );
  80. }