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

Add the ability to enable or disable a token #12876

Merged
merged 1 commit into from
Mar 25, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1. [12827](https://github.com/influxdata/influxdb/pull/12827): Fix screen tearing bug in Raw Data View
1. [12843](https://github.com/influxdata/influxdb/pull/12843): Add copy to clipboard button to export overlays
1. [12826](https://github.com/influxdata/influxdb/pull/12826): Enable copying error messages to the clipboard from dashboard cells
1. [12876](https://github.com/influxdata/influxdb/pull/12876): Add the ability to update token's status in Token list

### Bug Fixes

Expand Down
34 changes: 30 additions & 4 deletions ui/src/me/components/account/TokenRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import React, {PureComponent} from 'react'
import {connect} from 'react-redux'

// Actions
import {deleteAuthorization} from 'src/authorizations/actions'
import {
deleteAuthorization,
updateAuthorization,
} from 'src/authorizations/actions'

// Components
import {Alignment, ComponentSize} from '@influxdata/clockface'
import {Alignment, ComponentSize, SlideToggle} from '@influxdata/clockface'
import {IndexList, ComponentSpacer, ConfirmationButton} from 'src/clockface'

// Types
Expand All @@ -19,13 +22,14 @@ interface OwnProps {

interface DispatchProps {
onDelete: typeof deleteAuthorization
onUpdate: typeof updateAuthorization
}

type Props = DispatchProps & OwnProps

class TokenRow extends PureComponent<Props> {
public render() {
const {description, status, id} = this.props.auth
const {description, id} = this.props.auth

return (
<IndexList.Row>
Expand All @@ -38,7 +42,13 @@ class TokenRow extends PureComponent<Props> {
{description}
</a>
</IndexList.Cell>
<IndexList.Cell>{status}</IndexList.Cell>
<IndexList.Cell>
<SlideToggle
active={this.isTokenEnbled}
size={ComponentSize.ExtraSmall}
onChange={this.changeToggle}
/>
</IndexList.Cell>
<IndexList.Cell alignment={Alignment.Right} revealOnHover={true}>
<ComponentSpacer align={Alignment.Right}>
<ConfirmationButton
Expand All @@ -53,6 +63,21 @@ class TokenRow extends PureComponent<Props> {
)
}

private get isTokenEnbled(): boolean {
const {auth} = this.props
return auth.status === Authorization.StatusEnum.Active
}

private changeToggle = () => {
const {auth, onUpdate} = this.props
if (auth.status === Authorization.StatusEnum.Active) {
auth.status = Authorization.StatusEnum.Inactive
} else {
auth.status = Authorization.StatusEnum.Active
}
onUpdate(auth)
}

private handleDelete = () => {
const {id, description} = this.props.auth
this.props.onDelete(id, description)
Expand All @@ -66,6 +91,7 @@ class TokenRow extends PureComponent<Props> {

const mdtp = {
onDelete: deleteAuthorization,
onUpdate: updateAuthorization,
}

export default connect<{}, DispatchProps, OwnProps>(
Expand Down