| 1 |
import { Bar } from './templates/Bar'; |
| 2 |
import { Card } from './templates/Card'; |
| 3 |
import { Pill } from './templates/Pill'; |
| 4 |
|
| 5 |
export const SLOTS = { |
| 6 |
ADMIN_DASHBOARD: 'admin-dashboard', |
| 7 |
ADMIN_OTHERS: 'admin-others', |
| 8 |
ADMIN_ASSIST: 'admin-assist', |
| 9 |
AGENT_CHAT: 'agent-chat', |
| 10 |
FRONTEND_BOTTOM: 'frontend-bottom', |
| 11 |
FRONTEND_TOPBAR: 'frontend-topbar', |
| 12 |
}; |
| 13 |
|
| 14 |
// agent-chat is null because the Agent renders it as a chat suggestion. |
| 15 |
const TEMPLATES = { |
| 16 |
[SLOTS.ADMIN_DASHBOARD]: Card, |
| 17 |
[SLOTS.ADMIN_OTHERS]: Card, |
| 18 |
[SLOTS.ADMIN_ASSIST]: Card, |
| 19 |
[SLOTS.AGENT_CHAT]: null, |
| 20 |
[SLOTS.FRONTEND_BOTTOM]: Bar, |
| 21 |
[SLOTS.FRONTEND_TOPBAR]: Pill, |
| 22 |
}; |
| 23 |
|
| 24 |
export const templateFor = (slot) => TEMPLATES[slot] ?? null; |
| 25 |
|
| 26 |
// Deciding this inside Pill would count a view for a pill that never rendered. |
| 27 |
const REQUIREMENTS = { |
| 28 |
[SLOTS.FRONTEND_TOPBAR]: (notification, href) => |
| 29 |
Boolean(notification['cta-label'] && href), |
| 30 |
}; |
| 31 |
|
| 32 |
export const fillsSlot = (slot, notification, href) => |
| 33 |
REQUIREMENTS[slot]?.(notification, href) ?? true; |
| 34 |
|
| 35 |
// The pill stays as the persistent reminder after the bar is dismissed. |
| 36 |
const DISMISSAL_EXEMPT = [SLOTS.FRONTEND_TOPBAR]; |
| 37 |
|
| 38 |
export const ignoresDismissal = (slot) => DISMISSAL_EXEMPT.includes(slot); |
| 39 |
|