Skip to content

Commit 9687d45

Browse files
committed
Merge branch 'trunk' into issue/5616-setup-path
2 parents 37c4657 + 11bf2bd commit 9687d45

33 files changed

+2320
-598
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
8.4
44
-----
55
- [***] In-Person Payments: Support for Stripe M2 card reader. [https://github.com/woocommerce/woocommerce-ios/pull/5844]
6-
6+
- [*] Add/Edit Product screen: Fix transient product name while adding images.[https://github.com/woocommerce/woocommerce-ios/pull/5840]
77

88
8.3
99
-----

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ private extension ProductFormViewController {
492492
}
493493

494494
/// Observe product name changes and re-render the product if the change happened outside this screen.
495+
///
496+
/// This method covers the following case:
497+
/// 1. User changes the product name locally
498+
/// 2. User creates an attribute or a variation (This updates the whole product, overriding the unsaved product name)
499+
/// 3. ViewModel detects that there was a pending name change and fires an event to the name observable
500+
/// 4. View re-renders un-saved product name and updates the save button state.
501+
///
495502
/// The "happened outside" condition is needed to not reload the view while the user is typing a new name.
496503
///
497504
func observeProductName() {
@@ -511,7 +518,7 @@ private extension ProductFormViewController {
511518
}
512519

513520
/// Updates table rows when the price of the underlying variations change.
514-
/// Needed to show/hide the `.noPrinceWarning` row.
521+
/// Needed to show/hide the `.noPriceWarning` row.
515522
///
516523
func observeVariationsPriceChanges() {
517524
cancellableNewVariationsPrice = viewModel.newVariationsPrice.subscribe { [weak self] in
@@ -528,6 +535,30 @@ private extension ProductFormViewController {
528535
}
529536

530537
func onImageStatusesUpdated(statuses: [ProductImageStatus]) {
538+
///
539+
/// Why are we recreating the `tableViewModel`?
540+
///
541+
/// When the user types and changes the product name, the `product` will change.
542+
/// But, we are NOT recreating `tableViewModel` and reloading the `tableView`
543+
/// to avoid reloading the cell while the user is still typing.
544+
///
545+
/// The above scenario results in `tableViewModel` and `product` getting out of sync.
546+
/// i.e. `product` has name changed in it, but `tableViewModel` doesn’t reflect the "changed name".
547+
///
548+
/// Now, if the user tries to add/edit images before saving the product name `onImageStatusesUpdated` is fired.
549+
///
550+
/// If `onImageStatusesUpdated` calls `reconfigureDataSource` without recreating `tableViewModel`
551+
/// we end up showing old `product` information (old name in this case) in the `tableView`.
552+
///
553+
/// By recreating `tableViewModel` using the latest `product` before calling `reconfigureDataSource`,
554+
/// we are making sure that we are not showing outdated `product` information in `tableView`.
555+
///
556+
/// Note that the new name information isn’t lost. It lives inside `product`.
557+
/// If we recreate `tableViewModel` and reload using `reconfigureDataSource` we will have the new product name displayed in `tableView`.
558+
///
559+
tableViewModel = DefaultProductFormTableViewModel(product: product,
560+
actionsFactory: viewModel.actionsFactory,
561+
currency: currency)
531562
reconfigureDataSource(tableViewModel: tableViewModel, statuses: statuses)
532563
}
533564

WooCommerce/UITestsFoundation/Screens/TabNavComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class TabNavComponent: ScreenObject {
3737
}
3838

3939
@discardableResult
40-
func goToMyStoreScreen() throws -> MyStoreScreen {
40+
public func goToMyStoreScreen() throws -> MyStoreScreen {
4141
// Avoid transitioning if it is already on screen
4242
if MyStoreScreen.isVisible == false {
4343
myStoreTabButton.tap()

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 80 additions & 52 deletions
Large diffs are not rendered by default.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"request": {
3+
"method": "GET",
4+
"urlPathPattern": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
5+
"queryParameters": {
6+
"json": {
7+
"equalTo": "true"
8+
},
9+
"path": {
10+
"matches": "/wc-analytics/leaderboards(.*)"
11+
},
12+
"query": {
13+
"matches": "(.*)interval\":\"day(.*)"
14+
}
15+
}
16+
},
17+
"response": {
18+
"status": 200,
19+
"jsonBody": {
20+
"data": [{
21+
"id": "customers",
22+
"label": "Top Customers - Total Spend",
23+
"headers": [{
24+
"label": "Customer Name"
25+
}, {
26+
"label": "Orders"
27+
}, {
28+
"label": "Total Spend"
29+
}],
30+
"rows": [
31+
[{
32+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=36'>Mira Workman<\/a>",
33+
"value": "Mira Workman"
34+
}, {
35+
"display": "1",
36+
"value": 1
37+
}, {
38+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>1,310.00<\/bdi><\/span>",
39+
"value": 1310
40+
}],
41+
[{
42+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=35'>Jack Smith<\/a>",
43+
"value": "Jack Smith"
44+
}, {
45+
"display": "1",
46+
"value": 1
47+
}, {
48+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>700.00<\/bdi><\/span>",
49+
"value": 700
50+
}],
51+
[{
52+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=29'> <\/a>",
53+
"value": " "
54+
}, {
55+
"display": "1",
56+
"value": 1
57+
}, {
58+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>450.00<\/bdi><\/span>",
59+
"value": 450
60+
}]
61+
]
62+
}, {
63+
"id": "coupons",
64+
"label": "Top Coupons - Number of Orders",
65+
"headers": [{
66+
"label": "Coupon Code"
67+
}, {
68+
"label": "Orders"
69+
}, {
70+
"label": "Amount Discounted"
71+
}],
72+
"rows": []
73+
}, {
74+
"id": "categories",
75+
"label": "Top Categories - Items Sold",
76+
"headers": [{
77+
"label": "Category"
78+
}, {
79+
"label": "Items Sold"
80+
}, {
81+
"label": "Net Sales"
82+
}],
83+
"rows": []
84+
}, {
85+
"id": "products",
86+
"label": "Top Products - Items Sold",
87+
"headers": [{
88+
"label": "Product"
89+
}, {
90+
"label": "Items Sold"
91+
}, {
92+
"label": "Net Sales"
93+
}],
94+
"rows": [
95+
[{
96+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2130'>Black Coral shades<\/a>",
97+
"value": "Black Coral shades"
98+
}, {
99+
"display": "1",
100+
"value": 1
101+
}, {
102+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>2,550.00<\/bdi><\/span>",
103+
"value": 250
104+
}],
105+
[{
106+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2123'>Malaya shades<\/a>",
107+
"value": "Malaya shades"
108+
}, {
109+
"display": "2",
110+
"value": 2
111+
}, {
112+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>1,540.00<\/bdi><\/span>",
113+
"value": 540
114+
}],
115+
[{
116+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2131'>Colorado shades<\/a>",
117+
"value": "Colorado shades"
118+
}, {
119+
"display": "1",
120+
"value": 1
121+
}, {
122+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>500.00<\/bdi><\/span>",
123+
"value": 500
124+
}]
125+
]
126+
}]
127+
},
128+
"headers": {
129+
"Content-Type": "application/json",
130+
"Connection": "keep-alive"
131+
}
132+
}
133+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"request": {
3+
"method": "GET",
4+
"urlPathPattern": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
5+
"queryParameters": {
6+
"json": {
7+
"equalTo": "true"
8+
},
9+
"path": {
10+
"matches": "/wc-analytics/leaderboards(.*)"
11+
},
12+
"query": {
13+
"matches": "(.*)interval\":\"month(.*)"
14+
}
15+
}
16+
},
17+
"response": {
18+
"status": 200,
19+
"jsonBody": {
20+
"data": [{
21+
"id": "customers",
22+
"label": "Top Customers - Total Spend",
23+
"headers": [{
24+
"label": "Customer Name"
25+
}, {
26+
"label": "Orders"
27+
}, {
28+
"label": "Total Spend"
29+
}],
30+
"rows": [
31+
[{
32+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=36'>Mira Workman<\/a>",
33+
"value": "Mira Workman"
34+
}, {
35+
"display": "1",
36+
"value": 1
37+
}, {
38+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>1,310.00<\/bdi><\/span>",
39+
"value": 1310
40+
}],
41+
[{
42+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=35'>Jack Smith<\/a>",
43+
"value": "Jack Smith"
44+
}, {
45+
"display": "1",
46+
"value": 1
47+
}, {
48+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>700.00<\/bdi><\/span>",
49+
"value": 700
50+
}],
51+
[{
52+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/customers&filter=single_customer&customers=29'> <\/a>",
53+
"value": " "
54+
}, {
55+
"display": "1",
56+
"value": 1
57+
}, {
58+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>450.00<\/bdi><\/span>",
59+
"value": 450
60+
}]
61+
]
62+
}, {
63+
"id": "coupons",
64+
"label": "Top Coupons - Number of Orders",
65+
"headers": [{
66+
"label": "Coupon Code"
67+
}, {
68+
"label": "Orders"
69+
}, {
70+
"label": "Amount Discounted"
71+
}],
72+
"rows": []
73+
}, {
74+
"id": "categories",
75+
"label": "Top Categories - Items Sold",
76+
"headers": [{
77+
"label": "Category"
78+
}, {
79+
"label": "Items Sold"
80+
}, {
81+
"label": "Net Sales"
82+
}],
83+
"rows": []
84+
}, {
85+
"id": "products",
86+
"label": "Top Products - Items Sold",
87+
"headers": [{
88+
"label": "Product"
89+
}, {
90+
"label": "Items Sold"
91+
}, {
92+
"label": "Net Sales"
93+
}],
94+
"rows": [
95+
[{
96+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2130'>Black Coral shades<\/a>",
97+
"value": "Black Coral shades"
98+
}, {
99+
"display": "17",
100+
"value": 17
101+
}, {
102+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>2,550.00<\/bdi><\/span>",
103+
"value": 2550
104+
}],
105+
[{
106+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2123'>Malaya shades<\/a>",
107+
"value": "Malaya shades"
108+
}, {
109+
"display": "11",
110+
"value": 11
111+
}, {
112+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>1,540.00<\/bdi><\/span>",
113+
"value": 1540
114+
}],
115+
[{
116+
"display": "<a href='https:\/\/automatticwidgets.com\/wp-admin\/admin.php?page=wc-admin&path=\/analytics\/products&filter=single_product&products=2131'>Colorado shades<\/a>",
117+
"value": "Colorado shades"
118+
}, {
119+
"display": "5",
120+
"value": 5
121+
}, {
122+
"display": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>500.00<\/bdi><\/span>",
123+
"value": 500
124+
}]
125+
]
126+
}]
127+
},
128+
"headers": {
129+
"Content-Type": "application/json",
130+
"Connection": "keep-alive"
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)