Skip to content

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

Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
95f7966
fix: spaces in ProductFormTableViewDataSource
pmusolino May 20, 2024
07c0544
fix: space ProductFormTableViewDataSource
pmusolino May 20, 2024
c0d2eb5
feat: introduced dynamic variable isPrivateWPCOMSite in `Site` model
pmusolino May 20, 2024
8ba173c
feat: logic to understand is a wpcom store is private, passing the in…
pmusolino May 21, 2024
fd046bf
feat: added titleTintColor into ImageAndTitleAndTextTableViewCell
pmusolino May 23, 2024
5b059b4
- Introduced the presentURL(_:) method to handle URL presentation mod…
pmusolino May 23, 2024
54649ae
update: ProductFormActionsFactoryTests
pmusolino May 23, 2024
cf953f6
update: tests for `isStorePublic`
pmusolino May 23, 2024
6577162
update: ProductFormActionsFactory_ReadonlyProductTests
pmusolino May 23, 2024
e631fd7
fix: line lenght
pmusolino May 23, 2024
5fa6f8d
feat: tests clean up
pmusolino May 23, 2024
059db02
fix: lines should be 163 characters or less
pmusolino May 24, 2024
60a6927
update: RELEASE-NOTES
pmusolino May 24, 2024
a3fd3bd
fix: indentation
pmusolino May 27, 2024
445234a
fix: typo
pmusolino May 27, 2024
c2255b7
feat: removed unused StoresManager from DefaultProductFormTableViewModel
pmusolino May 27, 2024
7223f38
Merge branch 'trunk' into issue/12646-Users-Unable-to-Upload-Product-…
pmusolino May 27, 2024
2fac786
Merge commit 'b3894996b5a6d897fbe75c8e93efdc8a84f1fa86' into issue/12…
pmusolino May 30, 2024
a91a6fc
feat: migration of `isPublic` to -> `visibility` in the `Site` model,…
pmusolino May 30, 2024
44036af
Set default visibility for self-hosted sites to be public
itsmeichigo May 31, 2024
b21ed6e
update: release notes
pmusolino May 31, 2024
a11871a
update: MIGRATIONS.md
pmusolino May 31, 2024
408181a
feat: implemented test method `test_migrating_from_111_to_112_updates…
pmusolino May 31, 2024
fde919c
Merge branch 'trunk' into issue/12646-Users-Unable-to-Upload-Product-…
pmusolino Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Fakes/Fakes/Networking.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ extension Networking.Site {
jetpackConnectionActivePlugins: .fake(),
timezone: .fake(),
gmtOffset: .fake(),
isPublic: .fake(),
visibility: .fake(),
canBlaze: .fake(),
isAdmin: .fake(),
wasEcommerceTrial: .fake()
Expand Down Expand Up @@ -2190,6 +2190,13 @@ extension Networking.SiteSummaryStats {
)
}
}
extension Networking.SiteVisibility {
/// Returns a "ready to use" type filled with fake values.
///
public static func fake() -> Networking.SiteVisibility {
.privateSite
}
}
extension Networking.SiteVisitStats {
/// Returns a "ready to use" type filled with fake values.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,7 @@ extension Networking.Site {
jetpackConnectionActivePlugins: CopiableProp<[String]> = .copy,
timezone: CopiableProp<String> = .copy,
gmtOffset: CopiableProp<Double> = .copy,
isPublic: CopiableProp<Bool> = .copy,
visibility: CopiableProp<SiteVisibility> = .copy,
canBlaze: CopiableProp<Bool> = .copy,
isAdmin: CopiableProp<Bool> = .copy,
wasEcommerceTrial: CopiableProp<Bool> = .copy
Expand All @@ -3068,7 +3068,7 @@ extension Networking.Site {
let jetpackConnectionActivePlugins = jetpackConnectionActivePlugins ?? self.jetpackConnectionActivePlugins
let timezone = timezone ?? self.timezone
let gmtOffset = gmtOffset ?? self.gmtOffset
let isPublic = isPublic ?? self.isPublic
let visibility = visibility ?? self.visibility
let canBlaze = canBlaze ?? self.canBlaze
let isAdmin = isAdmin ?? self.isAdmin
let wasEcommerceTrial = wasEcommerceTrial ?? self.wasEcommerceTrial
Expand All @@ -3091,7 +3091,7 @@ extension Networking.Site {
jetpackConnectionActivePlugins: jetpackConnectionActivePlugins,
timezone: timezone,
gmtOffset: gmtOffset,
isPublic: isPublic,
visibility: visibility,
canBlaze: canBlaze,
isAdmin: isAdmin,
wasEcommerceTrial: wasEcommerceTrial
Expand Down
25 changes: 19 additions & 6 deletions Networking/Networking/Model/Site.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {

/// Whether the site is launched and public.
///
public let isPublic: Bool
public let visibility: SiteVisibility

/// Whether the site is partially eligible for Blaze. For the site to be fully eligible for Blaze, `isAdmin` needs to be `true` as well.
///
Expand Down Expand Up @@ -113,7 +113,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
let loginURL = try optionsContainer.decode(String.self, forKey: .loginURL)
let frameNonce = try optionsContainer.decode(String.self, forKey: .frameNonce)
let canBlaze = optionsContainer.failsafeDecodeIfPresent(booleanForKey: .canBlaze) ?? false
let isPublic = optionsContainer.failsafeDecodeIfPresent(booleanForKey: .isPublic) ?? false
let visibility = optionsContainer.failsafeDecodeIfPresent(SiteVisibility.self, forKey: .visibility) ?? .privateSite

let planContainer = try siteContainer.nestedContainer(keyedBy: PlanInfo.self, forKey: .plan)
let plan = try planContainer.decode(String.self, forKey: .slug)
Expand Down Expand Up @@ -143,7 +143,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
jetpackConnectionActivePlugins: jetpackConnectionActivePlugins,
timezone: timezone,
gmtOffset: gmtOffset,
isPublic: isPublic,
visibility: visibility,
canBlaze: canBlaze,
isAdmin: isAdmin,
wasEcommerceTrial: wasEcommerceTrial)
Expand All @@ -168,7 +168,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
jetpackConnectionActivePlugins: [String],
timezone: String,
gmtOffset: Double,
isPublic: Bool,
visibility: SiteVisibility,
canBlaze: Bool,
isAdmin: Bool,
wasEcommerceTrial: Bool) {
Expand All @@ -189,7 +189,7 @@ public struct Site: Decodable, Equatable, GeneratedFakeable, GeneratedCopiable {
self.jetpackConnectionActivePlugins = jetpackConnectionActivePlugins
self.timezone = timezone
self.gmtOffset = gmtOffset
self.isPublic = isPublic
self.visibility = visibility
self.canBlaze = canBlaze
self.isAdmin = isAdmin
self.wasEcommerceTrial = wasEcommerceTrial
Expand Down Expand Up @@ -264,7 +264,7 @@ private extension Site {
case adminURL = "admin_url"
case loginURL = "login_url"
case frameNonce = "frame_nonce"
case isPublic = "blog_public"
case visibility = "blog_public"
case canBlaze = "can_blaze"
}

Expand All @@ -273,6 +273,14 @@ private extension Site {
}
}

/// Enum representing the visibility status of a site.
///
public enum SiteVisibility: Int, Codable, GeneratedFakeable {
case privateSite = -1
case comingSoon = 0
case publicSite = 1
}

/// Computed properties
///
public extension Site {
Expand All @@ -284,6 +292,11 @@ public extension Site {
return TimeZone(secondsFromGMT: secondsFromGMT) ?? .current
}

/// Returns true only if the site is hosted on WP.com and is private.
///
var isPrivateWPCOMSite: Bool {
return isWordPressComStore && (visibility == .privateSite)
}
}

private extension Site {
Expand Down
2 changes: 1 addition & 1 deletion Networking/Networking/Model/WordPressSite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public extension WordPressSite {
jetpackConnectionActivePlugins: [],
timezone: timezone,
gmtOffset: Double(gmtOffset) ?? 0,
isPublic: false,
visibility: .comingSoon,
canBlaze: false,
isAdmin: false,
wasEcommerceTrial: false)
Expand Down
4 changes: 2 additions & 2 deletions Networking/NetworkingTests/Mapper/AccountMapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class AccountMapperTests: XCTestCase {
XCTAssertEqual(first.gmtOffset, 3.5)
XCTAssertEqual(first.siteTimezone, TimeZone(secondsFromGMT: 12600))
XCTAssertEqual(first.jetpackConnectionActivePlugins, [])
XCTAssertEqual(first.isPublic, true)
XCTAssertEqual(first.visibility, .publicSite)
XCTAssertEqual(first.canBlaze, true)
XCTAssertEqual(first.isAdmin, true)
XCTAssertTrue(first.wasEcommerceTrial)
Expand All @@ -69,7 +69,7 @@ final class AccountMapperTests: XCTestCase {
XCTAssertEqual(second.gmtOffset, -4)
XCTAssertEqual(second.siteTimezone, TimeZone(secondsFromGMT: -14400))
XCTAssertEqual(second.jetpackConnectionActivePlugins, ["jetpack", "woocommerce-payments"])
XCTAssertEqual(second.isPublic, false)
XCTAssertEqual(second.visibility, .comingSoon)
XCTAssertEqual(second.canBlaze, false)
XCTAssertEqual(second.isAdmin, false)
XCTAssertFalse(second.wasEcommerceTrial)
Expand Down
2 changes: 1 addition & 1 deletion Networking/NetworkingTests/Remote/AccountRemoteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class AccountRemoteTests: XCTestCase {
// Sites in `sites.json` include one Jetpack CP site and one site with Jetpack-the-plugin.
let jcpSites = sites.filter { $0.isJetpackCPConnected }
let nonJCPSites = sites.filter { $0.isJetpackCPConnected == false }
let publicSites = sites.filter { $0.isPublic }
let publicSites = sites.filter { $0.visibility == .publicSite }
XCTAssertEqual(jcpSites.count, 1)
XCTAssertEqual(nonJCPSites.count, 1)
XCTAssertEqual(publicSites.count, 1)
Expand Down
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

18.9
-----
- [internal] Resolved an issue where users were unable to upload product images when the store is set to private on WP.com. [https://github.com/woocommerce/woocommerce-ios/issues/12646]
- [*] Orders: Fixes an issue where adding shipping to an order without selecting a shipping method prevented the order from being created/updated. [https://github.com/woocommerce/woocommerce-ios/pull/12870]
- [**] Orders: Multiple shipping lines can now be viewed, added, edited, or removed on orders; previously only the first shipping line on an order was supported. [https://github.com/woocommerce/woocommerce-ios/pull/12888]
- [internal] Orders: An empty order list screen after applying filters no longer affects Dashboard cards eligibility. [https://github.com/woocommerce/woocommerce-ios/pull/12873]
Expand Down
8 changes: 7 additions & 1 deletion Storage/Storage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
454005AA24AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 454005A924AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel */; };
455C0C9025DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455C0C8E25DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift */; };
455C0C9125DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455C0C8F25DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift */; };
456C14082C08D838006710C0 /* WooCommerceModelV111toV112.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 456C14072C08D838006710C0 /* WooCommerceModelV111toV112.xcmappingmodel */; };
457E6E8227D8B60F00173F69 /* Order+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457E6E8027D8B60F00173F69 /* Order+CoreDataClass.swift */; };
457E6E8327D8B60F00173F69 /* Order+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 457E6E8127D8B60F00173F69 /* Order+CoreDataProperties.swift */; };
45E1862E2370450C009241F3 /* ShippingLine+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45E1862D2370450C009241F3 /* ShippingLine+CoreDataClass.swift */; };
Expand Down Expand Up @@ -356,6 +357,8 @@
454005A924AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV28toV29.xcmappingmodel; sourceTree = "<group>"; };
455C0C8E25DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountSettings+CoreDataClass.swift"; sourceTree = "<group>"; };
455C0C8F25DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountSettings+CoreDataProperties.swift"; sourceTree = "<group>"; };
456C14062C08D7C4006710C0 /* Model 112.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 112.xcdatamodel"; sourceTree = "<group>"; };
456C14072C08D838006710C0 /* WooCommerceModelV111toV112.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV111toV112.xcmappingmodel; sourceTree = "<group>"; };
457E6E7F27D8B51E00173F69 /* Model 66.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 66.xcdatamodel"; sourceTree = "<group>"; };
457E6E8027D8B60F00173F69 /* Order+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Order+CoreDataClass.swift"; sourceTree = "<group>"; };
457E6E8127D8B60F00173F69 /* Order+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Order+CoreDataProperties.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -801,6 +804,7 @@
0284BD8825BAC83700D00C06 /* WooCommerceModelV42toV43.xcmappingmodel */,
CCD2E70625DE9AAA00BD975D /* WooCommerceModelV45toV46.xcmappingmodel */,
688908A928FD00320081A07E /* WooCommerceModelV74toV75.xcmappingmodel */,
456C14072C08D838006710C0 /* WooCommerceModelV111toV112.xcmappingmodel */,
);
name = "Mapping Models";
sourceTree = "<group>";
Expand Down Expand Up @@ -1360,6 +1364,7 @@
688908AA28FD00320081A07E /* WooCommerceModelV74toV75.xcmappingmodel in Sources */,
D821645D2239F5FC00F46F89 /* ShipmentTrackingProviderGroup+CoreDataClass.swift in Sources */,
B9B8B5052AA0D7F500B36811 /* TaxRate+CoreDataProperties.swift in Sources */,
456C14082C08D838006710C0 /* WooCommerceModelV111toV112.xcmappingmodel in Sources */,
D88E233B25AE08C90023F3B1 /* OrderFeeLine+CoreDataClass.swift in Sources */,
03101EFF29DD7D1300769CF3 /* CardReaderType.swift in Sources */,
0371C38128781E2900277E2C /* FeatureAnnouncementCampaignSettings.swift in Sources */,
Expand Down Expand Up @@ -2003,6 +2008,7 @@
DEC51AA4275B41BE009F3DF4 /* WooCommerce.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
456C14062C08D7C4006710C0 /* Model 112.xcdatamodel */,
CE606D962BE3AA4B001CB424 /* Model 111.xcdatamodel */,
CECE6BB42BA9CA1700A57C1F /* Model 110.xcdatamodel */,
DEA0D0692BA953D3007786F2 /* Model 109.xcdatamodel */,
Expand Down Expand Up @@ -2115,7 +2121,7 @@
DEC51ADE275B41BE009F3DF4 /* Model 47.xcdatamodel */,
DEC51ADF275B41BE009F3DF4 /* Model 19.xcdatamodel */,
);
currentVersion = CE606D962BE3AA4B001CB424 /* Model 111.xcdatamodel */;
currentVersion = 456C14062C08D7C4006710C0 /* Model 112.xcdatamodel */;
path = WooCommerce.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
6 changes: 6 additions & 0 deletions Storage/Storage/Model/MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.

## Model 112 (Release 18.9.0.0)
- @pmusolino 2024-05-30
- Added `visibility` attribute to `Site` entity.
- Removed `isPublic` attribute from `Site` entity.
- Added `WooCommerceModelV111toV112` mapping model.

## Model 111 (Release 18.5.0.0)
- @rachelmcr 2024-05-02
- Add `ShippingMethod` entity.
Expand Down
2 changes: 1 addition & 1 deletion Storage/Storage/Model/Site+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Site {
@NSManaged public var isJetpackConnected: Bool
@NSManaged public var isJetpackThePluginInstalled: Bool
@NSManaged public var jetpackConnectionActivePlugins: [String]?
@NSManaged public var isPublic: Bool
@NSManaged public var visibility: Int64
@NSManaged public var isSiteOwner: Bool
@NSManaged public var isAdmin: Bool
@NSManaged public var canBlaze: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model 111.xcdatamodel</string>
<string>Model 112.xcdatamodel</string>
</dict>
</plist>
Loading