-
Notifications
You must be signed in to change notification settings - Fork 117
Fix: Users Unable to Upload Product Images if the store is private #12824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Users Unable to Upload Product Images if the store is private #12824
Conversation
…formation to products
…ally using SFSafariViewController. - Updated ProductFormTableViewDataSource to handle image configuration based on store visibility and editability.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @pmusolino! This test didn't pass for me:
In wp-admin set the site to Coming soon mode in the Settings
In the app, switch to a different site and switch back (or re-login, or close and reopen the app)
Go to Products -> Tap on some product
Verify the images are available (either existing images or button to add one)
/// Returns true only if the site is hosted on WP.com and is private. | ||
/// | ||
var isPrivateWPCOMSite: Bool { | ||
return isWordPressComStore && !isPublic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic includes only public sites. Is it possible to access images for sites with Coming soon status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not expected, unfortunately. As you can see here C06NC969ZF0/p1715793466695389?thread_ts=1715193928.110329&cid=C06NC969ZF0 I was expecting that parsing blog_public
limiting it to Atomic websites return private = true
only if the store is private
and not coming soon
or public
.
It seems btw that the app parse isPublic
alias blog_public
as a boolean, while it's an integer. From my tests, the values should be private = -1
, coming soon = 0
, public = 1
. When it's -1
, it's automatically false
, that's why it works as expected. When it's coming soon, it's also false (0), and that's why you see the banner.
I'm going to address this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmeichigo this is ready for another review!
Here are all the changes: a91a6fc
Below is the list of changes:
- I removed the
isPublic
property from theSite
model, which has been replaced withvisibility
, a property of typeSiteVisibility
.SiteVisibility
is an enum that contains the valuesprivate = -1
,coming soon = 0
,public = 1
. - Following the above change, I created a new Core Data model (version 112). As there is a data migration involved from the old Boolean value to the new Int64 in the database, there is also a new mapping model that converts the old Boolean value from model version 111 to the new Int64 in model version 112.
- I updated all the code to use the new
visibility
property.
WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormTableViewDataSource.swift
Outdated
Show resolved
Hide resolved
...erce/Classes/ViewRelated/Products/Edit Product/Cells/ImageAndTitleAndTextTableViewCell.swift
Show resolved
Hide resolved
WooCommerce/Classes/ViewRelated/Products/Edit Product/DefaultProductFormTableViewModel.swift
Outdated
Show resolved
Hide resolved
…Images-on-iOS-App-if-the-store-is-private
…646-Users-Unable-to-Upload-Product-Images-on-iOS-App-if-the-store-is-private
… from Bool to int enum `SiteVisibility` + DB migration
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found issues with self-hosted sites when checking their visibility to display the Share option for products and Test order on the Orders tab, so I pushed a commit to fix that.
Although this works as described now, I'm not confident I didn't miss any edge cases. There aren't any migration tests for the migration from Core Data model version V111 to 112, and it's quite close to the code freeze, it's safer to delay the merge until the next version.
@@ -49,7 +49,7 @@ final class OrderListViewModel { | |||
} | |||
|
|||
/// Enabled if site is launched, has published at least 1 product and set up payments. | |||
return site.isPublic && hasAnyPaymentGateways && hasAnyPublishedProducts | |||
return (site.visibility == .publicSite) && hasAnyPaymentGateways && hasAnyPublishedProducts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails for self-hosted sites because you were setting the default visibility for them as .comingSoon
. I pushed a change in 44036af to make them public by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely an error that existed previously since the WordPressSite had the isPublic
property set to false
, which was equivalent to comingSoon
. Therefore, with the configuration I had in place, there should not have been any difference in behavior.
Added the test for the migration from Core Data model version V111 to 112 408181a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the migration test Paolo!
…Images-on-iOS-App-if-the-store-is-private
Closes: #12646
Description
The PR adds a notice in Product detail when a WP.com site is in Private mode since this makes the images not accessible.
This happens just on WP.com sites, since on self-hosted store it's not possible to put a store in the "private" state.
This has been already fixed here woocommerce/woocommerce-android#11383 and here woocommerce/woocommerce-android#11493 on Android.
Detail implementation
I decided to use a custom table view cell inside the image section instead of showing it as a banner, because it can happen to have another banner already displayed while the user is editing a product (or it can appear later). In this way, this notice in product images is always displayed when the store is private.
Testing instructions
Test 1
Public
wp-admin
set the site toPrivate
mode in Settings (more info here)wp-admin
set the site toComing soon
mode in the SettingsTest 2
Screenshots
RELEASE-NOTES.txt
if necessary.