fix(ui/dashboards): prevent default on anchor tag (#14434)

fix(ui/editable_name): update anchor to Link tag
pull/14441/head
Delmer 2019-07-24 15:15:47 -04:00 committed by GitHub
parent e3cc930d75
commit e7a92f57cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 30 deletions

View File

@ -32,17 +32,12 @@ const CheckCard: FunctionComponent<Props> = ({
check, check,
updateCheck, updateCheck,
deleteCheck, deleteCheck,
router,
params: {orgID}, params: {orgID},
}) => { }) => {
const onUpdateName = (name: string) => { const onUpdateName = (name: string) => {
updateCheck({id: check.id, name}) updateCheck({id: check.id, name})
} }
const onClickName = () => {
router.push(`/orgs/${orgID}/checks/${check.id}`)
}
const onDelete = () => { const onDelete = () => {
deleteCheck(check.id) deleteCheck(check.id)
} }
@ -66,7 +61,7 @@ const CheckCard: FunctionComponent<Props> = ({
name={() => ( name={() => (
<ResourceList.EditableName <ResourceList.EditableName
onUpdate={onUpdateName} onUpdate={onUpdateName}
onClick={onClickName} hrefValue={`/orgs/${orgID}/checks/${check.id}`}
name={check.name} name={check.name}
noNameString={DEFAULT_CHECK_NAME} noNameString={DEFAULT_CHECK_NAME}
parentTestID="check-card--name" parentTestID="check-card--name"

View File

@ -35,17 +35,12 @@ const NotificationRuleCard: FunctionComponent<Props> = ({
notificationRule, notificationRule,
updateNotificationRule, updateNotificationRule,
deleteNotificationRule, deleteNotificationRule,
router,
params: {orgID}, params: {orgID},
}) => { }) => {
const onUpdateName = (name: string) => { const onUpdateName = (name: string) => {
updateNotificationRule({id: notificationRule.id, name}) updateNotificationRule({id: notificationRule.id, name})
} }
const onClickName = () => {
router.push(`/orgs/${orgID}/notificationRules/${notificationRule.id}`)
}
const onDelete = () => { const onDelete = () => {
deleteNotificationRule(notificationRule.id) deleteNotificationRule(notificationRule.id)
} }
@ -69,7 +64,7 @@ const NotificationRuleCard: FunctionComponent<Props> = ({
name={() => ( name={() => (
<ResourceList.EditableName <ResourceList.EditableName
onUpdate={onUpdateName} onUpdate={onUpdateName}
onClick={onClickName} hrefValue={`/orgs/${orgID}/notificationRules/${notificationRule.id}`}
name={notificationRule.name} name={notificationRule.name}
noNameString={DEFAULT_NOTIFICATION_RULE_NAME} noNameString={DEFAULT_NOTIFICATION_RULE_NAME}
parentTestID="notificationRule-card--name" parentTestID="notificationRule-card--name"

View File

@ -1,5 +1,5 @@
// Libraries // Libraries
import React, {PureComponent} from 'react' import React, {PureComponent, MouseEvent} from 'react'
import {connect} from 'react-redux' import {connect} from 'react-redux'
// Actions // Actions
@ -82,8 +82,11 @@ class TokenRow extends PureComponent<Props> {
this.props.onDelete(id, description) this.props.onDelete(id, description)
} }
private handleClickDescription = () => { private handleClickDescription = (e: MouseEvent<HTMLAnchorElement>) => {
const {onClickDescription, auth} = this.props const {onClickDescription, auth} = this.props
e.preventDefault()
onClickDescription(auth.id) onClickDescription(auth.id)
} }

View File

@ -1,6 +1,7 @@
// Libraries // Libraries
import React, {Component, KeyboardEvent, ChangeEvent, MouseEvent} from 'react' import React, {Component, KeyboardEvent, ChangeEvent, MouseEvent} from 'react'
import classnames from 'classnames' import classnames from 'classnames'
import {Link} from 'react-router'
// Components // Components
import {Input, SpinnerContainer, TechnoSpinner} from '@influxdata/clockface' import {Input, SpinnerContainer, TechnoSpinner} from '@influxdata/clockface'
@ -16,7 +17,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
interface Props { interface Props {
onUpdate: (name: string) => void onUpdate: (name: string) => void
name: string name: string
onClick?: (e: MouseEvent<HTMLAnchorElement>) => void onClick?: (e: MouseEvent) => void
placeholder?: string placeholder?: string
noNameString: string noNameString: string
parentTestID: string parentTestID: string
@ -65,9 +66,9 @@ class ResourceEditableName extends Component<Props, State> {
loading={this.state.loading} loading={this.state.loading}
spinnerComponent={<TechnoSpinner diameterPixels={20} />} spinnerComponent={<TechnoSpinner diameterPixels={20} />}
> >
<a href={hrefValue} onClick={this.handleClick}> <Link to={hrefValue} onClick={this.handleClick}>
<span>{name || noNameString}</span> <span>{name || noNameString}</span>
</a> </Link>
</SpinnerContainer> </SpinnerContainer>
<div <div
className="resource-editable-name--toggle" className="resource-editable-name--toggle"
@ -106,8 +107,9 @@ class ResourceEditableName extends Component<Props, State> {
} }
} }
private handleClick = (e: MouseEvent<HTMLAnchorElement>) => { private handleClick = (e: MouseEvent) => {
const {onClick} = this.props const {onClick} = this.props
if (onClick) { if (onClick) {
onClick(e) onClick(e)
} }

View File

@ -49,7 +49,12 @@ type Props = PassedProps & DispatchProps & StateProps & WithRouterProps
class DashboardCard extends PureComponent<Props> { class DashboardCard extends PureComponent<Props> {
public render() { public render() {
const {dashboard, onFilterChange, labels} = this.props const {
dashboard,
onFilterChange,
labels,
params: {orgID},
} = this.props
const {id} = dashboard const {id} = dashboard
return ( return (
@ -59,6 +64,7 @@ class DashboardCard extends PureComponent<Props> {
name={() => ( name={() => (
<ResourceList.EditableName <ResourceList.EditableName
onUpdate={this.handleUpdateDashboard} onUpdate={this.handleUpdateDashboard}
hrefValue={`/orgs/${orgID}/dashboards/${dashboard.id}`}
onClick={this.handleClickDashboard} onClick={this.handleClickDashboard}
name={dashboard.name} name={dashboard.name}
noNameString={DEFAULT_DASHBOARD_NAME} noNameString={DEFAULT_DASHBOARD_NAME}
@ -133,16 +139,9 @@ class DashboardCard extends PureComponent<Props> {
} }
private handleClickDashboard = () => { private handleClickDashboard = () => {
const { const {onResetViews} = this.props
router,
dashboard,
onResetViews,
params: {orgID},
} = this.props
onResetViews() onResetViews()
router.push(`/orgs/${orgID}/dashboards/${dashboard.id}`)
} }
private handleUpdateDescription = (description: string): void => { private handleUpdateDescription = (description: string): void => {

View File

@ -116,7 +116,7 @@ export class TaskCard extends PureComponent<Props & WithRouterProps> {
) )
} }
private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => { private handleNameClick = (e: MouseEvent) => {
e.preventDefault() e.preventDefault()
this.props.onSelect(this.props.task) this.props.onSelect(this.props.task)

View File

@ -146,8 +146,9 @@ class CollectorRow extends PureComponent<Props & WithRouterProps> {
} }
} }
private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => { private handleNameClick = (e: MouseEvent) => {
e.preventDefault() e.preventDefault()
this.handleOpenConfig() this.handleOpenConfig()
} }

View File

@ -191,8 +191,9 @@ class TemplateCard extends PureComponent<Props & WithRouterProps> {
onClone(id) onClone(id)
} }
private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => { private handleNameClick = (e: MouseEvent) => {
e.preventDefault() e.preventDefault()
this.handleViewTemplate() this.handleViewTemplate()
} }