fix(readarr): move the book file delete to the File tab
Pressing Del on the Editions tab opened a delete prompt operating on the currently selected book file, which is not visible from that tab. On the File tab, where the book files are listed, Del did nothing even though the tab advertised a "delete book file" hint. Gate the delete on the File tab instead and drop the now inaccurate hint from the Editions tab clue set. A Readarr edition carries no file id, unlike a Lidarr track, so the book files live in their own table and the delete cannot be driven from the editions table.
This commit is contained in:
4 files changed
+23
-14
No files matched your search
@@ -93,7 +93,7 @@ pub static MANUAL_AUTHOR_SEARCH_CONTEXT_CLUES: [ContextClue; 7] = [
|
||||
(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc),
|
||||
];
|
||||
|
||||
pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 6] = [
|
||||
pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 5] = [
|
||||
(
|
||||
DEFAULT_KEYBINDINGS.refresh,
|
||||
DEFAULT_KEYBINDINGS.refresh.desc,
|
||||
@@ -105,7 +105,6 @@ pub static BOOK_DETAILS_CONTEXT_CLUES: [ContextClue; 6] = [
|
||||
),
|
||||
(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc),
|
||||
(DEFAULT_KEYBINDINGS.submit, "edition details"),
|
||||
(DEFAULT_KEYBINDINGS.delete, "delete book file"),
|
||||
];
|
||||
|
||||
pub static BOOK_HISTORY_CONTEXT_CLUES: [ContextClue; 7] = [
|
||||
|
||||
@@ -269,10 +269,6 @@ mod tests {
|
||||
book_details_context_clues_iter.next(),
|
||||
&(DEFAULT_KEYBINDINGS.submit, "edition details")
|
||||
);
|
||||
assert_some_eq_x!(
|
||||
book_details_context_clues_iter.next(),
|
||||
&(DEFAULT_KEYBINDINGS.delete, "delete book file")
|
||||
);
|
||||
assert_none!(book_details_context_clues_iter.next());
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveReadarrBlock> for BookDetailsHandler<
|
||||
fn handle_end(&mut self) {}
|
||||
|
||||
fn handle_delete(&mut self) {
|
||||
if self.active_readarr_block == ActiveReadarrBlock::BookDetails
|
||||
if self.active_readarr_block == ActiveReadarrBlock::BookFileInfo
|
||||
&& self.book_files_are_populated()
|
||||
{
|
||||
self
|
||||
|
||||
@@ -164,13 +164,25 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_delete_book_file_prompt() {
|
||||
let mut app = App::test_default();
|
||||
app.data.readarr_data.book_details_modal = Some(book_details_modal());
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into());
|
||||
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::DeleteBookFilePrompt.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_book_file_prompt_is_a_no_op_on_the_editions_tab() {
|
||||
let mut app = App::test_default();
|
||||
app.data.readarr_data.book_details_modal = Some(book_details_modal());
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into());
|
||||
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::DeleteBookFilePrompt.into());
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -179,11 +191,12 @@ mod tests {
|
||||
let mut modal = book_details_modal();
|
||||
modal.book_files.set_items(Vec::new());
|
||||
app.data.readarr_data.book_details_modal = Some(modal);
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into());
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into());
|
||||
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle();
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into());
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::BookFileInfo.into());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -191,11 +204,12 @@ mod tests {
|
||||
let mut app = App::test_default();
|
||||
app.is_loading = true;
|
||||
app.data.readarr_data.book_details_modal = Some(book_details_modal());
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookDetails.into());
|
||||
app.push_navigation_stack(ActiveReadarrBlock::BookFileInfo.into());
|
||||
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookDetails, None).handle();
|
||||
BookDetailsHandler::new(DELETE_KEY, &mut app, ActiveReadarrBlock::BookFileInfo, None)
|
||||
.handle();
|
||||
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::BookDetails.into());
|
||||
assert_navigation_pushed!(app, ActiveReadarrBlock::BookFileInfo.into());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user