Skip to content

Commit

Permalink
Add Edit menu for deleting repository and snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoneybun committed May 21, 2024
1 parent 8fb72a6 commit d8484d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
4 changes: 3 additions & 1 deletion i18n/en/cosmic_backups.ftl
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
cosmic-backups = COSMIC Backups
app-title = COSMIC Backups
welcome = Backup and backup often! ✨
welcome = Backup often! ✨
# Dialogs
save = Save
create = Create
cancel = Cancel
confirm = Confirm
create-repo = Create a new repository
delete-repo = Delete repository
repo-location = Repository location
create-snapshot = Create a new snapshot
delete-snapshot = Delete snapshot
snapshot-description = A snapshot is a point-in-time copy of your repository.
# Context Pages
Expand Down
12 changes: 12 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ pub enum Message {
CreateSnapshot,
OpenCreateRepositoryDialog,
OpenCreateSnapshotDialog,
DeleteRepositoryDialog,
DeleteSnapshotDialog,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -93,6 +95,8 @@ pub enum Action {
About,
CreateRepository,
CreateSnapshot,
DeleteRepository,
DeleteSnapshot,
Settings,
WindowClose,
WindowNew,
Expand All @@ -105,6 +109,8 @@ impl MenuAction for Action {
Action::About => Message::ToggleContextPage(ContextPage::About),
Action::CreateRepository => Message::OpenCreateRepositoryDialog,
Action::CreateSnapshot => Message::OpenCreateSnapshotDialog,
Action::DeleteRepository => Message::DeleteRepositoryDialog,
Action::DeleteSnapshot => Message::DeleteSnapshotDialog,
Action::Settings => Message::ToggleContextPage(ContextPage::Settings),
Action::WindowClose => Message::WindowClose,
Action::WindowNew => Message::WindowNew,
Expand Down Expand Up @@ -377,6 +383,12 @@ impl Application for App {
eprintln!("failed to create repository: {}", e)
}
},
Message::DeleteRepositoryDialog => {
println!("Deleting repository");
}
Message::DeleteSnapshotDialog => {
println!("Deleting snapshot");
}
Message::CreateSnapshot => {
if let Some(repository) = &self.selected_repository {
let Some(path) = repository.path.to_str() else {
Expand Down
19 changes: 10 additions & 9 deletions src/app/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ pub fn menu_bar<'a>(key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message
],
),
),
// Tree::with_children(
// root(fl!("edit")),
// items(
// key_binds,
// vec![
// Item::Button(fl!("cut"), Action::Cut),
// ],
// ),
// ),
Tree::with_children(
root(fl!("edit")),
items(
key_binds,
vec![
Item::Button(fl!("delete-repo"), Action::DeleteRepository),
Item::Button(fl!("delete-snapshot"), Action::DeleteSnapshot),
],
),
),
Tree::with_children(
root(fl!("view")),
items(
Expand Down

0 comments on commit d8484d6

Please sign in to comment.