From 10e65f7fe8e6e8a93875fa2f6f627cd168aa3c5b Mon Sep 17 00:00:00 2001 From: Rishabh Date: Wed, 28 Sep 2022 00:16:47 +0530 Subject: [PATCH] Fixed incorrect import handling for data attributes refs https://github.com/TryGhost/Portal/commit/c3c503632b64c1ac07a35e89962812d58fa77555 --- ghost/portal/src/App.js | 2 +- ghost/portal/src/data-attributes.js | 14 ++++---------- ghost/portal/src/tests/data-attributes.test.js | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index 3581e1f077..3997b3902d 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -11,8 +11,8 @@ import ActionHandler from './actions'; import './App.css'; import NotificationParser from './utils/notifications'; import {allowCompMemberUpgrade, createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers'; +import {handleDataAttributes} from './data-attributes'; -const {handleDataAttributes} = require('./data-attributes'); const React = require('react'); const DEV_MODE_DATA = { diff --git a/ghost/portal/src/data-attributes.js b/ghost/portal/src/data-attributes.js index ee6634f6ff..ff8ce9912f 100644 --- a/ghost/portal/src/data-attributes.js +++ b/ghost/portal/src/data-attributes.js @@ -2,7 +2,7 @@ import {getQueryPrice, getUrlHistory} from './utils/helpers'; -function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) { +export function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) { form.removeEventListener('submit', submitHandler); event.preventDefault(); if (errorEl) { @@ -59,7 +59,7 @@ function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) { }); } -function planClickHandler({event, el, errorEl, siteUrl, site, member, clickHandler}) { +export function planClickHandler({event, el, errorEl, siteUrl, site, member, clickHandler}) { el.removeEventListener('click', clickHandler); event.preventDefault(); let plan = el.dataset.membersPlan; @@ -140,7 +140,7 @@ function planClickHandler({event, el, errorEl, siteUrl, site, member, clickHandl }); } -function handleDataAttributes({siteUrl, site, member}) { +export function handleDataAttributes({siteUrl, site, member}) { if (!siteUrl) { return; } @@ -350,10 +350,4 @@ function handleDataAttributes({siteUrl, site, member}) { } el.addEventListener('click', clickHandler); }); -} - -module.exports = { - handleDataAttributes, - formSubmitHandler, - planClickHandler -}; +} \ No newline at end of file diff --git a/ghost/portal/src/tests/data-attributes.test.js b/ghost/portal/src/tests/data-attributes.test.js index be9f962021..5f3d2ac93e 100644 --- a/ghost/portal/src/tests/data-attributes.test.js +++ b/ghost/portal/src/tests/data-attributes.test.js @@ -3,7 +3,7 @@ import {site as FixturesSite, member as FixtureMember} from '../utils/test-fixtu import {fireEvent, appRender, within} from '../utils/test-utils'; import setupGhostApi from '../utils/api'; import * as helpers from '../utils/helpers'; -const {formSubmitHandler, planClickHandler} = require('../data-attributes'); +import {formSubmitHandler, planClickHandler} from '../data-attributes'; // Mock data function getMockData() {