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.

RuleDetailsHeaderSide.tsx 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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 styled from '@emotion/styled';
  21. import { LightLabel, themeBorder } from 'design-system';
  22. import React from 'react';
  23. import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill';
  24. import SoftwareImpactPillList from '../../../components/shared/SoftwareImpactPillList';
  25. import { translate } from '../../../helpers/l10n';
  26. import { RuleDetails } from '../../../types/types';
  27. interface Props {
  28. ruleDetails: RuleDetails;
  29. }
  30. export default function RuleDetailsHeaderSide({ ruleDetails }: Readonly<Props>) {
  31. return (
  32. <StyledSection className="sw-flex sw-flex-col sw-pl-4 sw-gap-6 sw-max-w-[250px]">
  33. {ruleDetails.cleanCodeAttributeCategory && ruleDetails.cleanCodeAttribute && (
  34. <RuleHeaderInfo title={translate('coding_rules.cct_attribute.label')}>
  35. <CleanCodeAttributePill
  36. cleanCodeAttributeCategory={ruleDetails.cleanCodeAttributeCategory}
  37. cleanCodeAttribute={ruleDetails.cleanCodeAttribute}
  38. type="rule"
  39. />
  40. </RuleHeaderInfo>
  41. )}
  42. <RuleHeaderInfo title={translate('coding_rules.software_qualities.label')}>
  43. <SoftwareImpactPillList
  44. className="sw-flex-wrap"
  45. softwareImpacts={ruleDetails.impacts}
  46. type="rule"
  47. />
  48. </RuleHeaderInfo>
  49. </StyledSection>
  50. );
  51. }
  52. interface RuleHeaderMetaItemProps {
  53. children: React.ReactNode;
  54. title: string;
  55. className?: string;
  56. }
  57. function RuleHeaderInfo({ children, title, ...props }: Readonly<RuleHeaderMetaItemProps>) {
  58. return (
  59. <div {...props}>
  60. <LightLabel as="div" className="sw-text-xs sw-font-semibold sw-mb-1">
  61. {title}
  62. </LightLabel>
  63. {children}
  64. </div>
  65. );
  66. }
  67. const StyledSection = styled.div`
  68. border-left: ${themeBorder('default', 'pageBlockBorder')};
  69. `;