| @@ -1,15 +1,19 @@ | ||
| 1 | +import { publishesSite } from './publish-site'; | |
| 1 | 2 | import { Bar } from './templates/Bar'; |
| 2 | 3 | import { Card } from './templates/Card'; |
| 3 | 4 | import { Pill } from './templates/Pill'; |
| 5 | +import { Pricing } from './templates/Pricing'; | |
| 4 | 6 | |
| 5 | 7 | export const SLOTS = { |
| 6 | 8 | ADMIN_DASHBOARD: 'admin-dashboard', |
| 7 | 9 | ADMIN_OTHERS: 'admin-others', |
| 8 | 10 | ADMIN_ASSIST: 'admin-assist', |
| 11 | + ADMIN_MODAL: 'admin-modal', | |
| 9 | 12 | AGENT_CHAT: 'agent-chat', |
| 10 | 13 | FRONTEND_BOTTOM: 'frontend-bottom', |
| 11 | 14 | FRONTEND_TOPBAR: 'frontend-topbar', |
| 15 | + FRONTEND_MODAL: 'frontend-modal', | |
| 12 | 16 | }; |
| 13 | 17 | |
| 14 | 18 | // agent-chat is null because the Agent renders it as a chat suggestion. |
| 15 | 19 | const TEMPLATES = { |
| @@ -15,19 +19,28 @@ | ||
| 15 | 19 | const TEMPLATES = { |
| 16 | 20 | [SLOTS.ADMIN_DASHBOARD]: Card, |
| 17 | 21 | [SLOTS.ADMIN_OTHERS]: Card, |
| 18 | 22 | [SLOTS.ADMIN_ASSIST]: Card, |
| 23 | + [SLOTS.ADMIN_MODAL]: Pricing, | |
| 19 | 24 | [SLOTS.AGENT_CHAT]: null, |
| 20 | 25 | [SLOTS.FRONTEND_BOTTOM]: Bar, |
| 21 | 26 | [SLOTS.FRONTEND_TOPBAR]: Pill, |
| 27 | + [SLOTS.FRONTEND_MODAL]: Pricing, | |
| 22 | 28 | }; |
| 23 | 29 | |
| 24 | 30 | export const templateFor = (slot) => TEMPLATES[slot] ?? null; |
| 25 | 31 | |
| 32 | +// A trial-block modal is the paywall, so without an offer there is nothing to show. | |
| 33 | +const hasOfferWhenBlocking = (notification) => | |
| 34 | + notification.trigger !== 'trial-block' || Boolean(notification.offer); | |
| 35 | + | |
| 26 | 36 | // Deciding this inside Pill would count a view for a pill that never rendered. |
| 27 | 37 | const REQUIREMENTS = { |
| 28 | 38 | [SLOTS.FRONTEND_TOPBAR]: (notification, href) => |
| 29 | - Boolean(notification['cta-label'] && href), | |
| 39 | + // A publishing pill has no href; it acts in place on click. | |
| 40 | + Boolean(notification['cta-label'] && (href || publishesSite(notification))), | |
| 41 | + [SLOTS.ADMIN_MODAL]: hasOfferWhenBlocking, | |
| 42 | + [SLOTS.FRONTEND_MODAL]: hasOfferWhenBlocking, | |
| 30 | 43 | }; |
| 31 | 44 | |
| 32 | 45 | export const fillsSlot = (slot, notification, href) => |
| 33 | 46 | REQUIREMENTS[slot]?.(notification, href) ?? true; |