woocommerce/packages/woocommerce-admin/dist/wp-admin-scripts/payment-method-promotions.js

2 lines
21 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
/*! For license information please see payment-method-promotions.js.LICENSE.txt */
this.wc=this.wc||{},this.wc.paymentMethodPromotions=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=472)}({0:function(e,t){e.exports=window.wp.element},11:function(e,t){e.exports=window.wc.data},16:function(e,t){e.exports=window.wc.tracks},2:function(e,t){e.exports=window.wp.i18n},21:function(e,t){e.exports=window.wc.components},3:function(e,t){e.exports=window.wp.components},460:function(e,t,n){},472:function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(21),i=n(3),a=n(11),l=n(16),c=n(7),s=n(53),u=n(2);n(460);function m(e){return{__html:Object(s.sanitize)(e,{ALLOWED_TAGS:["a","img","br"],ALLOWED_ATTR:["href","src","class","alt","target"]})}}const d=({pluginSlug:e,sortColumnContent:t,descriptionColumnContent:n,title:s,titleLink:d,subTitleContent:p})=>{const[f,g]=Object(r.useState)(!1),{installAndActivatePlugins:y}=Object(c.useDispatch)(a.PLUGINS_STORE_NAME),{createNotice:h}=Object(c.useDispatch)("core/notices"),{gatewayIsActive:v,paymentGateway:b}=Object(c.useSelect)(t=>{const{getPaymentGateway:n}=t(a.PAYMENT_GATEWAYS_STORE_NAME),r=t(a.PLUGINS_STORE_NAME).getActivePlugins(),o=r&&r.includes(e);let i;return o&&(i=n(e.replace(/\-/g,"_"))),{gatewayIsActive:o,paymentGateway:i}});Object(r.useEffect)(()=>{v&&b&&b.settings_url&&(window.location.href=b.settings_url)},[v,b]);return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("td",{className:"sort ui-sortable-handle",width:"1%",dangerouslySetInnerHTML:{__html:t}}),Object(r.createElement)("td",{className:"name"},Object(r.createElement)("div",{className:"wc-payment-gateway-method_name"},Object(r.createElement)(o.Link,{target:"_blank",type:"external",rel:"noreferrer",href:d},s),p?Object(r.createElement)("div",{className:"pre-install-payment-gateway_subtitle",dangerouslySetInnerHTML:m(p)}):null)),Object(r.createElement)("td",{className:"pre-install-payment-gateway_status"}),Object(r.createElement)("td",{className:"description",dangerouslySetInnerHTML:m(n)}),Object(r.createElement)("td",{className:"action"},Object(r.createElement)(i.Button,{className:"button alignright",onClick:()=>{f||(g(!0),Object(l.recordEvent)("settings_payments_recommendations_setup",{extension_selected:e}),y([e]).catch(e=>{e.message&&h("error",e.message),g(!1)}))},isSecondary:!0,isBusy:f,"aria-disabled":f},Object(u.__)("Install",'woocommerce'))))};[{gatewayId:"pre_install_woocommerce_payments_promotion",pluginSlug:"woocommerce-payments",link:"https://woocommerce.com/payments/?utm_medium=product"}].forEach(e=>{const t=document.querySelector(`[data-gateway_id="${e.gatewayId}"]`);if(t){const n=t.children[0].innerHTML,o=t.children[3].innerHTML,i=t.getElementsByClassName("wc-payment-gateway-method-title"),a=t.getElementsByClassName("gateway-subtitle");Object(r.render)(Object(r.createElement)(d,{pluginSlug:e.pluginSlug,sortColumnContent:n,descriptionColumnContent:o,title:1===i.length?i[0].innerHTML:void 0,titleLink:e.link,subTitleContent:1===a.length?a[0].innerHTML:void 0}),t)}})},53:function(e,t,n){e.exports=function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,o=Object.getOwnPropertyDescriptor,i=Object.freeze,a=Object.seal,l=Object.create,c="undefined"!=typeof Reflect&&Reflect,s=c.apply,u=c