mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #14929 from overleaf/tm-writefull-b2b-banner-rule
Workaround to prevent Writefull and B2B banners overlapping GitOrigin-RevId: a6a933e4f16c35e08c9c07b3c17e292b461fd9a2
This commit is contained in:
parent
e226dc1442
commit
e5b09df542
2 changed files with 54 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { JSXElementConstructor } from 'react'
|
import { JSXElementConstructor, useState } from 'react'
|
||||||
import Common from './groups/common'
|
import Common from './groups/common'
|
||||||
import Institution from './groups/institution'
|
import Institution from './groups/institution'
|
||||||
import ConfirmEmail from './groups/confirm-email'
|
import ConfirmEmail from './groups/confirm-email'
|
||||||
|
@ -10,6 +10,13 @@ import LATAMBanner from './ads/latam-banner'
|
||||||
import getMeta from '../../../../utils/meta'
|
import getMeta from '../../../../utils/meta'
|
||||||
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
||||||
import BackToSchoolModal from './ads/back-to-school-modal'
|
import BackToSchoolModal from './ads/back-to-school-modal'
|
||||||
|
import customLocalStorage from '../../../../infrastructure/local-storage'
|
||||||
|
import { sendMB } from '../../../../infrastructure/event-tracking'
|
||||||
|
|
||||||
|
const isChromium = () =>
|
||||||
|
(window.navigator as any).userAgentData?.brands?.some(
|
||||||
|
(item: { brand: string }) => item.brand === 'Chromium'
|
||||||
|
)
|
||||||
|
|
||||||
type Subscription = {
|
type Subscription = {
|
||||||
groupId: string
|
groupId: string
|
||||||
|
@ -41,6 +48,24 @@ function UserNotifications() {
|
||||||
)
|
)
|
||||||
const showLATAMBanner = getMeta('ol-showLATAMBanner', false)
|
const showLATAMBanner = getMeta('ol-showLATAMBanner', false)
|
||||||
|
|
||||||
|
// Temporary workaround to prevent also showing groups/enterprise banner
|
||||||
|
const [showWritefull, setShowWritefull] = useState(() => {
|
||||||
|
if (isChromium()) {
|
||||||
|
const show =
|
||||||
|
getMeta('ol-showWritefullPromoBanner') &&
|
||||||
|
!customLocalStorage.getItem('has_dismissed_writefull_promo_banner')
|
||||||
|
if (show) {
|
||||||
|
sendMB('promo-prompt', {
|
||||||
|
location: 'dashboard-banner',
|
||||||
|
page: '/project',
|
||||||
|
name: 'writefull',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return show
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const [dismissedWritefull, setDismissedWritefull] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="user-notifications">
|
<div className="user-notifications">
|
||||||
<ul className="list-unstyled">
|
<ul className="list-unstyled">
|
||||||
|
@ -56,6 +81,10 @@ function UserNotifications() {
|
||||||
<Institution />
|
<Institution />
|
||||||
<ConfirmEmail />
|
<ConfirmEmail />
|
||||||
<ReconfirmationInfo />
|
<ReconfirmationInfo />
|
||||||
|
{!showLATAMBanner &&
|
||||||
|
!showInrGeoBanner &&
|
||||||
|
!showWritefull &&
|
||||||
|
!dismissedWritefull && <GroupsAndEnterpriseBanner />}
|
||||||
{showLATAMBanner ? (
|
{showLATAMBanner ? (
|
||||||
<LATAMBanner />
|
<LATAMBanner />
|
||||||
) : showInrGeoBanner ? (
|
) : showInrGeoBanner ? (
|
||||||
|
@ -63,13 +92,17 @@ function UserNotifications() {
|
||||||
variant={inrGeoBannerVariant}
|
variant={inrGeoBannerVariant}
|
||||||
splitTestName={inrGeoBannerSplitTestName}
|
splitTestName={inrGeoBannerSplitTestName}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : null}
|
||||||
<GroupsAndEnterpriseBanner />
|
|
||||||
)}
|
|
||||||
{showBackToSchoolModal ? (
|
{showBackToSchoolModal ? (
|
||||||
<BackToSchoolModal />
|
<BackToSchoolModal />
|
||||||
) : (
|
) : (
|
||||||
<WritefullPromoBanner />
|
<WritefullPromoBanner
|
||||||
|
show={showWritefull}
|
||||||
|
setShow={setShowWritefull}
|
||||||
|
onDismiss={() => {
|
||||||
|
setDismissedWritefull(true)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,53 +1,41 @@
|
||||||
import { memo, useCallback, useState } from 'react'
|
import { memo, useCallback } from 'react'
|
||||||
import Notification from './notification'
|
import Notification from './notification'
|
||||||
import { sendMB } from '../../../../infrastructure/event-tracking'
|
import { sendMB } from '../../../../infrastructure/event-tracking'
|
||||||
import getMeta from '../../../../utils/meta'
|
|
||||||
import customLocalStorage from '../../../../infrastructure/local-storage'
|
import customLocalStorage from '../../../../infrastructure/local-storage'
|
||||||
|
|
||||||
const STORAGE_KEY = 'has_dismissed_writefull_promo_banner'
|
|
||||||
|
|
||||||
const eventSegmentation = {
|
const eventSegmentation = {
|
||||||
location: 'dashboard-banner',
|
location: 'dashboard-banner',
|
||||||
page: '/project',
|
page: '/project',
|
||||||
name: 'writefull',
|
name: 'writefull',
|
||||||
}
|
}
|
||||||
|
|
||||||
const isChromium = () =>
|
function WritefullPromoBanner({
|
||||||
(window.navigator as any).userAgentData?.brands?.some(
|
show,
|
||||||
(item: { brand: string }) => item.brand === 'Chromium'
|
setShow,
|
||||||
)
|
onDismiss,
|
||||||
|
}: {
|
||||||
function WritefullPromoBanner() {
|
show: boolean
|
||||||
const [show, setShow] = useState(() => {
|
setShow: (value: boolean) => void
|
||||||
const show =
|
onDismiss: () => void
|
||||||
getMeta('ol-showWritefullPromoBanner') &&
|
}) {
|
||||||
!customLocalStorage.getItem(STORAGE_KEY)
|
|
||||||
|
|
||||||
if (show) {
|
|
||||||
sendMB('promo-prompt', eventSegmentation)
|
|
||||||
}
|
|
||||||
|
|
||||||
return show
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleOpenLink = useCallback(() => {
|
const handleOpenLink = useCallback(() => {
|
||||||
sendMB('promo-click', eventSegmentation)
|
sendMB('promo-click', eventSegmentation)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
customLocalStorage.setItem(STORAGE_KEY, new Date())
|
customLocalStorage.setItem(
|
||||||
|
'has_dismissed_writefull_promo_banner',
|
||||||
|
new Date()
|
||||||
|
)
|
||||||
setShow(false)
|
setShow(false)
|
||||||
sendMB('promo-dismiss', eventSegmentation)
|
sendMB('promo-dismiss', eventSegmentation)
|
||||||
}, [])
|
onDismiss()
|
||||||
|
}, [setShow, onDismiss])
|
||||||
|
|
||||||
if (!show) {
|
if (!show) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChromium()) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Notification
|
<Notification
|
||||||
bsStyle="info"
|
bsStyle="info"
|
||||||
|
|
Loading…
Reference in a new issue