文件操作 - ForgottenPassword.tsx
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/core/components/ForgottenPassword/ForgottenPassword.tsx
编辑文件内容
import React, { FC, useState } from 'react'; import { Form, Field, Input, Button, Legend, Container, useStyles, HorizontalGroup, LinkButton } from '@grafana/ui'; import { getBackendSrv } from '@grafana/runtime'; import { css } from 'emotion'; import { GrafanaTheme } from '@grafana/data'; interface EmailDTO { userOrEmail: string; } const paragraphStyles = (theme: GrafanaTheme) => css` color: ${theme.colors.formDescription}; font-size: ${theme.typography.size.sm}; font-weight: ${theme.typography.weight.regular}; margin-top: ${theme.spacing.sm}; display: block; `; export const ForgottenPassword: FC = () => { const [emailSent, setEmailSent] = useState(false); const styles = useStyles(paragraphStyles); const sendEmail = async (formModel: EmailDTO) => { const res = await getBackendSrv().post('/api/user/password/send-reset-email', formModel); if (res) { setEmailSent(true); } }; if (emailSent) { return ( <div> <p>An email with a reset link has been sent to the email address. You should receive it shortly.</p> <Container margin="md" /> <LinkButton variant="primary" href="/login"> Back to login </LinkButton> </div> ); } return ( <Form onSubmit={sendEmail}> {({ register, errors }) => ( <> <Legend>Reset password</Legend> <Field label="User" description="Enter your information to get a reset link sent to you" invalid={!!errors.userOrEmail} error={errors?.userOrEmail?.message} > <Input placeholder="Email or username" name="userOrEmail" ref={register({ required: true })} /> </Field> <HorizontalGroup> <Button>Send reset email</Button> <LinkButton variant="link" href="/login"> Back to login </LinkButton> </HorizontalGroup> <p className={styles}>Did you forget your username or email? Contact your Grafana administrator.</p> </> )} </Form> ); };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件