From 085bee632b84b3e1e034fb4de27788c5fd91e133 Mon Sep 17 00:00:00 2001 From: stanislavh Date: Wed, 5 Jul 2023 14:03:51 +0200 Subject: [PATCH] SONAR-19633 Some links are badly formatted when SQ is configured with a root URL --- .../js/apps/projectDump/components/Export.tsx | 3 +- .../details/ProfileExporters.tsx | 63 ++++++++----------- .../__tests__/ProfileExporters-test.tsx | 5 +- .../authentication/SamlAuthenticationTab.tsx | 7 +-- .../js/components/common/FormattingTips.tsx | 3 +- server/sonar-web/src/main/js/helpers/urls.ts | 2 +- 6 files changed, 35 insertions(+), 48 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projectDump/components/Export.tsx b/server/sonar-web/src/main/js/apps/projectDump/components/Export.tsx index 2e3f9fe9dcb..c97edfef2fc 100644 --- a/server/sonar-web/src/main/js/apps/projectDump/components/Export.tsx +++ b/server/sonar-web/src/main/js/apps/projectDump/components/Export.tsx @@ -25,7 +25,6 @@ import DateFromNow from '../../../components/intl/DateFromNow'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { Alert } from '../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { getBaseUrl } from '../../../helpers/system'; import { DumpStatus, DumpTask } from '../../../types/project-dump'; interface Props { @@ -100,7 +99,7 @@ export default class Export extends React.Component { renderWhenExportFailed() { const { componentKey } = this.props; - const detailsUrl = `${getBaseUrl()}/project/background_tasks?id=${encodeURIComponent( + const detailsUrl = `/project/background_tasks?id=${encodeURIComponent( componentKey )}&status=FAILED&taskType=PROJECT_EXPORT`; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx index ae138ecec41..a8569f1c1cd 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileExporters.tsx @@ -22,7 +22,6 @@ import { getQualityProfileExporterUrl } from '../../../api/quality-profiles'; import Link from '../../../components/common/Link'; import { Alert } from '../../../components/ui/Alert'; import { translate } from '../../../helpers/l10n'; -import { getBaseUrl } from '../../../helpers/system'; import { Exporter, Profile } from '../types'; interface Props { @@ -30,42 +29,34 @@ interface Props { profile: Profile; } -export default class ProfileExporters extends React.PureComponent { - getExportUrl(exporter: Exporter) { - const { profile } = this.props; - return `${getBaseUrl()}${getQualityProfileExporterUrl(exporter, profile)}`; - } - - render() { - const { exporters, profile } = this.props; - const exportersForLanguage = exporters.filter((e) => e.languages.includes(profile.language)); +export default function ProfileExporters({ exporters, profile }: Props) { + const exportersForLanguage = exporters.filter((e) => e.languages.includes(profile.language)); - if (exportersForLanguage.length === 0) { - return null; - } + if (exportersForLanguage.length === 0) { + return null; + } - return ( -
-

{translate('quality_profiles.exporters')}

-
- - {translate('quality_profiles.exporters.deprecated')} - -
    - {exportersForLanguage.map((exporter, index) => ( -
  • 0 ? 'spacer-top' : undefined} - data-key={exporter.key} - key={exporter.key} - > - - {exporter.name} - -
  • - ))} -
-
+ return ( +
+

{translate('quality_profiles.exporters')}

+
+ + {translate('quality_profiles.exporters.deprecated')} + +
    + {exportersForLanguage.map((exporter, index) => ( +
  • 0 ? 'spacer-top' : undefined} + data-key={exporter.key} + key={exporter.key} + > + + {exporter.name} + +
  • + ))} +
- ); - } +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx index 06119751512..ca8d96a1520 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/__tests__/ProfileExporters-test.tsx @@ -20,6 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { mockQualityProfile, mockQualityProfileExporter } from '../../../../helpers/testMocks'; +import { FCProps } from '../../../../types/misc'; import ProfileExporters from '../ProfileExporters'; it('should render correctly', () => { @@ -27,9 +28,9 @@ it('should render correctly', () => { expect(wrapper).toMatchSnapshot(); }); -function shallowRender(props: Partial = {}) { +function shallowRender(props: Partial> = {}) { const profile = mockQualityProfile(); - return shallow( + return shallow(
- + {translate('settings.authentication.saml.form.test')}