"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{1528(e,t,s){s.r(t),s.d(t,{default:()=>i});var a=s(372),n=s(693),d=s(373);const i=({onClose:e,isOpen:t=!0,closeOnFormSuccess:s=!0,closeUrl:i="..",form:o,...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(i,{preventScrollReset:!0}));c(!1),p.current=setTimeout(()=>{s(...t),p.current=null},300)},[i,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(o&&s){if((0,a.isValidElement)(o))return(0,a.cloneElement)(o,{onSuccess:(...e)=>{o.props.onSuccess?.(...e),m()}});if("object"==typeof o)return{...o,onSuccess:(...e)=>{o.onSuccess?.(...e),m()}}}return o},[s,m,o]);return(0,a.jsx)(d.Drawer,{...r,form:f,onClose:m,isOpen:l})}},1527(e,t,s){s.r(t),s.d(t,{default:()=>m});var a=s(372),n=s(693),d=s(373),i=s(1528),o=s(95),r=s(785),u=s(676),l=s(639);const c=u.gql`
    mutation UpdateIpAddressDefaultDomain($input: UpdateIpAddressDefaultDomainInput!) {
        updateIpAddressDefaultDomain(input: $input) {
            ipAddress {
                id
                defaultDomain {
                    id
                }
            }
        }
    }
`,p=o.Locale.getTranslate("components.pages.ip-address-domains"),m=()=>{const e=(0,n.useNavigate)(),[t,s]=(0,a.useState)(),{ipAddress:o,viewer:u}=(0,n.useLoaderData)(),{ipAddressId:m}=(0,n.useParams)(),[f,{loading:g}]=(0,r.useMutation)(c,{onCompleted:()=>e(-1)}),D=t||o.defaultDomain?.id,h=t&&t!==o.defaultDomain?.id,y="ADMIN"===u.type||"EXCLUSIVE"===o.type,A=e=>()=>s(e),b=(0,a.useMemo)(()=>[{key:"name",title:(0,a.jsx)(p,{content:"site"}),type:"title",render:({id:e,name:t,htype:s})=>y?(0,a.jsx)(d.Radio,{onChange:A(e),checked:D===e,disabled:"NONE"===s,children:t}):t}],[D,y]);return(0,a.jsx)(i.default,{"data-type":"ip-address-domains-drawer",title:(0,a.jsx)(p,{content:"title",params:{type:(0,a.jsx)(p,{content:`type-${o.type}`}),ipAddress:o.ipAddress}}),children:(0,a.jsx)(d.List,{id:"ip-address-domains-list",rowKey:"id",data:o.domains,columns:b,toolbar:y?(0,a.jsx)(d.Toolbar,{children:(0,a.jsx)(d.Button,{"data-testid":"updateDomainButton",onClick:async()=>{try{await f({variables:{input:{ipAddressId:m,domainId:t}}})}catch(e){(0,l.addToast)({intent:"danger",message:e.message})}},disabled:!h,state:g?"loading":void 0,children:(0,a.jsx)(p,{content:"setAsDefault"})})}):null})})}}}]);
//# sourceMappingURL=IpAddressDomainsPage.js.map?36341c4358b814888e2c