"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/SpamFilterWhiteListPage"],{1425:(e,t,s)=>{s.r(t),s.d(t,{SORT_ASC:()=>l,SORT_DESC:()=>d,default:()=>h});var n=s(295),o=s(667),i=s.n(o),a=s(296);const r=s(90).Locale.getSection("components.list"),l="ASC",d="DESC",c="all",u={set(e,t){localStorage.setItem(e,JSON.stringify(t))},get(e){const t=localStorage.getItem(e);return JSON.parse(t)}},m=e=>`list-sort_${e}`,p=e=>`list-page_${e}`,g=({id:e,data:t,columns:s,itemsPerPage:o=25,itemsPerPageOptions:i=[10,25,100,c],sortColumn:d,sortDirection:g=l,searchField:h,locale:y={},emptyView:f,emptyFilteredView:P,toolbar:x,selection:T=[],onSelectionChange:S,searchBarInputProps:j,rowKey:b="key",useStorage:C=!0,...L})=>{const{sortColumn:F,sortDirection:w,setSortState:A}=((e,{sortColumn:t,sortDirection:s})=>{const[{sortColumn:o,sortDirection:i},a]=(0,n.useState)({sortColumn:u.get(m(e))?.sortColumn??t,sortDirection:u.get(m(e))?.sortDirection??s});return{sortColumn:o,sortDirection:i,setSortState:t=>{a(e=>({...e,...t})),u.set(m(e),{...u.get(m(e)),...t})}}})(e,{sortColumn:d??s.find(({sortable:e})=>e)?.key,sortDirection:g}),{page:D,itemsPerPage:k,searchPattern:v,setPageState:R}=((e,{itemsPerPage:t},s=!0)=>{const o=s?{page:u.get(p(e))?.page,itemsPerPage:u.get(p(e))?.itemsPerPage,searchPattern:u.get(p(e))?.searchPattern}:{},[{page:i,itemsPerPage:a,searchPattern:r},l]=(0,n.useState)({page:o.page??1,itemsPerPage:o.itemsPerPage??t,searchPattern:o.searchPattern??""});return{page:i,itemsPerPage:a,searchPattern:r,setPageState:t=>{l(e=>({...e,...t})),s&&u.set(p(e),{...u.get(p(e)),...t})}}})(e,{itemsPerPage:i.includes(o)?o:i[0]},C),B=(0,n.useMemo)(()=>v?P??(0,n.jsx)(a.ListEmptyView,{reason:"filtered","data-testid":"list-empty-view-filtered"}):f??(0,n.jsx)(a.ListEmptyView,{}),[v,f,P]),M=(0,n.useMemo)(()=>s.map(({sortDataField:e,...t})=>t),[s]),O=(0,n.useMemo)(()=>h&&v?t.filter(e=>(Array.isArray(h)?h:[h]).some(t=>e[t]&&String(e[t]).toLowerCase().includes(v.toLowerCase()))):t,[t,v,h]),E=(0,n.useMemo)(()=>{if(!F)return O;const e=s.find(({key:e})=>e===F)?.sortDataField??F,t=s.find(({key:e})=>e===F)?.sort??((t,s)=>t[e]<s[e]?-1:t[e]>s[e]?1:0);return[...O].sort((e,s)=>l===w?t(e,s):t(s,e))},[O,F,w,s]),q=(0,n.useMemo)(()=>{if(k===c)return E;const e=k*(D-1),t=e+k;return E.slice(e,t)},[D,E,k]),$=(0,n.useCallback)(e=>{R({searchPattern:e}),e!==v&&R({page:1})},[v]),I=(0,n.useCallback)(e=>{R({itemsPerPage:e});(e===c?1:Math.ceil(O.length/e))<D&&R({page:1})},[O.length,D]);return(0,n.useEffect)(()=>{if("function"==typeof S&&T.length){const e=O.map(e=>{return t=e,"function"==typeof(s=b)?s(t):t[s];var t,s}).filter(e=>T.includes(e));S(e)}},[O]),(0,n.jsx)(a.List,{pagination:(0,n.jsx)(a.Pagination,{current:D,total:k===c?1:Math.ceil(O.length/k),onSelect:e=>R({page:e}),itemsPerPage:k,itemsPerPageOptions:i,onItemsPerPageChange:I}),toolbar:(x||h)&&(0,n.jsxs)(a.Toolbar,{children:[x,h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.ToolbarExpander,{}),(0,n.jsx)(a.ToolbarGroup,{title:"",children:(0,n.jsx)(a.SearchBar,{inputProps:{placeholder:r.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:v,...j??{}},onTyping:$})})]})]}),totalRows:O.length,sortColumn:F,sortDirection:w,onSortChange:A,columns:M,data:q,filtered:!!v,locale:{totalRows:({totalRows:e})=>r.formatMessage("recordsTotal",{total:e}),...y},emptyView:B,onSelectionChange:S,selection:T,rowKey:b,...L})};g.propTypes={id:i().string.isRequired,data:i().array.isRequired,columns:i().array.isRequired,itemsPerPage:i().number,itemsPerPageOptions:i().array,sortColumn:i().string,sortDirection:i().string,searchField:i().oneOfType([i().string,i().arrayOf(i().string.isRequired)]),locale:i().object,emptyView:i().node,emptyFilteredView:i().node,toolbar:i().node,onSelectionChange:i().func,selection:i().array,rowKey:i().oneOfType([i().string,i().func]),searchBarInputProps:i().object,useStorage:i().bool};const h=g},2610:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var n=s(667),o=s(296),i=s(90),a=s(1425),r=s(295),l=s(545),d=s(695),c=s(582),u=s(1292),m=s.n(u),p=s(1297),g=s.n(p);const h=i.Locale.getTranslate("components.lists.spam-filter"),y=i.Locale.getSection("components.lists.spam-filter"),f=i.Locale.getTranslate("components.buttons"),P="BlackList",x=c.gql`
    mutation DeleteAddressesFromSpamFilterList($input: DeleteAddressesFromSpamFilterListInput!) {
        deleteAddressesFromSpamFilterList(input: $input) {
            __typename
        }
    }
`,T=({list:e,type:t,onAddDomain:s})=>{const[n,i]=(0,r.useState)([]),[c,u]=(0,r.useState)([]),p=(0,r.useMemo)(()=>e.filter(({id:e})=>n.includes(e)),[e,n]),[T]=(0,d.useMutation)(x,{refetchQueries:[{query:"BlackList"===t?m():g()}],awaitRefetchQueries:!0});return(0,r.jsx)(a.default,{id:`server-mail-${t}`,toolbar:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.ToolbarGroup,{title:y.lmsg("groupAdd"),children:(0,r.jsx)(o.Button,{id:`add${t}edDomain`,intent:"primary",icon:"plus",tooltip:y.lmsg(t===P?"buttonAddAddressToBlackListHint":"buttonAddAddressToWhiteListHint"),tooltipAsLabel:!0,onClick:s})}),(0,r.jsx)(o.ToolbarGroup,{title:y.lmsg("groupActions"),children:(0,r.jsx)(o.ListOperation,{critical:!0,noSelectionText:(0,r.jsx)(h,{content:"removeEmptySelection"}),confirmationText:y.formatMessage("removeConfirmation",{name:(0,r.jsx)("b",{children:p[0]?.name}),count:p.length}),actionButtonText:(0,r.jsx)(f,{content:"yesRemove"}),cancelButtonText:(0,r.jsx)(f,{content:"cancel"}),children:(0,r.jsx)(o.Button,{id:`remove${t}edDomain`,onClick:async()=>{u(n);try{await T({variables:{input:{ids:n}}}),(0,l.addToast)({intent:"success",message:(0,r.jsx)(h,{content:"removeSuccess"})})}catch(e){e.graphQLErrors?e.graphQLErrors.forEach(({message:e,debugMessage:t})=>{(0,l.addToast)({intent:"danger",message:t||e})}):(0,l.addToast)({intent:"danger",message:e.message})}finally{i([]),u([])}},children:(0,r.jsx)(h,{content:"buttonRemove"})})})})]}),columns:[{key:"name",title:(0,r.jsx)(h,{content:"entries"}),type:"title",sortable:!0}],rowKey:"id",data:e,searchField:"name",selection:n,onSelectionChange:e=>i(e),loadingRows:c,emptyView:(0,r.jsx)(o.ListEmptyView,{title:(0,r.jsx)(h,{content:`addAddressTo${t}EmptyTitle`}),description:(0,r.jsx)(h,{content:`addAddressTo${t}EmptyDescription`}),actions:(0,r.jsx)(o.Button,{id:`add${t}edDomain`,intent:"primary",tooltip:(0,r.jsx)(h,{content:`buttonAddAddressTo${t}Hint`}),onClick:s,children:(0,r.jsx)(h,{content:"buttonAddAddress"})})})})};T.propTypes={list:n.PropTypes.array.isRequired,type:n.PropTypes.string.isRequired,onAddDomain:n.PropTypes.func.isRequired};const S=T},2611:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var n=s(667),o=s(296),i=s(90),a=s(295),r=s(695),l=s(582),d=s(545),c=s(1300),u=s(1292),m=s.n(u),p=s(1297),g=s.n(p);const h=i.Locale.getTranslate("components.forms.spam-filter.add"),y=i.Locale.getSection("components.forms.spam-filter.add"),f=l.gql`
    mutation AddAddressesToSpamFilterList($input: AddAddressesToSpamFilterListInput!) {
        addAddressesToSpamFilterList(input: $input) {
            warnings
        }
    }
`,P="file",x="string",T=({isBlackList:e,isOpen:t=!1,onClose:s})=>{const[n,i]=(0,a.useState)({dataType:P,file:null,addresses:""}),[l,{loading:u}]=(0,r.useMutation)(f,{refetchQueries:[{query:e?m():g()}],awaitRefetchQueries:!0});return(0,a.jsx)(o.Drawer,{"data-type":"add-domain-to-spam-filter-list",title:(0,a.jsx)(h,{content:e?"titleBlack":"titleWhite"}),isOpen:t,onClose:s,size:"sm",form:(0,a.jsxs)(c.default,{state:u?"submit":null,applyButton:!1,submitButton:{id:"btn-save"},onSubmit:({dataType:t,file:s,addresses:n})=>({listType:e?"blacklist_from":"whitelist_from",dataType:t,addresses:n,file:s}),onSuccess:({addAddressesToSpamFilterList:{warnings:e}})=>{e.length?e.forEach(e=>{(0,d.addToast)({intent:"danger",message:e})}):(0,d.addToast)({intent:"success",message:(0,a.jsx)(h,{content:"success"})}),s(),i({dataType:P,file:null,addresses:""})},onFieldChange:(e,t)=>i((0,o.setIn)(n,e,t)),values:n,mutation:l,children:[(0,a.jsx)(o.Text,{component:"p",children:(0,a.jsx)("div",{dangerouslySetInnerHTML:{__html:y.lmsg("listDescription")}})}),(0,a.jsx)(o.FormFieldRadioButtons,{label:null,name:"dataType",options:[{value:P,label:(0,a.jsx)(h,{content:"fromFile"}),indentFields:[(0,a.jsx)(o.FormField,{name:"file",label:null,description:(0,a.jsx)(h,{content:"fileDescription"}),children:({getId:e,getName:t,setValue:s,isDisabled:n})=>(0,a.jsx)(o.InputFile,{id:e(),name:t(),disabled:n(),onChange:e=>s(e)})},"file")]},{value:x,label:(0,a.jsx)(h,{content:"fromList"}),indentFields:[(0,a.jsx)(o.FormFieldText,{name:"addresses",label:null,multiline:!0,size:"xl"},"addresses")]}]})]})})};T.propTypes={isOpen:n.PropTypes.bool,isBlackList:n.PropTypes.bool.isRequired,onClose:n.PropTypes.func.isRequired};const S=T},2612:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var n=s(619),o=s(2610),i=s(2611),a=s(1297),r=s.n(a),l=s(295);const d=()=>{const[e,t]=(0,l.useState)(!1),{data:{serverMail:{spamAssassin:{whiteList:s}}}}=(0,n.useQuery)(r());return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.default,{isOpen:e,isBlackList:!1,onClose:()=>t(!1)}),(0,l.jsx)(o.default,{list:s,type:"WhiteList",onAddDomain:()=>t(!0)})]})}}}]);
//# sourceMappingURL=SpamFilterWhiteListPage.js.map?be3d8cbce22f9d7c9062