Skip to content

[harmony] Bug 1983391: Add a donation banner to the home page - #156

Open
justdave wants to merge 22 commits into
mainfrom
bug-1983391-harmony
Open

justdave wants to merge 22 commits into
mainfrom
bug-1983391-harmony

Conversation

@justdave

@justdave justdave commented Jul 1, 2026

Copy link
Copy Markdown
Member

Details

Adds a donation banner to the front page, per the specification in Bug 1983391 comment 3

Light mode:
Screenshot_2026-07-01_at_5 12 36_AM

Dark mode:
Screenshot_2026-07-01_at_5 09 55_AM

The "call to action" message at the top is randomly picked from the following list:

use constant BANNER_MESSAGES => (
  'Help us make Bugzilla better more often.',
  'A small donation helps keep Bugzilla moving forward.',
  'Support the people who keep Bugzilla running.',
  'Even a little funding helps Bugzilla improve more quickly.',
  'If Bugzilla helps your team, consider helping Bugzilla too.',
);

I'm open to suggestion for messaging in there.
It could use a real graphic on the left, too. Buggie holding a wad of cash? @hellcp

The administrative params screen linked to in the bottom of that banner:
Screenshot 2026-07-01 at 5 28 52 AM

The end-user preferences screen:
Screenshot 2026-07-01 at 5 34 36 AM

Additional info

Test Plan

  1. Fired up Bugzilla using the docker image, and played around.

@justdave
justdave requested review from dannycolin and mrenvoize July 1, 2026 11:25
@dannycolin

Copy link
Copy Markdown
Contributor

No strong feeling if we keep the current list of options but it might be better to have less. For example,

  • Remind me later (default: 1 month)
  • Pick a date...
  • Never...

Feel free to file a follow-up bug to explore this option if you consider it low priority for the next release ;)

Comment thread skins/standard/global.css Resolved
@mrenvoize

Copy link
Copy Markdown
Contributor
image

We don't need the settings exposed twice under 'Preferences' do we.. once without good descriptive names under 'Bugzilla.org' in the 'General preferences' and a second time in their own tab on the left 'Donate to Bugzilla'

@justdave

justdave commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Nope, should only be on the donate tab. I'll fix that.

@mrenvoize

Copy link
Copy Markdown
Contributor

OK, not just cosmetic.. there's some other leakage of those preferences going on...

  1. On the home page, in the banner dropdown pick "Remind me after the next Bugzilla upgrade" → Save. Banner disappears; reload home to confirm it stays gone.
  2. Now go to Preferences → General Preferences and click Submit Changes without touching anything.
  3. Reload the home page → the banner is back.

Looking at the database, it looks like when saving settings from the 'General preferences' area, even if nothing changed.. we wipe the banner settings.

@mrenvoize

Copy link
Copy Markdown
Contributor

Dismissing via the Donate tab doesn't actually dismiss

  1. Go to Preferences → Donate to Bugzilla (userprefs.cgi?tab=donate).
  2. Select "Remind me after the next Bugzilla upgrade" → Submit Changes.
  3. Reload the home page → the banner is STILL showing.

Looking at the database donate_banner_pref does get properly set to 'next_upgrade' but theres no donate_banner_last_version row

@mrenvoize

Copy link
Copy Markdown
Contributor

I think the banner itself should match the width of the homepage.. it looks a bit odd having part of the page nicely centred with gutters and the banner not adhering to the same.

@mrenvoize

Copy link
Copy Markdown
Contributor

The buggy picture is a bit stretched.. but you've already suggested that you'd like to improve that.

@mrenvoize

Copy link
Copy Markdown
Contributor

I think I'd also display the banner on the 'Administration' page until it's dismissed.

@mrenvoize

Copy link
Copy Markdown
Contributor

Inspecting the code a little.. it looks like we're using the same '#new_release' slot in the template as the security release warnings stuff..

Doesn't that mean that the donation banner hides the new-release / EOS notice

I couldn't quit work out how to replicate that one for reals, but the code is fairly clear to follow.. I think the donation banner should be more distinct in the template.

Comment thread Bugzilla/Install/DB.pm Resolved
@mrenvoize
mrenvoize requested a review from dannycolin July 3, 2026 10:12
@mrenvoize

Copy link
Copy Markdown
Contributor

Nope, should only be on the donate tab. I'll fix that.

Fixed in a follow-up above

@mrenvoize

Copy link
Copy Markdown
Contributor

Whilst working through this I think I found bugs in how we're triggering update notifications and how bugzilla is versioned now.. the Bugzilla::Constants version (which take a semantic form) is basically ignored everywhere and instead we're using the Bugzilla->VERSION string (which is a date format string) instead... it's tied into all the CSS and JS static file endpoints too, so it's not a fix I think we should work on here.. I'll report a new bug for it

