Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ui/src/alerting/components/CheckCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ const CheckCard: FunctionComponent<Props> = ({
check,
updateCheck,
deleteCheck,
router,
params: {orgID},
}) => {
const onUpdateName = (name: string) => {
updateCheck({id: check.id, name})
}

const onClickName = () => {
router.push(`/orgs/${orgID}/checks/${check.id}`)
}

const onDelete = () => {
deleteCheck(check.id)
}
Expand All @@ -66,7 +61,7 @@ const CheckCard: FunctionComponent<Props> = ({
name={() => (
<ResourceList.EditableName
onUpdate={onUpdateName}
onClick={onClickName}
hrefValue={`/orgs/${orgID}/checks/${check.id}`}
name={check.name}
noNameString={DEFAULT_CHECK_NAME}
parentTestID="check-card--name"
Expand Down
7 changes: 1 addition & 6 deletions ui/src/alerting/components/NotificationRuleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,12 @@ const NotificationRuleCard: FunctionComponent<Props> = ({
notificationRule,
updateNotificationRule,
deleteNotificationRule,
router,
params: {orgID},
}) => {
const onUpdateName = (name: string) => {
updateNotificationRule({id: notificationRule.id, name})
}

const onClickName = () => {
router.push(`/orgs/${orgID}/notificationRules/${notificationRule.id}`)
}

const onDelete = () => {
deleteNotificationRule(notificationRule.id)
}
Expand All @@ -69,7 +64,7 @@ const NotificationRuleCard: FunctionComponent<Props> = ({
name={() => (
<ResourceList.EditableName
onUpdate={onUpdateName}
onClick={onClickName}
hrefValue={`/orgs/${orgID}/notificationRules/${notificationRule.id}`}
name={notificationRule.name}
noNameString={DEFAULT_NOTIFICATION_RULE_NAME}
parentTestID="notificationRule-card--name"
Expand Down
7 changes: 5 additions & 2 deletions ui/src/authorizations/components/TokenRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libraries
import React, {PureComponent} from 'react'
import React, {PureComponent, MouseEvent} from 'react'
import {connect} from 'react-redux'

// Actions
Expand Down Expand Up @@ -82,8 +82,11 @@ class TokenRow extends PureComponent<Props> {
this.props.onDelete(id, description)
}

private handleClickDescription = () => {
private handleClickDescription = (e: MouseEvent<HTMLAnchorElement>) => {
const {onClickDescription, auth} = this.props

e.preventDefault()

onClickDescription(auth.id)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Libraries
import React, {Component, KeyboardEvent, ChangeEvent, MouseEvent} from 'react'
import classnames from 'classnames'
import {Link} from 'react-router'

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

private handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
private handleClick = (e: MouseEvent) => {
const {onClick} = this.props

if (onClick) {
onClick(e)
}
Expand Down
17 changes: 8 additions & 9 deletions ui/src/dashboards/components/dashboard_index/DashboardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ type Props = PassedProps & DispatchProps & StateProps & WithRouterProps

class DashboardCard extends PureComponent<Props> {
public render() {
const {dashboard, onFilterChange, labels} = this.props
const {
dashboard,
onFilterChange,
labels,
params: {orgID},
} = this.props
const {id} = dashboard

return (
Expand All @@ -59,6 +64,7 @@ class DashboardCard extends PureComponent<Props> {
name={() => (
<ResourceList.EditableName
onUpdate={this.handleUpdateDashboard}
hrefValue={`/orgs/${orgID}/dashboards/${dashboard.id}`}
onClick={this.handleClickDashboard}
name={dashboard.name}
noNameString={DEFAULT_DASHBOARD_NAME}
Expand Down Expand Up @@ -133,16 +139,9 @@ class DashboardCard extends PureComponent<Props> {
}

private handleClickDashboard = () => {
const {
router,
dashboard,
onResetViews,
params: {orgID},
} = this.props
const {onResetViews} = this.props

onResetViews()

router.push(`/orgs/${orgID}/dashboards/${dashboard.id}`)
}

private handleUpdateDescription = (description: string): void => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/tasks/components/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class TaskCard extends PureComponent<Props & WithRouterProps> {
)
}

private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => {
private handleNameClick = (e: MouseEvent) => {
e.preventDefault()

this.props.onSelect(this.props.task)
Expand Down
3 changes: 2 additions & 1 deletion ui/src/telegrafs/components/CollectorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ class CollectorRow extends PureComponent<Props & WithRouterProps> {
}
}

private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => {
private handleNameClick = (e: MouseEvent) => {
e.preventDefault()

this.handleOpenConfig()
}

Expand Down
3 changes: 2 additions & 1 deletion ui/src/templates/components/TemplateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ class TemplateCard extends PureComponent<Props & WithRouterProps> {
onClone(id)
}

private handleNameClick = (e: MouseEvent<HTMLAnchorElement>) => {
private handleNameClick = (e: MouseEvent) => {
e.preventDefault()

this.handleViewTemplate()
}

Expand Down