mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { connect, ConnectedProps } from 'react-redux';
|
|
import { useMount } from 'react-use';
|
|
|
|
import { NavModel } from '@grafana/data';
|
|
import Page from 'app/core/components/Page/Page';
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { StoreState } from 'app/types';
|
|
|
|
import { ChangePasswordForm } from './ChangePasswordForm';
|
|
import { changePassword, loadUser } from './state/actions';
|
|
|
|
export interface OwnProps {
|
|
navModel: NavModel;
|
|
}
|
|
|
|
function mapStateToProps(state: StoreState) {
|
|
const userState = state.user;
|
|
const { isUpdating, user } = userState;
|
|
return {
|
|
navModel: getNavModel(state.navIndex, `change-password`),
|
|
isUpdating,
|
|
user,
|
|
};
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
loadUser,
|
|
changePassword,
|
|
};
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
|
|
|
export function ChangePasswordPage({ navModel, loadUser, isUpdating, user, changePassword }: Props) {
|
|
useMount(() => loadUser());
|
|
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents isLoading={!Boolean(user)}>
|
|
{user ? (
|
|
<>
|
|
<h3 className="page-heading">Change Your Password</h3>
|
|
<ChangePasswordForm user={user} onChangePassword={changePassword} isSaving={isUpdating} />
|
|
</>
|
|
) : null}
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
|
|
export default connector(ChangePasswordPage);
|