…d of signup (#2377)
* Read one connection status from GoDAM Central and show renewal instead of signup
- Add a Connection_Status enum (connected, trial, expired, unreachable, none)
and a Connection helper that stores what verify_api_key returns:
connection_status, trial_ends_at, organization and (when sent) expired_at
- Read those fields from Central's 200, 401 and 403 answers, only for the stored
key or a new key being saved, so a mistyped key changes nothing
- On an older Central that doesn't send connection_status, work the status out
from the key status as before
- Treat a 200 with "none" (subscription still being set up) as connected, and a
403 that still says connected or trial (site not on the key's allowed sites)
as no usable key, so neither shows the wrong screen
- Report "unreachable" while Central can't be reached and the last good answer
is still trusted
- Show a renewal screen in the onboarding overlay when the plan has expired,
instead of the signup screens: Renew plan, "I've renewed, check again",
use a different license key, Contact support
- Show the onboarding overlay only for "none" and "expired"; never while Central
is unreachable
- Build the renewal link from the organization:
/godam_upgrade?organization=<org>&wp_return=<dashboard>, falling back to the
Plans page when the organization isn't known
- Count trial days left by calendar date in the site's timezone, since Central
sends the trial's last day as UTC midnight
- Show "Your GoDAM trial ends in N days" in the Media Library with an upgrade
link; point the expired notice at renewal, and at Settings when Central
refused the key for another reason
- Add connectionStatus, trialDaysLeft and renewalUrl to the data the admin
pages get, for the Woo add-on and the dashboard to use
- Expose when the plan lapsed (Central's expired_at, otherwise the first time the
site saw the key as expired) for the Woo grace period
- Clear the stored status when the API key is removed
- Add PHP tests for the status helper and for what verify_api_key stores, and
JS tests for the renewal screen
Refs rtCamp/godam-plugin-wp#101
* Show renewal for a lapsed plan without blocking a key that still works
- Keep Central's connection_status as sent, including on the not-allowed-site
403; it describes the plan, while the key status still decides features
- Show the renewal screen only when the plan has expired and the key stopped
working; when the key still works, show a renewal notice instead
- Show the trial notice only when the key works, and point a refused key with a
live plan to settings instead of renewal
- Update the connection status tests
* subscription-ended notice and licence-failed grace start
- Show a dismissible wp-admin notice when the subscription has ended but the
licence still works: "Your GoDAM subscription has ended. Renew to keep Pro
features." Never on the site, never a full screen
- Save the dismissal for the whole site, and show the notice again for the next
lapse
- Replace get_expired_since() with get_licence_failed_since(): count Woo's grace
period from the licence failing, not from connection_status saying expired
- Return nothing while the licence works; use Central's expired_at once sent,
otherwise the first failed check; Central being unreachable never starts it
- Update the connection status tests
* Align with Central's final connection status contract
- Start Woo's grace period from the first failed key check, not Central's expired_at (the subscription can lapse while the licence still works)
- Use expired_at only when no failed check is on record
- Document what Central sends for 200, 401 and both 403 cases
- Add tests for every final Central answer and the grace start date
* Address review on the connection status
- "Check again" says GoDAM couldn't be reached when the refresh can't reach Central or the request fails, not "still expired"
- Back from the license key screen returns to renewal for a site with a lapsed plan
- Remove rtgodam-connection and the dismissed-notice option on uninstall
- Forget the previous key's answer, including its organization, when a different key is saved
- Read an older Central's 401 as a key it doesn't know (connect screens, not renewal)
- Match the key-check test answers to Central's shapes: subscription ended on a 200 with its date, an inactive licence on a 403 with no date
* Make the license key screen's Back tests pass in any order
- Clear WordPress's record of logged deprecations before each test, so the text field's size warning shows in every test, not only the first one run
- Expect the warning in both tests
* Show how many trial days are left on the GoDAM dashboard (#2378)
* Show how many trial days are left on the GoDAM dashboard
- Add a TrialDaysNotice shared component: "Your GoDAM trial ends in N days" (or
"ends today") with an upgrade link ↗ to the renewal URL
- Show it only for a trial whose key works on this site and whose end date
Central sent; switch to a warning in the last three days
- Read the days left whether wp_localize_script sends them as a number or as
text, so the notice shows on real pages
- Match the dashboard content's width and side spacing so the notice lines up
with the cards at every screen size
- Use the same wording as the Media Library trial notice so both share one
translation
- Add unit tests for the notice
Refs rtCamp/godam-plugin-wp#114
* Address review on the dashboard trial notice
- Read days left from any number (strings, decimals) instead of digits only, counting a part day as a day
- Hide the notice while the header's Free plan banner (TrialCountdownBanner) shows, so the trial end isn't shown twice
- Share the content box's max width and gutter with .dashboard-container through a content-box partial
- Show the warning for the last 3 days (2, 1, 0 left), matching the description
- Add tests for days-left parsing, decimals and the banner overlap
Summary
Shows how many trial days are left on the GoDAM dashboard, with a link to upgrade, for sites on a GoDAM trial.
Closes rtCamp/godam-plugin-wp#114 · Part of rtCamp/godam-plugin-wp#101
Why
rtCamp/godam-plugin-wp#101's status table says a trial is "Everything on, with days left". The rtCamp/godam-plugin-wp#101 branch shows the days left only as a notice in the Media Library. Trial sites manage their account from the GoDAM dashboard, so they should see it there too, with a way to upgrade before Pro features stop.
What changed
New:
TrialDaysNotice(pages/shared/TrialDaysNotice.jsx)trialvalidApiKey), so a site Central refused gets no countdowntrialDaysLeftis a number)window.userData(connectionStatus,trialDaysLeft,renewalUrl,validApiKey), whichrtgodam_get_user_data( true )already sends on the rtCamp/godam-plugin-wp#101 branch. No PHP changes.trialDaysLeftandvalidApiKeyas strings, becausewp_localize_script()sends every number as text ("5") andfalseas"".render_trial_notice()), so both share one translation.Dashboard (
pages/dashboard/Dashboard.js)<TrialDaysNotice area="dashboard" />under the GoDAM header, above the Dashboard title.Styles (
pages/shared/trial-days-notice.scss).dashboard-container): centred, at most 1440px wide, 1rem either side. Its edges line up with the cards at every screen width.Screenshots
How to test
Central doesn't send
trial_ends_atyet (rtCamp/godam-core#1957), so fake its answer with wp-cli on a site with a valid key, then open GoDAM → Dashboard.The plugin re-checks the key about once an hour and overwrites this test value with
connected. If the notice disappears mid-test, set the option again.https://app.godam.io/godam_upgrade?organization=acme&wp_return=…in a new tab.5*86400to2*86400. The notice turns yellow and says "2 days".0. The notice says "Your GoDAM trial ends today.""status":"connected"(or"expired"). No notice.trial_ends_atfrom the JSON. No notice.Tests
pages/shared/TrialDaysNotice.test.jshas 12 tests:wp_localize_script()sends themfalseand as""), no end date (asnulland as""), no user data