"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{1069:(e,s,t)=>{t.r(s),t.d(s,{default:()=>l});var n=t(270),o=t(575),a=t(272),d=t.n(a),i=t(271);const r=({onClose:e,isOpen:s=!0,closeOnFormSuccess:t=!0,closeUrl:a="..",form:d,...r})=>{const l=(0,o.useNavigate)(),[u,c]=(0,n.useState)(s),p=(0,n.useRef)(null),m=(0,n.useCallback)(((...s)=>{const t=e??(()=>l(a,{preventScrollReset:!0}));c(!1),p.current=setTimeout((()=>{t(...s),p.current=null}),300)}),[a,l,e]);(0,n.useEffect)((()=>()=>clearTimeout(p.current)),[]),(0,n.useEffect)((()=>{s?p.current&&clearTimeout(p.current):c(s)}),[s]);const f=(0,n.useMemo)((()=>{if(d&&t){if((0,n.isValidElement)(d))return(0,n.cloneElement)(d,{onSuccess:()=>{d.props.onSuccess?.(),m()}});if("object"==typeof d)return{...d,onSuccess:()=>{d.onSuccess?.(),m()}}}return d}),[t,m,d]);return(0,n.jsx)(i.Drawer,{...r,form:f,onClose:m,isOpen:u})};r.propTypes={onClose:d().func,isOpen:d().bool,form:d().oneOfType([d().object,d().node]),closeOnFormSuccess:d().bool,closeUrl:d().oneOfType([d().string,d().object])};const l=r},1068:(e,s,t)=>{t.r(s),t.d(s,{default:()=>p});var n=t(270),o=t(575),a=t(271),d=t(1069),i=t(89),r=t(495),l=t(619);const u=r.gql`
    mutation UpdateIpAddressDefaultDomain($input: UpdateIpAddressDefaultDomainInput!) {
        updateIpAddressDefaultDomain(input: $input) {
            ipAddress {
                id
                defaultDomain {
                    id
                }
            }
        }
    }
`,c=i.Locale.getTranslate("components.pages.ip-address-domains"),p=()=>{const e=(0,o.useNavigate)(),[s,t]=(0,n.useState)(),{ipAddress:i,viewer:r}=(0,o.useLoaderData)(),{ipAddressId:p}=(0,o.useParams)(),[m,{loading:f}]=(0,l.useMutation)(u,{onCompleted:()=>e(-1)}),D=s||i.defaultDomain?.id,y=s&&s!==i.defaultDomain?.id,j="ADMIN"===r.type||"EXCLUSIVE"===i.type,b=e=>()=>t(e),A=(0,n.useMemo)((()=>[{key:"name",title:(0,n.jsx)(c,{content:"site"}),type:"title",render:({id:e,name:s})=>j?(0,n.jsx)(a.Radio,{onChange:b(e),checked:D===e,children:s}):s}]),[D,j]);return(0,n.jsx)(d.default,{"data-type":"ip-address-domains-drawer",title:(0,n.jsx)(c,{content:"title",params:{type:(0,n.jsx)(c,{content:`type-${i.type}`}),ipAddress:i.ipAddress}}),children:(0,n.jsx)(a.List,{id:"ip-address-domains-list",rowKey:"id",data:i.domains,columns:A,toolbar:j?(0,n.jsx)(a.Toolbar,{children:(0,n.jsx)(a.Button,{"data-testid":"updateDomainButton",onClick:async()=>{await m({variables:{input:{ipAddressId:p,domainId:s}}})},disabled:!y,state:f?"loading":void 0,children:(0,n.jsx)(c,{content:"setAsDefault"})})}):null})})}}}]);
//# sourceMappingURL=IpAddressDomainsPage.js.map?a326d7c8cf531ad16f88