]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10299 drop special rendering of developer connection link
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 8 Feb 2018 11:15:41 +0000 (12:15 +0100)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 20 Feb 2018 09:06:52 +0000 (10:06 +0100)
server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx
server/sonar-web/src/main/js/apps/overview/meta/__tests__/__snapshots__/MetaLink-test.tsx.snap
server/sonar-web/src/main/js/apps/project-admin/links/LinkRow.js
server/sonar-web/src/main/js/apps/project-admin/links/utils.js

index b704420b5ed61b411c23d0e88ae1f60cd5bee5cc..04c7ae09745cf55d0236d6556cc00bd5a55cfc17 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
-import { isProvided, isClickable } from '../../project-admin/links/utils';
+import { isProvided } from '../../project-admin/links/utils';
 import BugTrackerIcon from '../../../components/ui/BugTrackerIcon';
 import { ProjectLink } from '../../../api/projectLinks';
 
@@ -26,61 +26,24 @@ interface Props {
   link: ProjectLink;
 }
 
-interface State {
-  expanded: boolean;
+export default function MetaLink({ link }: Props) {
+  return (
+    <li>
+      <a className="link-with-icon" href={link.url} rel="nofollow" target="_blank">
+        <MetaLinkIcon link={link} /> {link.name}
+      </a>
+    </li>
+  );
 }
 
-export default class MetaLink extends React.PureComponent<Props, State> {
-  state: State = { expanded: false };
-
-  handleClick = (e: React.SyntheticEvent<HTMLAnchorElement>) => {
-    e.preventDefault();
-    e.currentTarget.blur();
-    this.setState((s: State) => ({ expanded: !s.expanded }));
-  };
-
-  handleInputClick = (e: React.SyntheticEvent<HTMLInputElement>) => {
-    e.currentTarget.select();
-  };
-
-  renderLinkIcon = (link: ProjectLink) => {
-    if (link.type === 'issue') {
-      return <BugTrackerIcon />;
-    }
-
-    return isProvided(link) ? (
-      <i className={`icon-color-link icon-${link.type}`} />
-    ) : (
-      <i className="icon-color-link icon-detach" />
-    );
-  };
-
-  render() {
-    const { link } = this.props;
-
-    return (
-      <li>
-        <a
-          className="link-with-icon"
-          href={link.url}
-          target="_blank"
-          onClick={!isClickable(link) ? this.handleClick : undefined}>
-          {this.renderLinkIcon(link)}
-          &nbsp;
-          {link.name}
-        </a>
-        {this.state.expanded && (
-          <div className="little-spacer-top">
-            <input
-              type="text"
-              className="overview-key"
-              value={link.url}
-              readOnly={true}
-              onClick={this.handleInputClick}
-            />
-          </div>
-        )}
-      </li>
-    );
+function MetaLinkIcon({ link }: Props) {
+  if (link.type === 'issue') {
+    return <BugTrackerIcon />;
   }
+
+  return isProvided(link) ? (
+    <i className={`icon-color-link icon-${link.type}`} />
+  ) : (
+    <i className="icon-color-link icon-detach" />
+  );
 }
index 20c6a30481a923d4d7be27233ba09c854e603da6..1b37c9bfe64a8d363273e8555778b49ad404496f 100644 (file)
@@ -5,13 +5,20 @@ exports[`should expand and collapse link 1`] = `
   <a
     className="link-with-icon"
     href="scm:git:git@github.com"
-    onClick={[Function]}
+    rel="nofollow"
     target="_blank"
   >
-    <i
-      className="icon-color-link icon-detach"
+    <MetaLinkIcon
+      link={
+        Object {
+          "id": "1",
+          "name": "Foo",
+          "type": "foo",
+          "url": "scm:git:git@github.com",
+        }
+      }
     />
-     
+     
     Foo
   </a>
 </li>
@@ -22,26 +29,22 @@ exports[`should expand and collapse link 2`] = `
   <a
     className="link-with-icon"
     href="scm:git:git@github.com"
-    onClick={[Function]}
+    rel="nofollow"
     target="_blank"
   >
-    <i
-      className="icon-color-link icon-detach"
+    <MetaLinkIcon
+      link={
+        Object {
+          "id": "1",
+          "name": "Foo",
+          "type": "foo",
+          "url": "scm:git:git@github.com",
+        }
+      }
     />
-     
+     
     Foo
   </a>
-  <div
-    className="little-spacer-top"
-  >
-    <input
-      className="overview-key"
-      onClick={[Function]}
-      readOnly={true}
-      type="text"
-      value="scm:git:git@github.com"
-    />
-  </div>
 </li>
 `;
 
@@ -50,13 +53,20 @@ exports[`should expand and collapse link 3`] = `
   <a
     className="link-with-icon"
     href="scm:git:git@github.com"
-    onClick={[Function]}
+    rel="nofollow"
     target="_blank"
   >
-    <i
-      className="icon-color-link icon-detach"
+    <MetaLinkIcon
+      link={
+        Object {
+          "id": "1",
+          "name": "Foo",
+          "type": "foo",
+          "url": "scm:git:git@github.com",
+        }
+      }
     />
-     
+     
     Foo
   </a>
 </li>
@@ -67,12 +77,20 @@ exports[`should match snapshot 1`] = `
   <a
     className="link-with-icon"
     href="http://example.com"
+    rel="nofollow"
     target="_blank"
   >
-    <i
-      className="icon-color-link icon-detach"
+    <MetaLinkIcon
+      link={
+        Object {
+          "id": "1",
+          "name": "Foo",
+          "type": "foo",
+          "url": "http://example.com",
+        }
+      }
     />
-     
+     
     Foo
   </a>
 </li>
index 5fcf1c694f7ded6afaf5a510c89b9c2feead4b1c..9c36959c021121b3618322ef4f89f2ee8ea1564c 100644 (file)
@@ -19,7 +19,7 @@
  */
 import React from 'react';
 import PropTypes from 'prop-types';
-import { isProvided, isClickable } from './utils';
+import { isProvided } from './utils';
 import { translate } from '../../../helpers/l10n';
 import BugTrackerIcon from '../../../components/ui/BugTrackerIcon';
 
@@ -82,18 +82,6 @@ export default class LinkRow extends React.PureComponent {
     );
   }
 
-  renderUrl(link) {
-    if (isClickable(link)) {
-      return (
-        <a href={link.url} target="_blank">
-          {link.url}
-        </a>
-      );
-    }
-
-    return link.url;
-  }
-
   renderDeleteButton(link) {
     if (isProvided(link)) {
       return null;
@@ -112,7 +100,11 @@ export default class LinkRow extends React.PureComponent {
     return (
       <tr data-name={link.name}>
         <td className="nowrap">{this.renderName(link)}</td>
-        <td className="nowrap js-url">{this.renderUrl(link)}</td>
+        <td className="nowrap js-url">
+          <a href={link.url} rel="nofollow" target="_blank">
+            {link.url}
+          </a>
+        </td>
         <td className="thin nowrap">{this.renderDeleteButton(link)}</td>
       </tr>
     );
index 9ae5e6ef3d7356fe561cff4a602b308cd87f870c..bfd19ca8da7c097bf4390bef2f92e74f2d1bf3be 100644 (file)
@@ -32,8 +32,3 @@ export function orderLinks(links) {
     ...sortBy(unknown, link => link.name.toLowerCase())
   ];
 }
-
-export function isClickable(link) {
-  // stupid simple check
-  return link.url.indexOf('http') === 0;
-}