(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{"5gaU":function(e,r,t){"use strict";t.d(r,"d",(function(){return u})),t.d(r,"g",(function(){return l})),t.d(r,"c",(function(){return f})),t.d(r,"e",(function(){return p})),t.d(r,"h",(function(){return m})),t.d(r,"f",(function(){return h})),t.d(r,"a",(function(){return v})),t.d(r,"b",(function(){return j}));var n=t("Obii"),i=t("t8hP"),s=t("NXk7"),o=t("3SGO"),a=t("v2PB"),d=t("Xmxp"),c=t("BAXh");function u(e){return async r=>{const t=await s.b.getFolderByUid(e);r(Object(c.b)(t)),r(Object(o.d)(Object(a.a)(t)))}}function l(e){return async r=>{const t=await s.b.put("/api/folders/"+e.uid,{title:e.title,version:e.version});d.b.emit(n.AppEvents.alertSuccess,["Folder saved"]),i.locationService.push(t.url+"/settings")}}function f(e){return async r=>{await s.b.delete(`/api/folders/${e}?forceDeleteRules=true`),i.locationService.push("/dashboards")}}function p(e){return async r=>{const t=await s.b.get(`/api/folders/${e}/permissions`);r(Object(c.c)(t))}}function b(e){return{userId:e.userId,teamId:e.teamId,role:e.role,permission:e.permission}}function m(e,r){return async(t,n)=>{const i=n().folder,o=[];for(const t of i.permissions){if(t.inherited)continue;const n=b(t);e===t&&(n.permission=r),o.push(n)}await s.b.post(`/api/folders/${i.uid}/permissions`,{items:o}),await t(p(i.uid))}}function h(e){return async(r,t)=>{const n=t().folder,i=[];for(const r of n.permissions)r.inherited||r===e||i.push(b(r));await s.b.post(`/api/folders/${n.uid}/permissions`,{items:i}),await r(p(n.uid))}}function v(e){return async(r,t)=>{const n=t().folder,i=[];for(const e of n.permissions)e.inherited||i.push(b(e));i.push({userId:e.userId,teamId:e.teamId,role:e.role,permission:e.permission}),await s.b.post(`/api/folders/${n.uid}/permissions`,{items:i}),await r(p(n.uid))}}function j(e){return async()=>{const r=await Object(i.getBackendSrv)().post("/api/folders",{title:e});d.b.emit(n.AppEvents.alertSuccess,["Folder Created","OK"]),i.locationService.push(n.locationUtil.stripBaseFromUrl(r.url))}}},tg3w:function(e,r,t){"use strict";t.r(r),t.d(r,"NewDashboardsFolder",(function(){return h}));var n,i,s=t("q1tI"),o=t("/MKj"),a=t("kDLi"),d=t("ZGyg"),c=t("5gaU"),u=t("lzJ5"),l=t("d4Ek"),f=t("nKUr");function p(){return(p=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function b(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const m={folderName:""};class h extends s.PureComponent{constructor(...e){super(...e),b(this,"onSubmit",e=>{this.props.createNewFolder(e.folderName)}),b(this,"validateFolderName",e=>l.a.validateNewFolderName(e).then(()=>!0).catch(e=>e.message))}render(){return Object(f.jsx)(d.b,{navModel:this.props.navModel,children:Object(f.jsxs)(d.b.Contents,{children:[n||(n=Object(f.jsx)("h3",{children:"New dashboard folder"})),Object(f.jsx)(a.Form,{defaultValues:m,onSubmit:this.onSubmit,children:({register:e,errors:r})=>Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(a.Field,{label:"Folder name",invalid:!!r.folderName,error:r.folderName&&r.folderName.message,children:Object(f.jsx)(a.Input,p({},e("folderName",{required:"Folder name is required.",validate:async e=>await this.validateFolderName(e)})))}),i||(i=Object(f.jsx)(a.Button,{type:"submit",children:"Create"}))]})})]})})}}const v={createNewFolder:c.b};r.default=Object(o.connect)(e=>({navModel:Object(u.a)(e.navIndex,"manage-dashboards")}),v)(h)},v2PB:function(e,r,t){"use strict";function n(e){const r={icon:"folder",id:"manage-folder",subTitle:"Manage folder dashboards and permissions",url:"",text:e.title,breadcrumbs:[{title:"Dashboards",url:"dashboards"}],children:[{active:!1,icon:"apps",id:"folder-dashboards-"+e.uid,text:"Dashboards",url:e.url}]};return r.children.push({active:!1,icon:"library-panel",id:"folder-library-panels-"+e.uid,text:"Panels",url:e.url+"/library-panels"}),e.canAdmin&&r.children.push({active:!1,icon:"lock",id:"folder-permissions-"+e.uid,text:"Permissions",url:e.url+"/permissions"}),e.canSave&&r.children.push({active:!1,icon:"cog",id:"folder-settings-"+e.uid,text:"Settings",url:e.url+"/settings"}),r}function i(e){const r=n({id:1,uid:"loading",title:"Loading",url:"url",canSave:!0,canEdit:!0,canAdmin:!0,version:0});return r.children[e].active=!0,{main:r,node:r.children[e]}}t.d(r,"a",(function(){return n})),t.d(r,"b",(function(){return i}))}}]);
//# sourceMappingURL=NewDashboardsFolder.d7cfb4e56c8be9229275.js.map