1 |
- {"version":3,"file":"NewDashboardsFolder.82841af471ab7e9dd097.js","mappings":"kXAWA,MAIMA,EAAqB,CACzBC,gBAAeA,EAAAA,IAGXC,GAAYC,EAAAA,EAAAA,UAROC,IAAD,CACtBC,UAAUC,EAAAA,EAAAA,GAAYF,EAAMG,SAAU,wBAOGP,GAQrCQ,EAA8B,CAAEC,WAAY,IAI3C,MAAMC,UAA4BC,EAAAA,cAAqB,qDAChDC,IACVC,KAAKC,MAAMb,gBAAgBW,EAASH,eAFsB,6BAKtCA,GACbM,EAAAA,EAAAA,sBACkBN,GACtBO,MAAK,KACG,IAERC,OAAOC,GACCA,EAAEC,YAIfC,SACE,OACE,SAAC,IAAD,CAAMf,SAAUQ,KAAKC,MAAMT,SAA3B,UACE,UAAC,aAAD,kBACE,mDACA,SAAC,EAAAgB,KAAD,CAAMC,cAAed,EAAkBe,SAAUV,KAAKU,SAAtD,SACG,QAAC,SAAEC,EAAF,OAAYC,GAAb,SACC,iCACE,SAAC,EAAAC,MAAD,CACEC,MAAM,cACNC,UAAWH,EAAOhB,WAClBoB,MAAOJ,EAAOhB,YAAcgB,EAAOhB,WAAWU,QAHhD,UAKE,SAAC,EAAAW,MAAD,eACEC,GAAG,qBACCP,EAAS,aAAc,CACzBQ,SAAU,2BACVC,SAAUC,MAAAA,SAAmBrB,KAAKsB,mBAAmBC,SAV7D,OAcE,SAAC,EAAAC,OAAD,CAAQC,KAAK,SAAb,iCAUhB,QAAepC,EAAUQ","sources":["webpack://grafana/./public/app/features/folders/components/NewDashboardsFolder.tsx"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport { Button, Input, Form, Field } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { StoreState } from 'app/types';\n\nimport { validationSrv } from '../../manage-dashboards/services/ValidationSrv';\nimport { createNewFolder } from '../state/actions';\n\nconst mapStateToProps = (state: StoreState) => ({\n navModel: getNavModel(state.navIndex, 'manage-dashboards'),\n});\n\nconst mapDispatchToProps = {\n createNewFolder,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\ninterface OwnProps {}\n\ninterface FormModel {\n folderName: string;\n}\n\nconst initialFormModel: FormModel = { folderName: '' };\n\ntype Props = OwnProps & ConnectedProps<typeof connector>;\n\nexport class NewDashboardsFolder extends PureComponent<Props> {\n onSubmit = (formData: FormModel) => {\n this.props.createNewFolder(formData.folderName);\n };\n\n validateFolderName = (folderName: string) => {\n return validationSrv\n .validateNewFolderName(folderName)\n .then(() => {\n return true;\n })\n .catch((e) => {\n return e.message;\n });\n };\n\n render() {\n return (\n <Page navModel={this.props.navModel}>\n <Page.Contents>\n <h3>New dashboard folder</h3>\n <Form defaultValues={initialFormModel} onSubmit={this.onSubmit}>\n {({ register, errors }) => (\n <>\n <Field\n label=\"Folder name\"\n invalid={!!errors.folderName}\n error={errors.folderName && errors.folderName.message}\n >\n <Input\n id=\"folder-name-input\"\n {...register('folderName', {\n required: 'Folder name is required.',\n validate: async (v) => await this.validateFolderName(v),\n })}\n />\n </Field>\n <Button type=\"submit\">Create</Button>\n </>\n )}\n </Form>\n </Page.Contents>\n </Page>\n );\n }\n}\n\nexport default connector(NewDashboardsFolder);\n"],"names":["mapDispatchToProps","createNewFolder","connector","connect","state","navModel","getNavModel","navIndex","initialFormModel","folderName","NewDashboardsFolder","PureComponent","formData","this","props","validationSrv","then","catch","e","message","render","Form","defaultValues","onSubmit","register","errors","Field","label","invalid","error","Input","id","required","validate","async","validateFolderName","v","Button","type"],"sourceRoot":""}
|