"use strict";(self.webpackChunk_digicms_admin=self.webpackChunk_digicms_admin||[]).push([[9514],{1372:function(it,v,t){t.r(v),t.d(v,{default:function(){return X}});var e=t(32735),h=t(5636),R=t(89793),z=t.n(R),B=t(60216),d=t.n(B),I=t(96709),W=t(28356),O=t(17e3),r=t(58521),y=t(66456),$=t(41415),b=t(29439),G=t(27649),P=t(15335),E=t(5803),F=t(72850),p=t(70218),C=t(84967),l=t(20069),D=t(68781);const S=({sort:i="",pageSize:s=10,onChange:n})=>{const{formatMessage:o}=(0,h.useIntl)();return e.createElement(F.x,{background:"neutral0",hasRadius:!0,shadow:"tableShadow",paddingTop:6,paddingBottom:6,paddingLeft:7,paddingRight:7},e.createElement(P.r,{gap:4},e.createElement(E.P,{s:12,col:6},e.createElement(p.P,{label:o({id:(0,l.Z)("config.entries.title"),defaultMessage:"Entries per page"}),hint:o({id:(0,l.Z)("config.entries.note"),defaultMessage:"Number of assets displayed by default in the Media Library"}),onChange:a=>n({target:{name:"pageSize",value:a}}),name:"pageSize",value:s,"test-pageSize":s,"data-testid":"pageSize-select"},D.ay.map(a=>e.createElement(C.W,{"data-testid":`pageSize-option-${a}`,key:a,value:a},a)))),e.createElement(E.P,{s:12,col:6},e.createElement(p.P,{label:o({id:(0,l.Z)("config.sort.title"),defaultMessage:"Default sort order"}),hint:o({id:(0,l.Z)("config.note"),defaultMessage:"Note: You can override this value in the media library."}),onChange:a=>n({target:{name:"sort",value:a}}),name:"sort",value:i,"test-sort":i,"data-testid":"sort-select"},D.Fo.map(a=>e.createElement(C.W,{"data-testid":`sort-option-${a.value}`,key:a.key,value:a.value},o({id:(0,l.Z)(a.key),defaultMessage:`${a.value}`})))))))};S.propTypes={sort:d().string.isRequired,pageSize:d().number.isRequired,onChange:d().func.isRequired};var H=t(97889),x=t(3040),U=t.n(x),V=t(33795),Y=t.n(V),c=t(74951);const M=`${c.Z}/ON_CHANGE`,Z=`${c.Z}/SET_LOADED`,m={initialData:{},modifiedData:{}},L=i=>({...m,initialData:i,modifiedData:i});var j=(i=m,s)=>(0,H.default)(i,n=>{switch(s.type){case M:{U()(n,["modifiedData",...s.keys.split(".")],s.value);break}case Z:{const o=L(Y()(n,["modifiedData"],{}));n.initialData=o.initialData,n.modifiedData=o.modifiedData;break}default:return n}});const J=({name:i,value:s})=>({type:M,keys:i,value:s}),K=()=>({type:Z});var Q=t(68715);const T=({config:i})=>{const{trackUsage:s}=(0,r.useTracking)(),{formatMessage:n}=(0,h.useIntl)(),o=(0,r.useNotification)(),{mutateConfig:a}=(0,Q.Z)(),{isLoading:A}=a,[k,w]=(0,e.useState)(!1),f=()=>w(g=>!g),[q,N]=(0,e.useReducer)(j,m,()=>L(i)),{initialData:_,modifiedData:u}=q,tt=g=>{g.preventDefault(),f()},et=async()=>{s("willEditMediaLibraryConfig"),await a.mutateAsync(u),f(),N(K()),o({type:"success",message:{id:"notification.form.success.fields",defaultMessage:"Changes saved"}})},at=({target:{name:g,value:nt}})=>{N(J({name:g,value:nt}))};return(0,r.useFocusWhenNavigate)(),e.createElement(I.A,null,e.createElement(G.o,{"aria-busy":A},e.createElement("form",{onSubmit:tt},e.createElement(W.T,{navigationAction:e.createElement(r.Link,{startIcon:e.createElement(b.Z,null),to:`/plugins/${c.Z}`,id:"go-back"},n({id:(0,l.Z)("config.back"),defaultMessage:"Back"})),primaryAction:e.createElement($.z,{size:"S",startIcon:e.createElement(y.Z,null),disabled:z()(u,_),type:"submit"},n({id:"global.save",defaultMessage:"Save"})),subtitle:n({id:(0,l.Z)("config.subtitle"),defaultMessage:"Define the view settings of the media library."}),title:n({id:(0,l.Z)("config.title"),defaultMessage:"Configure the view - Media Library"})}),e.createElement(O.D,null,e.createElement(S,{"data-testid":"settings",pageSize:u.pageSize||"",sort:u.sort||"",onChange:at})),e.createElement(r.ConfirmDialog,{bodyText:{id:(0,l.Z)("config.popUpWarning.warning.updateAllSettings"),defaultMessage:"This will modify all your settings"},iconRightButton:e.createElement(y.Z,null),isConfirmButtonLoading:A,isOpen:k,onToggleDialog:f,onConfirm:et,variantRightButton:"success-light"}))))};T.propTypes={config:d().shape({pageSize:d().number,sort:d().string}).isRequired};var X=T}}]);
