"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/SpamFilterWhiteListPage"],{1037:(e,t,s)=>{s.r(t),s.d(t,{SORT_ASC:()=>c,SORT_DESC:()=>u,default:()=>f});var n=s(270),i=s(272),o=s.n(i),a=s(271),r=s(89);const l=r.Locale.getTranslate("components.list"),d=r.Locale.getSection("components.list"),c="ASC",u="DESC",m="all",p={set(e,t){localStorage.setItem(e,JSON.stringify(t))},get(e){const t=localStorage.getItem(e);return JSON.parse(t)}},g=e=>`list-sort_${e}`,y=e=>`list-page_${e}`,h=({id:e,data:t,columns:s,itemsPerPage:i=25,itemsPerPageOptions:o=[10,25,100,m],sortColumn:r,sortDirection:u=c,searchField:h,locale:f={},emptyView:x,emptyFilteredView:T,toolbar:P,selection:j=[],onSelectionChange:S,searchBarInputProps:b,rowKey:L="key",...C})=>{const{sortColumn:F,sortDirection:A,setSortState:w}=((e,{sortColumn:t,sortDirection:s})=>{const[{sortColumn:i,sortDirection:o},a]=(0,n.useState)({sortColumn:p.get(g(e))?.sortColumn??t,sortDirection:p.get(g(e))?.sortDirection??s});return{sortColumn:i,sortDirection:o,setSortState:t=>{a((e=>({...e,...t}))),p.set(g(e),{...p.get(g(e)),...t})}}})(e,{sortColumn:r??s.find((({sortable:e})=>e))?.key,sortDirection:u}),{page:D,itemsPerPage:k,searchPattern:v,setPageState:R}=((e,{itemsPerPage:t})=>{const[{page:s,itemsPerPage:i,searchPattern:o},a]=(0,n.useState)({page:p.get(y(e))?.page??1,itemsPerPage:p.get(y(e))?.itemsPerPage??t,searchPattern:p.get(y(e))?.searchPattern??""});return{page:s,itemsPerPage:i,searchPattern:o,setPageState:t=>{a((e=>({...e,...t}))),p.set(y(e),{...p.get(y(e)),...t})}}})(e,{itemsPerPage:o.includes(i)?i:o[0]}),B=(0,n.useMemo)((()=>v?T??(0,n.jsx)(a.ListEmptyView,{reason:"filtered",title:(0,n.jsx)(l,{content:"emptyViewFilteredTitle"}),description:(0,n.jsx)(l,{content:"emptyViewFilteredDescription"})}):x??(0,n.jsx)(a.ListEmptyView,{title:(0,n.jsx)(l,{content:"emptyViewTitle"})})),[v,x,T]),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)=>c===A?t(e,s):t(s,e)))}),[O,F,A,s]),q=(0,n.useMemo)((()=>{if(k===m)return E;const e=k*(D-1),t=e+k;return E.slice(e,t)}),[D,E,k]),V=(0,n.useCallback)((e=>{R({searchPattern:e}),e!==v&&R({page:1})}),[v]),$=(0,n.useCallback)((e=>{R({itemsPerPage:e});(e===m?1:Math.ceil(O.length/e))<D&&R({page:1})}),[O.length,D]);return(0,n.useEffect)((()=>{if("function"==typeof S&&j.length){const e=O.map((e=>{return t=e,"function"==typeof(s=L)?s(t):t[s];var t,s})).filter((e=>j.includes(e)));S(e)}}),[O]),(0,n.jsx)(a.List,{pagination:(0,n.jsx)(a.Pagination,{current:D,total:k===m?1:Math.ceil(O.length/k),onSelect:e=>R({page:e}),itemsPerPage:k,itemsPerPageOptions:o,onItemsPerPageChange:$}),toolbar:(P||h)&&(0,n.jsxs)(a.Toolbar,{children:[P,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:d.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:v,...b??{}},onTyping:V})})]})]}),totalRows:O.length,sortColumn:F,sortDirection:A,onSortChange:w,columns:M,data:q,filtered:!!v,locale:{totalRows:({totalRows:e})=>d.formatMessage("recordsTotal",{total:e}),...f},emptyView:B,onSelectionChange:S,selection:j,rowKey:L,...C})};h.propTypes={id:o().string.isRequired,data:o().array.isRequired,columns:o().array.isRequired,itemsPerPage:o().number,itemsPerPageOptions:o().array,sortColumn:o().string,sortDirection:o().string,searchField:o().oneOfType([o().string,o().arrayOf(o().string.isRequired)]),locale:o().object,emptyView:o().node,emptyFilteredView:o().node,toolbar:o().node,onSelectionChange:o().func,selection:o().array,rowKey:o().oneOfType([o().string,o().func]),searchBarInputProps:o().object};const f=h},2135:(e,t,s)=>{s.r(t),s.d(t,{default:()=>j});var n=s(272),i=s(271),o=s(89),a=s(270),r=s(495),l=s(616),d=s(530),c=s(847),u=s(843),m=s.n(u),p=s(844),g=s.n(p);const y=o.Locale.getTranslate("components.forms.spam-filter.add"),h=o.Locale.getSection("components.forms.spam-filter.add"),f=r.gql`
    mutation AddAddressesToSpamFilterList($input: AddAddressesToSpamFilterListInput!) {
        addAddressesToSpamFilterList(input: $input) {
            warnings
        }
    }
`,x="file",T="string",P=({isBlackList:e,isOpen:t=!1,onClose:s})=>{const[n,o]=(0,a.useState)({dataType:x,file:null,addresses:""}),[r,{loading:u}]=(0,l.useMutation)(f,{refetchQueries:[{query:e?m():g()}],awaitRefetchQueries:!0});return(0,a.jsx)(i.Drawer,{"data-type":"add-domain-to-spam-filter-list",title:(0,a.jsx)(y,{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)(y,{content:"success"})}),s(),o({dataType:x,file:null,addresses:""})},onFieldChange:(e,t)=>o((0,i.setIn)(n,e,t)),values:n,mutation:r,children:[(0,a.jsx)(i.Text,{component:"p",children:(0,a.jsx)("div",{dangerouslySetInnerHTML:{__html:h.lmsg("listDescription")}})}),(0,a.jsx)(i.FormFieldRadioButtons,{label:null,name:"dataType",options:[{value:x,label:(0,a.jsx)(y,{content:"fromFile"}),indentFields:[(0,a.jsx)(i.FormField,{name:"file",label:null,description:(0,a.jsx)(y,{content:"fileDescription"}),children:({getId:e,getName:t,setValue:s,isDisabled:n})=>(0,a.jsx)(i.InputFile,{id:e(),name:t(),disabled:n(),onChange:e=>s(e)})},"file")]},{value:T,label:(0,a.jsx)(y,{content:"fromList"}),indentFields:[(0,a.jsx)(i.FormFieldText,{name:"addresses",label:null,multiline:!0,size:"xl"},"addresses")]}]})]})})};P.propTypes={isOpen:n.PropTypes.bool,isBlackList:n.PropTypes.bool.isRequired,onClose:n.PropTypes.func.isRequired};const j=P},2134:(e,t,s)=>{s.r(t),s.d(t,{default:()=>j});var n=s(272),i=s(271),o=s(89),a=s(1037),r=s(270),l=s(530),d=s(495),c=s(616),u=s(843),m=s.n(u),p=s(844),g=s.n(p);const y=o.Locale.getTranslate("components.lists.spam-filter"),h=o.Locale.getSection("components.lists.spam-filter"),f=o.Locale.getTranslate("components.buttons"),x="BlackList",T=d.gql`
    mutation DeleteAddressesFromSpamFilterList($input: DeleteAddressesFromSpamFilterListInput!) {
        deleteAddressesFromSpamFilterList(input: $input) {
            __typename
        }
    }
`,P=({list:e,type:t,onAddDomain:s})=>{const[n,o]=(0,r.useState)([]),[d,u]=(0,r.useState)([]),p=(0,r.useMemo)((()=>e.filter((({id:e})=>n.includes(e)))),[e,n]),[P]=(0,c.useMutation)(T,{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)(i.ToolbarGroup,{title:h.lmsg("groupAdd"),children:(0,r.jsx)(i.Button,{id:`add${t}edDomain`,intent:"primary",icon:"plus",tooltip:(0,r.jsx)(y,{content:t===x?"buttonAddAddressToBlackListHint":"buttonAddAddressToWhiteListHint"}),"aria-label":h.lmsg(t===x?"buttonAddAddressToBlackListHint":"buttonAddAddressToWhiteListHint"),onClick:s})}),(0,r.jsx)(i.ToolbarGroup,{title:h.lmsg("groupActions"),children:(0,r.jsx)(i.ListOperation,{critical:!0,noSelectionText:(0,r.jsx)(y,{content:"removeEmptySelection"}),confirmationText:h.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)(i.Button,{id:`remove${t}edDomain`,onClick:async()=>{u(n);try{await P({variables:{input:{ids:n}}}),(0,l.addToast)({intent:"success",message:(0,r.jsx)(y,{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{o([]),u([])}},children:(0,r.jsx)(y,{content:"buttonRemove"})})})})]}),columns:[{key:"name",title:(0,r.jsx)(y,{content:"entries"}),type:"title",sortable:!0}],rowKey:"id",data:e,searchField:"name",selection:n,onSelectionChange:e=>o(e),loadingRows:d,emptyView:(0,r.jsx)(i.ListEmptyView,{title:(0,r.jsx)(y,{content:`addAddressTo${t}EmptyTitle`}),description:(0,r.jsx)(y,{content:`addAddressTo${t}EmptyDescription`}),actions:(0,r.jsx)(i.Button,{id:`add${t}edDomain`,intent:"primary",tooltip:(0,r.jsx)(y,{content:`buttonAddAddressTo${t}Hint`}),onClick:s,children:(0,r.jsx)(y,{content:"buttonAddAddress"})})})})};P.propTypes={list:n.PropTypes.array.isRequired,type:n.PropTypes.string.isRequired,onAddDomain:n.PropTypes.func.isRequired};const j=P},2136:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var n=s(579),i=s(2134),o=s(2135),a=s(844),r=s.n(a),l=s(270);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)(o.default,{isOpen:e,isBlackList:!1,onClose:()=>t(!1)}),(0,l.jsx)(i.default,{list:s,type:"WhiteList",onAddDomain:()=>t(!0)})]})}}}]);
//# sourceMappingURL=SpamFilterWhiteListPage.js.map?af9112ed5a1450d87477