| 1 |
import { __, sprintf } from "@wordpress/i18n"; |
| 2 |
import React from "react"; |
| 3 |
|
| 4 |
import LockedPreview from "../analytics/components/modules/LockedPreview"; |
| 5 |
import GlossaryMock from "./GlossaryMock"; |
| 6 |
import "../analytics/scss/dashboard.scss"; |
| 7 |
import "./glossary-teaser.scss"; |
| 8 |
|
| 9 |
const FEATURE_BULLETS = [ |
| 10 |
__( "A–Z glossary index, styled like the rest of your docs", "betterdocs" ), |
| 11 |
__( "Auto-link terms across every doc with hover tooltips", "betterdocs" ), |
| 12 |
__( "Write definitions with AI, then edit them inline", "betterdocs" ), |
| 13 |
__( "Drag-to-reorder, plus CSV import & export", "betterdocs" ) |
| 14 |
]; |
| 15 |
|
| 16 |
/** |
| 17 |
* Free's Glossaries screen — the locked slot shown when the real Pro manager is |
| 18 |
* not available. It reads two shapes off `betterdocs_admin`: |
| 19 |
* |
| 20 |
* - No Pro at all → the classic upsell ("Glossaries is a Pro feature", Pro |
| 21 |
* badge, Upgrade Now). |
| 22 |
* - Pro active but too old (Glossaries moved to Pro) → an *update* screen: the |
| 23 |
* user already owns Pro, so we drop the Pro badge and the pricing CTA and ask |
| 24 |
* them to update Pro to the version that ships the manager. |
| 25 |
* |
| 26 |
* Once a Pro new enough to register the taxonomy is active, its real manager |
| 27 |
* takes the `betterdocs-glossaries` route instead and this never renders. |
| 28 |
*/ |
| 29 |
export default function GlossaryTeaser() { |
| 30 |
const admin = ( typeof window !== "undefined" && window.betterdocs_admin ) || {}; |
| 31 |
const needsUpdate = !! admin.glossaries_needs_pro_update; |
| 32 |
|
| 33 |
if ( needsUpdate ) { |
| 34 |
const minVer = admin.glossaries_min_pro_version || "4.3.1"; |
| 35 |
const curVer = admin.betterdocs_pro_version || ""; |
| 36 |
const updateUrl = admin.glossaries_pro_update_url || ""; |
| 37 |
|
| 38 |
const subtitle = curVer |
| 39 |
? sprintf( |
| 40 |
/* translators: 1: current Pro version, 2: required Pro version. */ |
| 41 |
__( "You're on BetterDocs Pro %1$s — update to Pro %2$s or later to manage your glossary here.", "betterdocs" ), |
| 42 |
curVer, |
| 43 |
minVer |
| 44 |
) |
| 45 |
: sprintf( |
| 46 |
/* translators: %s: required Pro version. */ |
| 47 |
__( "Update to BetterDocs Pro %s or later to manage your glossary here.", "betterdocs" ), |
| 48 |
minVer |
| 49 |
); |
| 50 |
|
| 51 |
return ( |
| 52 |
<div className="betterdocs-dashboard-body betterdocs-faq-wrapper betterdocs-dashboard-container bd-gloss-wrapper"> |
| 53 |
<LockedPreview |
| 54 |
title={ __( "BetterDocs Pro Needs a Compatibility Update.", "betterdocs" ) } |
| 55 |
subtitle={ subtitle } |
| 56 |
bullets={ FEATURE_BULLETS } |
| 57 |
badge={ null } |
| 58 |
ctaLabel={ __( "Update BetterDocs Pro", "betterdocs" ) } |
| 59 |
ctaHref={ updateUrl } |
| 60 |
> |
| 61 |
<GlossaryMock /> |
| 62 |
</LockedPreview> |
| 63 |
</div> |
| 64 |
); |
| 65 |
} |
| 66 |
|
| 67 |
return ( |
| 68 |
<div className="betterdocs-dashboard-body betterdocs-faq-wrapper betterdocs-dashboard-container bd-gloss-wrapper"> |
| 69 |
<LockedPreview |
| 70 |
title={ __( "Glossaries is a Pro feature", "betterdocs" ) } |
| 71 |
subtitle={ __( "Build an A–Z glossary of your product's terms and auto-link them across every doc, so readers get an instant definition on hover — no more explaining the same jargon twice.", "betterdocs" ) } |
| 72 |
bullets={ FEATURE_BULLETS } |
| 73 |
> |
| 74 |
<GlossaryMock /> |
| 75 |
</LockedPreview> |
| 76 |
</div> |
| 77 |
); |
| 78 |
} |
| 79 |
|