Skip to content

Commit

Permalink
Add the ability to edit token's description
Browse files Browse the repository at this point in the history
  • Loading branch information
Palakp41 committed Apr 1, 2019
1 parent a7c3f20 commit 2683651
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v2.0.0-alpha.8 [unreleased]

### Features
1. [13024](https://github.com/influxdata/influxdb/pull/13024): Add the ability to edit token's description

### Bug Fixes

Expand Down
11 changes: 5 additions & 6 deletions ui/src/authorizations/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ interface EditAuthorization {
}
}

export const editLabel = (authorization: Authorization): EditAuthorization => ({
export const editAuthorization = (
authorization: Authorization
): EditAuthorization => ({
type: 'EDIT_AUTH',
payload: {authorization},
})
Expand Down Expand Up @@ -106,12 +108,9 @@ export const updateAuthorization = (authorization: Authorization) => async (
dispatch: Dispatch<Action>
) => {
try {
const label = await client.authorizations.update(
authorization.id,
authorization
)
await client.authorizations.update(authorization.id, authorization)

dispatch(editLabel(label))
dispatch(getAuthorizations())
} catch (e) {
console.error(e)
dispatch(notify(authorizationUpdateFailed(authorization.id)))
Expand Down
21 changes: 13 additions & 8 deletions ui/src/me/components/account/TokenRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
// Components
import {Alignment, ComponentSize, SlideToggle} from '@influxdata/clockface'
import {IndexList, ComponentSpacer, ConfirmationButton} from 'src/clockface'
import EditableName from 'src/shared/components/EditableName'

// Types
import {Authorization} from '@influxdata/influx'
Expand All @@ -29,18 +30,17 @@ type Props = DispatchProps & OwnProps

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

return (
<IndexList.Row>
<IndexList.Cell>
<a
href="#"
onClick={this.handleClickDescription}
data-testid={`token-description-${id}`}
>
{description}
</a>
<EditableName
onUpdate={this.handleUpdateName}
name={description}
noNameString="DEFAULT_BUCKET_NAME"
onEditName={this.handleClickDescription}
/>
</IndexList.Cell>
<IndexList.Cell>
<SlideToggle
Expand Down Expand Up @@ -87,6 +87,11 @@ class TokenRow extends PureComponent<Props> {
const {onClickDescription, auth} = this.props
onClickDescription(auth.id)
}

private handleUpdateName = async (value: string) => {
const {auth, onUpdate} = this.props
await onUpdate({...auth, description: value})
}
}

const mdtp = {
Expand Down

0 comments on commit 2683651

Please sign in to comment.