Skip to content

Conversation

@gajeshbhat
Copy link
Contributor

@gajeshbhat gajeshbhat commented Sep 5, 2025

Done

Adds a warning notification on snap detail pages for snaps that haven't been updated in over 2 years, helping users identify potentially outdated or unmaintained snaps.

Fixes #2988

Changes

  • Backend Logic: Added is_snap_old() function to detect snaps older than 2 years
  • Date Formatting: Added convert_date_month_year() for cleaner "Month Year" format
  • UI Component: Added warning notification in snap details sidebar with orange left border
  • Styling: Custom CSS for clean notification appearance (no borders except orange left border)
  • Testing: Comprehensive test coverage for date logic and edge cases

Implementation Details

  • Threshold: Configurable (default: 2 years)
  • Message: "This snap in this channel hasn't been updated since [Month Year]. Contact the developer to ask for an update."
  • Positioning: Appears after "Last Updated" section in sidebar
  • Styling: Uses Vanilla CSS p-notification--caution with custom .old-snap-warning class

How to QA

Unit Testing

  • All existing tests pass
  • New tests added for is_snap_old() function
  • New tests added for convert_date_month_year() function
  • Manual testing completed on local development server

Prerequisites

  • Checkout to my Branch: feat/signpost-old-snaps-2988
  • Run the development server locally: dotrun

Test Cases

Snaps that SHOULD show the warning (2+ years old):

  • Visit http://localhost:8004/mumble - Should show a warning
  • Visit http://localhost:8004/hello - Should show a warning
  • Visit http://localhost:8004/wekan - Should show a warning

Snaps that should NOT show the warning (recently updated):

  • Visit http://localhost:8004/vault - Should NOT show warning
  • Visit http://localhost:8004/microk8s - Should NOT show warning

What to Look For

  1. Warning Appearance:

    • Orange left border (no other borders)
    • Warning icon
    • Clean, minimal styling
    • Horizontal line below for consistency
  2. Message Format:

    • "This snap in this channel hasn't been updated since [Month Year]. Contact the developer to ask for an update."
    • Month and year only (no specific day)
  3. Positioning:

    • Appears in right sidebar
    • After "Last Updated" section
    • Before "Contact" section (if present)

Edge Cases to Test

  • Try snaps with different update dates
  • Verify warning only appears for snaps 2+ years old
  • Check that recent snaps don't show the warning

Screenshots

Screenshots are attached below showing:

Warning displayed on old snaps (mumble, hello, wekan)

Screenshot from 2025-09-05 23-26-31 Screenshot from 2025-09-05 23-27-05 Screenshot from 2025-09-05 23-27-23

No warning on recently updated snaps (vault, microk8s)

Screenshot from 2025-09-05 23-27-51 Screenshot from 2025-09-05 23-28-06

Notes

  • The feature is backward compatible and doesn't affect existing functionality
  • Uses timezone-aware datetime functions to avoid deprecation warnings
  • Follows existing design patterns and styling conventions
  • The message can be easily customized by modifying the template

@webteam-app
Copy link

gajeshbhat is not a collaborator of the repo

@gajeshbhat gajeshbhat changed the title feat(snap-details-ui): Add warning signpost for snaps not updated in 2+ years feat(snap-details-ui): Add warning signpost for old snaps Sep 5, 2025
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from 6c05c8c to 5d57e46 Compare September 5, 2025 00:47
@bartaz
Copy link
Member

bartaz commented Sep 5, 2025

Thanks again @gajeshbhat. I'll pass it through copilot first and we'll add it to our maintenance review list.

With feature requests like this, we usually get them through UX first, before even starting implementation. While your suggestion is OK, it hasn't been decided where such notification should be added, what should it say, how old snap needs to be for it to show up.

That said, we can use your PR to discuss these with UX during review.

@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (b8b6b55) to head (5d57e46).
⚠️ Report is 487 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #5352       +/-   ##
==========================================
- Coverage   66.80%       0   -66.81%     
==========================================
  Files         113       0      -113     
  Lines        3714       0     -3714     
  Branches      965       0      -965     
==========================================
- Hits         2481       0     -2481     
+ Misses       1098       0     -1098     
+ Partials      135       0      -135     

see 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bartaz bartaz requested a review from Copilot September 5, 2025 06:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a warning notification system for snap packages that haven't been updated in over 2 years, helping users identify potentially outdated or unmaintained snaps.

  • Added backend logic to detect old snaps and format dates appropriately
  • Implemented UI notification component in the snap details sidebar
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
webapp/store/snap_details_views.py Integrates old snap detection into snap details context
webapp/store/logic.py Implements core functions for detecting old snaps and date formatting
tests/store/tests_public_logic.py Adds comprehensive test coverage for new date and old snap logic
templates/store/snap-details/_details.html Adds warning notification UI component to snap details sidebar
static/sass/styles.scss Adds custom styling for the old snap warning notification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

