Skip to content
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

Product Form: Support viewing product page for coming soon sites #14931

Merged
merged 13 commits into from
Jan 24, 2025
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [*] Receipts: Email receipts can now be sent to customers after failed payments using WooCommerce Stripe 9.1.0+. [https://github.com/woocommerce/woocommerce-ios/pull/14864].
- [*] Order Creation: orders are always created using the store's currency, not the user's [https://github.com/woocommerce/woocommerce-ios/pull/14907]
- [*] Dashboard: Updated the drag gesture on the Performance chart to show stats instantly. [https://github.com/woocommerce/woocommerce-ios/pull/14906]
- [*] Product Form: Support previewing products on coming-soon stores. [https://github.com/woocommerce/woocommerce-ios/pull/14931]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I wonder if for end users it's more clear "Product Detail" instead of "Product Form".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll rewrite the message on the changelog anyway, I think this note is mostly for us developers. Since changing this will trigger CI again, I'll keep it as-is and merge the PR for the code freeze. I hope that's fine.

- [*] Jetpack Setup: Fix issue setting up Jetpack for JCP sites when authenticated without WPCom and removing application password after completion [https://github.com/woocommerce/woocommerce-ios/pull/14929]
- [Internal] Removed feedback survey for Store Setup feature [https://github.com/woocommerce/woocommerce-ios/pull/14888]
- [Internal] Removed feedback survey for shipping label creation [https://github.com/woocommerce/woocommerce-ios/pull/14889]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
saveProduct(status: .published)
}

@objc func dismissPresentedViewController() {
presentedViewController?.dismiss(animated: true, completion: nil)
}

func saveProductAsDraft() {
if viewModel.formType == .add {
ServiceLocator.analytics.track(.addProductSaveAsDraftTapped, withProperties: ["product_type": product.productType.rawValue])
Expand Down Expand Up @@ -1042,7 +1046,21 @@ private extension ProductFormViewController {
guard let url = URL(string: product.permalink) else {
return
}
WebviewHelper.launch(url, with: self)

let stores = ServiceLocator.stores
guard let site = stores.sessionManager.defaultSite,
stores.shouldAuthenticateAdminPage(for: site) else {
WebviewHelper.launch(url.absoluteString, with: self)
return
}

let viewModel = DefaultAuthenticatedWebViewModel(title: product.name, initialURL: url)
let controller = AuthenticatedWebViewController(viewModel: viewModel)
let navigationController = UINavigationController(rootViewController: controller)
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel,
target: self,
action: #selector(dismissPresentedViewController))
present(navigationController, animated: true)
}

func displayShareProduct(from sourceView: UIBarButtonItem, analyticSource: WooAnalyticsEvent.ProductForm.ShareProductSource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private extension LabeledTextViewTableViewCell {
func configureBackground() {
backgroundColor = .systemColor(.secondarySystemGroupedBackground)
productTextField.backgroundColor = .systemColor(.secondarySystemGroupedBackground)
productStatusBadgeHolder.backgroundColor = .listForeground(modal: false)
}

func configureLabelStyle() {
Expand Down