From a8f14ced18503abb466fefead861ea3d60f7115a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 7 Aug 2018 14:02:33 +0200 Subject: [PATCH] SONAR-11066 Fix home link in unauthorized page --- .../apps/sessions/components/Unauthorized.tsx | 10 ++--- .../__tests__/Unauthorized-test.tsx | 26 +++++++++++++ .../__snapshots__/Unauthorized-test.tsx.snap | 39 +++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/sessions/components/__tests__/Unauthorized-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/sessions/components/__tests__/__snapshots__/Unauthorized-test.tsx.snap diff --git a/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx b/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx index c765e11ca15..fd7c6b24d00 100644 --- a/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx +++ b/server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx @@ -18,8 +18,8 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { Link } from 'react-router'; import { translate } from '../../../helpers/l10n'; +import { getBaseUrl } from '../../../helpers/urls'; interface Props { location: { @@ -33,19 +33,19 @@ export default function Unauthorized(props: Props) { const { message } = props.location.query; return ( -
-
+
+

{translate('unauthorized.message')}

- {!!message && ( + {Boolean(message) && (

{translate('unauthorized.reason')} {message}

)}
- {translate('layout.home')} + {translate('layout.home')}
diff --git a/server/sonar-web/src/main/js/apps/sessions/components/__tests__/Unauthorized-test.tsx b/server/sonar-web/src/main/js/apps/sessions/components/__tests__/Unauthorized-test.tsx new file mode 100644 index 00000000000..c66726c4414 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/sessions/components/__tests__/Unauthorized-test.tsx @@ -0,0 +1,26 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as React from 'react'; +import { shallow } from 'enzyme'; +import Unauthorized from '../Unauthorized'; + +it('render', () => { + expect(shallow()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/sessions/components/__tests__/__snapshots__/Unauthorized-test.tsx.snap b/server/sonar-web/src/main/js/apps/sessions/components/__tests__/__snapshots__/Unauthorized-test.tsx.snap new file mode 100644 index 00000000000..5c538ff3ad3 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/sessions/components/__tests__/__snapshots__/Unauthorized-test.tsx.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`render 1`] = ` +
+
+
+

+ unauthorized.message +

+

+ unauthorized.reason + + Foo +

+ +
+
+
+`; -- 2.39.5