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