"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/admin/settings-ui/branding"],{1327:(e,n,l)=>{l.r(n),l.d(n,{default:()=>j});var o=l(224),t=l.n(o),i=l(222),s=l(223),a=l(97),c=l(702),r=l(272),d=l(774),g=l(864),u=l(508),m=l(273),b=l(379),F=l(740);const x=a.Locale.getTranslate("admin.components.forms.settings-ui.branding"),h=m.gql`
    mutation EditBranding($input: EditBrandingInput!) {
        editBranding(input: $input) {
            query {
                server {
                    branding {
                        customTitle
                        logo {
                            url
                        }
                    }
                }
            }
        }
    }
`,v=({branding:{customTitle:e,logo:n,customFavicon:l},returnUrl:o,isCustomFaviconAllowed:t})=>{const r=(0,c.useHistory)(),[d,m]=(0,i.useState)({customTitleEnabled:!!e,customTitle:e??"",customLogoEnabled:!!n,logoFile:null,logoUrlEnabled:n?.url?"enabled":"disabled",logoUrl:n?.url,customFaviconEnabled:l,faviconFileSvg:null,faviconFileIco:null}),v=()=>(0,u.isMatch)(o)?r.push(o):(0,a.redirect)(o),[j]=(0,b.useMutation)(h);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{children:(0,i.jsx)(x,{content:"description"})}),(0,i.jsxs)(g.default,{mutation:j,values:d,onFieldChange:(e,n)=>{m((l=>(0,s.setIn)(l,e,n)))},submitButton:{id:"buttonid-ok"},applyButton:{id:"buttonid-apply"},cancelButton:{id:"buttonid-cancel",onClick:v},onSubmit:({customTitleEnabled:e,customTitle:n,customLogoEnabled:l,logoUrlEnabled:o,logoUrl:t,logoFile:i,customFaviconEnabled:s,faviconFileSvg:a,faviconFileIco:c})=>({customTitle:e?n:"",customLogoEnabled:l,logoUrlEnabled:l&&"enabled"===o,logoUrl:l&&"enabled"===o?t:"",logoFile:l?i:null,customFaviconEnabled:s,faviconFileSvg:s?a:null,faviconFileIco:s?c:null}),onSuccess:(n,t)=>{(0,F.addToast)({intent:"success",message:(0,i.jsx)(x,{content:"updateSuccess"})});const c=(0,s.getIn)(d,"customTitleEnabled")?(0,s.getIn)(d,"customTitle"):"",r=(0,s.getIn)(d,"customFaviconEnabled")?(0,s.getIn)(d,"faviconFileSvg")||(0,s.getIn)(d,"faviconFileIco"):l;r&&window.location.reload(),t?(0,a.redirect)(window.location.pathname):e!==c||r?(0,a.redirect)(o):v()},children:[(0,i.jsxs)(s.Section,{title:(0,i.jsx)(x,{content:"sectionTitle"}),children:[(0,i.jsx)(s.FormFieldCheckbox,{name:"customTitleEnabled",label:(0,i.jsx)(x,{content:"enableCustomTitle"})}),(0,i.jsx)(s.FormFieldText,{name:"customTitle",label:(0,i.jsx)(x,{content:"customTitle"}),size:"lg",maxLength:"255",disabled:!(0,s.getIn)(d,"customTitleEnabled")})]}),(0,i.jsxs)(s.Section,{title:(0,i.jsx)(x,{content:"sectionLogo"}),children:[(0,i.jsx)(s.FormFieldCheckbox,{name:"customLogoEnabled",label:(0,i.jsx)(x,{content:"enableCustomLogo"})}),(0,i.jsx)(s.FormField,{name:"logoFile",label:(0,i.jsx)(x,{content:"logo"}),disabled:!(0,s.getIn)(d,"customLogoEnabled"),children:({getId:e,getName:l,setValue:o,isDisabled:t})=>(0,i.jsxs)(i.Fragment,{children:[n?.fake&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("img",{style:{"max-width":"224px"},src:`/images/logos/${n.fake}`,alt:""}),(0,i.jsx)("br",{}),(0,i.jsx)("br",{})]}),(0,i.jsx)(s.InputFile,{id:e(),name:l(),disabled:t(),onChange:e=>o(e)})]})}),(0,i.jsx)(s.FormFieldRadioButtons,{name:"logoUrlEnabled",label:(0,i.jsx)(x,{content:"logoUrl"}),disabled:!(0,s.getIn)(d,"customLogoEnabled"),options:[{value:"disabled",label:(0,i.jsx)(x,{content:"logoUrlDisabled"})},{value:"enabled",label:(0,i.jsx)(x,{content:"logoUrlEnabled"}),indentFields:[(0,i.jsx)(s.FormFieldText,{name:"logoUrl",label:null,size:"lg",maxLength:"245"},"logoUrl")]}]})]}),t&&(0,i.jsxs)(s.Section,{title:(0,i.jsx)(x,{content:"sectionFavicon"}),children:[(0,i.jsx)(s.FormFieldCheckbox,{name:"customFaviconEnabled",label:(0,i.jsx)(x,{content:"enableCustomFavicon"}),description:(0,i.jsx)(x,{content:"sectionFaviconDesc"})}),(0,i.jsx)(s.FormField,{name:"faviconFileSvg",label:(0,i.jsx)(x,{content:"faviconSvg"}),description:(0,i.jsx)(x,{content:"faviconSvgHint"}),disabled:!(0,s.getIn)(d,"customFaviconEnabled"),required:!0,children:({getId:e,getName:n,setValue:o,isDisabled:t})=>(0,i.jsxs)(i.Fragment,{children:[l&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Icon,{src:"/images/favicon.svg",size:"16"})," "]}),(0,i.jsx)(s.InputFile,{id:e(),name:n(),disabled:t(),onChange:e=>o(e)})]})}),(0,i.jsx)(s.FormField,{name:"faviconFileIco",label:(0,i.jsx)(x,{content:"faviconIco"}),description:(0,i.jsx)(x,{content:"faviconIcoHint"}),disabled:!(0,s.getIn)(d,"customFaviconEnabled"),required:!0,children:({getId:e,getName:n,setValue:o,isDisabled:t})=>(0,i.jsxs)(i.Fragment,{children:[l&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Icon,{src:"/favicon.ico",size:"16"})," "]}),(0,i.jsx)(s.InputFile,{id:e(),name:n(),disabled:t(),onChange:e=>o(e)})]})})]})]})]})};v.propTypes={branding:t().shape({customTitle:t().string,logo:t().shape({url:t().string.isRequired,fake:t().string.isRequired}),customFavicon:t().bool.isRequired}).isRequired,returnUrl:t().string.isRequired,isCustomFaviconAllowed:t().bool},v.defaultProps={isCustomFaviconAllowed:!1};const j=(0,d.withPageLayout)(v,(({viewer:{type:e},server:{branding:n}})=>{const{logo:l,showFrames:o,pageHeader:t,pageSidebar:i}=(0,r.default)(),s="ADMIN"===e?[i.isPowerUserPanel?null:{title:a.Locale.getSection("admin.controllers.home.admin").lmsg("title"),href:"/admin/home"},{title:a.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:"/admin/server/tools"}].filter(Boolean):[i.isPowerUserPanel?null:{title:a.Locale.getSection("admin.controllers.home.reseller").lmsg("title"),href:"/admin/home/reseller"},{title:a.Locale.getSection("admin.controllers.reseller.tools").lmsg("title"),href:"/admin/reseller/tools"}].filter(Boolean);s.push({title:a.Locale.getSection("admin.controllers.settings-ui.branding").lmsg("title"),href:"/cp/settings-ui/branding"});const c=s[s.length-1].title;return{branding:n,returnUrl:s[s.length-2].href,isCustomFaviconAllowed:"ADMIN"===e,logo:l,showFrames:o,pageHeader:{...t,helpMenu:{...t.helpMenu,helpContext:"ADMIN"===e?"logo":"reseller.logo",helpPrefix:"ADMIN"===e?null:"res/"}},pageSidebar:i,pageContentHeader:{pageTitle:c,breadcrumbs:s},pageTitle:c}}))}}]);
//# sourceMappingURL=branding.js.map?ebf360cf87da44821e3b