"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1510],{74410(y,d,n){n.d(d,{l:()=>p});var r=n(74848),u=n(22803),O=n(96540),o=n(49785);function p({defaultValues:v,onSubmit:c,validateOnMount:m=!1,validateFieldsOnMount:f,children:a,validateOn:e="onSubmit",maxWidth:i=600,...x}){const{handleSubmit:z,trigger:g,formState:h,...j}=(0,o.mN)({mode:e,defaultValues:v});return(0,O.useEffect)(()=>{m&&g(f)},[g,f,m]),(0,r.jsx)("form",{className:(0,u.css)({maxWidth:i!=="none"?i+"px":i,width:"100%"}),onSubmit:z(c),...x,children:a({errors:h.errors,formState:h,trigger:g,...j})})}},73318(y,d,n){n.r(d),n.d(d,{OrgDetailsPage:()=>C,default:()=>R});var r=n(74848),u=n(96540),O=n(71468),o=n(92745),p=n(41654),v=n(45229),c=n(13791),m=n(13126),f=n(84057),a=n(15130),e=n(11257),i=n(87745),x=n(16780),z=n(37386),g=n(63527),h=n(45861),j=n(74410);const E=({onSubmit:l,orgName:t})=>{const P=a.TP.hasPermission(e.w.OrgsWrite);return(0,r.jsx)(j.l,{defaultValues:{orgName:t},onSubmit:({orgName:s})=>l(s),children:({register:s})=>(0,r.jsxs)(x.n,{label:(0,o.t)("org.org-profile.label-organization-profile","Organization profile"),disabled:!P,children:[(0,r.jsx)(z.D,{label:(0,o.t)("org.org-profile.label-organization-name","Organization name"),children:(0,r.jsx)(g.p,{id:"org-name-input",type:"text",...s("orgName",{required:!0})})}),(0,r.jsx)(h.$n,{type:"submit",children:(0,r.jsx)(o.x6,{i18nKey:"org.org-profile.update-organization-name",children:"Update organization name"})})]})})};var D=n(93922),T=n(74396);class C extends u.PureComponent{constructor(){super(...arguments),this.onUpdateOrganization=t=>{this.props.setOrganizationName(t),this.props.updateOrganization()},this.handleConfirm=()=>new Promise(t=>{v.l.publish(new i.bY({title:(0,o.t)("org.org-details-page.title.confirm-preferences-update","Confirm preferences update"),text:"This will update the preferences for the whole organization. Are you sure you want to update the preferences?",yesText:"Save",yesButtonVariant:"primary",onConfirm:async()=>t(!0),onDismiss:async()=>t(!1)}))})}async componentDidMount(){await this.props.loadOrganization()}render(){const{navModel:t,organization:P}=this.props,s=Object.keys(P).length===0,U=a.TP.hasPermission(e.w.OrgsRead),B=a.TP.hasPermission(e.w.OrgsPreferencesRead),N=a.TP.hasPermission(e.w.OrgsPreferencesWrite);return(0,r.jsx)(c.Y,{navModel:t,children:(0,r.jsx)(c.Y.Contents,{isLoading:s,children:!s&&(0,r.jsxs)(p.B,{direction:"column",gap:3,children:[U&&(0,r.jsx)(E,{onSubmit:this.onUpdateOrganization,orgName:P.name}),B&&(0,r.jsx)(m.A,{resourceUri:"org",disabled:!N,preferenceType:"org",onConfirm:this.handleConfirm})]})})})}}function S(l){return{navModel:(0,f.tc)(l.navIndex,"org-settings"),organization:l.organization.organization}}const M={loadOrganization:D.YS,setOrganizationName:T.n,updateOrganization:D.L_},R=(0,O.connect)(S,M)(C)}}]);

//# sourceMappingURL=OrgDetailsPage.21e5118d37fec19f9b82.js.map