"use strict";(self.webpackChunkmavunoorgbackend=self.webpackChunkmavunoorgbackend||[]).push([[9456],{39456:(k,M,s)=>{s.r(M),s.d(M,{default:()=>y});var t=s(19968),c=s(62552),R=s(5e3),A=s(28724),O=s(70996),P=s(35933),m=s(13384),B=s(20596),W=s(48112),I=s(28464),U=s(35676),K=s(20436),g=s(95840),j=s(15396),h=s(53305),x=s(13192),_=s(33104),u=s(14632),i=s(93668),S=s(29088),z=s(85676),N=s(35184),w=s(9568),q=s(12132),ss=s(48632),ts=s(31812),as=s(52540),is=s(40980),es=s(3396),ns=s(79804);const C=({sort:n="",pageSize:d=10,onChange:e})=>{const{formatMessage:o}=(0,u.c)();return(0,t.jsx)(R.k,{background:"neutral0",hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7,children:(0,t.jsxs)(A.y,{gap:4,children:[(0,t.jsx)(O.C,{s:12,col:6,children:(0,t.jsx)(P.M,{label:o({id:(0,i.g)("config.entries.title"),defaultMessage:"Entries per page"}),hint:o({id:(0,i.g)("config.entries.note"),defaultMessage:"Number of assets displayed by default in the Media Library"}),onChange:a=>e({target:{name:"pageSize",value:a}}),name:"pageSize",value:d,children:i.C.map(a=>(0,t.jsx)(m.c,{value:a,children:a},a))})}),(0,t.jsx)(O.C,{s:12,col:6,children:(0,t.jsx)(P.M,{label:o({id:(0,i.g)("config.sort.title"),defaultMessage:"Default sort order"}),hint:o({id:(0,i.g)("config.note"),defaultMessage:"Note: You can override this value in the media library."}),onChange:a=>e({target:{name:"sort",value:a}}),name:"sort",value:n,"test-sort":n,"data-testid":"sort-select",children:i.D.map(a=>(0,t.jsx)(m.c,{"data-testid":`sort-option-${a.value}`,value:a.value,children:o({id:(0,i.g)(a.key),defaultMessage:`${a.value}`})},a.key))})})]})})};C.propTypes={sort:_.string.isRequired,pageSize:_.number.isRequired,onChange:_.func.isRequired};const v=`${i.p}/ON_CHANGE`,f=`${i.p}/SET_LOADED`,b=({name:n,value:d})=>({type:v,keys:n,value:d}),$=()=>({type:f}),r={initialData:{},modifiedData:{}},p=n=>({...r,initialData:n,modifiedData:n}),G=(n=r,d)=>(0,S.cp)(n,e=>{switch(d.type){case v:{N(e,["modifiedData",...d.keys.split(".")],d.value);break}case f:{const o=p(z(e,["modifiedData"],{}));e.initialData=o.initialData,e.modifiedData=o.modifiedData;break}default:return e}}),y=({config:n})=>{const{trackUsage:d}=(0,g.m4)(),{formatMessage:e}=(0,u.c)(),o=(0,g.eo)(),{mutateConfig:a}=(0,i.z)(),{isLoading:T}=a,[H,F]=(0,c.useState)(!1),D=()=>F(E=>!E),[V,L]=(0,c.useReducer)(G,r,()=>p(n)),{initialData:Y,modifiedData:l}=V,Z=E=>{E.preventDefault(),D()},J=async()=>{d("willEditMediaLibraryConfig"),await a.mutateAsync(l),D(),L($()),o({type:"success",message:{id:"notification.form.success.fields",defaultMessage:"Changes saved"}})},Q=({target:{name:E,value:X}})=>{L(b({name:E,value:X}))};return(0,g.G0)(),(0,t.jsx)(B._,{children:(0,t.jsx)(W.G,{"aria-busy":T,children:(0,t.jsxs)("form",{onSubmit:Z,children:[(0,t.jsx)(I.a,{navigationAction:(0,t.jsx)(g.cH,{startIcon:(0,t.jsx)(j.c,{}),to:`/plugins/${i.p}`,id:"go-back",children:e({id:(0,i.g)("config.back"),defaultMessage:"Back"})}),primaryAction:(0,t.jsx)(U.Z,{size:"S",startIcon:(0,t.jsx)(h.c,{}),disabled:x(l,Y),type:"submit",children:e({id:"global.save",defaultMessage:"Save"})}),subtitle:e({id:(0,i.g)("config.subtitle"),defaultMessage:"Define the view settings of the media library."}),title:e({id:(0,i.g)("config.title"),defaultMessage:"Configure the view - Media Library"})}),(0,t.jsx)(K.S,{children:(0,t.jsx)(C,{"data-testid":"settings",pageSize:l.pageSize||"",sort:l.sort||"",onChange:Q})}),(0,t.jsx)(g.cz,{bodyText:{id:(0,i.g)("config.popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:(0,t.jsx)(h.c,{}),isConfirmButtonLoading:T,isOpen:H,onToggleDialog:D,onConfirm:J,variantRightButton:"success-light"})]})})})};y.propTypes={config:_.shape({pageSize:_.number,sort:_.string}).isRequired}}}]);
