import React, { PureComponent } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { Button, Input, Form, Field } from '@grafana/ui'; import Page from 'app/core/components/Page/Page'; import { getNavModel } from 'app/core/selectors/navModel'; import { StoreState } from 'app/types'; import { validationSrv } from '../../manage-dashboards/services/ValidationSrv'; import { createNewFolder } from '../state/actions'; const mapStateToProps = (state: StoreState) => ({ navModel: getNavModel(state.navIndex, 'manage-dashboards'), }); const mapDispatchToProps = { createNewFolder, }; const connector = connect(mapStateToProps, mapDispatchToProps); interface OwnProps {} interface FormModel { folderName: string; } const initialFormModel: FormModel = { folderName: '' }; type Props = OwnProps & ConnectedProps; export class NewDashboardsFolder extends PureComponent { onSubmit = (formData: FormModel) => { this.props.createNewFolder(formData.folderName); }; validateFolderName = (folderName: string) => { return validationSrv .validateNewFolderName(folderName) .then(() => { return true; }) .catch((e) => { return e.message; }); }; render() { return (

New dashboard folder

{({ register, errors }) => ( <> await this.validateFolderName(v), })} /> )}
); } } export default connector(NewDashboardsFolder);