From: Stas Vilchik Date: Thu, 8 Feb 2018 11:15:41 +0000 (+0100) Subject: SONAR-10299 drop special rendering of developer connection link X-Git-Tag: 7.5~1646 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=152588a68d439f3b48b448c56b83e592259dea52;p=sonarqube.git SONAR-10299 drop special rendering of developer connection link --- 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 ( +
  • + + {link.name} + +
  • + ); } -export default class MetaLink extends React.PureComponent { - state: State = { expanded: false }; - - handleClick = (e: React.SyntheticEvent) => { - e.preventDefault(); - e.currentTarget.blur(); - this.setState((s: State) => ({ expanded: !s.expanded })); - }; - - handleInputClick = (e: React.SyntheticEvent) => { - e.currentTarget.select(); - }; - - renderLinkIcon = (link: ProjectLink) => { - if (link.type === 'issue') { - return ; - } - - return isProvided(link) ? ( - - ) : ( - - ); - }; - - render() { - const { link } = this.props; - - return ( -
  • - - {this.renderLinkIcon(link)} -   - {link.name} - - {this.state.expanded && ( -
    - -
    - )} -
  • - ); +function MetaLinkIcon({ link }: Props) { + if (link.type === 'issue') { + return ; } + + return isProvided(link) ? ( + + ) : ( + + ); } 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`] = ` - -   + Foo @@ -22,26 +29,22 @@ exports[`should expand and collapse link 2`] = ` - -   + Foo -
    - -
    `; @@ -50,13 +53,20 @@ exports[`should expand and collapse link 3`] = ` - -   + Foo @@ -67,12 +77,20 @@ exports[`should match snapshot 1`] = ` - -   + Foo 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 ( - - {link.url} - - ); - } - - return link.url; - } - renderDeleteButton(link) { if (isProvided(link)) { return null; @@ -112,7 +100,11 @@ export default class LinkRow extends React.PureComponent { return ( {this.renderName(link)} - {this.renderUrl(link)} + + + {link.url} + + {this.renderDeleteButton(link)} ); 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; -}