"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{1402:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var n=s(285),a=s(575),d=s(286);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})}},1401:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var n=s(285),a=s(575),d=s(286),o=s(1402),i=s(89),r=s(1115),u=s(623);const l=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,a.useNavigate)(),[t,s]=(0,n.useState)(),{ipAddress:i,viewer:r}=(0,a.useLoaderData)(),{ipAddressId:p}=(0,a.useParams)(),[m,{loading:f}]=(0,u.useMutation)(l,{onCompleted:()=>e(-1)}),D=t||i.defaultDomain?.id,A=t&&t!==i.defaultDomain?.id,j="ADMIN"===r.type||"EXCLUSIVE"===i.type,y=e=>()=>s(e),g=(0,n.useMemo)((()=>[{key:"name",title:(0,n.jsx)(c,{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)(c,{content:"title",params:{type:(0,n.jsx)(c,{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)(c,{content:"setAsDefault"})})}):null})})}}}]);
//# sourceMappingURL=IpAddressDomainsPage.js.map?f38d977d263ddc62095e