*/
import * as React from 'react';
+import { colors } from '../../../app/theme';
+import DocumentationTooltip from '../../../components/common/DocumentationTooltip';
import Link from '../../../components/common/Link';
import Dropdown from '../../../components/controls/Dropdown';
import HelpTooltip from '../../../components/controls/HelpTooltip';
import Tooltip from '../../../components/controls/Tooltip';
import { ButtonLink } from '../../../components/controls/buttons';
+import IssueTypeIcon from '../../../components/icons/IssueTypeIcon';
import LinkIcon from '../../../components/icons/LinkIcon';
import DateFormatter from '../../../components/intl/DateFormatter';
import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill';
+import SeverityHelper from '../../../components/shared/SeverityHelper';
import SoftwareImpactPill from '../../../components/shared/SoftwareImpactPill';
import TagsList from '../../../components/tags/TagsList';
import { PopupPlacement } from '../../../components/ui/popups';
const EXTERNAL_RULE_REPO_PREFIX = 'external_';
export default class RuleDetailsMeta extends React.PureComponent<Props> {
+ renderType = () => {
+ const { ruleDetails } = this.props;
+ return (
+ <li className="coding-rules-detail-property muted" data-meta="type">
+ <DocumentationTooltip
+ content={
+ <>
+ <p className="sw-mb-4">{translate('coding_rules.type.deprecation.title')}</p>
+ <p>{translate('coding_rules.type.deprecation.filter_by')}</p>
+ </>
+ }
+ links={[
+ {
+ href: '/user-guide/rules',
+ label: translate('learn_more'),
+ },
+ ]}
+ >
+ <IssueTypeIcon className="little-spacer-right" query={ruleDetails.type} />
+ {translate('issue.type', ruleDetails.type)}
+ </DocumentationTooltip>
+ </li>
+ );
+ };
+
+ renderSeverity = () => (
+ <li className="coding-rules-detail-property muted" data-meta="severity">
+ <DocumentationTooltip
+ content={
+ <>
+ <p className="sw-mb-4">{translate('coding_rules.severity.deprecation.title')}</p>
+ <p>{translate('coding_rules.severity.deprecation.filter_by')}</p>
+ </>
+ }
+ links={[
+ {
+ href: '/user-guide/rules',
+ label: translate('learn_more'),
+ },
+ ]}
+ >
+ <SeverityHelper
+ fill={colors.neutral200}
+ className="display-inline-flex-center"
+ severity={this.props.ruleDetails.severity}
+ />
+ </DocumentationTooltip>
+ </li>
+ );
+
renderStatus = () => {
const { ruleDetails } = this.props;
if (ruleDetails.status === 'READY') {
const allTags = [...sysTags, ...tags];
return (
- <li className="coding-rules-detail-property" data-meta="tags">
+ <div className="coding-rules-detail-property null-spacer-bottom" data-meta="tags">
{this.props.canWrite ? (
<Dropdown
closeOnClick={false}
tags={tags}
/>
}
- overlayPlacement={PopupPlacement.BottomLeft}
+ overlayPlacement={PopupPlacement.BottomRight}
>
<ButtonLink>
<TagsList
tags={allTags.length > 0 ? allTags : [translate('coding_rules.no_tags')]}
/>
)}
- </li>
+ </div>
);
};
const hasTypeData = !ruleDetails.isExternal || ruleDetails.type !== 'UNKNOWN';
return (
<div className="js-rule-meta">
- {ruleDetails.cleanCodeAttributeCategory !== undefined && (
- <CleanCodeAttributePill
- className="big-spacer-bottom"
- cleanCodeAttributeCategory={ruleDetails.cleanCodeAttributeCategory}
- cleanCodeAttribute={ruleDetails.cleanCodeAttribute}
- type="rule"
- />
- )}
-
- <div className="page-header">
- <div className="pull-right">
+ <div className="display-flex-space-between spacer-bottom">
+ {ruleDetails.cleanCodeAttributeCategory !== undefined && (
+ <CleanCodeAttributePill
+ cleanCodeAttributeCategory={ruleDetails.cleanCodeAttributeCategory}
+ cleanCodeAttribute={ruleDetails.cleanCodeAttribute}
+ type="rule"
+ />
+ )}
+ <div className="pull-right display-flex-center spacer-right">
{this.renderKey()}
{!ruleDetails.isExternal && (
<Link
</Link>
)}
</div>
+ </div>
+
+ <div className="display-flex-space-between big-spacer-bottom">
<h1 className="page-title coding-rules-detail-header">{ruleDetails.name}</h1>
+ {this.renderTags()}
</div>
<div className="display-flex-center">
- {ruleDetails.impacts !== undefined && (
+ {!!ruleDetails.impacts.length && (
<div className="sw-flex sw-items-center flex-1">
<span>{translate('issue.software_qualities.label')}</span>
<ul className="sw-flex sw-gap-2">
{hasTypeData && (
<ul className="coding-rules-detail-properties">
+ {this.renderType()}
+ {this.renderSeverity()}
{!ruleDetails.isExternal && this.renderStatus()}
- {this.renderTags()}
{!ruleDetails.isExternal && this.renderCreationDate()}
{this.renderRepository()}
{!ruleDetails.isExternal && (
<Icon {...iconProps}>
<path
d="M8 14c-3.311 0-6-2.689-6-6s2.689-6 6-6 6 2.689 6 6-2.689 6-6 6zM7 9h2V4H7v5zm0 3h2v-2H7v2z"
- style={{ fill: colors.red, fillRule: 'nonzero' }}
+ style={{ fill: iconProps.fill ?? colors.red, fillRule: 'nonzero' }}
/>
</Icon>
);
<Icon {...iconProps}>
<path
d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 10V7.414l1.893 1.893c.13.124.282.216.457.261a1.006 1.006 0 0 0 1.176-.591 1.01 1.01 0 0 0 .01-.729 1.052 1.052 0 0 0-.229-.355c-1.212-1.212-2.394-2.456-3.638-3.636a1.073 1.073 0 0 0-.169-.123 1.05 1.05 0 0 0-.448-.133h-.104a1.053 1.053 0 0 0-.493.16 1.212 1.212 0 0 0-.162.132C6.08 5.505 4.836 6.687 3.656 7.932a.994.994 0 0 0-.051 1.275c.208.271.548.42.888.389.198-.019.378-.098.535-.218.041-.035.04-.034.079-.071L7 7.414V12h2z"
- style={{ fill: colors.red, fillRule: 'nonzero' }}
+ style={{ fill: iconProps.fill ?? colors.red, fillRule: 'nonzero' }}
/>
</Icon>
);
<Icon {...iconProps}>
<path
d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm.08 2.903c.071.008.14.019.208.039.138.042.26.114.37.205 1.244 1.146 2.426 2.357 3.639 3.536.1.103.181.218.234.352a1.01 1.01 0 0 1 .001.728 1.002 1.002 0 0 1-1.169.609 1.042 1.042 0 0 1-.46-.255L8 7.295l-2.903 2.822c-.039.036-.039.036-.08.07a1.002 1.002 0 0 1-1.604-.947c.032-.196.122-.37.253-.519C4.847 7.51 6.09 6.362 7.303 5.183c.052-.048.106-.093.167-.131a1.041 1.041 0 0 1 .61-.149z"
- style={{ fill: colors.red }}
+ style={{ fill: iconProps.fill ?? colors.red }}
/>
</Icon>
);
<Icon {...iconProps}>
<path
d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 6.586V4H7v4.586L5.107 6.693a1.178 1.178 0 0 0-.165-.134 1.041 1.041 0 0 0-.662-.152 1 1 0 0 0-.587 1.7c1.212 1.212 2.394 2.456 3.638 3.636.094.08.195.146.311.191a1.008 1.008 0 0 0 1.065-.227c1.213-1.212 2.457-2.394 3.637-3.639a.994.994 0 0 0 .051-1.275 1.012 1.012 0 0 0-.888-.389 1.041 1.041 0 0 0-.535.218c-.04.034-.04.034-.079.071L9 8.586z"
- style={{ fill: colors.green }}
+ style={{ fill: iconProps.fill ?? colors.green }}
/>
</Icon>
);
<Icon {...iconProps}>
<path
d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 5H7v5h2V7zm0-3H7v2h2V4z"
- style={{ fill: colors.darkBlue }}
+ style={{ fill: iconProps.fill ?? colors.darkBlue }}
/>
</Icon>
);