import React, { PureComponent, MouseEvent } from 'react'; import config from 'app/core/config'; import { Button, LinkButton } from '@grafana/ui'; import { ChangePasswordFields } from 'app/core/utils/UserProvider'; import { PasswordInput } from 'app/core/components/PasswordInput/PasswordInput'; export interface Props { isSaving: boolean; onChangePassword: (payload: ChangePasswordFields) => void; } export interface State { oldPassword: string; newPassword: string; confirmNew: string; } export class ChangePasswordForm extends PureComponent { state: State = { oldPassword: '', newPassword: '', confirmNew: '', }; onOldPasswordChange = (oldPassword: string) => { this.setState({ oldPassword }); }; onNewPasswordChange = (newPassword: string) => { this.setState({ newPassword }); }; onConfirmPasswordChange = (confirmNew: string) => { this.setState({ confirmNew }); }; onSubmitChangePassword = (event: MouseEvent) => { event.preventDefault(); this.props.onChangePassword({ ...this.state }); }; render() { const { oldPassword, newPassword, confirmNew } = this.state; const { isSaving } = this.props; const { ldapEnabled, authProxyEnabled } = config; if (ldapEnabled || authProxyEnabled) { return

You cannot change password when ldap or auth proxy authentication is enabled.

; } return (
Cancel
); } } export default ChangePasswordForm;