years_diff = days_diff / 365.25 # Account for leap years
years_since_update = int(years_diff)

is_old = days_diff >= (old_threshold_years * 365)
Copy link

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The calculation uses a fixed 365 days per year while line 248 correctly uses 365.25 to account for leap years. This inconsistency could cause edge cases where years_diff and is_old don't align. Use (old_threshold_years * 365.25) for consistency.

Suggested change
is_old = days_diff >= (old_threshold_years * 365)
is_old = days_diff >= (old_threshold_years * 365.25)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated! Changed to use (old_threshold_years * 365.25) for consistency with the leap year calculation on line 248. Updated tests accordingly to handle the more precise calculation.

}

.old-snap-warning {
border: none !important;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what's the reasoning behind this. Ideally we would not want to modify existing Vanilla patterns like that. Especially the use of !important is a bad practice in CSS.

Notification does have a "borderless" variant if you were aiming at something like that: https://vanillaframework.io/docs/patterns/notification#appearance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I will look into the variant in the docs linked above. I was trying to style the box. My CSS knowledge is definitely below average so I will research and update.

Copy link
Contributor Author

@gajeshbhat gajeshbhat Sep 6, 2025

Choose a reason for hiding this comment

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

Thank you for the link. Removed the custom CSS with !important and switched to using Vanilla Framework's borderless variant: p-notification--caution is-borderless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kindly note that the orange line on the left in the screenshot is gone, as is-borderless class removes all borders. I will update the screenshots. I think we can leave it like that as the caution symbol still conveys the message and looks cleaner. I will wait for comments from UX before I make any other modifications.

Screenshot from 2025-09-05 23-17-40

@gajeshbhat
Copy link
Contributor Author

Thanks again @gajeshbhat. I'll pass it through copilot first and we'll add it to our maintenance review list.

With feature requests like this, we usually get them through UX first, before even starting implementation. While your suggestion is OK, it hasn't been decided where such notification should be added, what should it say, how old snap needs to be for it to show up.

That said, we can use your PR to discuss these with UX during review.

Thanks for taking a look @bartaz . Yes, I do remember seeing the Dev Ready label on some issues where the UX had been discussed, but as this is a minor change, I assumed that could be done during the PR review. Apologies for not checking early. Happy to work with UX to decide the place, the message and duration to display the warning. Will resolve other comments and wait for the suggestions on this. Thanks for pointing it out. Cheers.

@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from 5d57e46 to 07d256e Compare September 6, 2025 06:06
@gajeshbhat gajeshbhat requested a review from bartaz September 6, 2025 06:12
@gajeshbhat gajeshbhat changed the title feat(snap-details-ui): Add warning signpost for old snaps feat(ui): Add warning signpost for old snaps Sep 14, 2025
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch 2 times, most recently from a434581 to 53a0829 Compare September 18, 2025 20:05
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from 53a0829 to 25f90a3 Compare September 29, 2025 18:24
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from 25f90a3 to 687ff8e Compare October 18, 2025 05:55
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch 2 times, most recently from e07aeea to ea05e2c Compare October 29, 2025 07:05
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from ea05e2c to 4a59aa1 Compare November 16, 2025 00:25
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch 2 times, most recently from 27403bc to d62b840 Compare November 26, 2025 19:48
@gajeshbhat
Copy link
Contributor Author

Hey @bartaz , Hope you have been well. Any chance we can get a review from UI/UX for this PR ?

@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch 4 times, most recently from 0e38842 to cbc1ba9 Compare December 4, 2025 05:31
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch 2 times, most recently from da5889d to 84e8a3e Compare December 13, 2025 19:47
@gajeshbhat
Copy link
Contributor Author

Retriggerd CI using git commit --amend --no-edit && git push --forceand the Inclusive naming check passes now.

- Add is_snap_old() function to detect snaps older than 2 years
- Add convert_date_month_year() for cleaner date formatting
- Display warning notification on snap details for old snaps
- Use simple "Month Year" format for better readability
- Add custom styling with orange left border for consistency
- Include comprehensive test coverage for date logic
- Message: "This snap in this channel hasn't been updated since [Month Year]. Contact the developer to ask for an update."

Fixes canonical#2988
@gajeshbhat gajeshbhat force-pushed the feat/signpost-old-snaps-2988 branch from 84e8a3e to 7953a7d Compare December 30, 2025 01:01
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.

Consider signposting old snaps?

3 participants