Skip to content

Commit 2ebe274

Browse files
committed
Remove checks for order creation experimental toggle
1 parent 3ba78bf commit 2ebe274

File tree

3 files changed

+10
-66
lines changed

3 files changed

+10
-66
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/FlowCoordinator/AddOrderCoordinator.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ final class AddOrderCoordinator: Coordinator {
66
var navigationController: UINavigationController
77

88
private let siteID: Int64
9-
private let isOrderCreationEnabled: Bool
109
private let sourceBarButtonItem: UIBarButtonItem?
1110
private let sourceView: UIView?
1211

@@ -15,22 +14,18 @@ final class AddOrderCoordinator: Coordinator {
1514
var onOrderCreated: (Order) -> Void = { _ in }
1615

1716
init(siteID: Int64,
18-
isOrderCreationEnabled: Bool,
1917
sourceBarButtonItem: UIBarButtonItem,
2018
sourceNavigationController: UINavigationController) {
2119
self.siteID = siteID
22-
self.isOrderCreationEnabled = isOrderCreationEnabled
2320
self.sourceBarButtonItem = sourceBarButtonItem
2421
self.sourceView = nil
2522
self.navigationController = sourceNavigationController
2623
}
2724

2825
init(siteID: Int64,
29-
isOrderCreationEnabled: Bool,
3026
sourceView: UIView,
3127
sourceNavigationController: UINavigationController) {
3228
self.siteID = siteID
33-
self.isOrderCreationEnabled = isOrderCreationEnabled
3429
self.sourceBarButtonItem = nil
3530
self.sourceView = sourceView
3631
self.navigationController = sourceNavigationController
@@ -41,11 +36,7 @@ final class AddOrderCoordinator: Coordinator {
4136
}
4237

4338
func start() {
44-
if isOrderCreationEnabled {
45-
presentOrderTypeBottomSheet()
46-
} else {
47-
presentOrderCreationFlow(bottomSheetOrderType: .simple)
48-
}
39+
presentOrderTypeBottomSheet()
4940
}
5041
}
5142

WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ final class OrdersRootViewController: UIViewController {
5454
}
5555
}
5656

57-
/// Stores status for order creation availability.
58-
///
59-
private var isOrderCreationEnabled: Bool = false
60-
6157
private let storageManager: StorageManagerType
6258

6359
/// Used for looking up the `OrderStatus` to show in the `Order Filters`.
@@ -97,6 +93,7 @@ final class OrdersRootViewController: UIViewController {
9793
super.viewDidLoad()
9894
configureTitle()
9995
configureView()
96+
configureNavigationButtons()
10097
configureFiltersBar()
10198
configureChildViewController()
10299

@@ -112,9 +109,6 @@ final class OrdersRootViewController: UIViewController {
112109
override func viewWillAppear(_ animated: Bool) {
113110
super.viewWillAppear(animated)
114111

115-
// Needed in ViewWillAppear because this View Controller is never recreated.
116-
fetchExperimentalTogglesAndConfigureNavigationButtons()
117-
118112
ServiceLocator.pushNotesManager.resetBadgeCount(type: .storeOrder)
119113
}
120114

@@ -207,9 +201,9 @@ private extension OrdersRootViewController {
207201
/// Search: Is always present.
208202
/// Add: Always present.
209203
///
210-
func configureNavigationButtons(isOrderCreationExperimentalToggleEnabled: Bool) {
204+
func configureNavigationButtons() {
211205
let buttons: [UIBarButtonItem] = [
212-
createAddOrderItem(isOrderCreationEnabled: isOrderCreationExperimentalToggleEnabled),
206+
createAddOrderItem(),
213207
createSearchBarButtonItem()
214208
]
215209
navigationItem.rightBarButtonItems = buttons
@@ -244,24 +238,6 @@ private extension OrdersRootViewController {
244238
ordersViewController.didMove(toParent: self)
245239
}
246240

247-
/// Fetches the latest values of order-related experimental feature toggles and re configures navigation buttons.
248-
///
249-
func fetchExperimentalTogglesAndConfigureNavigationButtons() {
250-
let group = DispatchGroup()
251-
var isOrderCreationEnabled = false
252-
253-
group.enter()
254-
let orderCreationAction = AppSettingsAction.loadOrderCreationSwitchState { result in
255-
isOrderCreationEnabled = (try? result.get()) ?? false
256-
group.leave()
257-
}
258-
ServiceLocator.stores.dispatch(orderCreationAction)
259-
260-
group.notify(queue: .main) { [weak self] in
261-
self?.configureNavigationButtons(isOrderCreationExperimentalToggleEnabled: isOrderCreationEnabled)
262-
}
263-
}
264-
265241
/// Connect hooks on `ResultsController` and query cached data.
266242
/// This is useful for stay up to date with the remote statuses, resetting the filters if one of the local status filters was deleted remotely.
267243
///
@@ -354,22 +330,14 @@ private extension OrdersRootViewController {
354330

355331
/// Create a `UIBarButtonItem` to be used as a way to create a new order.
356332
///
357-
func createAddOrderItem(isOrderCreationEnabled: Bool) -> UIBarButtonItem {
358-
self.isOrderCreationEnabled = isOrderCreationEnabled
359-
333+
func createAddOrderItem() -> UIBarButtonItem {
360334
let button = UIBarButtonItem(image: .plusBarButtonItemImage,
361335
style: .plain,
362336
target: self,
363337
action: #selector(presentOrderCreationFlow(sender:)))
364338
button.accessibilityTraits = .button
365-
366-
if isOrderCreationEnabled {
367-
button.accessibilityLabel = NSLocalizedString("Choose new order type", comment: "Opens action sheet to choose a type of a new order")
368-
button.accessibilityIdentifier = "new-order-type-sheet-button"
369-
} else {
370-
button.accessibilityLabel = NSLocalizedString("Add simple payments order", comment: "Navigates to a screen to create a simple payments order")
371-
button.accessibilityIdentifier = "simple-payments-add-button"
372-
}
339+
button.accessibilityLabel = NSLocalizedString("Choose new order type", comment: "Opens action sheet to choose a type of a new order")
340+
button.accessibilityIdentifier = "new-order-type-sheet-button"
373341
return button
374342
}
375343

@@ -381,7 +349,6 @@ private extension OrdersRootViewController {
381349
}
382350

383351
let coordinatingController = AddOrderCoordinator(siteID: siteID,
384-
isOrderCreationEnabled: isOrderCreationEnabled,
385352
sourceBarButtonItem: sender,
386353
sourceNavigationController: navigationController)
387354
coordinatingController.onOrderCreated = { [weak self] order in

WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Creation/AddOrderCoordinatorTests.swift

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ final class AddOrderCoordinatorTests: XCTestCase {
3030
super.tearDown()
3131
}
3232

33-
func test_it_presents_bottom_sheet_when_all_types_are_available() throws {
33+
func test_it_presents_bottom_sheet_on_start() throws {
3434
// Given
35-
let coordinator = makeAddProductCoordinator(isOrderCreationEnabled: true)
35+
let coordinator = makeAddProductCoordinator()
3636

3737
// When
3838
coordinator.start()
@@ -43,26 +43,12 @@ final class AddOrderCoordinatorTests: XCTestCase {
4343
// Then
4444
assertThat(coordinator.navigationController.presentedViewController, isAnInstanceOf: BottomSheetViewController.self)
4545
}
46-
47-
func test_it_opens_simple_payments_when_its_only_available_type() throws {
48-
// Given
49-
let coordinator = makeAddProductCoordinator(isOrderCreationEnabled: false)
50-
51-
// When
52-
coordinator.start()
53-
54-
// Then
55-
let presentedNC = coordinator.navigationController.presentedViewController as? UINavigationController
56-
assertThat(presentedNC, isAnInstanceOf: WooNavigationController.self)
57-
assertThat(presentedNC?.topViewController, isAnInstanceOf: SimplePaymentsAmountHostingController.self)
58-
}
5946
}
6047

6148
private extension AddOrderCoordinatorTests {
62-
func makeAddProductCoordinator(isOrderCreationEnabled: Bool) -> AddOrderCoordinator {
49+
func makeAddProductCoordinator() -> AddOrderCoordinator {
6350
let sourceView = UIView()
6451
return AddOrderCoordinator(siteID: 100,
65-
isOrderCreationEnabled: isOrderCreationEnabled,
6652
sourceView: sourceView,
6753
sourceNavigationController: navigationController)
6854
}

0 commit comments

Comments
 (0)