refactor(announcements): use StorageApi instead of WebStorage - #10328
Open
fredericoferreiracosta wants to merge 2 commits into
Open
refactor(announcements): use StorageApi instead of WebStorage#10328fredericoferreiracosta wants to merge 2 commits into
fredericoferreiracosta wants to merge 2 commits into
Conversation
Replace the single-timestamp lastSeenDate dismiss mechanism with per-announcement ID tracking. Each banner can now be dismissed independently without affecting the visibility of other announcements. Changes: - Add dismissAnnouncement(id) and isAnnouncementDismissed(id) to the AnnouncementsApi interface - Implement dismissed ID storage in AnnouncementsClient with a cap of 50 IDs to prevent localStorage bloat - Update NewAnnouncementBanner to use per-ID dismiss instead of markLastSeenDate - Update AnnouncementsCard to check per-ID dismiss for the New icon - Keep lastSeenDate as backward-compatible fallback for pre-existing state and overflow scenarios - Update test mocks for both components Fixes: backstage#9118 Signed-off-by: Frederico Ferreira Costa <fredericoferreiracosta@users.noreply.github.com>
Replace direct WebStorage instantiation with the StorageApi interface for announcement dismiss state persistence. This decouples the plugin from the concrete localStorage implementation and allows Backstage instances with a user-settings backend to automatically persist state server-side. Changes: - Replace WebStorage import with StorageApi from core-plugin-api - Add storageApi to AnnouncementsClientOptions - Use StorageApi.snapshot() instead of WebStorage.get() - Update both legacy plugin.ts and alpha apis.ts factories to pass storageApiRef - Remove @backstage/core-app-api dependency from announcements-react Signed-off-by: Frederico Costa (EXT) <frederico.costa.ext@ericsson.com>
fredericoferreiracosta
requested review from
a team,
gaelgoth and
kurtaking
as code owners
August 14, 2026 14:52
Contributor
Changed Packages
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, I just made a Pull Request!
This PR replaces direct
WebStorageinstantiation with the BackstageStorageApiinterface for announcement dismiss state persistence.Problem
The
AnnouncementsClientdirectly instantiatesWebStorage(from@backstage/core-app-api), bypassing the BackstageStorageApiabstraction. This means even if a Backstage instance has the User Settings Backend deployed (which persists state server-side per user), the announcements plugin always uses raw browser localStorage.This causes dismissed announcements to reappear on new devices, incognito mode, or after clearing browser data.
Solution
WebStorageimport withStorageApifrom@backstage/core-plugin-apistorageApi: StorageApitoAnnouncementsClientOptionsStorageApi.snapshot()instead of the non-standardWebStorage.get()storageApi.forBucket("announcements")instead ofnew WebStorage("announcements", errorApi)plugin.tsand alphaapis.tsfactories to injectstorageApiRef@backstage/core-app-apidependency fromannouncements-react(no longer needed)Benefits
@backstage/core-app-apifrom the react packageTesting
Note
This PR is based on #10316 (per-announcement dismiss tracking) which must be merged first.
✔️ Checklist
Signed-off-byline in the message.Related: #9118