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

Add "Create a new campaign" modal #37044

Merged
merged 46 commits into from Mar 13, 2023

Conversation

ecgan
Copy link
Member

@ecgan ecgan commented Mar 2, 2023

All Submissions:

Changes proposed in this Pull Request:

Closes #34909. Previous draft PR and discussions are in PR #36130.

This PR implements the "Create a new campaign" modal.

image

image

The implemented modal here is different from the figma designs in #34909. Specifically, there are no borders within the modal component. This is to be more consistent with the WordPress Modal component which no longer has border under the modal title since PR WordPress/gutenberg#40781.

The new campaign types data is loaded from GET /marketing/campaign-types API. The API is called when the Campaigns card is rendered, so that when users click on the "Create new campaign" button, the data is already there and no additional waiting is required.

How to test the changes in this Pull Request:

Pre-conditions:

  1. Go to WooCommerce Marketing page: /wp-admin/admin.php?page=wc-admin&path=%2Fmarketing
  2. Click on the "Create new campaign" button in the Campaigns card.
  3. You should see the modal like the screenshot above.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you created a changelog file for each project being changed, ie pnpm --filter=<project> changelog add?
  • Have you included testing instructions?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

…paigns-card' into feature/34903-multichannel-marketing-frontend/34909-create-campaign-modal

Conflicts:
	plugins/woocommerce-admin/client/marketing/hooks/index.ts
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/RecommendedChannels.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/useChannels.ts
…909-marketing-create-campaign-modal

Conflicts:
	plugins/woocommerce-admin/client/marketing/components/RecommendedChannelsList.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.scss
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Campaigns/Campaigns.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx
	plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/RecommendedChannels.tsx
…909-marketing-create-campaign-modal

Conflicts:
	plugins/woocommerce-admin/client/marketing/data-multichannel/action-types.ts
	plugins/woocommerce-admin/client/marketing/data-multichannel/actions.ts
	plugins/woocommerce-admin/client/marketing/data-multichannel/resolvers.ts
@ecgan ecgan added the focus: marketing Marketing page in WooCommerce Admin, i.e. `/wp-admin/admin.php?page=wc-admin&path=%2Fmarketing`. label Mar 2, 2023
@ecgan ecgan self-assigned this Mar 2, 2023
@ecgan ecgan mentioned this pull request Mar 2, 2023
7 tasks
@ecgan ecgan requested review from a team March 2, 2023 18:57
@ecgan
Copy link
Member Author

ecgan commented Mar 9, 2023

@eason9487 , thanks for the thorough review, great eyes as always! 😀 👍 I have addressed your code review comments in this PR, this is ready for another round of review. 🙏


The following is about the 6 points mentioned in your code review summary in #37044 (review). Thanks so much for bringing them up!

  1. It will show a "0" when no campaigns.

I'll fix it in a separate PR. I'm thinking to check through the marketing code base to make sure this is handled correctly. We recently just fixed a similar issue #37083.

  1. Same as the getCampaignTypes reducer, the other three reducers also have the same concern of re-throwing errors.

This is related to #37044 (comment). The problem is I don't see the issue that you are seeing. We can talk about it in that comment thread.

  1. Although not causing actual problems at this moment, there is a concern about incorrect state caching within useCampaigns, which could lead to incorrect results in the future for standalone components like Campaigns.

Agree. I actually thought of doing some changes with useCampaigns. I feel like useCampaigns is doing too much with useRegisteredChannels in it, I want to make it leaner and remove "channel" things. I'm thinking to work with what we have now and change it later.

  1. After installing or activating an extension in MarketingOverviewMultichannel, the refetch doesn't trigger the data refetching for getRegisteredChannels.

I couldn't reproduce this, it works as expected for me. 🤔 See my demo video below.

demo-pr-activate-channel-refetch.mp4
  1. In the relevant processing of getCampaigns in wp-data store and useCampaigns hook, they don't include perPage as a part of the data key. It will lead to incorrect data and states if other implementations use a different perPage to request data someday.

Good point! I guess I can make the perPage as a part of the key, or don't expose perPage as a parameter 😂 . I'll create a separate issue and label it as low priority since this isn't a major issue now.

  1. After activating GLA via the Channels card, the GLA item in the Installed extensions card is still remaining unactivated.

This should not be a problem with issue #34907 and its PR #37126, because the extension should only appear in one card, it shouldn't appear in both Channels card and Installed extensions card.

@eason9487
Copy link
Member

4. After installing or activating an extension in MarketingOverviewMultichannel, the refetch doesn't trigger the data refetching for getRegisteredChannels.

I couldn't reproduce this, it works as expected for me.

Just realized it's because of different WP versions. See #37044 (comment) and #37044 (comment).

Considering the latest WC still states it supports WP 5.9, I guess it would still need to add the second parameter to the invalidateResolution call in useRegisteredChannels at this moment.

Copy link
Member

@eason9487 eason9487 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates.

The two remaining concerns are about the compatibility with WP 5.9:

About the remaining issues mentioned in the main content of this #37044 (review), I also think they could be addressed in separate PRs. 👍

In WP 5.9, if we throw error, there would be an uncaught promise, and it causes UI to break.
@ecgan
Copy link
Member Author

ecgan commented Mar 10, 2023

  1. After installing or activating an extension in MarketingOverviewMultichannel, the refetch doesn't trigger the data refetching for getRegisteredChannels.

I couldn't reproduce this, it works as expected for me.

Just realized it's because of different WP versions. See #37044 (comment) and #37044 (comment).

Considering the latest WC still states it supports WP 5.9, I guess it would still need to add the second parameter to the invalidateResolution call in useRegisteredChannels at this moment.

Got it. I have created a separate issue #37176 for this.

  1. It will show a "0" when no campaigns.

I'll fix it in a separate PR. I'm thinking to check through the marketing code base to make sure this is handled correctly. We recently just fixed a similar issue #37083.

Created issue #37175.

  1. In the relevant processing of getCampaigns in wp-data store and useCampaigns hook, they don't include perPage as a part of the data key. It will lead to incorrect data and states if other implementations use a different perPage to request data someday.

Good point! I guess I can make the perPage as a part of the key, or don't expose perPage as a parameter 😂 . I'll create a separate issue and label it as low priority since this isn't a major issue now.

Created issue #37177.


@eason9487 , all the code review comments are addressed. This is ready for another round of review. 🙂 🙏

@ecgan ecgan requested a review from eason9487 March 10, 2023 18:47
Copy link
Member

@eason9487 eason9487 left a comment

Choose a reason for hiding this comment

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

Thanks for the further adjustments! LGTM.

@ecgan ecgan merged commit 7bf2ced into trunk Mar 13, 2023
27 of 29 checks passed
@ecgan ecgan deleted the feature/34909-marketing-create-campaign-modal branch March 13, 2023 05:24
@github-actions github-actions bot added this to the 7.6.0 milestone Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: marketing Marketing page in WooCommerce Admin, i.e. `/wp-admin/admin.php?page=wc-admin&path=%2Fmarketing`. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "Create a new campaign" modal
4 participants