import { WorkspaceContext } from '../../../components/workspace/context';
import { mockIssue, mockRuleDetails } from '../../../helpers/testMocks';
import { renderComponent } from '../../../helpers/testReactTestingUtils';
-import { byLabelText, byRole, byText } from '../../../helpers/testSelector';
-import { RuleStatus } from '../../../types/rules';
+import { byRole, byText } from '../../../helpers/testSelector';
import { Dict } from '../../../types/types';
import IssueHeader from '../components/IssueHeader';
codeVariants: ['first', 'second'],
effort: '5min',
quickFixAvailable: true,
- ruleStatus: RuleStatus.Deprecated,
externalRuleEngine: 'eslint',
},
},
- { eslint: 'yes' }
+ { eslint: 'eslint' }
);
// Title
// SonarLint badge
expect(byText('issue.quick_fix_available_with_sonarlint_no_link').get()).toBeInTheDocument();
- // Rule status - Deprecated
- expect(byLabelText(`issue.resolution.badge.${RuleStatus.Deprecated}`).get()).toBeInTheDocument();
-
// Rule external engine
- expect(byText(/issue.resolution.badge/).get()).toBeInTheDocument();
+ expect(byText('eslint').get()).toBeInTheDocument();
});
it('renders correctly when some data is not provided', () => {
byText('issue.quick_fix_available_with_sonarlint_no_link').query()
).not.toBeInTheDocument();
- // Rule status deprecated
- expect(
- byLabelText(`issue.resolution.badge.${RuleStatus.Deprecated}`).query()
- ).not.toBeInTheDocument();
-
// Rule external engine
- expect(byText(/issue.resolution.badge/).query()).not.toBeInTheDocument();
+ expect(byText('eslint').query()).not.toBeInTheDocument();
});
function renderIssueHeader(
await expect(
screen.getByText('issue.quick_fix_available_with_sonarlint_no_link')
).toHaveATooltipWithContent('issue.quick_fix_available_with_sonarlint');
-
- expect(
- screen.getByRole('status', {
- name: 'issue.resolution.badge.DEPRECATED',
- })
- ).toBeInTheDocument();
});
});
import { setIssueAssignee } from '../../../api/issues';
import { updateIssue } from '../../../components/issue/actions';
import IssueActionsBar from '../../../components/issue/components/IssueActionsBar';
-import { RuleBadge } from '../../../components/issue/components/IssueBadges';
import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill';
import SoftwareImpactPill from '../../../components/shared/SoftwareImpactPill';
import { WorkspaceContext } from '../../../components/workspace/context';
import { getComponentIssuesUrl, getPathUrlAsString, getRuleUrl } from '../../../helpers/urls';
import { BranchLike } from '../../../types/branch-like';
import { IssueActions, IssueType } from '../../../types/issues';
-import { RuleStatus } from '../../../types/rules';
import { Issue, RuleDetails } from '../../../types/types';
import IssueHeaderMeta from './IssueHeaderMeta';
return null;
}}
</WorkspaceContext.Consumer>
- {(issue.ruleStatus === RuleStatus.Deprecated ||
- issue.ruleStatus === RuleStatus.Removed) && (
- <RuleBadge ruleStatus={issue.ruleStatus} className="sw-ml-1" />
- )}
</Note>
);
};
IssueTransition,
IssueType,
} from '../../../types/issues';
-import { RuleStatus } from '../../../types/rules';
import Issue from '../Issue';
jest.mock('../../../helpers/preferences', () => ({
expect(onClick).toHaveBeenCalledWith(issue.key);
});
- it.each([RuleStatus.Deprecated, RuleStatus.Removed])(
- 'should render correctly for a %s rule',
- (ruleStatus) => {
- const { ui } = getPageObject();
- renderIssue({ issue: mockIssue(false, { ruleStatus }) });
- expect(ui.ruleStatusBadge(ruleStatus).get()).toBeInTheDocument();
- }
- );
-
it('should render correctly for external rule engines', () => {
renderIssue({ issue: mockIssue(true, { externalRuleEngine: 'ESLINT' }) });
expect(screen.getByRole('status', { name: 'ESLINT' })).toBeInTheDocument();
const selectors = {
// Issue
- ruleStatusBadge: (status: RuleStatus) => byText(`issue.resolution.badge.${status}`),
locationsBadge: (count: number) => byText(count),
lineInfo: (line: number) => byText(`L${line}`),
effort: (effort: string) => byText(`issue.x_effort.${effort}`),
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import classNames from 'classnames';
-import { Badge } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
-import { translate, translateWithParameters } from '../../../helpers/l10n';
-import { RuleStatus } from '../../../types/rules';
-import DocumentationTooltip from '../../common/DocumentationTooltip';
+import { translate } from '../../../helpers/l10n';
import Link from '../../common/Link';
import Tooltip from '../../controls/Tooltip';
import SonarLintIcon from '../../icons/SonarLintIcon';
export interface IssueBadgesProps {
quickFixAvailable?: boolean;
- ruleStatus?: RuleStatus;
}
export default function IssueBadges(props: IssueBadgesProps) {
- const { quickFixAvailable, ruleStatus } = props;
+ const { quickFixAvailable } = props;
return (
<div className="sw-flex">
<SonarLintBadge quickFixAvailable={quickFixAvailable} />
- <span className={classNames({ 'sw-ml-2': quickFixAvailable })}>
- <RuleBadge ruleStatus={ruleStatus} />
- </span>
</div>
);
}
-export function RuleBadge({
- ruleStatus,
- className,
-}: {
- ruleStatus?: RuleStatus;
- className?: string;
-}) {
- if (ruleStatus === RuleStatus.Deprecated || ruleStatus === RuleStatus.Removed) {
- return (
- <DocumentationTooltip
- content={translate('rules.status', ruleStatus, 'help')}
- links={[
- {
- href: '/user-guide/rules/overview/',
- label: translateWithParameters('see_x', translate('rules')),
- },
- ]}
- >
- <Badge variant="deleted" className={className}>
- {translate('issue.resolution.badge', ruleStatus)}
- </Badge>
- </DocumentationTooltip>
- );
- }
-
- return null;
-}
-
export function SonarLintBadge({ quickFixAvailable }: { quickFixAvailable?: boolean }) {
if (quickFixAvailable) {
return (
import * as React from 'react';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import { isDefined } from '../../../helpers/types';
-import { RuleStatus } from '../../../types/rules';
import { Issue } from '../../../types/types';
import Tooltip from '../../controls/Tooltip';
import DateFromNow from '../../intl/DateFromNow';
return (
<ul className="sw-flex sw-items-center sw-gap-2 sw-body-sm">
<li className={issueMetaListItemClassNames}>
- <IssueBadges
- quickFixAvailable={issue.quickFixAvailable}
- ruleStatus={issue.ruleStatus as RuleStatus | undefined}
- />
+ <IssueBadges quickFixAvailable={issue.quickFixAvailable} />
</li>
{ruleEngine && (
issue.resolution.WONTFIX.description=Issues that are accepted in this context. They and their effort will be ignored.
issue.resolution.REMOVED=Removed
issue.resolution.REMOVED.description=Either the rule or the resource was changed (removed, relocated, parameters changed, etc.) so that analysis no longer finds these issues.
-issue.resolution.badge.REMOVED=Rule removed
-issue.resolution.badge.DEPRECATED=Rule deprecated
issue.unresolved.description=Unresolved issues have not been addressed in any way.
issue.action.permalink=Get permalink