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KEC,KAAK,gBA5BX,OA+BE,SAAC,EAAAC,OAAD,CAAQD,KAAK,SAAb","sources":["webpack://grafana/./public/app/features/admin/UserCreatePage.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { connect } from 'react-redux';\nimport { useHistory } from 'react-router-dom';\n\nimport { NavModel } from '@grafana/data';\nimport { getBackendSrv } from '@grafana/runtime';\nimport { Form, Button, Input, Field } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\n\nimport { getNavModel } from '../../core/selectors/navModel';\nimport { StoreState } from '../../types';\n\ninterface UserCreatePageProps {\n navModel: NavModel;\n}\ninterface UserDTO {\n name: string;\n password: string;\n email?: string;\n login?: string;\n}\n\nconst createUser = async (user: UserDTO) => getBackendSrv().post('/api/admin/users', user);\n\nconst UserCreatePage: React.FC<UserCreatePageProps> = ({ navModel }) => {\n const history = useHistory();\n\n const onSubmit = useCallback(\n async (data: UserDTO) => {\n await createUser(data);\n history.push('/admin/users');\n },\n [history]\n );\n\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n <h1>Add new user</h1>\n <Form onSubmit={onSubmit} validateOn=\"onBlur\">\n {({ register, errors }) => {\n return (\n <>\n <Field\n label=\"Name\"\n required\n invalid={!!errors.name}\n error={errors.name ? 'Name is required' : undefined}\n >\n <Input id=\"name-input\" {...register('name', { required: true })} />\n </Field>\n\n <Field label=\"Email\">\n <Input id=\"email-input\" {...register('email')} />\n </Field>\n\n <Field label=\"Username\">\n <Input id=\"username-input\" {...register('login')} />\n </Field>\n <Field\n label=\"Password\"\n required\n invalid={!!errors.password}\n error={errors.password ? 'Password is required and must contain at least 4 characters' : undefined}\n >\n <Input\n id=\"password-input\"\n {...register('password', {\n validate: (value) => value.trim() !== '' && value.length >= 4,\n })}\n type=\"password\"\n />\n </Field>\n <Button type=\"submit\">Create user</Button>\n </>\n );\n }}\n </Form>\n </Page.Contents>\n </Page>\n );\n};\n\nconst mapStateToProps = (state: StoreState) => ({\n navModel: getNavModel(state.navIndex, 'global-users'),\n});\n\nexport default connect(mapStateToProps)(UserCreatePage);\n"],"names":["connect","state","navModel","getNavModel","navIndex","history","useHistory","onSubmit","useCallback","async","getBackendSrv","post","user","createUser","data","push","Form","validateOn","register","errors","Field","label","required","invalid","name","error","undefined","Input","id","password","validate","value","trim","length","type","Button"],"sourceRoot":""}