Skip to content

[1.x] feat: announcements widget on admin dashboard#4472

Draft
imorland wants to merge 3 commits into1.xfrom
im/announcements-widget
Draft

[1.x] feat: announcements widget on admin dashboard#4472
imorland wants to merge 3 commits into1.xfrom
im/announcements-widget

Conversation

@imorland
Copy link
Member

Backport of #4471 for Flarum 1.x.

Adds an Announcements widget to the admin dashboard that fetches and displays the latest posts from discuss.flarum.org. Results are cached for 14 days with manual cache-busting support. The widget can be hidden (persisted in localStorage) or disabled entirely via flarum_announcements.disabled in config.php.

Note: The 2.x version uses cache->flexible() (Laravel 13). This backport uses cache->remember() since Flarum 1.x runs on Laravel 8.

Components

Backend

  • AnnouncementsFetcher — fetches discussions from discuss.flarum.org with enriched User-Agent
  • ListAnnouncementsController — admin-only GET /api/flarum/announcements, supports ?bust=1 for forced refresh
  • RefreshAnnouncementsCommand + WeeklySchedule — weekly scheduled cache warming
  • AnnouncementsServiceProvider — conditionally registers console command and scheduler
  • Route registered in Api/routes.php
  • AdminPayload injects announcementsDisabled flag

Frontend

  • AnnouncementsWidget — dashboard widget with refresh/hide/show controls
  • AnnouncementList — handles loading, error, and empty states
  • AnnouncementItem — individual announcement card
  • Hide state persisted in localStorage

Backport of #4471 for Flarum 1.x.

Adds an Announcements widget to the admin dashboard that fetches and displays the latest posts from discuss.flarum.org. Results are cached for 14 days with manual cache-busting support. The widget can be hidden (persisted in localStorage) or disabled entirely via `flarum_announcements.disabled` in config.php.

- `AnnouncementsFetcher` — HTTP fetch with enriched User-Agent
- `ListAnnouncementsController` — admin-only `GET /api/flarum/announcements` with `?bust=1`
- `RefreshAnnouncementsCommand` + `WeeklySchedule` — weekly scheduled cache warming
- `AnnouncementsServiceProvider` — conditional registration
- `AnnouncementsWidget`, `AnnouncementList`, `AnnouncementItem` frontend components
- `AdminPayload` injection of `announcementsDisabled` flag
@imorland imorland added this to the 1.8.15 milestone Mar 20, 2026
Copy link
Contributor

@DavideIadeluca DavideIadeluca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool new feature! One minor thing for consideration

…ommand.php

Co-authored-by: Davide Iadeluca <146922689+DavideIadeluca@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants