Skip to content

Commit a163598

Browse files
authored
Merge pull request #8179 from woocommerce/feat/8178-account-deletion-for-all
Support account deletion for SIWA and with store creation features enabled
2 parents 976af81 + 028a36a commit a163598

File tree

10 files changed

+70
-66
lines changed

10 files changed

+70
-66
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
11.5
44
-----
5-
5+
- [*] Account deletion is now supported for all users in settings or in the empty stores screen. [https://github.com/woocommerce/woocommerce-ios/pull/8179]
66

77
11.4
88
-----

WooCommerce/Classes/Authentication/Epilogue/EmptyStoresTableViewCell.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ final class EmptyStoresTableViewCell: UITableViewCell {
2828

2929
@IBOutlet private weak var stackView: UIStackView!
3030
@IBOutlet private weak var emptyStoresImageView: UIImageView!
31-
@IBOutlet private weak var removeAppleIDAccessButton: UIButton!
31+
@IBOutlet private weak var closeAccountButton: UIButton!
3232

3333
override func awakeFromNib() {
3434
super.awakeFromNib()
3535

3636
configureStackView()
3737
configureImageView()
38-
configureRemoveAppleIDAccessButton()
39-
updateRemoveAppleIDAccessButtonVisibility(isVisible: false)
38+
configureCloseAccountButton()
39+
updateCloseAccountButtonVisibility(isVisible: false)
4040
}
4141

42-
func updateRemoveAppleIDAccessButtonVisibility(isVisible: Bool) {
43-
removeAppleIDAccessButton.isHidden = !isVisible
42+
func updateCloseAccountButtonVisibility(isVisible: Bool) {
43+
closeAccountButton.isHidden = !isVisible
4444
}
4545
}
4646

@@ -57,10 +57,10 @@ private extension EmptyStoresTableViewCell {
5757
emptyStoresImageView.image = .emptyStorePickerImage
5858
}
5959

60-
func configureRemoveAppleIDAccessButton() {
61-
removeAppleIDAccessButton.applyLinkButtonStyle()
62-
removeAppleIDAccessButton.setTitle(Localization.closeAccountTitle, for: .normal)
63-
removeAppleIDAccessButton.on(.touchUpInside) { [weak self] _ in
60+
func configureCloseAccountButton() {
61+
closeAccountButton.applyLinkButtonStyle()
62+
closeAccountButton.setTitle(Localization.closeAccountTitle, for: .normal)
63+
closeAccountButton.on(.touchUpInside) { [weak self] _ in
6464
self?.onCloseAccountButtonTapped?()
6565
}
6666
}

WooCommerce/Classes/Authentication/Epilogue/EmptyStoresTableViewCell.xib

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait" appearance="light"/>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
43
<dependencies>
5-
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
75
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
86
</dependencies>
97
<objects>
@@ -57,9 +55,9 @@
5755
</tableViewCellContentView>
5856
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5957
<connections>
58+
<outlet property="closeAccountButton" destination="XF9-r3-Vq9" id="sLP-Jl-0hK"/>
6059
<outlet property="emptyStoresImageView" destination="uuh-xp-DA5" id="4yf-Rz-3c2"/>
6160
<outlet property="legendLabel" destination="bPV-bJ-GBz" id="sQX-ir-ghQ"/>
62-
<outlet property="removeAppleIDAccessButton" destination="XF9-r3-Vq9" id="sLP-Jl-0hK"/>
6361
<outlet property="stackView" destination="pky-np-rBc" id="vRx-dY-Ma9"/>
6462
<outlet property="subtitleLabel" destination="Oil-C8-RKM" id="9VO-5Z-BNb"/>
6563
</connections>

WooCommerce/Classes/Authentication/Epilogue/StorePickerViewController.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ final class StorePickerViewController: UIViewController {
155155
}
156156
}
157157

158-
private lazy var removeAppleIDAccessCoordinator: RemoveAppleIDAccessCoordinator =
159-
RemoveAppleIDAccessCoordinator(sourceViewController: self) { [weak self] in
160-
guard let self = self else { throw RemoveAppleIDAccessError.presenterDeallocated }
161-
return try await self.removeAppleIDAccess()
158+
private lazy var closeAccountCoordinator: CloseAccountCoordinator =
159+
CloseAccountCoordinator(sourceViewController: self) { [weak self] in
160+
guard let self = self else { throw CloseAccountError.presenterDeallocated }
161+
return try await self.closeAccount()
162162
} onRemoveSuccess: { [weak self] in
163163
self?.restartAuthentication()
164164
}
@@ -698,13 +698,15 @@ extension StorePickerViewController: UITableViewDataSource {
698698
guard let site = viewModel.site(at: indexPath) else {
699699
hideActionButton()
700700
let cell = tableView.dequeueReusableCell(EmptyStoresTableViewCell.self, for: indexPath)
701-
let isRemoveAppleIDAccessButtonVisible = appleIDCredentialChecker.hasAppleUserID()
702-
cell.updateRemoveAppleIDAccessButtonVisibility(isVisible: isRemoveAppleIDAccessButtonVisible)
703-
if isRemoveAppleIDAccessButtonVisible {
701+
let isCloseAccountButtonVisible = appleIDCredentialChecker.hasAppleUserID()
702+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
703+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2)
704+
cell.updateCloseAccountButtonVisibility(isVisible: isCloseAccountButtonVisible)
705+
if isCloseAccountButtonVisible {
704706
cell.onCloseAccountButtonTapped = { [weak self] in
705707
guard let self = self else { return }
706708
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .emptyStores))
707-
self.removeAppleIDAccessCoordinator.start()
709+
self.closeAccountCoordinator.start()
708710
}
709711
}
710712
return cell
@@ -777,7 +779,7 @@ extension StorePickerViewController: UITableViewDelegate {
777779
}
778780

779781
private extension StorePickerViewController {
780-
func removeAppleIDAccess() async throws {
782+
func closeAccount() async throws {
781783
try await withCheckedThrowingContinuation { [weak self] continuation in
782784
guard let self = self else { return }
783785
let action = AccountAction.closeAccount { result in
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import UIKit
22
import protocol Yosemite.StoresManager
33

4-
/// Coordinates navigation for removing Apple ID access from various entry points (settings and empty stores screens).
5-
@MainActor final class RemoveAppleIDAccessCoordinator {
4+
/// Coordinates navigation for closing a WPCOM account from various entry points (settings and empty stores screens).
5+
@MainActor final class CloseAccountCoordinator {
66
private let sourceViewController: UIViewController
77
private let removeAction: () async throws -> Void
88
private let onRemoveSuccess: () -> Void
@@ -30,7 +30,7 @@ import protocol Yosemite.StoresManager
3030
}
3131
}
3232

33-
private extension RemoveAppleIDAccessCoordinator {
33+
private extension CloseAccountCoordinator {
3434
func presentConfirmationAlert() {
3535
// TODO: 7068 - analytics
3636

@@ -86,7 +86,7 @@ private extension RemoveAppleIDAccessCoordinator {
8686
}
8787

8888
func presentInProgressUI() {
89-
let viewProperties = InProgressViewProperties(title: Localization.RemoveAppleIDAccessInProgressView.title, message: "")
89+
let viewProperties = InProgressViewProperties(title: Localization.InProgressView.title, message: "")
9090
let inProgressViewController = InProgressViewController(viewProperties: viewProperties)
9191
inProgressViewController.modalPresentationStyle = .overFullScreen
9292
sourceViewController.present(inProgressViewController, animated: true)
@@ -140,9 +140,9 @@ private extension RemoveAppleIDAccessCoordinator {
140140
}
141141
}
142142

143-
private extension RemoveAppleIDAccessCoordinator {
143+
private extension CloseAccountCoordinator {
144144
enum Localization {
145-
enum RemoveAppleIDAccessInProgressView {
145+
enum InProgressView {
146146
static let title = NSLocalizedString(
147147
"Closing account...",
148148
comment: "Title of the Close Account in-progress view."
@@ -186,12 +186,12 @@ private extension RemoveAppleIDAccessCoordinator {
186186
}
187187
}
188188

189-
private extension RemoveAppleIDAccessCoordinator {
189+
private extension CloseAccountCoordinator {
190190
enum Constants {
191191
static let dotcomAPIErrorCodeKey = "WordPressComRestApiErrorCodeKey"
192192
}
193193
}
194194

195-
enum RemoveAppleIDAccessError: Error {
195+
enum CloseAccountError: Error {
196196
case presenterDeallocated
197197
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewController.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ final class SettingsViewController: UIViewController {
2929
///
3030
private var storePickerCoordinator: StorePickerCoordinator?
3131

32-
private lazy var removeAppleIDAccessCoordinator: RemoveAppleIDAccessCoordinator =
33-
RemoveAppleIDAccessCoordinator(sourceViewController: self) { [weak self] in
34-
guard let self = self else { throw RemoveAppleIDAccessError.presenterDeallocated }
35-
try await self.removeAppleIDAccess()
32+
private lazy var closeAccountCoordinator: CloseAccountCoordinator =
33+
CloseAccountCoordinator(sourceViewController: self) { [weak self] in
34+
guard let self = self else { throw CloseAccountError.presenterDeallocated }
35+
try await self.closeAccount()
3636
} onRemoveSuccess: { [weak self] in
3737
self?.logOutUser()
3838
}
@@ -154,8 +154,8 @@ private extension SettingsViewController {
154154
configureAppSettings(cell: cell)
155155
case let cell as BasicTableViewCell where row == .wormholy:
156156
configureWormholy(cell: cell)
157-
case let cell as BasicTableViewCell where row == .removeAppleIDAccess:
158-
configureRemoveAppleIDAccess(cell: cell)
157+
case let cell as BasicTableViewCell where row == .closeAccount:
158+
configureCloseAccount(cell: cell)
159159
case let cell as BasicTableViewCell where row == .logout:
160160
configureLogout(cell: cell)
161161
default:
@@ -249,7 +249,7 @@ private extension SettingsViewController {
249249
cell.textLabel?.text = Localization.whatsNew
250250
}
251251

252-
func configureRemoveAppleIDAccess(cell: BasicTableViewCell) {
252+
func configureCloseAccount(cell: BasicTableViewCell) {
253253
cell.selectionStyle = .default
254254
cell.textLabel?.textAlignment = .center
255255
cell.textLabel?.textColor = .error
@@ -279,12 +279,12 @@ private extension SettingsViewController {
279279
// MARK: - Actions
280280
//
281281
private extension SettingsViewController {
282-
func removeAppleIDAccessWasPressed() {
282+
func closeAccountWasPressed() {
283283
ServiceLocator.analytics.track(event: .closeAccountTapped(source: .settings))
284-
removeAppleIDAccessCoordinator.start()
284+
closeAccountCoordinator.start()
285285
}
286286

287-
func removeAppleIDAccess() async throws {
287+
func closeAccount() async throws {
288288
try await withCheckedThrowingContinuation { [weak self] continuation in
289289
guard let self = self else { return }
290290
let action = AccountAction.closeAccount { result in
@@ -542,8 +542,8 @@ extension SettingsViewController: UITableViewDelegate {
542542
wormholyWasPressed()
543543
case .whatsNew:
544544
whatsNewWasPressed()
545-
case .removeAppleIDAccess:
546-
removeAppleIDAccessWasPressed()
545+
case .closeAccount:
546+
closeAccountWasPressed()
547547
case .logout:
548548
logoutWasPressed()
549549
default:
@@ -621,7 +621,7 @@ extension SettingsViewController {
621621
case wormholy
622622

623623
// Account deletion
624-
case removeAppleIDAccess
624+
case closeAccount
625625

626626
// Logout
627627
case logout
@@ -651,7 +651,7 @@ extension SettingsViewController {
651651
return HostingTableViewCell<FeatureAnnouncementCardView>.self
652652
case .installJetpack:
653653
return BasicTableViewCell.self
654-
case .logout, .removeAppleIDAccess:
654+
case .logout, .closeAccount:
655655
return BasicTableViewCell.self
656656
case .privacy:
657657
return BasicTableViewCell.self

WooCommerce/Classes/ViewRelated/Dashboard/Settings/Settings/SettingsViewModel.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,15 @@ private extension SettingsViewModel {
286286
footerHeight: CGFloat.leastNonzeroMagnitude)
287287
}()
288288

289-
// Remove Apple ID Access
290-
let removeAppleIDAccessSection: Section? = {
291-
guard appleIDCredentialChecker.hasAppleUserID() else {
289+
// Close account
290+
let closeAccountSection: Section? = {
291+
guard appleIDCredentialChecker.hasAppleUserID()
292+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationMVP)
293+
|| featureFlagService.isFeatureFlagEnabled(.storeCreationM2) else {
292294
return nil
293295
}
294296
return Section(title: nil,
295-
rows: [.removeAppleIDAccess],
297+
rows: [.closeAccount],
296298
footerHeight: CGFloat.leastNonzeroMagnitude)
297299
}()
298300

@@ -308,7 +310,7 @@ private extension SettingsViewModel {
308310
appSettingsSection,
309311
aboutTheAppSection,
310312
otherSection,
311-
removeAppleIDAccessSection,
313+
closeAccountSection,
312314
logoutSection
313315
]
314316
.compactMap { $0 }

0 commit comments

Comments
 (0)