Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion WooCommerce/Classes/ViewRelated/Hub Menu/HubMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct HubMenu: View {
NavigationLink(destination: CouponListView(siteID: viewModel.siteID), isActive: $showingCoupons) {
EmptyView()
}.hidden()
NavigationLink(destination: InAppPurchasesDebugView(siteID: viewModel.siteID), isActive: $showingIAPDebug) {
NavigationLink(destination: InAppPurchasesDebugView(), isActive: $showingIAPDebug) {
EmptyView()
}.hidden()
LazyNavigationLink(destination: viewModel.getReviewDetailDestination(), isActive: $viewModel.showingReviewDetail) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Yosemite

@MainActor
struct InAppPurchasesDebugView: View {
let siteID: Int64
private let inAppPurchasesForWPComPlansManager = InAppPurchasesForWPComPlansManager()
@State var products: [WPComPlanProduct] = []
@State var entitledProductIDs: Set<String> = []
Expand All @@ -25,7 +24,8 @@ struct InAppPurchasesDebugView: View {
Text("No products")
} else if isPurchasing {
ActivityIndicator(isAnimating: .constant(true), style: .medium)
} else {
} else if let stringSiteID = ProcessInfo.processInfo.environment[Constants.siteIdEnvironmentVariableName],
let siteID = Int64(stringSiteID) {
ForEach(products, id: \.id) { product in
Button(entitledProductIDs.contains(product.id) ? "Entitled: \(product.description)" : product.description) {
Task {
Expand All @@ -36,6 +36,10 @@ struct InAppPurchasesDebugView: View {
}
}
}
} else {
Text("No valid site id could be retrieved to purchase product. " +
"Please set your Int64 test site id to the Xcode environment variable with name \(Constants.siteIdEnvironmentVariableName).")
.foregroundColor(.red)
}
}

Expand Down Expand Up @@ -104,6 +108,10 @@ struct InAppPurchasesDebugView: View {

struct InAppPurchasesDebugView_Previews: PreviewProvider {
static var previews: some View {
InAppPurchasesDebugView(siteID: 0)
InAppPurchasesDebugView()
}
}

private enum Constants {
static let siteIdEnvironmentVariableName = "iap-debug-site-id"
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "iap-debug-site-id"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down