[PM-31178] feat: Archive remove confirmation and update localizations (#2281)

This commit is contained in:
Federico Maccaroni 2026-01-23 14:53:54 -03:00 committed by GitHub
parent 30a494b5c5
commit f620aa5f82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 30 additions and 111 deletions

View File

@ -1286,12 +1286,10 @@
"Archive" = "Archive";
"Archived" = "Archived";
"Unarchive" = "Unarchive";
"ItemMovedToArchive" = "Item moved to Archive";
"ItemUnarchived" = "Item unarchived";
"ItemMovedToArchive" = "Item moved to archive";
"ItemMovedToVault" = "Item moved to vault";
"SendingToArchive" = "Sending to archive…";
"Unarchiving" = "Unarchiving…";
"DoYouReallyWantToUnarchiveThisItem" = "Do you really want to unarchive this item?";
"DoYouReallyWantToArchiveThisItem" = "Do you really want to archive this item?";
"MovingItemToVault" = "Moving item to vault";
"OrganizationNotFound" = "Organization not found.";
"ItemsTransferred" = "Items transferred";
"ArchiveIsEmpty" = "Archive is empty";

View File

@ -227,8 +227,8 @@ class DefaultVaultItemMoreOptionsHelper: VaultItemMoreOptionsHelper {
case let .unarchive(cipher):
await performOperationAndShowToast(
handleDisplayToast: handleDisplayToast,
loadingTitle: Localizations.unarchiving,
toastTitle: Localizations.itemUnarchived,
loadingTitle: Localizations.movingItemToVault,
toastTitle: Localizations.itemMovedToVault,
) {
try await services.vaultRepository.unarchiveCipher(cipher)
}

View File

@ -746,9 +746,9 @@ class VaultItemMoreOptionsHelperTests: BitwardenTestCase { // swiftlint:disable:
vaultRepository.unarchiveCipherResult = .success(())
try await optionsAlert.tapAction(title: Localizations.unarchive)
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.unarchiving)
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.movingItemToVault)
XCTAssertEqual(vaultRepository.unarchiveCipher, [cipherView])
XCTAssertEqual(toastToDisplay, Toast(title: Localizations.itemUnarchived))
XCTAssertEqual(toastToDisplay, Toast(title: Localizations.itemMovedToVault))
}
}

View File

@ -346,7 +346,7 @@ extension VaultGroupProcessor: CipherItemOperationDelegate {
}
func itemUnarchived() {
displayToastAndRefresh(toastTitle: Localizations.itemUnarchived)
displayToastAndRefresh(toastTitle: Localizations.itemMovedToVault)
}
// MARK: Private methods

View File

@ -144,7 +144,7 @@ class VaultGroupProcessorTests: BitwardenTestCase { // swiftlint:disable:this ty
XCTAssertNil(subject.state.toast)
subject.itemUnarchived()
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemUnarchived))
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemMovedToVault))
waitFor(vaultRepository.fetchSyncCalled)
}

View File

@ -137,28 +137,28 @@ class VaultGroupStateTests: BitwardenTestCase {
let subjectNoPremiumArchive = VaultGroupState(
group: .archive,
hasPremium: false,
vaultFilterType: .myVault
vaultFilterType: .myVault,
)
XCTAssertTrue(subjectNoPremiumArchive.showArchivePremiumSubscriptionEndedCard)
let subjectHasPremiumArchive = VaultGroupState(
group: .archive,
hasPremium: true,
vaultFilterType: .myVault
vaultFilterType: .myVault,
)
XCTAssertFalse(subjectHasPremiumArchive.showArchivePremiumSubscriptionEndedCard)
let subjectNoPremiumLogin = VaultGroupState(
group: .login,
hasPremium: false,
vaultFilterType: .myVault
vaultFilterType: .myVault,
)
XCTAssertFalse(subjectNoPremiumLogin.showArchivePremiumSubscriptionEndedCard)
let subjectHasPremiumLogin = VaultGroupState(
group: .login,
hasPremium: true,
vaultFilterType: .myVault
vaultFilterType: .myVault,
)
XCTAssertFalse(subjectHasPremiumLogin.showArchivePremiumSubscriptionEndedCard)
}

View File

@ -599,7 +599,7 @@ extension VaultListProcessor: CipherItemOperationDelegate {
}
func itemUnarchived() {
state.toast = Toast(title: Localizations.itemUnarchived)
state.toast = Toast(title: Localizations.itemMovedToVault)
}
}

View File

