"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{1419:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var n=s(295),a=s(598),d=s(296),o=s(1420),i=s(90),r=s(695);const u=s(582).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,a.useNavigate)(),[t,s]=(0,n.useState)(),{ipAddress:i,viewer:c}=(0,a.useLoaderData)(),{ipAddressId:p}=(0,a.useParams)(),[m,{loading:f}]=(0,r.useMutation)(u,{onCompleted:()=>e(-1)}),D=t||i.defaultDomain?.id,A=t&&t!==i.defaultDomain?.id,j="ADMIN"===c.type||"EXCLUSIVE"===i.type,y=e=>()=>s(e),g=(0,n.useMemo)(()=>[{key:"name",title:(0,n.jsx)(l,{content:"site"}),type:"title",render:({id:e,name:t})=>j?(0,n.jsx)(d.Radio,{onChange:y(e),checked:D===e,children:t}):t}],[D,j]);return(0,n.jsx)(o.default,{"data-type":"ip-address-domains-drawer",title:(0,n.jsx)(l,{content:"title",params:{type:(0,n.jsx)(l,{content:`type-${i.type}`}),ipAddress:i.ipAddress}}),children:(0,n.jsx)(d.List,{id:"ip-address-domains-list",rowKey:"id",data:i.domains,columns:g,toolbar:j?(0,n.jsx)(d.Toolbar,{children:(0,n.jsx)(d.Button,{"data-testid":"updateDomainButton",onClick:async()=>{await m({variables:{input:{ipAddressId:p,domainId:t}}})},disabled:!A,state:f?"loading":void 0,children:(0,n.jsx)(l,{content:"setAsDefault"})})}):null})})}},1420:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var n=s(295),a=s(598),d=s(296);const o=({onClose:e,isOpen:t=!0,closeOnFormSuccess:s=!0,closeUrl:o="..",form:i,...r})=>{const u=(0,a.useNavigate)(),[l,c]=(0,n.useState)(t),p=(0,n.useRef)(null),m=(0,n.useCallback)((...t)=>{const s=e??(()=>u(o,{preventScrollReset:!0}));c(!1),p.current=setTimeout(()=>{s(...t),p.current=null},300)},[o,u,e]);(0,n.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,n.useEffect)(()=>{t?p.current&&clearTimeout(p.current):c(t)},[t]);const f=(0,n.useMemo)(()=>{if(i&&s){if((0,n.isValidElement)(i))return(0,n.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,n.jsx)(d.Drawer,{...r,form:f,onClose:m,isOpen:l})}}}]);
//# sourceMappingURL=IpAddressDomainsPage.js.map?e4f29279759ac53d974a