diff --git a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift index e25f8e543f..5702c4889b 100644 --- a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift +++ b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift @@ -128,10 +128,6 @@ final class MoreOptionsMenu: NSMenu { @objc func openLoginsWithCreditCards(_ sender: NSMenuItem) { actionDelegate?.optionsButtonMenuRequestedLoginsPopover(self, selectedCategory: .cards) } - - @objc func openLoginsWithNotes(_ sender: NSMenuItem) { - actionDelegate?.optionsButtonMenuRequestedLoginsPopover(self, selectedCategory: .notes) - } @objc func openPreferences(_ sender: NSMenuItem) { WindowControllersManager.shared.showPreferencesTab() @@ -384,11 +380,6 @@ final class LoginsSubMenu: NSMenu { .targetting(target) .withImage(NSImage(named: "CreditCardGlyph")) .firingPixel(Pixel.Event.MoreResult.loginsMenuCreditCards) - - addItem(withTitle: UserText.passwordManagementNotes, action: #selector(MoreOptionsMenu.openLoginsWithNotes), keyEquivalent: "") - .targetting(target) - .withImage(NSImage(named: "NoteGlyph")) - .firingPixel(Pixel.Event.MoreResult.loginsMenuNotes) } } diff --git a/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift b/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift index 0cdf270717..f2138da4b8 100644 --- a/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift +++ b/DuckDuckGo/SecureVault/Model/PasswordManagementItemListModel.swift @@ -161,7 +161,7 @@ enum SecureVaultItem: Equatable, Identifiable, Comparable { case .account: return .logins case .card: return .cards case .identity: return .identities - case .note: return .notes + case .note: return .allItems } } @@ -419,7 +419,6 @@ final class PasswordManagementItemListModel: ObservableObject { case .cards: emptyState = .creditCards case .logins: emptyState = .logins case .identities: emptyState = .identities - case .notes: emptyState = .notes } } diff --git a/DuckDuckGo/SecureVault/Model/SecureVaultSorting.swift b/DuckDuckGo/SecureVault/Model/SecureVaultSorting.swift index 83ec3d77d8..3de939e147 100644 --- a/DuckDuckGo/SecureVault/Model/SecureVaultSorting.swift +++ b/DuckDuckGo/SecureVault/Model/SecureVaultSorting.swift @@ -30,7 +30,6 @@ struct SecureVaultSorting: Equatable { case logins case identities case cards - case notes var title: String { switch self { @@ -38,7 +37,6 @@ struct SecureVaultSorting: Equatable { case .logins: return UserText.passwordManagementLogins case .identities: return UserText.passwordManagementIdentities case .cards: return UserText.passwordManagementCreditCards - case .notes: return UserText.passwordManagementNotes } } @@ -48,7 +46,6 @@ struct SecureVaultSorting: Equatable { case .logins: return "LoginGlyph" case .identities: return "IdentityGlyph" case .cards: return "CreditCardGlyph" - case .notes: return "NoteGlyph" } } @@ -58,7 +55,6 @@ struct SecureVaultSorting: Equatable { case .logins: return NSColor(named: "LoginsColor")! case .identities: return NSColor(named: "IdentitiesColor")! case .cards: return NSColor(named: "CardsColor")! - case .notes: return NSColor(named: "NotesColor")! } } @@ -68,7 +64,6 @@ struct SecureVaultSorting: Equatable { case .logins: return .black case .identities: return .black case .cards: return .white - case .notes: return .black } } } diff --git a/DuckDuckGo/SecureVault/View/PasswordManagementItemList.swift b/DuckDuckGo/SecureVault/View/PasswordManagementItemList.swift index 6b5f64d478..acae9e4549 100644 --- a/DuckDuckGo/SecureVault/View/PasswordManagementItemList.swift +++ b/DuckDuckGo/SecureVault/View/PasswordManagementItemList.swift @@ -233,12 +233,22 @@ private struct ItemView: View { } VStack(alignment: .leading, spacing: 4) { - Text(item.displayTitle) - .foregroundColor(textColor) - .font(font) - Text(item.displaySubtitle) - .foregroundColor(textColor.opacity(0.8)) - .font(font) + switch item { + case .note: + Text(item.displayTitle) + .foregroundColor(textColor.opacity(0.7)) + .font(font) + Text(item.displaySubtitle) + .foregroundColor(textColor.opacity(0.5)) + .font(font) + default: + Text(item.displayTitle) + .foregroundColor(textColor) + .font(font) + Text(item.displaySubtitle) + .foregroundColor(textColor.opacity(0.8)) + .font(font) + } } .padding(.leading, 4) } diff --git a/DuckDuckGo/SecureVault/View/PasswordManagementNoteItemView.swift b/DuckDuckGo/SecureVault/View/PasswordManagementNoteItemView.swift index e7e7fe1e7b..53d584def2 100644 --- a/DuckDuckGo/SecureVault/View/PasswordManagementNoteItemView.swift +++ b/DuckDuckGo/SecureVault/View/PasswordManagementNoteItemView.swift @@ -32,26 +32,16 @@ struct PasswordManagementNoteItemView: View { if model.note != nil { - let editMode = model.isEditing || model.isNew - ZStack(alignment: .top) { Spacer() - if editMode { - - RoundedRectangle(cornerRadius: 8) - .foregroundColor(Color(NSColor.editingPanelColor)) - .shadow(radius: 6) - - } - VStack(alignment: .leading, spacing: 0) { HeaderView() - .padding(.bottom, editMode ? 20 : 30) + .padding(.bottom, 30) TextView() - + Spacer(minLength: 0) Buttons() @@ -78,38 +68,16 @@ private struct Buttons: View { var body: some View { HStack { - if model.isEditing && !model.isNew { - Button(UserText.pmDelete) { - model.requestDelete() - } - .buttonStyle(StandardButtonStyle()) - } + Text("⚠️ Notes are deprecated.") + .font(.body) + .foregroundColor(Color.secondary) Spacer() - if model.isEditing || model.isNew { - Button(UserText.pmCancel) { - model.cancel() - } - .buttonStyle(StandardButtonStyle()) - Button(UserText.pmSave) { - model.save() - } - .disabled(!model.isDirty) - .buttonStyle(DefaultActionButtonStyle(enabled: model.isDirty)) - - } else { - Button(UserText.pmDelete) { - model.requestDelete() - } - .buttonStyle(StandardButtonStyle()) - - Button(UserText.pmEdit) { - model.edit() - } - .buttonStyle(StandardButtonStyle()) - + Button(UserText.pmDelete) { + model.requestDelete() } + .buttonStyle(StandardButtonStyle()) } } @@ -143,21 +111,10 @@ private struct TextView: View { var body: some View { VStack(alignment: .leading, spacing: 0) { - if model.isEditing || model.isNew { - - EditableTextView(text: $model.text) - .overlay( - RoundedRectangle(cornerRadius: 4.0) - .stroke(Color.init(NSColor.tertiaryLabelColor), lineWidth: 1) - ) - .padding(.bottom, interItemSpacing) - - } else { - HStack { if #available(macOS 12, *) { Text(model.text) - .foregroundColor(Color.primary) + .foregroundColor(Color.secondary) .textSelection(.enabled) } else { Text(model.text) @@ -166,7 +123,6 @@ private struct TextView: View { Spacer() } .padding(.bottom, interItemSpacing) - } } } @@ -184,17 +140,9 @@ private struct HeaderView: View { Image("Note") .padding(.trailing, 10) - if model.isNew || model.isEditing { - - TextField("", text: $model.title) - .font(.title) - - } else { - - Text(model.title) - .font(.title) - - } + Text(model.title) + .font(.title) + .foregroundColor(Color.secondary) } diff --git a/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift b/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift index 52e1d90e67..d122ef3722 100644 --- a/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift +++ b/DuckDuckGo/SecureVault/View/PasswordManagementViewController.swift @@ -574,8 +574,7 @@ final class PasswordManagementViewController: NSViewController { menu.items = [ createMenuItem(title: UserText.pmNewCard, action: #selector(createNewCreditCard), imageName: "CreditCardGlyph"), createMenuItem(title: UserText.pmNewLogin, action: #selector(createNewLogin), imageName: "LoginGlyph"), - createMenuItem(title: UserText.pmNewIdentity, action: #selector(createNewIdentity), imageName: "IdentityGlyph"), - createMenuItem(title: UserText.pmNewNote, action: #selector(createNewNote), imageName: "NoteGlyph") + createMenuItem(title: UserText.pmNewIdentity, action: #selector(createNewIdentity), imageName: "IdentityGlyph") ] return menu @@ -610,9 +609,6 @@ final class PasswordManagementViewController: NSViewController { case .cards: let cards = (try? self.secureVault?.creditCards()) ?? [] items = cards.map(SecureVaultItem.card) - case .notes: - let notes = (try? self.secureVault?.notes()) ?? [] - items = notes.map(SecureVaultItem.note) } DispatchQueue.main.async { @@ -723,40 +719,6 @@ final class PasswordManagementViewController: NSViewController { createNew() } } - - @objc - private func createNewNote() { - guard let window = view.window else { return } - - func createNew() { - createNoteItemView() - - listModel?.clearSelection() - itemModel?.createNew() - } - - if isDirty { - let alert = NSAlert.passwordManagerSaveChangesToLogin() - alert.beginSheetModal(for: window) { response in - - switch response { - case .alertFirstButtonReturn: // Save - self.itemModel?.save() - createNew() - - case .alertSecondButtonReturn: // Discard - self.itemModel?.cancel() - createNew() - - default: // Cancel - break // just do nothing - } - - } - } else { - createNew() - } - } // MARK: - Empty State @@ -778,7 +740,6 @@ final class PasswordManagementViewController: NSViewController { case .logins: showEmptyState(imageName: "LoginsEmpty", title: UserText.pmEmptyStateLoginsTitle) case .identities: showEmptyState(imageName: "IdentitiesEmpty", title: UserText.pmEmptyStateIdentitiesTitle) case .cards: showEmptyState(imageName: "CreditCardsEmpty", title: UserText.pmEmptyStateCardsTitle) - case .notes: showEmptyState(imageName: "NotesEmpty", title: UserText.pmEmptyStateNotesTitle) } } diff --git a/Unit Tests/PasswordManager/PasswordManagementItemListModelTests.swift b/Unit Tests/PasswordManager/PasswordManagementItemListModelTests.swift index 6e7fe0c9bf..48ec3c3da3 100644 --- a/Unit Tests/PasswordManager/PasswordManagementItemListModelTests.swift +++ b/Unit Tests/PasswordManager/PasswordManagementItemListModelTests.swift @@ -117,21 +117,6 @@ final class PasswordManagementItemListModelTests: XCTestCase { XCTAssertEqual(model.emptyState, .logins) } - func testWhenGettingEmptyState_AndViewModelHasLoginsOnly_AndCategoryIsNotes_ThenEmptyStateIsNotes() { - let accounts = (0 ..< 10).map { makeAccount(id: $0, domain: "domain\($0)") } - let model = PasswordManagementItemListModel(onItemSelected: onItemSelected) - - model.update(items: accounts) - model.sortDescriptor.category = .notes - XCTAssertEqual(model.emptyState, .notes) - - model.filter = "domain" - XCTAssertEqual(model.emptyState, .notes) - - model.filter = "filter that won't match" - XCTAssertEqual(model.emptyState, .notes) - } - func makeAccount(id: Int64, title: String? = nil, username: String = "username", domain: String = "domain") -> SecureVaultItem { let account = SecureVaultModels.WebsiteAccount(id: id, title: title,