(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{"1Xqh":function(e,t,s){"use strict";var a,r,n,c,i,l,j=s("q1tI"),d=s("GQ3c"),o=s("Y/nG"),b=s("kDLi"),h=s("HJRA"),O=s("nKUr");t.a=e=>{const{users:t,onRoleChange:s,onRemoveUser:m}=e,u=h.b.hasPermission(d.a.OrgUsersRoleUpdate),x=h.b.hasPermission(d.a.OrgUsersRemove),[g,p]=Object(j.useState)(!1);return Object(O.jsxs)("table",{className:"filter-table form-inline",children:[Object(O.jsx)("thead",{children:Object(O.jsxs)("tr",{children:[a||(a=Object(O.jsx)("th",{})),r||(r=Object(O.jsx)("th",{children:"Login"})),n||(n=Object(O.jsx)("th",{children:"Email"})),c||(c=Object(O.jsx)("th",{children:"Name"})),i||(i=Object(O.jsx)("th",{children:"Seen"})),l||(l=Object(O.jsx)("th",{children:"Role"})),Object(O.jsx)("th",{style:{width:"34px"}})]})}),Object(O.jsx)("tbody",{children:t.map((e,t)=>Object(O.jsxs)("tr",{children:[Object(O.jsx)("td",{className:"width-2 text-center",children:Object(O.jsx)("img",{className:"filter-table__avatar",src:e.avatarUrl})}),Object(O.jsx)("td",{className:"max-width-6",children:Object(O.jsx)("span",{className:"ellipsis",title:e.login,children:e.login})}),Object(O.jsx)("td",{className:"max-width-5",children:Object(O.jsx)("span",{className:"ellipsis",title:e.email,children:e.email})}),Object(O.jsx)("td",{className:"max-width-5",children:Object(O.jsx)("span",{className:"ellipsis",title:e.name,children:e.name})}),Object(O.jsx)("td",{className:"width-1",children:e.lastSeenAtAge}),Object(O.jsx)("td",{className:"width-8",children:Object(O.jsx)(o.a,{value:e.role,disabled:!u,onChange:t=>s(t,e)})}),x&&Object(O.jsxs)("td",{children:[Object(O.jsx)(b.Button,{size:"sm",variant:"destructive",onClick:()=>p(e.login),icon:"times"}),Object(O.jsx)(b.ConfirmModal,{body:`Are you sure you want to delete user ${e.login}?`,confirmText:"Delete",title:"Delete",onDismiss:()=>p(!1),isOpen:e.login===g,onConfirm:()=>{m(e)}})]})]},`${e.userId}-${t}`))})]})}},vWlM:function(e,t,s){"use strict";s.r(t),s.d(t,"AdminEditOrgPage",(function(){return x}));var a,r,n,c=s("q1tI"),i=s("ZGyg"),l=s("/MKj"),j=s("lzJ5"),d=s("1Xqh"),o=s("Kwub"),b=s("t8hP"),h=s("kDLi"),O=s("vF1F"),m=s("nKUr");function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}const x=({match:e})=>{const t=Object(l.useSelector)(e=>e.navIndex),s=Object(j.a)(t,"global-orgs"),x=parseInt(e.params.id,10),[g,p]=Object(c.useState)([]),[v,w]=Object(o.a)(()=>(async e=>await Object(b.getBackendSrv)().get("/api/orgs/"+e))(x),[]),[,N]=Object(o.a)(()=>(async e=>await Object(b.getBackendSrv)().get("/api/orgs/"+e+"/users"))(x),[]);Object(c.useEffect)(()=>{w(),N().then(e=>p(e))},[w,N]);return Object(m.jsx)(i.b,{navModel:s,children:Object(m.jsx)(i.b.Contents,{children:Object(m.jsxs)(m.Fragment,{children:[a||(a=Object(m.jsx)(h.Legend,{children:"Edit organization"})),v.value&&Object(m.jsx)(h.Form,{defaultValues:{orgName:v.value.name},onSubmit:async e=>await(async e=>await Object(b.getBackendSrv)().put("/api/orgs/"+x,u({},v.value,{name:e})))(e.orgName),children:({register:e,errors:t})=>Object(m.jsxs)(m.Fragment,{children:[Object(m.jsx)(h.Field,{label:"Name",invalid:!!t.orgName,error:"Name is required",children:Object(m.jsx)(h.Input,u({},e("orgName",{required:!0})))}),r||(r=Object(m.jsx)(h.Button,{children:"Update"}))]})}),Object(m.jsxs)("div",{className:O.css`
              margin-top: 20px;
            `,children:[n||(n=Object(m.jsx)(h.Legend,{children:"Organization users"})),!!g.length&&Object(m.jsx)(d.a,{users:g,onRoleChange:(e,t)=>{(async(e,t)=>{await Object(b.getBackendSrv)().patch("/api/orgs/"+t+"/users/"+e.userId,e)})(u({},t,{role:e}),x),p(g.map(s=>t.userId===s.userId?u({},t,{role:e}):s)),N()},onRemoveUser:e=>{(async(e,t)=>{await Object(b.getBackendSrv)().delete("/api/orgs/"+t+"/users/"+e.userId)})(e,x),p(g.filter(t=>e.userId!==t.userId)),N()}})]})]})})})};t.default=x}}]);
//# sourceMappingURL=AdminEditOrgPage.d7cfb4e56c8be9229275.js.map