refactor: rename favorite renaming action to "Change sidebar label"
Address review feedback on the sidebar favorite renaming feature: - Context menu item and dialog title now share the same "change-sidebar-label" translation key - Rename NavMenuAction::RenameFavorite and DialogPage::RenameFavorite to ChangeSidebarLabel, with the dialog field renamed to "label" - Rename Favorite::with_name to Favorite::with_label - Dialog confirm button now uses the existing "save" key instead of "rename-confirm" - Replace the "rename-favorite"/"favorite-name" keys with "sidebar-label" in en and pt-BR translations Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YRJDQDBKhCqipbcZm7U1v9
This commit is contained in:
parent
3d520858f3
commit
08a637767d
4 changed files with 33 additions and 33 deletions
|
|
@ -118,9 +118,8 @@ rename-file = Rename file
|
||||||
rename-folder = Rename folder
|
rename-folder = Rename folder
|
||||||
rename-confirm = Rename
|
rename-confirm = Rename
|
||||||
|
|
||||||
## Rename Favorite Dialog
|
## Change Sidebar Label Dialog
|
||||||
rename-favorite = Rename sidebar item
|
sidebar-label = Sidebar label
|
||||||
favorite-name = Item name
|
|
||||||
|
|
||||||
## Replace Dialog
|
## Replace Dialog
|
||||||
replace = Replace
|
replace = Replace
|
||||||
|
|
@ -345,6 +344,7 @@ move-to = Move to...
|
||||||
move-to-trash = Move to trash
|
move-to-trash = Move to trash
|
||||||
restore-from-trash = Restore from trash
|
restore-from-trash = Restore from trash
|
||||||
remove-from-sidebar = Remove from sidebar
|
remove-from-sidebar = Remove from sidebar
|
||||||
|
change-sidebar-label = Change sidebar label
|
||||||
sort-by-name = Sort by name
|
sort-by-name = Sort by name
|
||||||
sort-by-modified = Sort by modified
|
sort-by-modified = Sort by modified
|
||||||
sort-by-size = Sort by size
|
sort-by-size = Sort by size
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,9 @@ permanently-delete-warning = Deseja realmente excluir permanentemente { $target
|
||||||
rename-file = Renomear arquivo
|
rename-file = Renomear arquivo
|
||||||
rename-folder = Renomear pasta
|
rename-folder = Renomear pasta
|
||||||
|
|
||||||
## Rename Favorite Dialog
|
## Change Sidebar Label Dialog
|
||||||
|
|
||||||
rename-favorite = Renomear item da barra lateral
|
sidebar-label = Rótulo da barra lateral
|
||||||
favorite-name = Nome do item
|
|
||||||
|
|
||||||
## Replace Dialog
|
## Replace Dialog
|
||||||
|
|
||||||
|
|
@ -370,6 +369,7 @@ open-in-terminal = Abrir no terminal
|
||||||
move-to-trash = Mover para a lixeira
|
move-to-trash = Mover para a lixeira
|
||||||
restore-from-trash = Restaurar da lixeira
|
restore-from-trash = Restaurar da lixeira
|
||||||
remove-from-sidebar = Remover da barra lateral
|
remove-from-sidebar = Remover da barra lateral
|
||||||
|
change-sidebar-label = Alterar rótulo na barra lateral
|
||||||
sort-by-name = Ordenar por nome
|
sort-by-name = Ordenar por nome
|
||||||
sort-by-modified = Ordenar por data de modificação
|
sort-by-modified = Ordenar por data de modificação
|
||||||
sort-by-size = Ordenar por tamanho
|
sort-by-size = Ordenar por tamanho
|
||||||
|
|
|
||||||
38
src/app.rs
38
src/app.rs
|
|
@ -321,7 +321,7 @@ pub enum NavMenuAction {
|
||||||
Preview(segmented_button::Entity),
|
Preview(segmented_button::Entity),
|
||||||
RunContextAction(segmented_button::Entity, usize),
|
RunContextAction(segmented_button::Entity, usize),
|
||||||
RemoveFromSidebar(segmented_button::Entity),
|
RemoveFromSidebar(segmented_button::Entity),
|
||||||
RenameFavorite(segmented_button::Entity),
|
ChangeSidebarLabel(segmented_button::Entity),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuAction for NavMenuAction {
|
impl MenuAction for NavMenuAction {
|
||||||
|
|
@ -576,9 +576,9 @@ pub enum DialogPage {
|
||||||
DeleteTrash {
|
DeleteTrash {
|
||||||
items: Vec<TrashItem>,
|
items: Vec<TrashItem>,
|
||||||
},
|
},
|
||||||
RenameFavorite {
|
ChangeSidebarLabel {
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
name: String,
|
label: String,
|
||||||
},
|
},
|
||||||
RenameItem {
|
RenameItem {
|
||||||
from: PathBuf,
|
from: PathBuf,
|
||||||
|
|
@ -2631,9 +2631,9 @@ impl Application for App {
|
||||||
items.push(cosmic::widget::menu::Item::Divider);
|
items.push(cosmic::widget::menu::Item::Divider);
|
||||||
if favorite_index_opt.is_some() {
|
if favorite_index_opt.is_some() {
|
||||||
items.push(cosmic::widget::menu::Item::Button(
|
items.push(cosmic::widget::menu::Item::Button(
|
||||||
fl!("rename-confirm"),
|
fl!("change-sidebar-label"),
|
||||||
None,
|
None,
|
||||||
NavMenuAction::RenameFavorite(entity),
|
NavMenuAction::ChangeSidebarLabel(entity),
|
||||||
));
|
));
|
||||||
items.push(cosmic::widget::menu::Item::Button(
|
items.push(cosmic::widget::menu::Item::Button(
|
||||||
fl!("remove-from-sidebar"),
|
fl!("remove-from-sidebar"),
|
||||||
|
|
@ -3285,13 +3285,13 @@ impl Application for App {
|
||||||
DialogPage::DeleteTrash { items } => {
|
DialogPage::DeleteTrash { items } => {
|
||||||
tasks.push(self.operation(Operation::DeleteTrash { items }));
|
tasks.push(self.operation(Operation::DeleteTrash { items }));
|
||||||
}
|
}
|
||||||
DialogPage::RenameFavorite { entity, name } => {
|
DialogPage::ChangeSidebarLabel { entity, label } => {
|
||||||
if let Some(FavoriteIndex(favorite_i)) =
|
if let Some(FavoriteIndex(favorite_i)) =
|
||||||
self.nav_model.data::<FavoriteIndex>(entity)
|
self.nav_model.data::<FavoriteIndex>(entity)
|
||||||
{
|
{
|
||||||
let mut favorites = self.config.favorites.clone();
|
let mut favorites = self.config.favorites.clone();
|
||||||
if let Some(favorite) = favorites.get_mut(*favorite_i) {
|
if let Some(favorite) = favorites.get_mut(*favorite_i) {
|
||||||
*favorite = favorite.with_name(name.trim());
|
*favorite = favorite.with_label(label.trim());
|
||||||
config_set!(favorites, favorites);
|
config_set!(favorites, favorites);
|
||||||
tasks.push(self.update_config());
|
tasks.push(self.update_config());
|
||||||
}
|
}
|
||||||
|
|
@ -5308,7 +5308,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavMenuAction::RenameFavorite(entity) => {
|
NavMenuAction::ChangeSidebarLabel(entity) => {
|
||||||
if let Some(favorite) = self
|
if let Some(favorite) = self
|
||||||
.nav_model
|
.nav_model
|
||||||
.data::<FavoriteIndex>(entity)
|
.data::<FavoriteIndex>(entity)
|
||||||
|
|
@ -5316,12 +5316,12 @@ impl Application for App {
|
||||||
self.config.favorites.get(*favorite_i)
|
self.config.favorites.get(*favorite_i)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let name = favorite
|
let label = favorite
|
||||||
.display_name()
|
.display_name()
|
||||||
.unwrap_or_else(|| fl!("filesystem"));
|
.unwrap_or_else(|| fl!("filesystem"));
|
||||||
return Task::batch([
|
return Task::batch([
|
||||||
self.dialog_pages
|
self.dialog_pages
|
||||||
.push_back(DialogPage::RenameFavorite { entity, name }),
|
.push_back(DialogPage::ChangeSidebarLabel { entity, label }),
|
||||||
widget::text_input::focus(self.dialog_text_input.clone()),
|
widget::text_input::focus(self.dialog_text_input.clone()),
|
||||||
widget::text_input::select_all(self.dialog_text_input.clone()),
|
widget::text_input::select_all(self.dialog_text_input.clone()),
|
||||||
]);
|
]);
|
||||||
|
|
@ -6220,18 +6220,18 @@ impl Application for App {
|
||||||
target = target
|
target = target
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
DialogPage::RenameFavorite { entity, name } => {
|
DialogPage::ChangeSidebarLabel { entity, label } => {
|
||||||
let entity = *entity;
|
let entity = *entity;
|
||||||
let complete_maybe = if name.trim().is_empty() {
|
let complete_maybe = if label.trim().is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Message::DialogComplete)
|
Some(Message::DialogComplete)
|
||||||
};
|
};
|
||||||
|
|
||||||
widget::dialog()
|
widget::dialog()
|
||||||
.title(fl!("rename-favorite"))
|
.title(fl!("change-sidebar-label"))
|
||||||
.primary_action(
|
.primary_action(
|
||||||
widget::button::suggested(fl!("rename-confirm"))
|
widget::button::suggested(fl!("save"))
|
||||||
.on_press_maybe(complete_maybe.clone()),
|
.on_press_maybe(complete_maybe.clone()),
|
||||||
)
|
)
|
||||||
.secondary_action(
|
.secondary_action(
|
||||||
|
|
@ -6239,13 +6239,13 @@ impl Application for App {
|
||||||
)
|
)
|
||||||
.control(
|
.control(
|
||||||
widget::column::with_children([
|
widget::column::with_children([
|
||||||
widget::text::body(fl!("favorite-name")).into(),
|
widget::text::body(fl!("sidebar-label")).into(),
|
||||||
widget::text_input("", name.as_str())
|
widget::text_input("", label.as_str())
|
||||||
.id(self.dialog_text_input.clone())
|
.id(self.dialog_text_input.clone())
|
||||||
.on_input(move |name| {
|
.on_input(move |label| {
|
||||||
Message::DialogUpdate(DialogPage::RenameFavorite {
|
Message::DialogUpdate(DialogPage::ChangeSidebarLabel {
|
||||||
entity,
|
entity,
|
||||||
name,
|
label,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on_submit_maybe(complete_maybe.map(|maybe| move |_| maybe.clone()))
|
.on_submit_maybe(complete_maybe.map(|maybe| move |_| maybe.clone()))
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ impl Favorite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return this favorite renamed with a custom name chosen by the user
|
/// Return this favorite with a custom sidebar label chosen by the user
|
||||||
pub fn with_name(&self, name: &str) -> Self {
|
pub fn with_label(&self, name: &str) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::Network { uri, path, .. } => Self::Network {
|
Self::Network { uri, path, .. } => Self::Network {
|
||||||
uri: uri.clone(),
|
uri: uri.clone(),
|
||||||
|
|
@ -428,10 +428,10 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn favorite_with_name_converts_path_to_named() {
|
fn favorite_with_label_converts_path_to_named() {
|
||||||
let favorite = Favorite::Path(PathBuf::from("/some/dir"));
|
let favorite = Favorite::Path(PathBuf::from("/some/dir"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
favorite.with_name("Custom"),
|
favorite.with_label("Custom"),
|
||||||
Favorite::Named {
|
Favorite::Named {
|
||||||
path: PathBuf::from("/some/dir"),
|
path: PathBuf::from("/some/dir"),
|
||||||
name: "Custom".to_string(),
|
name: "Custom".to_string(),
|
||||||
|
|
@ -440,14 +440,14 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn favorite_with_name_updates_network_in_place() {
|
fn favorite_with_label_updates_network_in_place() {
|
||||||
let favorite = Favorite::Network {
|
let favorite = Favorite::Network {
|
||||||
uri: "sftp://example.com/".to_string(),
|
uri: "sftp://example.com/".to_string(),
|
||||||
name: "example.com".to_string(),
|
name: "example.com".to_string(),
|
||||||
path: PathBuf::from("/run/mount/example"),
|
path: PathBuf::from("/run/mount/example"),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
favorite.with_name("Custom"),
|
favorite.with_label("Custom"),
|
||||||
Favorite::Network {
|
Favorite::Network {
|
||||||
uri: "sftp://example.com/".to_string(),
|
uri: "sftp://example.com/".to_string(),
|
||||||
name: "Custom".to_string(),
|
name: "Custom".to_string(),
|
||||||
|
|
@ -457,10 +457,10 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn favorite_with_name_converts_special_folder_to_named() {
|
fn favorite_with_label_converts_special_folder_to_named() {
|
||||||
let home = dirs::home_dir().unwrap();
|
let home = dirs::home_dir().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Favorite::Home.with_name("Custom"),
|
Favorite::Home.with_label("Custom"),
|
||||||
Favorite::Named {
|
Favorite::Named {
|
||||||
path: home,
|
path: home,
|
||||||
name: "Custom".to_string(),
|
name: "Custom".to_string(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue