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.

DetailsContent.tsx 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 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 DocTooltip from '../../../components/docs/DocTooltip';
  23. import Conditions from './Conditions';
  24. import Projects from './Projects';
  25. export interface DetailsContentProps {
  26. isDefault?: boolean;
  27. metrics: T.Dict<T.Metric>;
  28. organization?: string;
  29. onAddCondition: (condition: T.Condition) => void;
  30. onRemoveCondition: (Condition: T.Condition) => void;
  31. onSaveCondition: (newCondition: T.Condition, oldCondition: T.Condition) => void;
  32. qualityGate: T.QualityGate;
  33. }
  34. export function DetailsContent(props: DetailsContentProps) {
  35. const { isDefault, metrics, organization, qualityGate } = props;
  36. const conditions = qualityGate.conditions || [];
  37. const actions = qualityGate.actions || ({} as any);
  38. return (
  39. <div className="layout-page-main-inner">
  40. <Conditions
  41. canEdit={actions.manageConditions}
  42. conditions={conditions}
  43. metrics={metrics}
  44. onAddCondition={props.onAddCondition}
  45. onRemoveCondition={props.onRemoveCondition}
  46. onSaveCondition={props.onSaveCondition}
  47. organization={organization}
  48. qualityGate={qualityGate}
  49. />
  50. <div className="quality-gate-section" id="quality-gate-projects">
  51. <header className="display-flex-center spacer-bottom">
  52. <h3>{translate('quality_gates.projects')}</h3>
  53. <DocTooltip
  54. className="spacer-left"
  55. doc={import(
  56. /* webpackMode: "eager" */ 'Docs/tooltips/quality-gates/quality-gate-projects.md'
  57. )}
  58. />
  59. </header>
  60. {isDefault ? (
  61. translate('quality_gates.projects_for_default')
  62. ) : (
  63. <Projects
  64. canEdit={actions.associateProjects}
  65. // pass unique key to re-mount the component when the quality gate changes
  66. key={qualityGate.id}
  67. organization={organization}
  68. qualityGate={qualityGate}
  69. />
  70. )}
  71. </div>
  72. </div>
  73. );
  74. }
  75. export default React.memo(DetailsContent);