FolderSettingsPage.d4b1c3468dad9e8f546e.js 2.2 KB

12
  1. "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4827],{96225:(e,t,s)=>{s.r(t),s.d(t,{FolderSettingsPage:()=>j,default:()=>F});var a,n,o=s(68404),i=s(18745),r=s(69783),l=s(5831),d=s(33801),h=s(8674),c=s(21169),p=s(87413),u=s(49545),f=s(11304),g=s(45916);function m(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}const{Input:v}=r.LegacyForms,b={getFolderByUid:p.Pb,saveFolder:p.OD,setFolderTitle:f.Ss,deleteFolder:p.Go},x=(0,i.connect)(((e,t)=>{const s=t.match.params.uid;return{navModel:(0,h.h)(e.navIndex,`folder-settings-${s}`,(0,u._)(2)),folderUid:s,folder:e.folder}}),b);class j extends o.PureComponent{constructor(e){super(e),m(this,"onTitleChange",(e=>{this.props.setFolderTitle(e.target.value)})),m(this,"onSave",(async e=>{e.preventDefault(),e.stopPropagation(),this.setState({isLoading:!0}),await this.props.saveFolder(this.props.folder),this.setState({isLoading:!1})})),m(this,"onDelete",(e=>{e.stopPropagation(),e.preventDefault();l.Z.publish(new c.VJ({title:"Delete",text:"Do you want to delete this folder and all its dashboards and alerts?",icon:"trash-alt",yesText:"Delete",onConfirm:()=>{this.props.deleteFolder(this.props.folder.uid)}}))})),this.state={isLoading:!1}}componentDidMount(){this.props.getFolderByUid(this.props.folderUid)}render(){const{navModel:e,folder:t}=this.props;return(0,g.jsx)(d.Z,{navModel:e,children:(0,g.jsxs)(d.Z.Contents,{isLoading:this.state.isLoading,children:[a||(a=(0,g.jsx)("h3",{className:"page-sub-heading",children:"Folder settings"})),(0,g.jsx)("div",{className:"section gf-form-group",children:(0,g.jsxs)("form",{name:"folderSettingsForm",onSubmit:this.onSave,children:[(0,g.jsxs)("div",{className:"gf-form",children:[n||(n=(0,g.jsx)("label",{className:"gf-form-label width-7",children:"Name"})),(0,g.jsx)(v,{type:"text",className:"gf-form-input width-30",value:t.title,onChange:this.onTitleChange})]}),(0,g.jsxs)("div",{className:"gf-form-button-row",children:[(0,g.jsx)(r.Button,{type:"submit",disabled:!t.canSave||!t.hasChanged,children:"Save"}),(0,g.jsx)(r.Button,{variant:"destructive",onClick:this.onDelete,disabled:!t.canDelete,children:"Delete"})]})]})})]})})}}const F=x(j)}}]);
  2. //# sourceMappingURL=FolderSettingsPage.d4b1c3468dad9e8f546e.js.map