Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to view new add-ons #16728

Closed
wants to merge 48 commits into from
Closed

Conversation

nvdaes
Copy link
Contributor

@nvdaes nvdaes commented Jun 21, 2024

  • Add support to show new add-ons in the store
  • Add schedule job to show new add-ons at startup
  • Check for new add-ons before running scheduled job to show them
  • Fix lint

Link to issue number:

Closes #16681

Summary of the issue:

List of available add-ons is very long, and some users may wish to show a list of recent add-ons with their description and other details to decide if they wish to install them.

Description of user facing changes

  • A new combo box to filter add-ons by release date has been added to the available add-ons tab of the store.
  • A new combo box to determine the period of time to consider add-ons as new has been added to the add-on store settings panel.

Description of development approach

  • Cached compatible add-ons are saved in a backup file on NVDA exit, or at the datetime determined in the add-on store settings, for example, at startup, weekly or monthly, to be calculated considering the last modification date of the file used to cache old add-ons.
  • New add-ons can be retrieved comparing the current compatible available add-ons with previous add-ons. Specifically, if an add-on with a non existing id or a new version of an existing add-on is available, it will be listed in the New add-ons option of the Release date filter, unles it's already installed.

Testing strategy:

Tested manually:

  • Removed the _cachedCompatibleAddons-old.json file, saved when NVDA is started, and check that the second option of the Release date filter combo box shows that NVDA needs to be restarted to show new add-ons
  • Removed an entry corresponding to an old add-on in the json file, and check that it's listed as a new add-on.
  • Change the version number of an old add-on, and check that the add-on with the current available version is listed as a new add-on.
  • Check that, if an add-on is installed, it's not listed as a new add-on.
  • Check that dates to consider add-ons as new (recent) are properly updated in the Release date filter combo box, after changing the corresponding option in the add-on store settings panel.

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Introduced the ability to filter add-ons by release date in the add-on store.
    • Added a "Reset New Add-ons" feature, allowing users to specify reset periods (Monthly, Weekly, At startup).
    • Implemented a new status NEW for recently published add-ons, enhancing add-on discovery and management.
  • Enhancements

    • Updated add-on store settings panel with options for resetting the new add-ons status and filtering by release date.
    • Added new controls and logic in the add-on store UI for better management of add-on statuses and filters.
  • Documentation

    • Updated user guide and changelog to reflect new add-on management features and settings.

@nvdaes nvdaes requested a review from a team as a code owner June 21, 2024 12:47
Copy link
Contributor

coderabbitai bot commented Jun 21, 2024

Walkthrough

The changes introduce functionality to filter, notify, and manage new add-ons in an NVDA add-on store. Users can now select reset intervals for new add-ons (monthly, weekly, at startup) and manage visibility of new add-ons through various filters. The application was enhanced with methods and entities related to caching, filtering, and displaying new add-ons.

Changes

Files & Paths Change Summary
source/.../dataManager.py Added methods and attributes for caching and filtering compatible old add-ons
source/.../models/status.py Introduced a new NEW add-on status with display logic and a function to fetch the reset date for new add-ons
source/config/configFlags.py Added an enum ResetNewAddons class with display labels for different interval resets
source/config/configSpec.py Introduced options showNewAddons and resetNewAddons to manage new add-ons settings
source/gui/.../storeDialog.py Incorporated a filter control for new add-ons and managed filtering logic based on new add-on status
source/gui/.../viewModels/store.py Enhanced AddonListVM with filtering logic to differentiate between all add-ons and new add-ons
tests/manual/addonStore.md Added manual testing steps to check and reset new add-ons, including instructions for handling JSON files and adjusting store settings
user_docs/en/changes.md Documented the new features for filtering add-ons by release date and setting reset intervals for new add-ons
user_docs/en/userGuide.md Added details about the "Reset New Add-ons" option with different time period behaviors and the ability to filter add-ons by release date

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant DataManager
    participant Config

    User->>UI: Opens Add-on Store
    UI->>UI: Display add-ons
    UI->>Config: Fetch reset interval for new add-ons
    Config-->>UI: Return reset interval (e.g., monthly)
    UI->>DataManager: Request new add-ons based on interval
    DataManager-->>UI: Return list of new add-ons
    UI->>UI: Update display with new add-ons filter

    User->>UI: Select new add-ons filter
    UI->>DataManager: Filter new add-ons
    DataManager-->>UI: Return filtered add-ons
    UI->>UI: Update display with filtered new add-ons
Loading

Assessment against linked issues

Objective (Issue #16681) Addressed Explanation
Notify users about new add-ons
Add a tab or section for new add-ons in the store
Provide methods to set reset intervals
Display new add-ons upon startup or at set intervals

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nvdaes nvdaes marked this pull request as draft June 21, 2024 12:48
@nvdaes nvdaes changed the title hnewAddons Add ability to view new add-ons Jun 21, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

source/gui/__init__.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/addonStoreGui/__init__.py Outdated Show resolved Hide resolved
source/addonStore/dataManager.py Outdated Show resolved Hide resolved
source/addonStore/dataManager.py Outdated Show resolved Hide resolved
@nvdaes nvdaes marked this pull request as ready for review June 22, 2024 05:57
@nvdaes nvdaes requested a review from a team as a code owner June 22, 2024 05:57
@nvdaes nvdaes requested a review from Qchristensen June 22, 2024 05:57
@nvdaes nvdaes marked this pull request as draft June 23, 2024 03:18
@nvdaes nvdaes marked this pull request as ready for review June 23, 2024 04:09
@AppVeyorBot
Copy link

See test results for failed build of commit f54b3667a1

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

Hi @XLTechie , I think I've addressed all your comments. I'll fix the schedule job to show new add-ons at startup this weekend.

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

@XLTechie (%x) is not showing dates in the local format. I think we should try to use winKernel. I'll test it this weekend.

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Outside diff range and nitpick comments (9)
source/addonStore/dataManager.py (2)

172-186: Consider adding comments for clarity.

The method logic is sound, but adding comments would improve readability and maintainability.

def _shouldCacheCompatibleAddonsBackup(self) -> bool:
	# Check if the backup file exists
	if not os.path.exists(self._cacheCompatibleOldFile):
		return True
	resetNewAddons = config.conf["addonStore"]["resetNewAddons"]
	# If reset is set to startup, always create a backup
	if resetNewAddons == "startup":
		return True
	lastBackupTime = os.path.getmtime(self._cacheCompatibleOldFile)
	lastBackupDate = datetime.fromtimestamp(lastBackupTime)
	nowDate = datetime.now()
	diffDate = nowDate - lastBackupDate
	# Check if the reset period has elapsed
	if resetNewAddons == "weekly" and diffDate.days >= 7:
		return True
	if resetNewAddons == "monthly" and diffDate.days >= 30:
		return True
	return False

188-205: Use locale-specific date formatting.

Consider using locale-specific date formatting for better user experience.

- formattedLastBackupDate = lastBackupDate.strftime("%d/%m/%Y")
+ formattedLastBackupDate = lastBackupDate.strftime("%x")
source/gui/addonStoreGui/controls/storeDialog.py (3)

199-211: Consider a more descriptive label text.

The label text for the new filter control could be more descriptive to improve user understanding.

- labelText=pgettext("addonStore", "Release date filter:"),
+ labelText=pgettext("addonStore", "New add-ons filter:"),

344-349: Consider adding comments for clarity.

The logic is sound, but adding comments would improve readability and maintainability.

def _toggleFilterControls(self):
	self.channelFilterCtrl.Clear()
	for c in _channelFilters:
		if c != Channel.EXTERNAL:
			self.channelFilterCtrl.Append(c.displayString)
	# Show or hide the new filter control based on the selected tab
	if self._storeVM._filteredStatusKey == _StatusFilterKey.AVAILABLE:
		self.newFilterCtrl.Enable()
		self.newFilterCtrl.Show()
	else:
		self.newFilterCtrl.Hide()
		self.newFilterCtrl.Disable()

410-417: Consider adding comments for clarity.

The methods are well-implemented, but adding comments would improve readability and maintainability.

def onIncompatibleFilterChange(self, evt: wx.EVT_CHECKBOX):
	self._storeVM._filterIncludeIncompatible = self.includeIncompatibleCtrl.GetValue()
	# Show or hide the new filter control based on the incompatible filter
	if self._storeVM._filterIncludeIncompatible:
		self.newFilterCtrl.Hide()
		self.newFilterCtrl.Disable()
	else:
		self.newFilterCtrl.Enable()
		self.newFilterCtrl.Show()
	self._storeVM.refresh()

def onNewFilterChange(self, evt: wx.EVT_CHOICE):
	index = self.newFilterCtrl.GetCurrentSelection()
	self._storeVM._filterNew = list(NewStatus)[index]
	self._storeVM.refresh()
source/addonStore/models/status.py (2)

47-60: Add a docstring for clarity.

Consider adding a docstring to the NewStatus class to improve readability and maintainability.

class NewStatus(DisplayStringEnum):
	"""
	Enumeration representing the status of new add-ons in the add-on store.
	"""
	ALL = enum.auto()
	NEW = enum.auto()

	@property
	def _displayStringLabels(self) -> Dict["EnabledStatus", str]:
		resetNewAddonsDate = getResetNewAddonsDate()
		return {
			# Translators: The label of an option to filter the list of add-ons in the add-on store dialog.
			self.ALL: pgettext("addonStore", "All"),
			# Translators: The label of an option to filter the list of add-ons in the add-on store dialog.
			self.NEW: pgettext("addonStore", "New add-ons (%s)" % resetNewAddonsDate),
		}

Line range hint 362-386:
Add a docstring for clarity.

Consider adding a docstring to the _StatusFilterKey class to improve readability and maintainability.

class _StatusFilterKey(DisplayStringEnum):
	"""
	Enumeration representing keys for filtering by status in the NVDA add-on store.
	"""
	INSTALLED = enum.auto()
	UPDATE = enum.auto()
	AVAILABLE = enum.auto()
	INCOMPATIBLE = enum.auto()

	@property
	def _displayStringLabels(self) -> Dict["_StatusFilterKey", str]:
		return {
			# Translators: The label of a tab to display installed add-ons in the add-on store.
			# Ensure the translation matches the label for the add-on list which includes an accelerator key.
			self.INSTALLED: pgettext("addonStore", "Installed add-ons"),
			# Translators: The label of a tab to display updatable add-ons in the add-on store.
			# Ensure the translation matches the label for the add-on list which includes an accelerator key.
			self.UPDATE: pgettext("addonStore", "Updatable add-ons"),
			# Translators: The label of a tab to display available add-ons in the add-on store.
			# Ensure the translation matches the label for the add-on list which includes an accelerator key.
			self.AVAILABLE: pgettext("addonStore", "Available add-ons"),
			# Translators: The label of a tab to display incompatible add-ons in the add-on store.
			# Ensure the translation matches the label for the add-on list which includes an accelerator key.
			self.INCOMPATIBLE: pgettext("addonStore", "Installed incompatible add-ons"),
		}
source/gui/settingsDialogs.py (1)

3107-3130: Ensure consistency in naming conventions and code structure.

The new settings for showing and resetting new add-ons are well-integrated. Ensure consistency in naming conventions and code structure for better readability and maintainability.

- showNewAddonsLabelText = _("&Show new add-ons:")
+ showNewAddonsLabelText = _("&Show New Add-ons:")
user_docs/en/changes.md (1)

50-51: Improve clarity and adherence to style guide.

Ensure each change log entry references an issue or pull request number and follows the style of one sentence per line.

- * You can check for new add-ons from the New available add-ons tab of the store. (#16681, @nvdaes)
-   * From the Add-on store settings panel, new options are available to determine if the presence of new add-ons should be notified at startup, and the period of time to reset new add-ons.
+ * You can check for new add-ons from the "New available add-ons" tab of the store. (#16681, @nvdaes)
+ * From the Add-on store settings panel, new options are available to determine if the presence of new add-ons should be notified at startup, and the period of time to reset new add-ons.

source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/addonStoreGui/viewModels/store.py Outdated Show resolved Hide resolved
source/addonStore/dataManager.py Show resolved Hide resolved
tests/manual/addonStore.md Outdated Show resolved Hide resolved
resetNewAddons = config.conf["addonStore"]["resetNewAddons"]
if resetNewAddons == "startup":
# Translators: Message presented in the new add-ons tab, informing that new add-ons will be reset at startup
return _("Will be reset at startup")
Copy link
Collaborator

Choose a reason for hiding this comment

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

@nvdaes you may have missed this one, or at least it's not showing as resolved at my end.

timedeltaDays = 30
else: # weekly
timedeltaDays = 7
nextResetDate = lastBackupDate + timedelta(days=timedeltaDays)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@seanbudd how hard would it be to start embedding a generation timestamp in the JSON? I should think, not very.

return _("Will be reset at startup")
lastBackupTime = os.path.getmtime(self._cacheCompatibleOldFile)
lastBackupDate = datetime.fromtimestamp(lastBackupTime)
formattedLastBackupDate = lastBackupDate.strftime("%d/%m/%Y")
Copy link
Collaborator

Choose a reason for hiding this comment

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

@nvdaes if it's only ever going to show, at most, 30 days, then the year isn't even necessary. In that case, using something like "%d %B" is, imho, more user friendly.

That said, if you're going to use a full date, even the AI agreed you should use "%x". You said it doesn't work, but I am curious how it fails, as %x has been standard for a long, long time.

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

@nvdaes if it's only ever going to show, at most, 30 days, then the year isn't even necessary. In that case, using something like "%d %B" is, imho, more user friendly.
That said, if you're going to use a full date, even the AI agreed you should use "%x". You said it doesn't work, but I am curious how it fails, as %x has been standard for a long, long time.

On my system, %x returns 8/5, and in Spanish this is interpreted as May 8, not August 5.
Also, I¡ve tried to commit all your suggestions including the use of 31 days instead of 30 for months.
But I think we should include the year, since if we start saving old add-ons on 31 December 2024, I think it's better to include the 2025 year.
I think we can use this procedure, caching old compatible add-ons, and if a timestamp is added to add-ons some day, we can use another system replacing this or as an alternative.

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

I'll test again with %x to show dates, since testing this in the Python console results are right.

nvdaes and others added 2 commits July 5, 2024 12:32
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 5, 2024

@XLTechie, in fact %x works as expected to format dates. The problem was that I was testing from source but with NVDA set to English.
I'll remove code to notify about new add-ons at NVDA startup, since using a combo box, not a dedicated tab, imo this doesn't provide a good experience and it is not useful.

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 6, 2024

@coderabbitai resolve

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 6, 2024

@coderabbitai full review

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 6, 2024

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range and nitpick comments (1)
user_docs/en/userGuide.md (1)

2950-2963: Ensure clarity and consistency in new feature description.

The added segment clearly describes the new feature for resetting the period of time to consider add-ons as new. However, the phrase "considered as new" could be simplified to "considered new" for better readability.

- Add-ons will be considered as new for a month (31 days)
- Add-ons will be considered as new for a week (7 days)
- Add-ons will be considered as new until NVDA is restarted
+ Add-ons will be considered new for a month (31 days)
+ Add-ons will be considered new for a week (7 days)
+ Add-ons will be considered new until NVDA is restarted

user_docs/en/userGuide.md Outdated Show resolved Hide resolved
source/addonStore/dataManager.py Show resolved Hide resolved
source/addonStore/dataManager.py Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 6, 2024

@coderabbitai summary

@nvdaes
Copy link
Contributor Author

nvdaes commented Jul 7, 2024

Luke wrote:

@seanbudd how hard would it be to start embedding a generation timestamp in the JSON?

I understand that this would require to work in several repos, but, even if the release date is not presented in a column of the add-on list, I'd like to be timestamps added for the issue related to this PR. Now,the first time we start NVDA without cached old add-ons, the list is empty, and timestamps will make this cleaner.
If needed, I'll try to work in the store or the staging repo, and add-on-datastore-validation to add timestamps.

@seanbudd
Copy link
Member

@nvdaes - thanks for investigating this approach. Given issues around the UX, we think it would be best to go with the solution of adding timestamps and the ability to sort by them.
Closing this PR.

@seanbudd seanbudd closed this Aug 13, 2024
@github-actions github-actions bot added this to the 2024.4 milestone Aug 13, 2024
@nvdaes
Copy link
Contributor Author

nvdaes commented Aug 13, 2024

OK @seanbudd . I may create prs fr timestamps in the addon-datastore repo, in the addon-datastore-validation repo and in NVDA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/needs-product-decision A product decision needs to be made. Decisions about NVDA UX or supported use-cases. blocked/needs-testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to view new available add-ons
7 participants