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.

AdditionalCategories.tsx 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 {
  23. ALM_INTEGRATION,
  24. ANALYSIS_SCOPE_CATEGORY,
  25. LANGUAGES_CATEGORY,
  26. NEW_CODE_PERIOD_CATEGORY,
  27. PULL_REQUEST_DECORATION_BINDING_CATEGORY
  28. } from './AdditionalCategoryKeys';
  29. import AlmIntegration from './almIntegration/AlmIntegration';
  30. import { AnalysisScope } from './AnalysisScope';
  31. import Languages from './Languages';
  32. import NewCodePeriod from './NewCodePeriod';
  33. import PullRequestDecorationBinding from './pullRequestDecorationBinding/PRDecorationBinding';
  34. export interface AdditionalCategoryComponentProps {
  35. component: T.Component | undefined;
  36. selectedCategory: string;
  37. }
  38. export interface AdditionalCategory {
  39. availableGlobally: boolean;
  40. availableForProject: boolean;
  41. displayTab: boolean;
  42. key: string;
  43. name: string;
  44. renderComponent: (props: AdditionalCategoryComponentProps) => React.ReactNode;
  45. requiresBranchesEnabled?: boolean;
  46. }
  47. export const ADDITIONAL_CATEGORIES: AdditionalCategory[] = [
  48. {
  49. key: LANGUAGES_CATEGORY,
  50. name: translate('property.category.languages'),
  51. renderComponent: getLanguagesComponent,
  52. availableGlobally: true,
  53. availableForProject: true,
  54. displayTab: true
  55. },
  56. {
  57. key: NEW_CODE_PERIOD_CATEGORY,
  58. name: translate('settings.new_code_period.category'),
  59. renderComponent: getNewCodePeriodComponent,
  60. availableGlobally: true,
  61. availableForProject: false,
  62. displayTab: true
  63. },
  64. {
  65. key: ANALYSIS_SCOPE_CATEGORY,
  66. name: translate('property.category.exclusions'),
  67. renderComponent: getAnalysisScopeComponent,
  68. availableGlobally: true,
  69. availableForProject: true,
  70. displayTab: false
  71. },
  72. {
  73. key: ALM_INTEGRATION,
  74. name: translate('property.category.almintegration'),
  75. renderComponent: getAlmIntegrationComponent,
  76. availableGlobally: true,
  77. availableForProject: false,
  78. displayTab: false
  79. },
  80. {
  81. key: PULL_REQUEST_DECORATION_BINDING_CATEGORY,
  82. name: translate('settings.pr_decoration.binding.category'),
  83. renderComponent: getPullRequestDecorationBindingComponent,
  84. availableGlobally: false,
  85. availableForProject: true,
  86. displayTab: true,
  87. requiresBranchesEnabled: true
  88. }
  89. ];
  90. function getLanguagesComponent(props: AdditionalCategoryComponentProps) {
  91. return <Languages {...props} />;
  92. }
  93. function getNewCodePeriodComponent() {
  94. return <NewCodePeriod />;
  95. }
  96. function getAnalysisScopeComponent(props: AdditionalCategoryComponentProps) {
  97. return <AnalysisScope {...props} />;
  98. }
  99. function getAlmIntegrationComponent(props: AdditionalCategoryComponentProps) {
  100. return <AlmIntegration {...props} />;
  101. }
  102. function getPullRequestDecorationBindingComponent(props: AdditionalCategoryComponentProps) {
  103. return props.component && <PullRequestDecorationBinding component={props.component} />;
  104. }