From 37e065b99309f6e26239e7645b86b39ef35e336e Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Wed, 18 Dec 2024 10:20:09 +0000 Subject: [PATCH] Remove Writefull promo banner from projects dashboard (#22568) GitOrigin-RevId: 49f95f1317462248f4841882ec0ef0ac23c45fe3 --- .../Project/ProjectListController.mjs | 18 ----- services/web/app/views/project/list-react.pug | 1 - .../notifications/user-notifications.tsx | 41 +---------- .../writefull-premium-promo-banner.tsx | 71 ------------------- .../components/notifications.test.tsx | 68 ------------------ 5 files changed, 2 insertions(+), 197 deletions(-) delete mode 100644 services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index 092168c334..027c874272 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -370,23 +370,6 @@ async function projectListPage(req, res, next) { showGroupsAndEnterpriseBanner && _.sample(['on-premise', 'FOMO', 'FOMO', 'FOMO']) - let showWritefullPromoBanner = false - if (Features.hasFeature('saas') && !req.session.justRegistered) { - try { - const { variant } = await SplitTestHandler.promises.getAssignment( - req, - res, - 'writefull-promo-banner' - ) - showWritefullPromoBanner = variant === 'enabled' - } catch (error) { - logger.warn( - { err: error }, - 'failed to get "writefull-promo-banner" split test assignment' - ) - } - } - let showInrGeoBanner = false let showBrlGeoBanner = false let showLATAMBanner = false @@ -461,7 +444,6 @@ async function projectListPage(req, res, next) { groupsAndEnterpriseBannerVariant, showUSGovBanner, usGovBannerVariant, - showWritefullPromoBanner, showLATAMBanner, recommendedCurrency, showInrGeoBanner, diff --git a/services/web/app/views/project/list-react.pug b/services/web/app/views/project/list-react.pug index 5b452118f1..d24ce08449 100644 --- a/services/web/app/views/project/list-react.pug +++ b/services/web/app/views/project/list-react.pug @@ -29,7 +29,6 @@ block append meta })) meta(name="ol-currentUrl" data-type="string" content=currentUrl) meta(name="ol-showGroupsAndEnterpriseBanner" data-type="boolean" content=showGroupsAndEnterpriseBanner) - meta(name="ol-showWritefullPromoBanner" data-type="boolean" content=showWritefullPromoBanner) meta(name="ol-groupsAndEnterpriseBannerVariant" data-type="string" content=groupsAndEnterpriseBannerVariant) meta(name="ol-showInrGeoBanner" data-type="boolean" content=showInrGeoBanner) meta(name="ol-showBrlGeoBanner" data-type="boolean" content=showBrlGeoBanner) diff --git a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx b/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx index 0834a46c4b..0552a0d7ea 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx +++ b/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx @@ -1,15 +1,12 @@ -import { JSXElementConstructor, useState } from 'react' +import { JSXElementConstructor } from 'react' import Common from './groups/common' import Institution from './groups/institution' import ConfirmEmail from './groups/confirm-email' import ReconfirmationInfo from './groups/affiliation/reconfirmation-info' import GroupsAndEnterpriseBanner from './groups-and-enterprise-banner' -import WritefullPremiumPromoBanner from './writefull-premium-promo-banner' import GroupSsoSetupSuccess from './groups/group-sso-setup-success' import getMeta from '../../../../utils/meta' import importOverleafModules from '../../../../../macros/import-overleaf-module.macro' -import customLocalStorage from '../../../../infrastructure/local-storage' -import { sendMB } from '../../../../infrastructure/event-tracking' import GeoBanners from './geo-banners' import AccessibilitySurveyBanner from './accessibility-survey-banner' @@ -30,32 +27,6 @@ const USGovBanner: JSXElementConstructor> = function UserNotifications() { const groupSubscriptionsPendingEnrollment = getMeta('ol-groupSubscriptionsPendingEnrollment') || [] - const user = getMeta('ol-user') - - // Temporary workaround to prevent also showing groups/enterprise banner - const [showWritefull, setShowWritefull] = useState(() => { - const dismissed = customLocalStorage.getItem( - 'has_dismissed_writefull_promo_banner' - ) - if (dismissed) { - return false - } - - const show = - user?.writefull?.enabled === true || - window.writefull?.type === 'extension' - - if (show) { - sendMB('promo-prompt', { - location: 'dashboard-banner', - page: '/project', - name: 'writefull-premium', - }) - } - - return show - }) - const [dismissedWritefull, setDismissedWritefull] = useState(false) return (
@@ -74,18 +45,10 @@ function UserNotifications() { - {!showWritefull && !dismissedWritefull && } + {USGovBanner && } - - { - setDismissedWritefull(true) - }} - />
) diff --git a/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx b/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx deleted file mode 100644 index 1d3cb72af6..0000000000 --- a/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { memo, useCallback } from 'react' -import Notification from './notification' -import { sendMB } from '@/infrastructure/event-tracking' -import customLocalStorage from '@/infrastructure/local-storage' -import WritefullLogo from '@/shared/svgs/writefull-logo' -import OLButton from '@/features/ui/components/ol/ol-button' -import getMeta from '@/utils/meta' - -const eventSegmentation = { - location: 'dashboard-banner', - page: '/project', - name: 'writefull-premium', -} - -function WritefullPremiumPromoBanner({ - show, - setShow, - onDismiss, -}: { - show: boolean - setShow: (value: boolean) => void - onDismiss: () => void -}) { - // dont show the add to WF commons users since their license already includes it - const userAffiliations = getMeta('ol-userAffiliations') || [] - const hasWritefullCommons = userAffiliations.some( - affil => affil.institution?.writefullCommonsAccount - ) - const handleClose = useCallback(() => { - customLocalStorage.setItem('has_dismissed_writefull_promo_banner', true) - setShow(false) - sendMB('promo-dismiss', eventSegmentation) - onDismiss() - }, [setShow, onDismiss]) - - if (!show || hasWritefullCommons) { - return null - } - - return ( -
- - Enjoying Writefull? Get 10% off Writefull Premium, - giving you access to TeXGPT—AI assistance to generate LaTeX code. - Use OVERLEAF10 at the checkout. - - } - action={ - { - sendMB('promo-click', eventSegmentation) - }} - > - {' '} - Get Writefull Premium - - } - /> -
- ) -} - -export default memo(WritefullPremiumPromoBanner) diff --git a/services/web/test/frontend/features/project-list/components/notifications.test.tsx b/services/web/test/frontend/features/project-list/components/notifications.test.tsx index 1f0bdadf93..3ecb7b6750 100644 --- a/services/web/test/frontend/features/project-list/components/notifications.test.tsx +++ b/services/web/test/frontend/features/project-list/components/notifications.test.tsx @@ -26,7 +26,6 @@ import Common from '../../../../../frontend/js/features/project-list/components/ import Institution from '../../../../../frontend/js/features/project-list/components/notifications/groups/institution' import ConfirmEmail from '../../../../../frontend/js/features/project-list/components/notifications/groups/confirm-email' import ReconfirmationInfo from '../../../../../frontend/js/features/project-list/components/notifications/groups/affiliation/reconfirmation-info' -import UserNotifications from '../../../../../frontend/js/features/project-list/components/notifications/user-notifications' import { ProjectListProvider } from '../../../../../frontend/js/features/project-list/context/project-list-context' import { SplitTestProvider } from '@/shared/context/split-test-context' import { @@ -932,73 +931,6 @@ describe('', function () { }) }) - describe('', function () { - beforeEach(function () { - Object.assign(getMeta('ol-ExposedSettings'), exposedSettings) - window.metaAttributesCache.set('ol-showWritefullPromoBanner', true) - - // The older banner is only shown to Chrome users - const navigator = window.navigator as any - navigator.userAgentData = { brands: [{ brand: 'Chromium' }] } - - localStorage.clear() - }) - - describe('when the writefull integration is enabled', function () { - beforeEach(function () { - window.metaAttributesCache.set('ol-user', { - writefull: { enabled: true }, - }) - }) - it('shows the banner', function () { - renderWithinProjectListProvider(UserNotifications) - const ctaLink = screen.getByRole('button', { - name: 'Get Writefull Premium', - }) - expect(ctaLink.getAttribute('href')).to.equal( - 'https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans' - ) - }) - - it('dismisses the banner when the close button is clicked', function () { - renderWithinProjectListProvider(UserNotifications) - screen.getByRole('button', { name: /Writefull/ }) - const WritefullPromoBanner = screen.getByTestId( - 'writefull-premium-promo-banner' - ) - const closeButton = within(WritefullPromoBanner).getByRole('button', { - name: 'Close', - }) - fireEvent.click(closeButton) - expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null - expect(localStorage.getItem('has_dismissed_writefull_promo_banner')).to - .exist - }) - - it("doesn't show the banner if it has been dismissed", function () { - localStorage.setItem( - 'has_dismissed_writefull_promo_banner', - new Date(Date.now() - 500) - ) - renderWithinProjectListProvider(UserNotifications) - expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null - }) - }) - - describe('when the writefull integration is not enabled', function () { - beforeEach(function () { - window.metaAttributesCache.set('ol-user', { - writefull: { enabled: false }, - }) - }) - - it("doesn't show the banner", function () { - renderWithinProjectListProvider(UserNotifications) - expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null - }) - }) - }) - describe('GroupSsoSetupSuccess', function () { it('shows group SSO linked notification', function () { window.metaAttributesCache.set('ol-groupSsoSetupSuccess', true)