From 4e53b710a5e0223f49dc5a8c1bed5e2cdcb38bfc Mon Sep 17 00:00:00 2001 From: Slavasil Date: Thu, 7 May 2026 23:26:00 +0300 Subject: [PATCH] add context menu for groups --- src/KeyKeeper/Models/GroupData.cs | 5 ++ .../ViewModels/UnlockedRepositoryViewModel.cs | 23 ++++++ .../Views/CloseConfirmationDialog.axaml | 1 + src/KeyKeeper/Views/ConfirmationDialog.axaml | 38 +++++++++ .../Views/ConfirmationDialog.axaml.cs | 40 ++++++++++ src/KeyKeeper/Views/CreateGroupDialog.axaml | 7 +- .../Views/CreateGroupDialog.axaml.cs | 39 +++++++--- src/KeyKeeper/Views/RepositoryWindow.axaml | 6 ++ src/KeyKeeper/Views/RepositoryWindow.axaml.cs | 78 ++++++++++++++++++- 9 files changed, 219 insertions(+), 18 deletions(-) create mode 100644 src/KeyKeeper/Models/GroupData.cs create mode 100644 src/KeyKeeper/Views/ConfirmationDialog.axaml create mode 100644 src/KeyKeeper/Views/ConfirmationDialog.axaml.cs diff --git a/src/KeyKeeper/Models/GroupData.cs b/src/KeyKeeper/Models/GroupData.cs new file mode 100644 index 0000000..7b964be --- /dev/null +++ b/src/KeyKeeper/Models/GroupData.cs @@ -0,0 +1,5 @@ +using System; + +namespace KeyKeeper.Models; + +public record GroupEditData(string Name, Guid IconType); diff --git a/src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs b/src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs index 48db0af..3790d6d 100644 --- a/src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs +++ b/src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs @@ -160,6 +160,29 @@ public class UnlockedRepositoryViewModel : ViewModelBase OnPropertyChanged(nameof(Passwords)); } + public void UpdateGroup(PassStoreEntryGroup group, string newName, Guid newIconType) + { + group.Name = newName; + group.IconType = newIconType; + group.ModificationDate = DateTime.UtcNow; + HasUnsavedChanges = true; + OnPropertyChanged(nameof(PasswordGroups)); + } + + public void DeleteGroup(PassStoreEntryGroup group) + { + if (rootDirectory == null) + return; + + passStore.DeleteEntry(rootDirectory, group.Id); + if (currentDirectory == group && rootDirectory != null) + { + ChangeDirectory(rootDirectory.ChildGroups.FirstOrDefault() ?? rootDirectory); + } + HasUnsavedChanges = true; + OnPropertyChanged(nameof(PasswordGroups)); + } + public void Save() { passStore.Save(); diff --git a/src/KeyKeeper/Views/CloseConfirmationDialog.axaml b/src/KeyKeeper/Views/CloseConfirmationDialog.axaml index 2779e45..df19cdf 100644 --- a/src/KeyKeeper/Views/CloseConfirmationDialog.axaml +++ b/src/KeyKeeper/Views/CloseConfirmationDialog.axaml @@ -16,6 +16,7 @@