@ -193,7 +193,7 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ
XCTAssertNil(subject.state.toast)
subject.itemUnarchived()
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemUnarchived))
XCTAssertEqual(subject.state.toast, Toast(title: Localizations.itemMovedToVault))
}
/// `init()` has default values set in the state.

View File

@ -77,36 +77,26 @@ class DefaultVaultItemActionHelper: VaultItemActionHelper {
return
}
let alert = Alert.confirmation(title: Localizations.doYouReallyWantToArchiveThisItem) { [weak self] in
guard let self else { return }
await performOperation(
loadingTitle: Localizations.sendingToArchive,
operation: {
try await self.services.vaultRepository.archiveCipher(cipher)
},
completionHandler: completionHandler,
)
}
await coordinator.showAlert(alert)
await performOperation(
loadingTitle: Localizations.sendingToArchive,
operation: {
try await self.services.vaultRepository.archiveCipher(cipher)
},
completionHandler: completionHandler,
)
}
func unarchive(
cipher: CipherView,
completionHandler: @escaping () -> Void,
) async {
let alert = Alert.confirmation(title: Localizations.doYouReallyWantToUnarchiveThisItem) { [weak self] in
guard let self else { return }
await performOperation(
loadingTitle: Localizations.unarchiving,
operation: {
try await self.services.vaultRepository.unarchiveCipher(cipher)
},
completionHandler: completionHandler,
)
}
await coordinator.showAlert(alert)
await performOperation(
loadingTitle: Localizations.movingItemToVault,
operation: {
try await self.services.vaultRepository.unarchiveCipher(cipher)
},
completionHandler: completionHandler,
)
}
// MARK: Private methods

View File

@ -98,11 +98,6 @@ class VaultItemActionHelperTests: BitwardenTestCase {
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
try await alert?.tapAction(title: Localizations.yes)
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.sendingToArchive)
XCTAssertEqual(vaultRepository.archiveCipher.last?.id, "123")
@ -125,41 +120,11 @@ class VaultItemActionHelperTests: BitwardenTestCase {
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
try await alert?.tapAction(title: Localizations.yes)
XCTAssertEqual(coordinator.errorAlertsShown.count, 1)
XCTAssertEqual(errorReporter.errors as? [BitwardenTestError], [.example])
XCTAssertFalse(completionCalled)
}
/// `archive(cipher:handleOpenURL:completionHandler:)` does not archive when the user cancels
/// the confirmation alert.
@MainActor
func test_archive_cancel() async throws {
var completionCalled = false
let cipher = CipherView.loginFixture(id: "123")
vaultRepository.doesActiveAccountHavePremiumResult = true
vaultRepository.archiveCipherResult = .success(())
await subject.archive(
cipher: cipher,
handleOpenURL: { _ in },
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToArchiveThisItem)
try await alert?.tapCancel()
XCTAssertTrue(vaultRepository.archiveCipher.isEmpty)
XCTAssertFalse(completionCalled)
}
/// `unarchive(cipher:completionHandler:)` shows the confirmation alert and unarchives
/// the cipher when the user confirms.
@MainActor
@ -174,13 +139,7 @@ class VaultItemActionHelperTests: BitwardenTestCase {
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
XCTAssertNil(alert?.message)
try await alert?.tapAction(title: Localizations.yes)
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.unarchiving)
XCTAssertEqual(coordinator.loadingOverlaysShown.last?.title, Localizations.movingItemToVault)
XCTAssertEqual(vaultRepository.unarchiveCipher.last?.id, "123")
XCTAssertTrue(completionCalled)
@ -200,36 +159,8 @@ class VaultItemActionHelperTests: BitwardenTestCase {
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
try await alert?.tapAction(title: Localizations.yes)
XCTAssertEqual(coordinator.errorAlertsShown.count, 1)
XCTAssertEqual(errorReporter.errors as? [BitwardenTestError], [.example])
XCTAssertFalse(completionCalled)
}
/// `unarchive(cipher:completionHandler:)` does not unarchive when the user cancels
/// the confirmation alert.
@MainActor
func test_unarchive_cancel() async throws {
var completionCalled = false
let cipher = CipherView.loginFixture(archivedDate: .now, id: "123")
vaultRepository.unarchiveCipherResult = .success(())
await subject.unarchive(
cipher: cipher,
completionHandler: { completionCalled = true },
)
let alert = coordinator.alertShown.last
XCTAssertEqual(alert?.title, Localizations.doYouReallyWantToUnarchiveThisItem)
try await alert?.tapCancel()
XCTAssertTrue(vaultRepository.unarchiveCipher.isEmpty)
XCTAssertFalse(completionCalled)
}
}