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

Store controls in state #7706

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Draft

Conversation

donnapep
Copy link
Collaborator

@donnapep donnapep commented Nov 6, 2024

Related to https://github.com/Automattic/sensei-pro/issues/2620.

TODO:

  • "Add to Group" and "Remove from Group" options always add / remove the student in the first row (i.e. the modal in the first row is the one being opened)

Proposed Changes

Testing Instructions

  1. Checkout https://github.com/Automattic/sensei-pro/pull/2623.
  2. Run npm install.
  3. Log in as an admin and go to the Students page.
  4. Check that "Add to Group" and "Remove from Group" options are available in the dropdown menu for a student.

New/Updated Hooks

Deprecated Code

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Legacy courses (course without blocks) are tested
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@donnapep donnapep self-assigned this Nov 6, 2024
Copy link

github-actions bot commented Nov 6, 2024

Test the previous changes of this PR with WordPress Playground.

Copy link

github-actions bot commented Nov 6, 2024

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit 4f124fa and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Dependencies Removed Dependencies Total Size Size Diff
admin/students/student-action-menu/index.js 5.13 kB +203 B ( +4.12% 🔼 )

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

Copy link

github-actions bot commented Nov 6, 2024

Test the previous changes of this PR with WordPress Playground.

);
useEffect( () => {
async function getMenuControls() {
const response = await applyFiltersAsync(
Copy link
Collaborator Author

@donnapep donnapep Nov 6, 2024

Choose a reason for hiding this comment

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

Although this code works, I have no idea why or how. 😅 It looks good in theory, but when setting breakpoints or adding log statements in the code, I noticed that when the fetch in Sensei Pro returns and setControls is called below, the component does not re-render as expected. Despite this, the "Add to Group" and "Remove from Group" options are there in the UI. 🤯

Given I'm not clear on what is happening here, I'm somewhat averse to shipping this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing something, but I didn't find where the applyFiltersAsync comes from. Checking the Gutenberg package, it doesn't seem to be there.

I'm also seeing this error in my browser console: Uncaught (in promise) TypeError: (0 , _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.applyFiltersAsync) is not a function.

So I don't understand how the buttons are displayed for you. For me it's not being displayed. Maybe there is some other code adding them for you given a specific condition?

Copy link
Collaborator Author

@donnapep donnapep Nov 6, 2024

Choose a reason for hiding this comment

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

It's in @wordpress/hooks, so you'll need do reinstall npm packages as I updated the version.

Updated the testing instructions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even with that it's not finding the function for me. 🤔
Are you using a WP beta version?

The @wordpress/hooks is not bundled in our scripts. It's imported directly from WP because of the dependency extraction plugin. I checked that the function was added 1 month ago, so we probably shouldn't use it.

BTW, the link I used in my previous comment was the Gutenberg repo in the Automattic organization instead of the WordPress organization. That's the reason it wasn't there. :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you using a WP beta version?

Oof, yes I am. I wasn't able to downgrade in the Beta Tester plugin so had to stay on 6.7. Back to square one then I guess. 😄 Thanks for taking a look!

Copy link

github-actions bot commented Nov 6, 2024

Test the previous changes of this PR with WordPress Playground.

Copy link

github-actions bot commented Nov 6, 2024

Test the previous changes of this PR with WordPress Playground.

@donnapep donnapep marked this pull request as draft November 6, 2024 22:14
As a copy of the state was originally passed to the function.
Copy link

github-actions bot commented Nov 7, 2024

Test the previous changes of this PR with WordPress Playground.

Copy link

github-actions bot commented Nov 7, 2024

Test the previous changes of this PR with WordPress Playground.

Copy link

github-actions bot commented Nov 8, 2024

Test the previous changes of this PR with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants