관리-도구
편집 파일: AddonConditions.3ce0de6d.js
import{f as S,t as y,u as k,m as U}from"./index.20192476.js";import{a as n}from"./addons.9d0af6ad.js";import{C as x}from"./Caret.662da1f3.js";import{C as L}from"./Index.c0a0a208.js";import"./translations.12335a6a.js";import{_ as C}from"./_plugin-vue_export-helper.249dac1d.js";import{_ as m,s as P}from"./default-i18n.54b5d8cd.js";import{v as g,o as p,k as f,l as r,x as s,t as c,b as M,C as B,f as u}from"./runtime-dom.esm-bundler.6789c400.js";const b="all-in-one-seo-pack",T={emits:["addon-activated"],setup(){return{addonsStore:S(),pluginsStore:y(),rootStore:k()}},components:{CoreAlert:x,Cta:L},props:{addonSlug:{type:String,required:!0},featureList:{type:Array,default:()=>[]},postActivationPromises:{type:Array,default:()=>[]},ctaButtonText:String,ctaHeader:String,ctaDescription:String,learnMoreText:String,learnMoreLink:String,alignTop:Boolean,preventGlobalAddonUpdate:Boolean},data(){return{addons:n,strings:{activateError:m("An error occurred while activating the addon. Please upload it manually or contact support for more information.",b),permissionWarning:m("You currently don't have permission to activate this addon. Please ask a site administrator to activate first.",b)},failed:!1,activationLoading:!1}},methods:{activateAddon(){this.failed=!1,this.activationLoading=!0;const t=n.getAddon(this.addonSlug);this.pluginsStore.installPlugins([{plugin:t.basename}]).then(o=>{if(o.body.failed.length){this.activationLoading=!1,this.failed=!0;return}const e=this.postActivationPromises.map(i=>i());Promise.all(e).then(()=>{if(this.preventGlobalAddonUpdate){this.$emit("addon-activated",t);return}this.activationLoading=!1,t.hasMinimumVersion=!0,t.isActive=!0,this.addonsStore.updateAddon(t),this.$emit("addon-activated",t)})}).catch(()=>{this.activationLoading=!1})}}};function V(t,o,e,i,a,d){var _,A;const l=g("core-alert"),h=g("cta");return p(),f(h,{"cta-button-visible":a.addons.userCanInstallOrActivate(e.addonSlug),"cta-button-visible-warning":a.strings.permissionWarning,"cta-link":`${(A=(_=i.rootStore)==null?void 0:_.aioseo)==null?void 0:A.urls.aio.featureManager}&aioseo-activate=${e.addonSlug}`,"cta-button-action":"","cta-button-loading":a.activationLoading,onCtaButtonClick:d.activateAddon,"same-tab":"","button-text":e.ctaButtonText,"learn-more-link":e.learnMoreLink,"feature-list":e.featureList,"align-top":e.alignTop,"hide-bonus":""},{"header-text":r(()=>[s(c(e.ctaHeader),1)]),description:r(()=>[a.failed?(p(),f(l,{key:0,type:"red"},{default:r(()=>[s(c(a.strings.activateError),1)]),_:1})):M("",!0),s(" "+c(e.ctaDescription),1)]),"learn-more-text":r(()=>[s(c(e.learnMoreText),1)]),_:1},8,["cta-button-visible","cta-button-visible-warning","cta-link","cta-button-loading","onCtaButtonClick","button-text","learn-more-link","feature-list","align-top"])}const w=C(T,[["render",V]]),v="all-in-one-seo-pack",q={emits:["addon-activated"],setup(){return{addonsStore:S(),pluginsStore:y(),rootStore:k()}},components:{CoreAlert:x,Cta:L},props:{addonSlug:{type:String,required:!0},featureList:{type:Array,default:()=>[]},postActivationPromises:{type:Array,default:()=>[]},addonName:String,installedVersion:String,minimumVersion:String,ctaButtonText:String,ctaHeader:String,ctaDescription:String,learnMoreText:String,learnMoreLink:String,alignTop:Boolean,preventGlobalAddonUpdate:Boolean},data(){return{addons:n,strings:{activateError:m("An error occurred while activating the addon. Please upload it manually or contact support for more information.",v),permissionWarning:m("You currently don't have permission to activate this addon. Please ask a site administrator to activate first.",v),updateRequired:P(m("This addon requires an update. %1$s %2$s requires a minimum version of %3$s for the %4$s addon. You currently have %5$s installed.",v),"AIOSEO","Pro",n.getAddon(this.addonSlug).minimumVersion,n.getAddon(this.addonSlug).name,n.getAddon(this.addonSlug).installedVersion)},failed:!1,activationLoading:!1}},methods:{upgradeAddon(){this.failed=!1,this.activationLoading=!0;const t=n.getAddon(this.addonSlug);this.pluginsStore.upgradePlugins([{plugin:t.sku}]).then(o=>{if(o.body.failed.length){this.activationLoading=!1,this.failed=!0;return}const e=this.postActivationPromises.map(i=>i());Promise.all(e).then(()=>{if(this.preventGlobalAddonUpdate)return;const i=o.body.completed[t.sku];this.activationLoading=!1,t.hasMinimumVersion=!0,t.isActive=!0,t.installedVersion=i.installedVersion,this.addonsStore.updateAddon(t),this.$emit("addon-activated",t)})}).catch(()=>{this.activationLoading=!1})}}};function D(t,o,e,i,a,d){const l=g("core-alert"),h=g("cta");return p(),f(h,{"cta-button-visible":a.addons.userCanUpdate(e.addonSlug),"cta-button-visible-warning":a.strings.permissionWarning,"cta-link":`${i.rootStore.aioseo.urls.aio.featureManager}&aioseo-activate=${e.addonSlug}`,"cta-button-action":"","cta-button-loading":a.activationLoading,onCtaButtonClick:d.upgradeAddon,"same-tab":"","button-text":e.ctaButtonText,"learn-more-link":e.learnMoreLink,"feature-list":e.featureList,"align-top":e.alignTop,"hide-bonus":""},{"header-text":r(()=>[s(c(e.ctaHeader),1)]),description:r(()=>[B(l,{type:"yellow"},{default:r(()=>[s(c(a.strings.updateRequired),1)]),_:1}),a.failed?(p(),f(l,{key:0,type:"red"},{default:r(()=>[s(c(a.strings.activateError),1)]),_:1})):M("",!0),s(" "+c(e.ctaDescription),1)]),"learn-more-text":r(()=>[s(c(e.learnMoreText),1)]),_:1},8,["cta-button-visible","cta-button-visible-warning","cta-link","cta-button-loading","onCtaButtonClick","button-text","learn-more-link","feature-list","align-top"])}const E=C(q,[["render",D]]),j=({addonSlug:t})=>{const o=U(),e=u(()=>!o.isUnlicensed&&n.isActive(t)&&!n.requiresUpgrade(t)&&n.hasMinimumVersion(t)),i=u(()=>!o.isUnlicensed&&n.isInstalled(t)&&!n.requiresUpgrade(t)&&!n.hasMinimumVersion(t)),a=u(()=>!o.isUnlicensed&&!n.isActive(t)&&n.canActivate(t)&&!n.requiresUpgrade(t)&&(n.hasMinimumVersion(t)||!n.isInstalled(t))),d=u(()=>o.isUnlicensed||n.requiresUpgrade(t));return{ctaComponent:u(()=>i.value?E:w),shouldShowActivate:a,shouldShowLite:d,shouldShowMain:e,shouldShowUpdate:i}};export{j as u};