Skip to content

Commit d74e10c

Browse files
committed
Move ProductFormSection.SettingsRow extension to where the enum is defined.
1 parent 0a0c489 commit d74e10c

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormSection.SettingsRow+Visibility.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,28 @@ extension ProductFormSection.SettingsRow.ViewModel: Equatable {
8585
lhs.details == rhs.details
8686
}
8787
}
88+
89+
extension ProductFormSection.SettingsRow {
90+
func isVisible(product: Product) -> Bool {
91+
guard let bottomSheetAction = bottomSheetAction else {
92+
// If there is no corresponding bottom sheet action, the settings row is visible by default.
93+
return true
94+
}
95+
return bottomSheetAction.isVisible(product: product) == false
96+
}
97+
98+
private var bottomSheetAction: ProductFormBottomSheetAction? {
99+
switch self {
100+
case .inventory:
101+
return .editInventorySettings
102+
case .shipping:
103+
return .editShippingSettings
104+
case .categories:
105+
return .editCategories
106+
case .briefDescription:
107+
return .editBriefDescription
108+
default:
109+
return nil
110+
}
111+
}
112+
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@
201201
02B296A922FA6E0000FD7A4C /* DateStartAndEndTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B296A822FA6E0000FD7A4C /* DateStartAndEndTests.swift */; };
202202
02B653AC2429F7BF00A9C839 /* MockTaxClassStoresManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B653AB2429F7BF00A9C839 /* MockTaxClassStoresManager.swift */; };
203203
02BA12852461674B008D8325 /* Optional+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BA12842461674B008D8325 /* Optional+String.swift */; };
204-
02BA1287246167C7008D8325 /* ProductFormSection.SettingsRow+Visibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BA1286246167C7008D8325 /* ProductFormSection.SettingsRow+Visibility.swift */; };
205204
02BA128B24616B48008D8325 /* ProductFormSectionSettingsRow+VisibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BA128A24616B48008D8325 /* ProductFormSectionSettingsRow+VisibilityTests.swift */; };
206205
02BA128D2461711D008D8325 /* ProductFormBottomSheetAction+VisibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BA128C2461711D008D8325 /* ProductFormBottomSheetAction+VisibilityTests.swift */; };
207206
02BA23C022EE9DAF009539E7 /* AsyncDictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02BA23BF22EE9DAF009539E7 /* AsyncDictionaryTests.swift */; };
@@ -1040,7 +1039,6 @@
10401039
02B296A822FA6E0000FD7A4C /* DateStartAndEndTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateStartAndEndTests.swift; sourceTree = "<group>"; };
10411040
02B653AB2429F7BF00A9C839 /* MockTaxClassStoresManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTaxClassStoresManager.swift; sourceTree = "<group>"; };
10421041
02BA12842461674B008D8325 /* Optional+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+String.swift"; sourceTree = "<group>"; };
1043-
02BA1286246167C7008D8325 /* ProductFormSection.SettingsRow+Visibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductFormSection.SettingsRow+Visibility.swift"; sourceTree = "<group>"; };
10441042
02BA128A24616B48008D8325 /* ProductFormSectionSettingsRow+VisibilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductFormSectionSettingsRow+VisibilityTests.swift"; sourceTree = "<group>"; };
10451043
02BA128C2461711D008D8325 /* ProductFormBottomSheetAction+VisibilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProductFormBottomSheetAction+VisibilityTests.swift"; sourceTree = "<group>"; };
10461044
02BA23BF22EE9DAF009539E7 /* AsyncDictionaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncDictionaryTests.swift; sourceTree = "<group>"; };
@@ -1785,7 +1783,6 @@
17851783
025B1747237A92D800C780B4 /* ProductFormSection+ReusableTableRow.swift */,
17861784
025B1749237AA49D00C780B4 /* Product+ProductForm.swift */,
17871785
4580BA7123F192A300B5F764 /* Product Settings */,
1788-
02BA1286246167C7008D8325 /* ProductFormSection.SettingsRow+Visibility.swift */,
17891786
);
17901787
path = "Edit Product";
17911788
sourceTree = "<group>";
@@ -4846,7 +4843,6 @@
48464843
024DF31423742B7A006658FE /* AztecUnderlineFormatBarCommand.swift in Sources */,
48474844
CE32B10D20BEDE1C006FBCF4 /* TwoColumnSectionHeaderView.swift in Sources */,
48484845
D8D15F85230A18AB00D48B3F /* Analytics.swift in Sources */,
4849-
02BA1287246167C7008D8325 /* ProductFormSection.SettingsRow+Visibility.swift in Sources */,
48504846
D8C62471227AE0030011A7D6 /* SiteCountry.swift in Sources */,
48514847
B582F95920FFCEAA0060934A /* UITableViewHeaderFooterView+Helpers.swift in Sources */,
48524848
02C0CD2C23B5BC9600F880B1 /* DefaultImageService.swift in Sources */,

0 commit comments

Comments
 (0)