feat: TUI support for deleting a Lidarr album from the artist details popup
This commit is contained in:
@@ -40,7 +40,7 @@ pub struct LidarrData<'a> {
|
||||
pub albums: StatefulTable<Album>,
|
||||
pub artist_info_tabs: TabState,
|
||||
pub artists: StatefulTable<Artist>,
|
||||
pub delete_artist_files: bool,
|
||||
pub delete_files: bool,
|
||||
pub disk_space_vec: Vec<DiskSpace>,
|
||||
pub downloads: StatefulTable<DownloadRecord>,
|
||||
pub edit_artist_modal: Option<EditArtistModal>,
|
||||
@@ -57,8 +57,8 @@ pub struct LidarrData<'a> {
|
||||
}
|
||||
|
||||
impl LidarrData<'_> {
|
||||
pub fn reset_delete_artist_preferences(&mut self) {
|
||||
self.delete_artist_files = false;
|
||||
pub fn reset_delete_preferences(&mut self) {
|
||||
self.delete_files = false;
|
||||
self.add_import_list_exclusion = false;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ impl<'a> Default for LidarrData<'a> {
|
||||
add_searched_artists: None,
|
||||
albums: StatefulTable::default(),
|
||||
artists: StatefulTable::default(),
|
||||
delete_artist_files: false,
|
||||
delete_files: false,
|
||||
disk_space_vec: Vec::new(),
|
||||
downloads: StatefulTable::default(),
|
||||
edit_artist_modal: None,
|
||||
@@ -176,7 +176,7 @@ impl LidarrData<'_> {
|
||||
.set_items(vec![metadata_profile().name]);
|
||||
|
||||
let mut lidarr_data = LidarrData {
|
||||
delete_artist_files: true,
|
||||
delete_files: true,
|
||||
disk_space_vec: vec![diskspace()],
|
||||
quality_profile_map: quality_profile_map(),
|
||||
metadata_profile_map: metadata_profile_map(),
|
||||
@@ -226,6 +226,10 @@ pub enum ActiveLidarrBlock {
|
||||
AddArtistSelectRootFolder,
|
||||
AddArtistTagsInput,
|
||||
AutomaticallySearchArtistPrompt,
|
||||
DeleteAlbumPrompt,
|
||||
DeleteAlbumConfirmPrompt,
|
||||
DeleteAlbumToggleDeleteFile,
|
||||
DeleteAlbumToggleAddListExclusion,
|
||||
DeleteArtistPrompt,
|
||||
DeleteArtistConfirmPrompt,
|
||||
DeleteArtistToggleDeleteFile,
|
||||
@@ -304,6 +308,19 @@ pub const DELETE_ARTIST_SELECTION_BLOCKS: &[&[ActiveLidarrBlock]] = &[
|
||||
&[ActiveLidarrBlock::DeleteArtistConfirmPrompt],
|
||||
];
|
||||
|
||||
pub static DELETE_ALBUM_BLOCKS: [ActiveLidarrBlock; 4] = [
|
||||
ActiveLidarrBlock::DeleteAlbumPrompt,
|
||||
ActiveLidarrBlock::DeleteAlbumConfirmPrompt,
|
||||
ActiveLidarrBlock::DeleteAlbumToggleDeleteFile,
|
||||
ActiveLidarrBlock::DeleteAlbumToggleAddListExclusion,
|
||||
];
|
||||
|
||||
pub const DELETE_ALBUM_SELECTION_BLOCKS: &[&[ActiveLidarrBlock]] = &[
|
||||
&[ActiveLidarrBlock::DeleteAlbumToggleDeleteFile],
|
||||
&[ActiveLidarrBlock::DeleteAlbumToggleAddListExclusion],
|
||||
&[ActiveLidarrBlock::DeleteAlbumConfirmPrompt],
|
||||
];
|
||||
|
||||
pub static EDIT_ARTIST_BLOCKS: [ActiveLidarrBlock; 8] = [
|
||||
ActiveLidarrBlock::EditArtistPrompt,
|
||||
ActiveLidarrBlock::EditArtistConfirmPrompt,
|
||||
|
||||
@@ -5,8 +5,9 @@ mod tests {
|
||||
};
|
||||
use crate::models::lidarr_models::Album;
|
||||
use crate::models::servarr_data::lidarr::lidarr_data::{
|
||||
ADD_ARTIST_BLOCKS, ADD_ARTIST_SELECTION_BLOCKS, ARTIST_DETAILS_BLOCKS, DELETE_ARTIST_BLOCKS,
|
||||
DELETE_ARTIST_SELECTION_BLOCKS, EDIT_ARTIST_BLOCKS, EDIT_ARTIST_SELECTION_BLOCKS,
|
||||
ADD_ARTIST_BLOCKS, ADD_ARTIST_SELECTION_BLOCKS, ARTIST_DETAILS_BLOCKS, DELETE_ALBUM_BLOCKS,
|
||||
DELETE_ALBUM_SELECTION_BLOCKS, DELETE_ARTIST_BLOCKS, DELETE_ARTIST_SELECTION_BLOCKS,
|
||||
EDIT_ARTIST_BLOCKS, EDIT_ARTIST_SELECTION_BLOCKS,
|
||||
};
|
||||
use crate::models::{
|
||||
BlockSelectionState, Route,
|
||||
@@ -34,16 +35,16 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reset_delete_artist_preferences() {
|
||||
fn test_reset_delete_preferences() {
|
||||
let mut lidarr_data = LidarrData {
|
||||
delete_artist_files: true,
|
||||
delete_files: true,
|
||||
add_import_list_exclusion: true,
|
||||
..LidarrData::default()
|
||||
};
|
||||
|
||||
lidarr_data.reset_delete_artist_preferences();
|
||||
lidarr_data.reset_delete_preferences();
|
||||
|
||||
assert!(!lidarr_data.delete_artist_files);
|
||||
assert!(!lidarr_data.delete_files);
|
||||
assert!(!lidarr_data.add_import_list_exclusion);
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ mod tests {
|
||||
assert_none!(lidarr_data.add_searched_artists);
|
||||
assert_is_empty!(lidarr_data.albums);
|
||||
assert_is_empty!(lidarr_data.artists);
|
||||
assert!(!lidarr_data.delete_artist_files);
|
||||
assert!(!lidarr_data.delete_files);
|
||||
assert_is_empty!(lidarr_data.disk_space_vec);
|
||||
assert_is_empty!(lidarr_data.downloads);
|
||||
assert_none!(lidarr_data.edit_artist_modal);
|
||||
@@ -271,6 +272,34 @@ mod tests {
|
||||
assert_none!(delete_artist_block_iter.next());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_album_blocks_contents() {
|
||||
assert_eq!(DELETE_ALBUM_BLOCKS.len(), 4);
|
||||
assert!(DELETE_ALBUM_BLOCKS.contains(&ActiveLidarrBlock::DeleteAlbumPrompt));
|
||||
assert!(DELETE_ALBUM_BLOCKS.contains(&ActiveLidarrBlock::DeleteAlbumConfirmPrompt));
|
||||
assert!(DELETE_ALBUM_BLOCKS.contains(&ActiveLidarrBlock::DeleteAlbumToggleDeleteFile));
|
||||
assert!(DELETE_ALBUM_BLOCKS.contains(&ActiveLidarrBlock::DeleteAlbumToggleAddListExclusion));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_album_selection_blocks_ordering() {
|
||||
let mut delete_album_block_iter = DELETE_ALBUM_SELECTION_BLOCKS.iter();
|
||||
|
||||
assert_eq!(
|
||||
delete_album_block_iter.next().unwrap(),
|
||||
&[ActiveLidarrBlock::DeleteAlbumToggleDeleteFile]
|
||||
);
|
||||
assert_eq!(
|
||||
delete_album_block_iter.next().unwrap(),
|
||||
&[ActiveLidarrBlock::DeleteAlbumToggleAddListExclusion]
|
||||
);
|
||||
assert_eq!(
|
||||
delete_album_block_iter.next().unwrap(),
|
||||
&[ActiveLidarrBlock::DeleteAlbumConfirmPrompt]
|
||||
);
|
||||
assert_none!(delete_album_block_iter.next());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_artist_blocks() {
|
||||
assert_eq!(EDIT_ARTIST_BLOCKS.len(), 8);
|
||||
|
||||
Reference in New Issue
Block a user