-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add remove all missing files functionality #4108
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 remove all missing files functionality #4108
Conversation
There was a problem hiding this 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 handleDELETE_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 newdeleteAll
prop. When this prop is set totrue
, 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 theMissingFilesList
. This component includes an 'Export' button and the newDeleteMissingFilesButton
configured with thedeleteAll
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 theDeleteAllMissing
function and for the frontend component (ui/src/missing/DeleteMissingFilesButton.test.jsx
) to ensure thedeleteAll
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.
- Added a new test case (
- server/nativeapi/missing.go
- Modified the
deleteMissingFiles
function (starting around line 65) to check if theids
parameter is empty. If it is, it now callstx.MediaFile(r.Context()).DeleteAllMissing()
instead oftx.MediaFile(r.Context()).DeleteMissing(ids)
.
- Modified the
- ui/src/dataProvider/wrapperDataProvider.js
- Updated the
callDeleteMany
function (starting around line 38) to check if theparams.ids
array is empty. If it is, thequery
string is set to empty, resulting in a DELETE request without query parameters.
- Updated the
- ui/src/i18n/en.json
- Added a new translation key
remove_all
underresources.missing.actions
(around line 245). - Added new translation keys
remove_all_missing_title
andremove_all_missing_content
undermessage
(around lines 407-408).
- Added a new translation key
- ui/src/missing/DeleteMissingFilesButton.jsx
- Added a
deleteAll
prop with a default value offalse
(around line 32). - Modified the
ids
variable definition (around line 38) to use an empty array ifdeleteAll
is true, otherwise useselectedIds
. - Updated the
label
prop of theButton
component (around line 61) to conditionally display 'resources.missing.actions.remove_all' ifdeleteAll
is true, otherwise display 'ra.action.remove'. - Updated the
title
andcontent
props of theConfirm
component (around lines 74 and 79) to conditionally display the new 'remove all' translation keys ifdeleteAll
is true.
- Added a
- 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 whendeleteAll
is true (around line 34).
- ui/src/missing/MissingFilesList.jsx
- Imported
MissingListActions
(around line 11). - Added the
actions={<MissingListActions />}
prop to theList
component (around line 39).
- Imported
- ui/src/missing/MissingListActions.jsx
- Added a new component file.
- Defines
MissingListActions
usingTopToolbar
. - Includes
ExportButton
andDeleteMissingFilesButton
with thedeleteAll
prop set totrue
.
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
-
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. ↩
There was a problem hiding this 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. |
There was a problem hiding this 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 callingDeleteAllMissing
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 thedeleteAll
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 thedeleteAll
prop, ensuring the correct label is displayed and theuseDeleteMany
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 inserver/nativeapi/missing.go
correctly routes requests with no IDs to the newDeleteAllMissing
repository method, while preserving the existing behavior for deleting specific IDs. The use ofds.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>
Summary
Testing
npm run lint
npm run check-formatting
npm run test:ci
npm run type-check
make test