"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/SpamFilterBlackListPage"],{1407:(e,t,s)=>{s.r(t),s.d(t,{SORT_ASC:()=>l,SORT_DESC:()=>d,default:()=>y});var n=s(285),a=s(591),o=s.n(a),i=s(286);const r=s(89).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:a=25,itemsPerPageOptions:o=[10,25,100,c],sortColumn:d,sortDirection:g=l,searchField:y,locale:f={},emptyView:h,emptyFilteredView:P,toolbar:x,selection:T=[],onSelectionChange:S,searchBarInputProps:j,rowKey:b="key",useStorage:C=!0,...L})=>{const{sortColumn:F,sortDirection:A,setSortState:w}=((e,{sortColumn:t,sortDirection:s})=>{const[{sortColumn:a,sortDirection:o},i]=(0,n.useState)({sortColumn:u.get(m(e))?.sortColumn??t,sortDirection:u.get(m(e))?.sortDirection??s});return{sortColumn:a,sortDirection:o,setSortState:t=>{i((e=>({...e,...t}))),u.set(m(e),{...u.get(m(e)),...t})}}})(e,{sortColumn:d??s.find((({sortable:e})=>e))?.key,sortDirection:g}),{page:k,itemsPerPage:D,searchPattern:v,setPageState:B}=((e,{itemsPerPage:t},s=!0)=>{const a=s?{page:u.get(p(e))?.page,itemsPerPage:u.get(p(e))?.itemsPerPage,searchPattern:u.get(p(e))?.searchPattern}:{},[{page:o,itemsPerPage:i,searchPattern:r},l]=(0,n.useState)({page:a.page??1,itemsPerPage:a.itemsPerPage??t,searchPattern:a.searchPattern??""});return{page:o,itemsPerPage:i,searchPattern:r,setPageState:t=>{l((e=>({...e,...t}))),s&&u.set(p(e),{...u.get(p(e)),...t})}}})(e,{itemsPerPage:o.includes(a)?a:o[0]},C),R=(0,n.useMemo)((()=>v?P??(0,n.jsx)(i.ListEmptyView,{reason:"filtered","data-testid":"list-empty-view-filtered"}):h??(0,n.jsx)(i.ListEmptyView,{})),[v,h,P]),M=(0,n.useMemo)((()=>s.map((({sortDataField:e,...t})=>t))),[s]),O=(0,n.useMemo)((()=>y&&v?t.filter((e=>(Array.isArray(y)?y:[y]).some((t=>e[t]&&String(e[t]).toLowerCase().includes(v.toLowerCase()))))):t),[t,v,y]),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===A?t(e,s):t(s,e)))}),[O,F,A,s]),q=(0,n.useMemo)((()=>{if(D===c)return E;const e=D*(k-1),t=e+D;return E.slice(e,t)}),[k,E,D]),$=(0,n.useCallback)((e=>{B({searchPattern:e}),e!==v&&B({page:1})}),[v]),I=(0,n.useCallback)((e=>{B({itemsPerPage:e});(e===c?1:Math.ceil(O.length/e))<k&&B({page:1})}),[O.length,k]);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)(i.List,{pagination:(0,n.jsx)(i.Pagination,{current:k,total:D===c?1:Math.ceil(O.length/D),onSelect:e=>B({page:e}),itemsPerPage:D,itemsPerPageOptions:o,onItemsPerPageChange:I}),toolbar:(x||y)&&(0,n.jsxs)(i.Toolbar,{children:[x,y&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.ToolbarExpander,{}),(0,n.jsx)(i.ToolbarGroup,{title:"",children:(0,n.jsx)(i.SearchBar,{inputProps:{placeholder:r.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:v,...j??{}},onTyping:$})})]})]}),totalRows:O.length,sortColumn:F,sortDirection:A,onSortChange:w,columns:M,data:q,filtered:!!v,locale:{totalRows:({totalRows:e})=>r.formatMessage("recordsTotal",{total:e}),...f},emptyView:R,onSelectionChange:S,selection:T,rowKey:b,...L})};g.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,useStorage:o().bool};const y=g},2585:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var n=s(591),a=s(286),o=s(89),i=s(285),r=s(1115),l=s(623),d=s(536),c=s(1285),u=s(1281),m=s.n(u),p=s(1282),g=s.n(p);const y=o.Locale.getTranslate("components.forms.spam-filter.add"),f=o.Locale.getSection("components.forms.spam-filter.add"),h=r.gql`
    mutation AddAddressesToSpamFilterList($input: AddAddressesToSpamFilterListInput!) {
        addAddressesToSpamFilterList(input: $input) {
            warnings
        }
    }
`,P="file",x="string",T=({isBlackList:e,isOpen:t=!1,onClose:s})=>{const[n,o]=(0,i.useState)({dataType:P,file:null,addresses:""}),[r,{loading:u}]=(0,l.useMutation)(h,{refetchQueries:[{query:e?m():g()}],awaitRefetchQueries:!0});return(0,i.jsx)(a.Drawer,{"data-type":"add-domain-to-spam-filter-list",title:(0,i.jsx)(y,{content:e?"titleBlack":"titleWhite"}),isOpen:t,onClose:s,size:"sm",form:(0,i.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,i.jsx)(y,{content:"success"})}),s(),o({dataType:P,file:null,addresses:""})},onFieldChange:(e,t)=>o((0,a.setIn)(n,e,t)),values:n,mutation:r,children:[(0,i.jsx)(a.Text,{component:"p",children:(0,i.jsx)("div",{dangerouslySetInnerHTML:{__html:f.lmsg("listDescription")}})}),(0,i.jsx)(a.FormFieldRadioButtons,{label:null,name:"dataType",options:[{value:P,label:(0,i.jsx)(y,{content:"fromFile"}),indentFields:[(0,i.jsx)(a.FormField,{name:"file",label:null,description:(0,i.jsx)(y,{content:"fileDescription"}),children:({getId:e,getName:t,setValue:s,isDisabled:n})=>(0,i.jsx)(a.InputFile,{id:e(),name:t(),disabled:n(),onChange:e=>s(e)})},"file")]},{value:x,label:(0,i.jsx)(y,{content:"fromList"}),indentFields:[(0,i.jsx)(a.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},2584:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var n=s(591),a=s(286),o=s(89),i=s(1407),r=s(285),l=s(536),d=s(1115),c=s(623),u=s(1281),m=s.n(u),p=s(1282),g=s.n(p);const y=o.Locale.getTranslate("components.lists.spam-filter"),f=o.Locale.getSection("components.lists.spam-filter"),h=o.Locale.getTranslate("components.buttons"),P="BlackList",x=d.gql`
    mutation DeleteAddressesFromSpamFilterList($input: DeleteAddressesFromSpamFilterListInput!) {
        deleteAddressesFromSpamFilterList(input: $input) {
            __typename
        }
    }
`,T=({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]),[T]=(0,c.useMutation)(x,{refetchQueries:[{query:"BlackList"===t?m():g()}],awaitRefetchQueries:!0});return(0,r.jsx)(i.default,{id:`server-mail-${t}`,toolbar:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(a.ToolbarGroup,{title:f.lmsg("groupAdd"),children:(0,r.jsx)(a.Button,{id:`add${t}edDomain`,intent:"primary",icon:"plus",tooltip:f.lmsg(t===P?"buttonAddAddressToBlackListHint":"buttonAddAddressToWhiteListHint"),tooltipAsLabel:!0,onClick:s})}),(0,r.jsx)(a.ToolbarGroup,{title:f.lmsg("groupActions"),children:(0,r.jsx)(a.ListOperation,{critical:!0,noSelectionText:(0,r.jsx)(y,{content:"removeEmptySelection"}),confirmationText:f.formatMessage("removeConfirmation",{name:(0,r.jsx)("b",{children:p[0]?.name}),count:p.length}),actionButtonText:(0,r.jsx)(h,{content:"yesRemove"}),cancelButtonText:(0,r.jsx)(h,{content:"cancel"}),children:(0,r.jsx)(a.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)(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)(a.ListEmptyView,{title:(0,r.jsx)(y,{content:`addAddressTo${t}EmptyTitle`}),description:(0,r.jsx)(y,{content:`addAddressTo${t}EmptyDescription`}),actions:(0,r.jsx)(a.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"})})})})};T.propTypes={list:n.PropTypes.array.isRequired,type:n.PropTypes.string.isRequired,onAddDomain:n.PropTypes.func.isRequired};const S=T},2583:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var n=s(581),a=s(2584),o=s(2585),i=s(1281),r=s.n(i),l=s(285);const d=()=>{const[e,t]=(0,l.useState)(!1),{data:{serverMail:{spamAssassin:{blackList:s}}}}=(0,n.useQuery)(r());return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.default,{isOpen:e,isBlackList:!0,onClose:()=>t(!1)}),(0,l.jsx)(a.default,{list:s,type:"BlackList",onAddDomain:()=>t(!0)})]})}}}]);
//# sourceMappingURL=SpamFilterBlackListPage.js.map?80117c07412a86f92792