]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20154 Fix issues link
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 15 Aug 2023 09:11:31 +0000 (11:11 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Aug 2023 20:02:43 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/issues/test-utils.tsx
server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx
server/sonar-web/src/main/js/components/issue/components/IssueMessage.tsx

index 401d9d4924b20b9b95bde971f6fbe37930f3c9ab..764d733fa16cbc4a156727422e0e46e552a8ccef 100644 (file)
@@ -113,7 +113,7 @@ export async function waitOnDataLoaded() {
 }
 
 export function renderIssueApp(currentUser?: CurrentUser) {
-  renderApp('project/issues', <IssuesApp />, { currentUser: mockCurrentUser(currentUser) });
+  renderApp('issues', <IssuesApp />, { currentUser: mockCurrentUser(currentUser) });
 }
 
 export function renderProjectIssuesApp(navigateTo?: string, overrides?: Partial<Component>) {
index 2560444a0b101f68166a7d4abd1fc9f0eb819cc0..e7a4e18fff65a2a78ff48cdd0b64b956baae4913 100644 (file)
@@ -59,7 +59,7 @@ describe('rendering', () => {
     expect(ui.effort('2 days').get()).toBeInTheDocument();
     expect(ui.issueMessageLink.get()).toHaveAttribute(
       'href',
-      '/project/issues?scopes=MAIN&severities=MINOR&types=VULNERABILITY&open=AVsae-CQS-9G3txfbFN2&id=myproject'
+      '/issues?scopes=MAIN&severities=MINOR&types=VULNERABILITY&open=AVsae-CQS-9G3txfbFN2'
     );
 
     await ui.clickIssueMessage();
index 5e24e2959d116db2f38065b589ab296d91ddcdb9..ba011b04b1f6d3ce7826fa552573ca7fc6cd9833 100644 (file)
  */
 import { StandoutLink } from 'design-system';
 import * as React from 'react';
-import { parseQuery, serializeQuery } from '../../../apps/issues/utils';
+import { ComponentContext } from '../../../app/components/componentContext/ComponentContext';
+import { areMyIssuesSelected, parseQuery, serializeQuery } from '../../../apps/issues/utils';
 import { getBranchLikeQuery } from '../../../helpers/branch-like';
 import { translate } from '../../../helpers/l10n';
-import { getComponentIssuesUrl } from '../../../helpers/urls';
+import { getComponentIssuesUrl, getIssuesUrl } from '../../../helpers/urls';
 import { BranchLike } from '../../../types/branch-like';
 import { Issue } from '../../../types/types';
 import { useLocation } from '../../hoc/withRouter';
@@ -38,6 +39,9 @@ export default function IssueMessage(props: IssueMessageProps) {
   const { issue, branchLike, displayWhyIsThisAnIssue } = props;
   const location = useLocation();
   const query = parseQuery(location.query);
+  const myIssuesSelected = areMyIssuesSelected(location.query);
+
+  const { component } = React.useContext(ComponentContext);
 
   const { message, messageFormattings } = issue;
 
@@ -49,22 +53,22 @@ export default function IssueMessage(props: IssueMessageProps) {
     why: '1',
   });
 
-  const issueUrl = getComponentIssuesUrl(issue.project, {
+  const urlQuery = {
     ...getBranchLikeQuery(branchLike),
     ...serializeQuery(query),
+    myIssues: myIssuesSelected ? 'true' : undefined,
     open: issue.key,
-  });
+  };
+
+  const issueUrl = component?.key
+    ? getComponentIssuesUrl(component?.key, urlQuery)
+    : getIssuesUrl(urlQuery);
+
   return (
     <>
-      {issueUrl?.pathname ? (
-        <StandoutLink className="it__issue-message" to={issueUrl}>
-          <IssueMessageHighlighting message={message} messageFormattings={messageFormattings} />
-        </StandoutLink>
-      ) : (
-        <span className="spacer-right">
-          <IssueMessageHighlighting message={message} messageFormattings={messageFormattings} />
-        </span>
-      )}
+      <StandoutLink className="it__issue-message" to={issueUrl}>
+        <IssueMessageHighlighting message={message} messageFormattings={messageFormattings} />
+      </StandoutLink>
 
       {displayWhyIsThisAnIssue && (
         <StandoutLink