"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8431],{8645:(e,s,i)=>{i.r(s),i.d(s,{AccessControlFolderPermissions:()=>P,default:()=>g});var n=i(76687),o=i(46958),r=i(94679),d=i(36131),t=i(31271),a=i(3276),l=i(99462),c=i(89348),h=i(92114),m=i(52010);const p={getFolderByUid:c.Pb},u=(0,o.connect)((function(e,s){const i=s.match.params.uid;return{uid:i,navModel:(0,a.h)(e.navIndex,`folder-permissions-${i}`,(0,h._)(1))}}),p),P=e=>{let{uid:s,getFolderByUid:i,navModel:o}=e;(0,n.useEffect)((()=>{i(s)}),[i,s]);const a=t.Vt.hasPermission(l.bW.FoldersPermissionsWrite);return(0,m.jsx)(d.Z,{navModel:o,children:(0,m.jsx)(d.Z.Contents,{children:(0,m.jsx)(r.P,{resource:"folders",resourceId:s,canSetPermissions:a})})})},g=u(P)},7535:(e,s,i)=>{i.r(s),i.d(s,{FolderPermissions:()=>b,default:()=>C});var n,o,r,d,t=i(76687),a=i(46958),l=i(70534),c=i(26193),h=i(36131),m=i(75734),p=i(44497),u=i(14763),P=i(3276),g=i(89348),f=i(92114),v=i(52010);function x(e,s,i){return s in e?Object.defineProperty(e,s,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[s]=i,e}const j={getFolderByUid:g.Pb,getFolderPermissions:g.a,updateFolderPermission:g.v7,removeFolderPermission:g.Uk,addFolderPermission:g.pz},F=(0,a.connect)(((e,s)=>{const i=s.match.params.uid;return{navModel:(0,P.h)(e.navIndex,`folder-permissions-${i}`,(0,f._)(1)),folderUid:i,folder:e.folder}}),j);class b extends t.PureComponent{constructor(e){super(e),x(this,"onOpenAddPermissions",(()=>{this.setState({isAdding:!0})})),x(this,"onRemoveItem",(e=>{this.props.removeFolderPermission(e)})),x(this,"onPermissionChanged",((e,s)=>{this.props.updateFolderPermission(e,s)})),x(this,"onAddPermission",(e=>this.props.addFolderPermission(e))),x(this,"onCancelAddPermission",(()=>{this.setState({isAdding:!1})})),this.state={isAdding:!1}}componentDidMount(){this.props.getFolderByUid(this.props.folderUid),this.props.getFolderPermissions(this.props.folderUid)}render(){const{navModel:e,folder:s}=this.props,{isAdding:i}=this.state;if(0===s.id)return(0,v.jsx)(h.Z,{navModel:e,children:n||(n=(0,v.jsx)(h.Z.Contents,{isLoading:!0,children:(0,v.jsx)("span",{})}))});const t={title:s.title,url:s.url,id:s.id};return(0,v.jsx)(h.Z,{navModel:e,children:(0,v.jsxs)(h.Z.Contents,{children:[(0,v.jsxs)("div",{className:"page-action-bar",children:[o||(o=(0,v.jsx)("h3",{className:"page-sub-heading",children:"Folder Permissions"})),r||(r=(0,v.jsx)(l.Tooltip,{placement:"auto",content:(0,v.jsx)(u.Z,{}),children:(0,v.jsx)(l.Icon,{className:"icon--has-hover page-sub-heading-icon",name:"question-circle"})})),d||(d=(0,v.jsx)("div",{className:"page-action-bar__spacer"})),(0,v.jsx)(l.Button,{className:"pull-right",onClick:this.onOpenAddPermissions,disabled:i,children:"Add Permission"})]}),(0,v.jsx)(c.s,{in:i,children:(0,v.jsx)(m.Z,{onAddPermission:this.onAddPermission,onCancel:this.onCancelAddPermission})}),(0,v.jsx)(p.Z,{items:s.permissions,onRemoveItem:this.onRemoveItem,onPermissionChanged:this.onPermissionChanged,isFetching:!1,folderInfo:t})]})})}}const C=F(b)}}]);
//# sourceMappingURL=FolderPermissions.2bd4c8c6a25cc0e151f9.js.map