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

Blaze: Ad destination parameters #10762

Merged
merged 10 commits into from
Feb 13, 2024
Merged

Conversation

0nko
Copy link
Contributor

@0nko 0nko commented Feb 9, 2024

Implements #10737, a subtask of #10665.

Screen_recording_20240209_213359.webm

To test:

  1. Apply the patch below to see any parameters
  2. Create a new Blaze campaign
  3. Tap on the Ad destination property
  4. Notice the base URL and parameters are printed out
  5. Tap on the URL parameters property
  6. Notice the 2 parameters are displayed in a list
  7. Notice a full URL is shown below the list
  8. Delete one parameter
  9. Notice the full URL and remaining character count is updated
  10. Tap on back
  11. Notice the parameters property got updated

Patch:

Index: WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/preview/BlazeCampaignCreationPreviewFragment.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/preview/BlazeCampaignCreationPreviewFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/preview/BlazeCampaignCreationPreviewFragment.kt
--- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/preview/BlazeCampaignCreationPreviewFragment.kt	(revision Staged)
+++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/creation/preview/BlazeCampaignCreationPreviewFragment.kt	(date 1707510168898)
@@ -77,7 +77,7 @@
                 is NavigateToAdDestinationScreen -> findNavController().navigateSafely(
                     BlazeCampaignCreationPreviewFragmentDirections
                         .actionBlazeCampaignCreationPreviewFragmentToBlazeCampaignCreationAdDestinationFragment(
-                            event.targetUrl,
+                            event.targetUrl + "?test=true&yes=no",
                             event.productId
                         )
                 )

@0nko 0nko added feature: blaze Related to the Blaze project unit-tests-exemption labels Feb 9, 2024
@0nko 0nko added this to the 17.4 milestone Feb 9, 2024
@dangermattic
Copy link
Collaborator

3 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class BlazeCampaignCreationAdDestinationParametersViewModel is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class ViewState is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 9, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit7c63302
Direct Downloadwoocommerce-prototype-build-pr10762-7c63302.apk

@JorgeMucientes JorgeMucientes self-assigned this Feb 12, 2024
Comment on lines +146 to +151
item(key = "footer") {
Column(
modifier = Modifier
.animateItemPlacement()
.fillMaxWidth()
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity why did you add the footer inside the lazy column? Why not just below it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of the animation. When I put it outside, the lazy column items are animated but the footer jumps.

savedStateHandle: SavedStateHandle
) : ScopedViewModel(savedStateHandle) {
companion object {
// The maximum number of characters allowed in a URL by Chrome
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we following the Chrome restrictions in the end or the Calypso web restrictions? Just double checking after seeing this convo: p1707498869846739-slack-C03L1NF1EA3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I've updated the behavior to match the web/iOS.

Comment on lines 72 to 77
private fun getParameters(url: String): String {
return url.split("?")
.getOrNull(1)
?.replace("&", "\n")
?: return resourceProvider.getString(R.string.blaze_campaign_edit_ad_destination_empty_parameters_message)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor suggestion, you can maybe reuse the parseParameters() function to make it slightly "more readable"?

    private fun getParameters(url: String): String {
        return url.parseParameters().entries.joinToString(separator = "\n")
            .ifBlank { resourceProvider.getString(R.string.blaze_campaign_edit_ad_destination_empty_parameters_message) }
    }

It's more of a personal taste thing, so feel free to ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I updated the code.

@JorgeMucientes
Copy link
Contributor

Great work @0nko. Everything works as expected and code looks good! I just left a couple questions, but aside from that this si ready to be merged. :shipit:

@peril-woocommerce
Copy link

Warnings
⚠️ PR has more than 300 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2024

Codecov Report

Attention: 51 lines in your changes are missing coverage. Please review.

Comparison is base (3c97bdf) 41.44% compared to head (7c63302) 41.41%.
Report is 97 commits behind head on trunk.

Files Patch % Lines
...ampaignCreationAdDestinationParametersViewModel.kt 0.00% 21 Missing ⚠️
...ion/BlazeCampaignCreationAdDestinationViewModel.kt 0.00% 21 Missing ⚠️
...in/kotlin/com/woocommerce/android/util/UrlUtils.kt 0.00% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #10762      +/-   ##
============================================
- Coverage     41.44%   41.41%   -0.04%     
  Complexity     5017     5017              
============================================
  Files          1016     1017       +1     
  Lines         58364    58407      +43     
  Branches       7803     7806       +3     
============================================
  Hits          24190    24190              
- Misses        32030    32073      +43     
  Partials       2144     2144              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@0nko
Copy link
Contributor Author

0nko commented Feb 13, 2024

@JorgeMucientes Thanks for the review. I've addressed your feedback.

@JorgeMucientes JorgeMucientes merged commit c2ab3b0 into trunk Feb 13, 2024
15 checks passed
@JorgeMucientes JorgeMucientes deleted the issue/10737-ad-url-params branch February 13, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: blaze Related to the Blaze project unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants