Skip to content

Conversation

deluan
Copy link
Member

@deluan deluan commented May 23, 2025

Summary

  • allow deleting all missing files via native API when no ids are provided
  • update dataProvider to omit query string on DELETE without ids
  • support delete-all option in DeleteMissingFilesButton
  • add Remove All button to missing files list
  • add translations for Remove All
  • test delete-all button behaviour
  • test DeleteAllMissing in media file repository

Testing

  • npm run lint
  • npm run check-formatting
  • npm run test:ci
  • npm run type-check
  • make test

@deluan deluan requested a review from Copilot May 23, 2025 02:13
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. This PR introduces a new feature allowing users to delete all missing files from the database at once, in addition to the existing functionality for deleting selected missing files. This involves changes across the backend API, the data provider layer, the frontend UI components, and adds corresponding tests.

Highlights

  • Backend API Enhancement: The native API endpoint for deleting missing files (DELETE /missing) is updated to handle requests without specific IDs. If no IDs are provided in the request parameters, the backend will now trigger a mass deletion of all files marked as missing.
  • Frontend Data Provider Update: The wrapperDataProvider is modified to correctly handle DELETE_MANY calls for the 'missing' resource when the list of IDs is empty. It now constructs the request URL without the ?id=... query string in this specific case, aligning with the backend change.
  • UI Component Flexibility: The DeleteMissingFilesButton component is enhanced with a new deleteAll prop. When this prop is set to true, the button's label and the confirmation dialog's title and content are updated to reflect the 'Remove All' action, and it triggers the delete operation with an empty list of IDs.
  • New 'Remove All' Button: A new MissingListActions component is introduced and added to the MissingFilesList. This component includes an 'Export' button and the new DeleteMissingFilesButton configured with the deleteAll prop, providing a dedicated button in the UI to initiate the mass deletion.
  • Translations Added: New translation keys (remove_all, remove_all_missing_title, remove_all_missing_content) are added to the English translation file (en.json) to support the text for the new 'Remove All' button and its confirmation dialog.
  • Comprehensive Testing: New tests are added for both the backend repository (persistence/mediafile_repository_test.go) to verify the DeleteAllMissing function and for the frontend component (ui/src/missing/DeleteMissingFilesButton.test.jsx) to ensure the deleteAll prop behaves as expected, including using the correct label and calling the data provider with an empty ID list.

Changelog

Click here to see the changelog
  • persistence/mediafile_repository_test.go
    • Added a new test case (It("deletes all missing files", func() { ... })) starting around line 55 to verify the functionality of deleting all missing files via the repository method.
  • server/nativeapi/missing.go
    • Modified the deleteMissingFiles function (starting around line 65) to check if the ids parameter is empty. If it is, it now calls tx.MediaFile(r.Context()).DeleteAllMissing() instead of tx.MediaFile(r.Context()).DeleteMissing(ids).
  • ui/src/dataProvider/wrapperDataProvider.js
    • Updated the callDeleteMany function (starting around line 38) to check if the params.ids array is empty. If it is, the query string is set to empty, resulting in a DELETE request without query parameters.
  • ui/src/i18n/en.json
    • Added a new translation key remove_all under resources.missing.actions (around line 245).
    • Added new translation keys remove_all_missing_title and remove_all_missing_content under message (around lines 407-408).
  • ui/src/missing/DeleteMissingFilesButton.jsx
    • Added a deleteAll prop with a default value of false (around line 32).
    • Modified the ids variable definition (around line 38) to use an empty array if deleteAll is true, otherwise use selectedIds.
    • Updated the label prop of the Button component (around line 61) to conditionally display 'resources.missing.actions.remove_all' if deleteAll is true, otherwise display 'ra.action.remove'.
    • Updated the title and content props of the Confirm component (around lines 74 and 79) to conditionally display the new 'remove all' translation keys if deleteAll is true.
  • ui/src/missing/DeleteMissingFilesButton.test.jsx
    • Added a new test file.
    • Includes tests to verify that the button label is 'resources.missing.actions.remove_all' when deleteAll is true (around line 27).
    • Includes tests to verify that useDeleteMany is called with an empty array for IDs when deleteAll is true (around line 34).
  • ui/src/missing/MissingFilesList.jsx
    • Imported MissingListActions (around line 11).
    • Added the actions={<MissingListActions />} prop to the List component (around line 39).
  • ui/src/missing/MissingListActions.jsx
    • Added a new component file.
    • Defines MissingListActions using TopToolbar.
    • Includes ExportButton and DeleteMissingFilesButton with the deleteAll prop set to true.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Files gone astray,
Marked missing, day by day.
One button press, poof!
Database gets its proof,
Clean slate, a brand new way.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@Copilot 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 the ability to remove all missing files at once through both the native API and frontend components. Key changes include:

  • New remove-all functionality implemented in the native API and integrated in the DeleteMissingFilesButton component.
  • Updates to the data provider to omit query strings on DELETE requests when no IDs are provided.
  • Addition of a dedicated action button and corresponding translations for the remove-all feature.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ui/src/missing/MissingListActions.jsx Adds a new action toolbar that includes the DeleteMissingFilesButton with the delete-all option.
ui/src/missing/MissingFilesList.jsx Integrates the new MissingListActions component into the missing files list.
ui/src/missing/DeleteMissingFilesButton.test.jsx Introduces tests verifying the delete-all behavior and label selection.
ui/src/missing/DeleteMissingFilesButton.jsx Updates the DeleteMissingFilesButton to conditionally handle delete-all behavior with adjusted labels and confirmation messages.
ui/src/i18n/en.json Adds translation keys for the new remove-all action and confirmation messages.
ui/src/dataProvider/wrapperDataProvider.js Updates DELETE request construction to omit query parameters when no IDs are provided.
server/nativeapi/missing.go Implements backend logic to delete all missing files when no IDs are specified.
persistence/mediafile_repository_test.go Adds tests to ensure the deletion of all missing files works as expected.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds the functionality to remove all missing files from the database via the native API and the UI. The changes are well-structured, covering the backend API, data provider, UI components, translations, and tests. The implementation correctly reuses existing components and patterns where appropriate.

Summary of Findings

  • Backend Test Coverage: The new test for DeleteAllMissing (persistence/mediafile_repository_test.go) correctly verifies that missing files are deleted. A minor improvement could be to assert the exact count of missing files before calling DeleteAllMissing to ensure the test setup is correct and the >= 2 assertion is more precise. (Not commented on due to review settings)
  • Frontend Component Readability: In ui/src/missing/DeleteMissingFilesButton.jsx, the use of ternary operators for selecting labels and confirmation messages based on the deleteAll prop is functional. For future maintainability, especially if more conditional text were added, using a helper function or an object lookup could make the code slightly cleaner. (Not commented on due to review settings)
  • Frontend Test Coverage: The new tests in ui/src/missing/DeleteMissingFilesButton.test.jsx adequately cover the new behavior introduced by the deleteAll prop, ensuring the correct label is displayed and the useDeleteMany hook is called with an empty array. (Not commented on due to review settings)
  • Translation Updates: New translation keys for the 'Remove All' action and confirmation messages have been added correctly in ui/src/i18n/en.json. (Not commented on due to review settings)
  • Data Provider Logic: The modification in ui/src/dataProvider/wrapperDataProvider.js to handle empty ID lists for DELETE requests correctly aligns the frontend behavior with the new backend API endpoint logic. (Not commented on due to review settings)
  • Backend API Logic: The update to the deleteMissingFiles handler in server/nativeapi/missing.go correctly routes requests with no IDs to the new DeleteAllMissing repository method, while preserving the existing behavior for deleting specific IDs. The use of ds.WithTx and the permission checks within the repository methods are appropriate. (Not commented on due to review settings)

Merge Readiness

The code changes appear correct and well-tested for the new functionality. Based on my review, there are no critical or high severity issues that would block merging. The pull request seems ready to be merged, but please note that I am unable to directly approve it. Other reviewers should review and approve this code before merging.

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan merged commit 3ccc02f into master May 23, 2025
9 checks passed
@deluan deluan deleted the jrgw1g-codex/add--remove-all--button-to-missinglist branch May 23, 2025 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant