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:
César Mendonça 2026-08-20 13:53:47 -03:00
parent 3d520858f3
commit 08a637767d
4 changed files with 33 additions and 33 deletions

View file

@ -118,9 +118,8 @@ rename-file = Rename file
rename-folder = Rename folder
rename-confirm = Rename
## Rename Favorite Dialog
rename-favorite = Rename sidebar item
favorite-name = Item name
## Change Sidebar Label Dialog
sidebar-label = Sidebar label
## Replace Dialog
replace = Replace
@ -345,6 +344,7 @@ move-to = Move to...
move-to-trash = Move to trash
restore-from-trash = Restore from trash
remove-from-sidebar = Remove from sidebar
change-sidebar-label = Change sidebar label
sort-by-name = Sort by name
sort-by-modified = Sort by modified
sort-by-size = Sort by size

View file

@ -109,10 +109,9 @@ permanently-delete-warning = Deseja realmente excluir permanentemente { $target
rename-file = Renomear arquivo
rename-folder = Renomear pasta
## Rename Favorite Dialog
## Change Sidebar Label Dialog
rename-favorite = Renomear item da barra lateral
favorite-name = Nome do item
sidebar-label = Rótulo da barra lateral
## Replace Dialog
@ -370,6 +369,7 @@ open-in-terminal = Abrir no terminal
move-to-trash = Mover para a lixeira
restore-from-trash = Restaurar da lixeira
remove-from-sidebar = Remover da barra lateral
change-sidebar-label = Alterar rótulo na barra lateral
sort-by-name = Ordenar por nome
sort-by-modified = Ordenar por data de modificação
sort-by-size = Ordenar por tamanho

View file

@ -321,7 +321,7 @@ pub enum NavMenuAction {
Preview(segmented_button::Entity),
RunContextAction(segmented_button::Entity, usize),
RemoveFromSidebar(segmented_button::Entity),
RenameFavorite(segmented_button::Entity),
ChangeSidebarLabel(segmented_button::Entity),
}
impl MenuAction for NavMenuAction {
@ -576,9 +576,9 @@ pub enum DialogPage {
DeleteTrash {
items: Vec<TrashItem>,
},
RenameFavorite {
ChangeSidebarLabel {
entity: Entity,
name: String,
label: String,
},
RenameItem {
from: PathBuf,
@ -2631,9 +2631,9 @@ impl Application for App {
items.push(cosmic::widget::menu::Item::Divider);
if favorite_index_opt.is_some() {
items.push(cosmic::widget::menu::Item::Button(
fl!("rename-confirm"),
fl!("change-sidebar-label"),
None,
NavMenuAction::RenameFavorite(entity),
NavMenuAction::ChangeSidebarLabel(entity),
));
items.push(cosmic::widget::menu::Item::Button(
fl!("remove-from-sidebar"),
@ -3285,13 +3285,13 @@ impl Application for App {
DialogPage::DeleteTrash { items } => {
tasks.push(self.operation(Operation::DeleteTrash { items }));
}
DialogPage::RenameFavorite { entity, name } => {
DialogPage::ChangeSidebarLabel { entity, label } => {
if let Some(FavoriteIndex(favorite_i)) =
self.nav_model.data::<FavoriteIndex>(entity)
{
let mut favorites = self.config.favorites.clone();
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);
tasks.push(self.update_config());
}
@ -5308,7 +5308,7 @@ impl Application for App {
}
}
NavMenuAction::RenameFavorite(entity) => {
NavMenuAction::ChangeSidebarLabel(entity) => {
if let Some(favorite) = self
.nav_model
.data::<FavoriteIndex>(entity)
@ -5316,12 +5316,12 @@ impl Application for App {
self.config.favorites.get(*favorite_i)
})
{
let name = favorite
let label = favorite
.display_name()
.unwrap_or_else(|| fl!("filesystem"));
return Task::batch([
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::select_all(self.dialog_text_input.clone()),
]);
@ -6220,18 +6220,18 @@ impl Application for App {
target = target
)))
}
DialogPage::RenameFavorite { entity, name } => {
DialogPage::ChangeSidebarLabel { entity, label } => {
let entity = *entity;
let complete_maybe = if name.trim().is_empty() {
let complete_maybe = if label.trim().is_empty() {
None
} else {
Some(Message::DialogComplete)
};
widget::dialog()
.title(fl!("rename-favorite"))
.title(fl!("change-sidebar-label"))
.primary_action(
widget::button::suggested(fl!("rename-confirm"))
widget::button::suggested(fl!("save"))
.on_press_maybe(complete_maybe.clone()),
)
.secondary_action(
@ -6239,13 +6239,13 @@ impl Application for App {
)
.control(
widget::column::with_children([
widget::text::body(fl!("favorite-name")).into(),
widget::text_input("", name.as_str())
widget::text::body(fl!("sidebar-label")).into(),
widget::text_input("", label.as_str())
.id(self.dialog_text_input.clone())
.on_input(move |name| {
Message::DialogUpdate(DialogPage::RenameFavorite {
.on_input(move |label| {
Message::DialogUpdate(DialogPage::ChangeSidebarLabel {
entity,
name,
label,
})
})
.on_submit_maybe(complete_maybe.map(|maybe| move |_| maybe.clone()))

View file

@ -120,8 +120,8 @@ impl Favorite {
}
}
/// Return this favorite renamed with a custom name chosen by the user
pub fn with_name(&self, name: &str) -> Self {
/// Return this favorite with a custom sidebar label chosen by the user
pub fn with_label(&self, name: &str) -> Self {
match self {
Self::Network { uri, path, .. } => Self::Network {
uri: uri.clone(),
@ -428,10 +428,10 @@ mod tests {
use super::*;
#[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"));
assert_eq!(
favorite.with_name("Custom"),
favorite.with_label("Custom"),
Favorite::Named {
path: PathBuf::from("/some/dir"),
name: "Custom".to_string(),
@ -440,14 +440,14 @@ mod tests {
}
#[test]
fn favorite_with_name_updates_network_in_place() {
fn favorite_with_label_updates_network_in_place() {
let favorite = Favorite::Network {
uri: "sftp://example.com/".to_string(),
name: "example.com".to_string(),
path: PathBuf::from("/run/mount/example"),
};
assert_eq!(
favorite.with_name("Custom"),
favorite.with_label("Custom"),
Favorite::Network {
uri: "sftp://example.com/".to_string(),
name: "Custom".to_string(),
@ -457,10 +457,10 @@ mod tests {
}
#[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();
assert_eq!(
Favorite::Home.with_name("Custom"),
Favorite::Home.with_label("Custom"),
Favorite::Named {
path: home,
name: "Custom".to_string(),