InheritanceIcon,
Link,
Note,
+ SeparatorCircleIcon,
SubTitle,
Table,
TableRow,
TableRowInteractive,
+ TextSubdued,
} from 'design-system';
import { filter } from 'lodash';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { Profile } from '../../../api/quality-profiles';
-import { useAvailableFeatures } from '../../../app/components/available-features/withAvailableFeatures';
import { translate } from '../../../helpers/l10n';
import { getQualityProfileUrl } from '../../../helpers/urls';
import {
useActivateRuleMutation,
useDeactivateRuleMutation,
} from '../../../queries/quality-profiles';
-import { Feature } from '../../../types/features';
import { Dict, RuleActivation, RuleDetails } from '../../../types/types';
import BuiltInQualityProfileBadge from '../../quality-profiles/components/BuiltInQualityProfileBadge';
import ActivatedRuleActions from './ActivatedRuleActions';
const { activations = [], referencedProfiles, ruleDetails, canDeactivateInherited } = props;
const { mutate: activateRule } = useActivateRuleMutation(props.onActivate);
const { mutate: deactivateRule } = useDeactivateRuleMutation(props.onDeactivate);
- const { hasFeature } = useAvailableFeatures();
const canActivate = Object.values(referencedProfiles).some((profile) =>
Boolean(profile.actions?.edit && profile.language === ruleDetails.lang),
ruleDetails.templateKey === undefined &&
ruleDetails?.params !== undefined &&
ruleDetails.params.length > 0;
- const showPrioritizedRuleColumn =
- hasFeature(Feature.PrioritizedRules) && activations.some((a) => a.prioritizedRule);
const handleDeactivate = (key?: string) => {
if (key !== undefined) {
return (
<TableRowInteractive key={profile.key}>
- <ContentCell className="sw-flex sw-flex-col sw-gap-2 sw-w-64">
- <div
- className="sw-truncate sw-w-full"
- title={`${profile.name}${
- profile.isBuiltIn ? ` (${translate('quality_profiles.built_in')})` : ''
- }`}
- >
+ <ContentCell className="sw-flex sw-flex-col sw-gap-2">
+ <div className="sw-self-start sw-flex sw-gap-2 sw-items-center">
<Link
+ className="sw-truncate sw-max-w-64"
aria-label={profile.name}
+ title={profile.name}
to={getQualityProfileUrl(profile.name, profile.language)}
>
{profile.name}
</Link>
- {profile.isBuiltIn && <BuiltInQualityProfileBadge className="sw-ml-2" />}
+ {activation.prioritizedRule && (
+ <>
+ <SeparatorCircleIcon />
+ <TextSubdued>{translate('coding_rules.prioritized_rule.title')}</TextSubdued>
+ </>
+ )}
+
+ {profile.isBuiltIn && <BuiltInQualityProfileBadge />}
</div>
{inheritedProfileSection}
</CellComponent>
)}
- {showPrioritizedRuleColumn && (
- <ContentCell>{activation.prioritizedRule && <span>{translate('yes')}</span>}</ContentCell>
- )}
-
{renderRowActions(activation, profile)}
</TableRowInteractive>
);
return (
<div className="js-rule-profiles sw-mb-8">
- <SubTitle id={PROFILES_HEADING_ID}>
- <FormattedMessage id="coding_rules.quality_profiles" />
- </SubTitle>
+ <div className="sw-flex sw-justify-between sw-items-end">
+ <div>
+ <SubTitle id={PROFILES_HEADING_ID}>
+ <FormattedMessage id="coding_rules.quality_profiles" />
+ </SubTitle>
+ <Note>
+ <FormattedMessage id="coding_rules.quality_profiles.description" />
+ </Note>
+ </div>
- {canActivate && (
- <ActivationButton
- buttonText={translate('coding_rules.activate')}
- className="sw-mt-6"
- modalHeader={translate('coding_rules.activate_in_quality_profile')}
- onDone={props.onActivate}
- profiles={filter(
- referencedProfiles,
- (profile) => !activations.find((activation) => activation.qProfile === profile.key),
- )}
- rule={ruleDetails}
- />
- )}
+ {canActivate && (
+ <ActivationButton
+ buttonText={translate('coding_rules.activate')}
+ modalHeader={translate('coding_rules.activate_in_quality_profile')}
+ onDone={props.onActivate}
+ profiles={filter(
+ referencedProfiles,
+ (profile) => !activations.find((activation) => activation.qProfile === profile.key),
+ )}
+ rule={ruleDetails}
+ />
+ )}
+ </div>
{activations.length > 0 && (
<Table
aria-labelledby={PROFILES_HEADING_ID}
className="sw-my-6"
- columnCount={MANDATORY_COLUMNS_COUNT + +showParamsColumn + +showPrioritizedRuleColumn}
+ columnCount={MANDATORY_COLUMNS_COUNT + +showParamsColumn}
header={
<TableRow>
<ContentCell>{translate('profile_name')}</ContentCell>
{showParamsColumn && <ContentCell>{translate('parameters')}</ContentCell>}
- {showPrioritizedRuleColumn && (
- <ContentCell>{translate('coding_rules.prioritized_rule.title')}</ContentCell>
- )}
<ActionCell>{translate('actions')}</ActionCell>
</TableRow>
}
coding_rules.parameters=Parameters
coding_rules.parameters.default_value=Default Value:
coding_rules.quality_profiles=Quality Profiles
+coding_rules.quality_profiles.description=List of all Quality Profiles where this rule is activated. Built-in profiles can't be changed.
coding_rules.quality_profiles.template_caption=This rule template was activated on the following profiles in previous versions of {instance}. It is not possible anymore to do so. Instead, please create a custom rule.
coding_rules.quality_profile=Quality Profile
coding_rules.reactivate=Reactivate
coding_rules.prioritized_rule.title=Prioritized rule
coding_rules.prioritized_rule.label={state, select, on {Mark} other {Unmark}} as Prioritized
coding_rules.prioritized_rule.switch_label=Indicates that all corresponding issues in Overall Code should be fixed
-coding_rules.prioritized_rule.note=You need to add a condition to your Quality Gate that checks whether any issues have been raised from the prioritized rules.
+coding_rules.prioritized_rule.note=For your Quality Gate to fail when corresponding issues exist in the overall code, you must add a condition that checks whether any issues have been raised from prioritized rules.
coding_rules.update_custom_rule=Update Custom Rule