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 edit token's description #13024

Merged
merged 1 commit into from
Apr 1, 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
@@ -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