"use strict";(self.webpackChunkmavunoorgbackend=self.webpackChunkmavunoorgbackend||[]).push([[7004],{27004:(x,D,s)=>{s.r(D),s.d(D,{default:()=>j});var t=s(19968),_=s(62552),i=s(48112),c=s(28464),O=s(35676),h=s(20436),o=s(5e3),f=s(48936),A=s(63358),C=s(28724),m=s(70996),l=s(28216),v=s(62492),g=s(17324),d=s(95840),I=s(53305),r=s(14032),E=s(63648),M=s(31812),L=s(14632),R=s(3704),u=s(52540),a=s(96728),e=s(58476),B=s(48632);const S=u.kt().shape({restrictedAccess:u.cT(),password:u.Qb().when("restrictedAccess",(n,p)=>n?p.required(d.aO.required):p)}),j=()=>{(0,d.G0)();const{formatMessage:n}=(0,L.c)(),{submit:p,data:W,isLoading:$}=(0,e.u)(),[T,Q]=(0,_.useState)(!1),{allowedActions:G}=(0,d.aU)(a.P),N=U=>{p.mutate({prefix:W?.prefix,body:U})};return(0,t.jsx)(i.G,{children:$?(0,t.jsx)(d.Wm,{children:"Plugin settings are loading"}):(0,t.jsx)(M.QJ,{initialValues:{restrictedAccess:W?.documentationAccess.restrictedAccess||!1,password:""},onSubmit:N,validationSchema:S,children:({handleSubmit:U,values:P,handleChange:Y,errors:K,setFieldTouched:Z,setFieldValue:y,dirty:F})=>(0,t.jsxs)(d.QF,{noValidate:!0,onSubmit:U,children:[(0,t.jsx)(c.a,{title:n({id:(0,e.g)("plugin.name"),defaultMessage:"Documentation"}),subtitle:n({id:(0,e.g)("pages.SettingsPage.header.description"),defaultMessage:"Configure the documentation plugin"}),primaryAction:(0,t.jsx)(O.Z,{type:"submit",startIcon:(0,t.jsx)(I.c,{}),disabled:!F&&G.canUpdate,children:n({id:(0,e.g)("pages.SettingsPage.Button.save"),defaultMessage:"Save"})})}),(0,t.jsx)(h.S,{children:(0,t.jsx)(o.k,{background:"neutral0",hasRadius:!0,shadow:"filterShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7,children:(0,t.jsxs)(f.C,{direction:"column",alignItems:"stretch",gap:4,children:[(0,t.jsx)(A.O,{variant:"delta",as:"h2",children:n({id:"global.settings",defaultMessage:"Settings"})}),(0,t.jsxs)(C.y,{gap:4,children:[(0,t.jsx)(m.C,{col:6,s:12,children:(0,t.jsx)(l.a,{name:"restrictedAccess",label:n({id:(0,e.g)("pages.SettingsPage.toggle.label"),defaultMessage:"Restricted Access"}),hint:n({id:(0,e.g)("pages.SettingsPage.toggle.hint"),defaultMessage:"Make the documentation endpoint private"}),checked:P.restrictedAccess,onChange:()=>{P.restrictedAccess===!0&&(y("password","",!1),Z("password",!1,!1)),y("restrictedAccess",!P.restrictedAccess,!1)},onLabel:"On",offLabel:"Off"})}),P.restrictedAccess&&(0,t.jsx)(m.C,{col:6,s:12,children:(0,t.jsx)(v.g,{label:n({id:"global.password",defaultMessage:"Password"}),name:"password",placeholder:"**********",type:T?"text":"password",value:P.password,onChange:Y,error:K.password?n({id:K.password,defaultMessage:"Invalid value"}):null,endAction:(0,t.jsx)(w,{onClick:H=>{H.stopPropagation(),Q(J=>!J)},label:n(T?{id:"Auth.form.password.show-password",defaultMessage:"Show password"}:{id:"Auth.form.password.hide-password",defaultMessage:"Hide password"}),children:T?(0,t.jsx)(r.c,{}):(0,t.jsx)(E.c,{})})})})]})]})})})]})})})},w=(0,R.cp)(g.d)`
  svg {
    height: 1rem;
    width: 1rem;
    path {
      fill: ${({theme:n})=>n.colors.neutral600};
    }
  }
`},58476:(x,D,s)=>{s.d(D,{g:()=>O,u:()=>h});var t=s(62552),_=s(95840),i=s(48632),c=s(96728);const O=o=>`${c.p}.${o}`,h=()=>{const o=(0,_.eo)(),{del:f,post:A,put:C,get:m}=(0,_.Qn)(),{formatAPIError:l}=(0,_.An)(),{isLoading:v,isError:g,data:d,refetch:I,error:r}=(0,i.useQuery)(["get-documentation",c.p],async()=>{const{data:a}=await m(`/${c.p}/getInfos`);return a});(0,t.useEffect)(()=>{g&&r&&o({type:"warning",message:r?l(r):{id:"notification.error"}})},[g,r,o,l]);const E=a=>{o({type:"warning",message:l(a)})},M=(a,e,B)=>{I(),o({type:a,message:{id:O(e),defaultMessage:B}})},L=(0,i.useMutation)(({prefix:a,version:e})=>f(`${a}/deleteDoc/${e}`),{onSuccess:()=>M("info","notification.delete.success","Successfully deleted documentation"),onError:E}),R=(0,i.useMutation)(({prefix:a,body:e})=>C(`${a}/updateSettings`,e),{onSuccess:()=>M("success","notification.update.success","Successfully updated settings"),onError:E}),u=(0,i.useMutation)(({prefix:a,version:e})=>A(`${a}/regenerateDoc`,{version:e}),{onSuccess:()=>M("info","notification.generate.success","Successfully generated documentation"),onError:E});return{data:d,isLoading:v,isError:g,remove:L,submit:R,regenerate:u}}}}]);