Comment thread skins/standard/global.css Resolved
@mrenvoize
mrenvoize force-pushed the bug-1983391-harmony branch from 54def39 to 339cfff Compare July 13, 2026 08:10
@mrenvoize

Copy link
Copy Markdown
Contributor

Good catch there @dannycolin

I've fixed, squashed the fix and pushed.

Could you re-review please ?

@mrenvoize
mrenvoize requested a review from dannycolin July 13, 2026 08:11
@mrenvoize
mrenvoize force-pushed the bug-1983391-harmony branch from 339cfff to 8192d3d Compare July 13, 2026 08:24
@mrenvoize

Copy link
Copy Markdown
Contributor

OK, another little push with the 5.14 update to get the tests happy again now I've rebased it all

dannycolin
dannycolin previously approved these changes Jul 14, 2026
Comment thread skins/standard/global.css Resolved
@justdave

Copy link
Copy Markdown
Member Author

My idea for the graphic was to have Buggie holding a wad of cash or something. Maybe that would look too greedy though. The current Buggie image only got used because it was already in the source tree.

@dannycolin

Copy link
Copy Markdown
Contributor

My idea for the graphic was to have Buggie holding a wad of cash or something. Maybe that would look too greedy though. The current Buggie image only got used because it was already in the source tree.

We could have a bugzy that water a small tree to symbolize the idea of growth. Maybe there's another even better analogy but you get the idea.

@justdave

Copy link
Copy Markdown
Member Author

This is looking pretty good to me. Now to get the updates from here backported to the 5.2 PR.

@justdave
justdave dismissed dannycolin’s stale review July 30, 2026 23:23

Going to refactor this more before committing, so getting it off the "ready to commit" list.

@mrenvoize
mrenvoize force-pushed the bug-1983391-harmony branch from 8192d3d to 7781ac7 Compare August 3, 2026 15:51
@mrenvoize

Copy link
Copy Markdown
Contributor

Doh.. I just rebased but didn't spot @justdave said he was going to refactor some more.

@mrenvoize

Copy link
Copy Markdown
Contributor

Looks reasonable: no third-party fetches, CSP nonce on the script, FILTER html on output, and POST plus a token on the dismiss endpoint. Suggestions: add rel=noreferrer to the donate link; the CSS/JS load on every page, so consider loading only on the home page; and a test for the dismiss endpoint. The base is a stacked branch, so it will need retargeting once its parent merges.

@justdave
justdave force-pushed the bug-1983391-harmony branch from d5e0ce3 to 1a2a69c Compare November 1, 2026 03:31
@justdave

justdave commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

The new test suite I just added gets run by the "Sanity Tests" test job, in case you want to see the output from GitHub running them.

@justdave
justdave force-pushed the bug-1983391-harmony branch from af3b00d to 589d723 Compare November 1, 2026 06:37
@mrenvoize

Copy link
Copy Markdown
Contributor

I ran this against the PR head (589d723) in Docker as an admin and as a plain user: all three visibility modes, each dismissal path, the preferences tab, the params panel and static asset serving. It all behaves as described, and the extension tests and the t/ sanity set pass. I'm going to hold off approving until the first item below is sorted. The rest are small and fine as follow-ups if you'd rather not hold this up.

  1. Cache-bust the CSS and JS. The banner links donation-banner.css and donation-banner.js at a fixed path (extensions/BugzillaDonationBanner/web/...), and the server serves those with Cache-Control: public, max-age=31536000, immutable. After an upgrade that changes either file, browsers can keep the old copy for up to a year. Core handles this with the version filter (see format_js_link in global/header.html.tmpl), and I confirmed the versioned form serves the extension's files, e.g. /static/v20200805.1/extensions/BugzillaDonationBanner/web/donation-banner.css returns 200. So in donation/banner.html.tmpl and account/prefs/donate.html.tmpl, use [% 'extensions/BugzillaDonationBanner/web/donation-banner.css' FILTER version FILTER html %] for the <link> and the same for the two <script src> tags. The SVG can stay unversioned.
  2. Unknown or missing donate_action is a silent no-op. bin/donate.cgi passes the parameter straight to dismiss(). With a valid token and an unrecognised action it redirects as if it worked and changes nothing, and with the parameter missing it hits an uninitialised-value warning on eq. Throwing a user error for anything outside next_upgrade, week, month, date and never would be cleaner.
  3. template_before_process matches more than the home page. m{(?:^|/)index\.html\.tmpl$} also matches admin/params/index.html.tmpl, so banner data is computed there for nothing. $file eq 'index.html.tmpl' would be tighter.
  4. The "Donate to Bugzilla" preferences tab is shown to non-admins under the default admins_only setting, even though they never see the banner, so the preference has no effect for them. Hiding the tab unless the banner can be shown to that user would avoid that.

For other reviewers: / is a static, cacheable redirect to /home (Bug 1532766), so the banner appears on /home, not /. That's existing behaviour, not an issue with this PR.

