]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11066 Fix home link in unauthorized page
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 7 Aug 2018 12:02:33 +0000 (14:02 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 9 Aug 2018 18:20:50 +0000 (20:20 +0200)
server/sonar-web/src/main/js/apps/sessions/components/Unauthorized.tsx
server/sonar-web/src/main/js/apps/sessions/components/__tests__/Unauthorized-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/apps/sessions/components/__tests__/__snapshots__/Unauthorized-test.tsx.snap [new file with mode: 0644]

index c765e11ca1534593fc45c0b844c9615bc3cf0aa6..fd7c6b24d00ba1ea84ddc69125e527600640303b 100644 (file)
@@ -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 (
-    <div id="bd" className="page-wrapper-simple">
-      <div id="nonav" className="page-simple">
+    <div className="page-wrapper-simple" id="bd">
+      <div className="page-simple" id="nonav">
         <div className="text-center">
           <p id="unauthorized">{translate('unauthorized.message')}</p>
 
-          {!!message && (
+          {Boolean(message) && (
             <p className="spacer-top">
               {translate('unauthorized.reason')} {message}
             </p>
           )}
 
           <div className="big-spacer-top">
-            <Link to="/">{translate('layout.home')}</Link>
+            <a href={getBaseUrl() + '/'}>{translate('layout.home')}</a>
           </div>
         </div>
       </div>
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 (file)
index 0000000..c66726c
--- /dev/null
@@ -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(<Unauthorized location={{ query: { message: 'Foo' } }} />)).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 (file)
index 0000000..5c538ff
--- /dev/null
@@ -0,0 +1,39 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render 1`] = `
+<div
+  className="page-wrapper-simple"
+  id="bd"
+>
+  <div
+    className="page-simple"
+    id="nonav"
+  >
+    <div
+      className="text-center"
+    >
+      <p
+        id="unauthorized"
+      >
+        unauthorized.message
+      </p>
+      <p
+        className="spacer-top"
+      >
+        unauthorized.reason
+         
+        Foo
+      </p>
+      <div
+        className="big-spacer-top"
+      >
+        <a
+          href="/"
+        >
+          layout.home
+        </a>
+      </div>
+    </div>
+  </div>
+</div>
+`;