]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20023 Remove rule deprecated and removed badges from list/details
authorstanislavh <stanislav.honcharov@sonarsource.com>
Thu, 17 Aug 2023 08:21:42 +0000 (10:21 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 18 Aug 2023 20:02:50 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/issues/__tests__/IssueHeader-it.tsx
server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx
server/sonar-web/src/main/js/apps/issues/components/IssueHeader.tsx
server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx
server/sonar-web/src/main/js/components/issue/components/IssueBadges.tsx
server/sonar-web/src/main/js/components/issue/components/IssueMetaBar.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 54fdfeb64a4cf7363b7fdf3725feba79b85b26c4..fce07fd17436c20b794ca735ff2b17b6ead18187 100644 (file)
@@ -22,8 +22,7 @@ import * as React from 'react';
 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';
 
@@ -38,11 +37,10 @@ it('renders correctly', async () => {
         codeVariants: ['first', 'second'],
         effort: '5min',
         quickFixAvailable: true,
-        ruleStatus: RuleStatus.Deprecated,
         externalRuleEngine: 'eslint',
       },
     },
-    { eslint: 'yes' }
+    { eslint: 'eslint' }
   );
 
   // Title
@@ -88,11 +86,8 @@ it('renders correctly', async () => {
   // 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', () => {
@@ -112,13 +107,8 @@ 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(
index 08cd336d4891abdcd4cc0fc518d19580c256fb0a..9ea10f02b66dd7ba9d3f2b562cbffd6c3939ede7 100644 (file)
@@ -657,12 +657,6 @@ describe('issues item', () => {
     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();
   });
 });
 
index 95aeb66c06431cc491aac6df2916ff8a1ef91d4c..a0b4fd5adba47d6d764e9d8d8c768009bd9f4934 100644 (file)
@@ -31,7 +31,6 @@ import * as React from 'react';
 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';
@@ -43,7 +42,6 @@ import { getKeyboardShortcutEnabled } from '../../../helpers/preferences';
 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';
 
@@ -148,10 +146,6 @@ export default class IssueHeader extends React.PureComponent<Props, State> {
             return null;
           }}
         </WorkspaceContext.Consumer>
-        {(issue.ruleStatus === RuleStatus.Deprecated ||
-          issue.ruleStatus === RuleStatus.Removed) && (
-          <RuleBadge ruleStatus={issue.ruleStatus} className="sw-ml-1" />
-        )}
       </Note>
     );
   };
index b99f1ced82539099fc0fbde123f64b81e12b8420..f6d0752ed531f6aeb921024a9d55132e8374d353 100644 (file)
@@ -36,7 +36,6 @@ import {
   IssueTransition,
   IssueType,
 } from '../../../types/issues';
-import { RuleStatus } from '../../../types/rules';
 import Issue from '../Issue';
 
 jest.mock('../../../helpers/preferences', () => ({
@@ -66,15 +65,6 @@ describe('rendering', () => {
     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();
@@ -194,7 +184,6 @@ function getPageObject() {
 
   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}`),
index e62255154bc74bf23a2f3bb15793c580661d320c..f2ece1a912467aaf13084fb58380c602945a8ae9 100644 (file)
  * 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 (
index 14c5223eaa5baa7228c4af86616918f27f6db7c3..d25f0d6cf5d7cc50e41f10917f8e00d6ae1980cc 100644 (file)
@@ -23,7 +23,6 @@ import { Badge, CommentIcon, SeparatorCircleIcon, themeColor } from 'design-syst
 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';
@@ -52,10 +51,7 @@ export default function IssueMetaBar(props: Props) {
   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 && (
index f930730bd56023b136d2cf05da8f241ca6c0825e..d7a47cb9578026f9e242b9c4d91da971c411cfbd 100644 (file)
@@ -1064,8 +1064,6 @@ issue.resolution.WONTFIX=Won't Fix
 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