Skip to content

Commit 8e285df

Browse files
committed
Use temporary site name based logic to detect garden/ciab site
1 parent 784f760 commit 8e285df

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

WooCommerce/Classes/CIAB/CIABEligibilityChecker.swift

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ final class CIABEligibilityChecker {
2222

2323
extension CIABEligibilityChecker: CIABEligibilityCheckerProtocol {
2424
var isCurrentSiteCIAB: Bool {
25-
/// Temp mocked value
26-
return true
25+
guard let currentSite = stores.sessionManager.defaultSite else {
26+
return false
27+
}
28+
return isSiteCIAB(currentSite)
2729
}
2830

2931
func isSiteCIAB(_ site: Site) -> Bool {
30-
/// Temp mocked value
31-
return true
32+
/// Temp logic
33+
/// If site name contains either `garden` or `ciab` then it's considered a CIAB site
34+
return isCIABSupportedForBuildEnvironment && CIABUnlockingSiteNameSubstrings.allCases.contains {
35+
site.name.lowercased().contains($0.rawValue)
36+
}
3237
}
3338

3439
func isFeatureSupportedForCurrentSite(_ feature: CIABAffectedFeature) -> Bool {
@@ -42,3 +47,23 @@ extension CIABEligibilityChecker: CIABEligibilityCheckerProtocol {
4247
return !isSiteCIAB(site) || !CIABAffectedFeature.unsupportedFeatures.contains(feature)
4348
}
4449
}
50+
51+
// MARK: - Temporary constants for CIAB identifying logic
52+
53+
fileprivate extension CIABEligibilityChecker {
54+
enum CIABUnlockingSiteNameSubstrings: String, CaseIterable {
55+
case garden
56+
case ciab
57+
}
58+
}
59+
60+
// MARK: - Temporary environment checks
61+
62+
import enum WooFoundationCore.BuildConfiguration
63+
64+
private extension CIABEligibilityChecker {
65+
var isCIABSupportedForBuildEnvironment: Bool {
66+
let buildConfig = BuildConfiguration.current
67+
return buildConfig == .localDeveloper || buildConfig == .alpha
68+
}
69+
}

0 commit comments

Comments
 (0)