diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-02-08 12:15:41 +0100 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2018-02-20 10:06:52 +0100 |
commit | 152588a68d439f3b48b448c56b83e592259dea52 (patch) | |
tree | d97bbfab50e441e8a74e94a391690036ee729042 | |
parent | 73a157ba6181a3320dabe1caa452e18806cbd9f9 (diff) | |
download | sonarqube-152588a68d439f3b48b448c56b83e592259dea52.tar.gz sonarqube-152588a68d439f3b48b448c56b83e592259dea52.zip |
SONAR-10299 drop special rendering of developer connection link
4 files changed, 68 insertions, 100 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx index b704420b5ed..04c7ae09745 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx +++ b/server/sonar-web/src/main/js/apps/overview/meta/MetaLink.tsx @@ -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)} - - {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" /> + ); } diff --git a/server/sonar-web/src/main/js/apps/overview/meta/__tests__/__snapshots__/MetaLink-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/meta/__tests__/__snapshots__/MetaLink-test.tsx.snap index 20c6a30481a..1b37c9bfe64 100644 --- a/server/sonar-web/src/main/js/apps/overview/meta/__tests__/__snapshots__/MetaLink-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/overview/meta/__tests__/__snapshots__/MetaLink-test.tsx.snap @@ -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> diff --git a/server/sonar-web/src/main/js/apps/project-admin/links/LinkRow.js b/server/sonar-web/src/main/js/apps/project-admin/links/LinkRow.js index 5fcf1c694f7..9c36959c021 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/links/LinkRow.js +++ b/server/sonar-web/src/main/js/apps/project-admin/links/LinkRow.js @@ -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> ); diff --git a/server/sonar-web/src/main/js/apps/project-admin/links/utils.js b/server/sonar-web/src/main/js/apps/project-admin/links/utils.js index 9ae5e6ef3d7..bfd19ca8da7 100644 --- a/server/sonar-web/src/main/js/apps/project-admin/links/utils.js +++ b/server/sonar-web/src/main/js/apps/project-admin/links/utils.js @@ -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; -} |