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.

GitlabTab.tsx 3.0KB

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