"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{942:(e,s,t)=>{t.r(s),t.d(s,{default:()=>l});var n=t(251),o=t(581),a=t(253),d=t.n(a),r=t(252);const i=({onClose:e,isOpen:s,closeOnFormSuccess:t,closeUrl:a,...d})=>{const i=(0,o.useNavigate)(),[l,u]=(0,n.useState)(s),c=(0,n.useRef)(null),p=(0,n.useCallback)(((...s)=>{const t=e??(()=>i(a,{preventScrollReset:!0}));u(!1),c.current=setTimeout((()=>{t(...s),c.current=null}),300)}),[a,i,e]);(0,n.useEffect)((()=>()=>clearTimeout(c.current)),[]),(0,n.useEffect)((()=>{s?c.current&&clearTimeout(c.current):u(s)}),[s]);const m=(0,n.useMemo)((()=>{const{form:e}=d;if(e&&t){if((0,n.isValidElement)(e))return(0,n.cloneElement)(e,{onSuccess:()=>{e.props.onSuccess?.(),p()}});if("object"==typeof e)return{...e,onSuccess:()=>{e.onSuccess?.(),p()}}}return e}),[t,p,d]);return(0,n.jsx)(r.Drawer,{...d,form:m,onClose:p,isOpen:l})};i.propTypes={onClose:d().func,isOpen:d().bool,form:d().oneOfType([d().object,d().node]),closeOnFormSuccess:d().bool,closeUrl:d().string},i.defaultProps={onClose:void 0,form:void 0,isOpen:!0,closeOnFormSuccess:!0,closeUrl:".."};const l=i},941:(e,s,t)=>{t.r(s),t.d(s,{default:()=>p});var n=t(251),o=t(581),a=t(252),d=t(942),r=t(89),i=t(495),l=t(617);const u=i.gql`
    mutation UpdateIpAddressDefaultDomain($input: UpdateIpAddressDefaultDomainInput!) {
        updateIpAddressDefaultDomain(input: $input) {
            ipAddress {
                id
                defaultDomain {
                    id
                }
            }
        }
    }
`,c=r.Locale.getTranslate("components.pages.ip-address-domains"),p=()=>{const e=(0,o.useNavigate)(),[s,t]=(0,n.useState)(),{ipAddress:r,viewer:i}=(0,o.useLoaderData)(),{ipAddressId:p}=(0,o.useParams)(),[m,{loading:f}]=(0,l.useMutation)(u,{onCompleted:()=>e(-1)}),D=s||r.defaultDomain?.id,y=s&&s!==r.defaultDomain?.id,j="ADMIN"===i.type||"EXCLUSIVE"===r.type,A=e=>()=>t(e),b=(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:A(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-${r.type}`}),ipAddress:r.ipAddress}}),children:(0,n.jsx)(a.List,{id:"ip-address-domains-list",rowKey:"id",data:r.domains,columns:b,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?99f158e7179a8de7412f