Base automatically changed from bug-2066699-harmony to main November 9, 2026 20:25
justdave and others added 22 commits November 9, 2026 15:25
…te tab

SaveDonate() set donate_banner_pref but never stamped
donate_banner_last_version, so Bugzilla::Donation::get_banner() still saw
last_version ne BUGZILLA_VERSION and kept showing the banner. Choosing
'Remind me after the next upgrade' in the Donate preferences tab therefore
did not actually dismiss the banner, unlike the home page banner path
(set_banner_preference) which stamps the version.

Stamp BUGZILLA_VERSION when saving the donate preferences so both dismiss
paths behave consistently.
…s tab

The donation banner stores its per-user state as three user settings.
donate_banner_last_version and donate_banner_reminder_date have no
legal_values, so they rendered as empty dropdowns under a new 'Bugzilla.org'
category in Preferences > General Preferences. Worse, because their only
submitted value was the '<name>-isdefault' sentinel, saving that tab reset
them to their defaults via reset_to_default(), which silently made a
previously dismissed banner reappear. donate_banner_pref was also duplicated
there alongside its dedicated Donate tab.

These settings are managed from the Donate tab and the home page banner, so
exclude all three from both the display (DoSettings) and the save loop
(SaveSettings) of the generic Settings tab.
Bugzilla::User::Setting::Donation defined a custom validate_value(), but no
setting declared subclass => 'Donation' in Bugzilla::Install::SETTINGS, so the
class was never loaded. It is dead code on two counts: the subclass is unwired,
and Bugzilla::User::Setting::set() writes directly to the database without
calling validate_value() at all. The values it guarded are only ever set from
trusted sources -- BUGZILLA_VERSION for the version, and validate_date()-checked
input for the reminder date -- so no validation is lost by removing it.
index.html.tmpl rendered the donation banner and the new-release / end-of-
support notice as mutually exclusive ([% IF donation %] ... [% ELSIF release %]),
both sharing the #new_release element. Because the banner is shown to admins by
default until dismissed, it suppressed the upgrade and end-of-support security
notice from Bugzilla::Update::get_notifications().

Render the two as independent blocks so both can appear. The banner now uses its
own .donation_banner container instead of reusing the #new_release id (which also
avoids duplicate ids on the page); the CSS selectors are updated to the class and
given the margin/padding they previously inherited from #new_release.
… banners

The 'do not hide the new-release notice' change split the donation banner off
the #new_release element, which dropped the shared box styling (margins,
padding, and the small-print .notice styling) from the donation banner.

Introduce a .home_banner base class carrying the shared box styling and .notice
sizing, applied to both the #new_release and .donation_banner elements. Each
banner keeps only its distinctive bits (red vs green border color, bold vs
normal weight, the donation layout/shadow). The shared rule uses the
border-width/-style longhands so it never resets each banner's own
border-color regardless of stylesheet load order.
Bugzilla::Donation::get_banner() issued a session token on every home page
render that showed the banner, writing a row to the tokens table each time and
leaving it there until the (single-use) form was submitted or the row aged out.
For a banner shown to every eligible user on every uncached home page view that
is needless database churn.

Switch to issue_hash_token()/check_hash_token(), which are stateless: the token
is an HMAC of the user and a data tag, validated by recomputation with no
database row and nothing to delete afterwards. Same CSRF protection, no churn.
buggie.png is a tall portrait image (78x215) but .donation_banner_image forces
it into a 110x110 square, distorting it horizontally. Add object-fit: contain
(centered) so Buggie keeps his aspect ratio and sits centered within the frame.
On the Donate preferences tab the date picker was always visible, even for the
'next upgrade' and 'never' choices where it does nothing, which is confusing.
Hide the date row by default (unless the saved preference is specific_date) and
toggle it from the reminder dropdown via a small CSP-nonced script.
The dim rgba(green, 0.6) border barely separated the banner from the dark page
background. Use the brighter --accent-color-lightgreen-1 for the border (and a
low-alpha lightgreen tint for the background) so the banner stands out while the
light body text stays readable.
The banners rendered full width (~1250px at a 1280px viewport) while the welcome
heading and tiles are a centered 640px column, so the banner looked oddly wide
and disconnected. Move both banners inside #page-index and cap .home_banner at
the content width (max-width: 640px, border-box) centered with auto side margins,
so they line up with the tiles and gain proper gutters.
donate_banner_reminder_date defaults to 1970-01-01 as a 'show immediately'
sentinel, which the Donate tab date picker rendered literally, forcing the user
to navigate forward decades. Since a reminder is always a future date, fall back
to today (computed in Bugzilla->local_timezone, matching get_banner and
set_banner_preference) when the stored value is still the epoch sentinel.
The tab title is "Donate to Bugzilla" so we might as well let them do so from there. :-)
@justdave
justdave force-pushed the bug-1983391-harmony branch from 589d723 to dc27446 Compare November 9, 2026 20:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants