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

DataViews: use action.disabled state to disable actions (primary and secondary) #68275

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Dec 24, 2024

Related #67790 (comment)

What?

This PR uses the existing disabled property in the Actions API to disable the action buttons.

How?

Pass the action.disabled property to the button that renders it.

Testing Instructions

  • Go to the Pages page.
  • Make one of the actions disabled. For example, add disabled: true to edit.
  • Switch to every layout and verify that the edit action is disabled (both as primary and secondary).
List Grid Table
Screenshot 2024-12-24 at 15 03 20 Screenshot 2024-12-24 at 15 03 10 Screenshot 2024-12-24 at 15 03 00

@oandregal oandregal self-assigned this Dec 24, 2024
Copy link

github-actions bot commented Dec 24, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@oandregal oandregal added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Dec 24, 2024
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

This looks good. But I'm curious why did we introduce the action.disabled API in the first place? I mean what are the use-cases?

Copy link

Flaky tests detected in 45a1d78.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12482690337
📝 Reported issues:

@oandregal oandregal merged commit 75ef79e into trunk Dec 24, 2024
77 checks passed
@oandregal oandregal deleted the fix/dataviews-actions-disable branch December 24, 2024 14:56
@github-actions github-actions bot added this to the Gutenberg 20.0 milestone Dec 24, 2024
@oandregal
Copy link
Member Author

This looks good. But I'm curious why did we introduce the action.disabled API in the first place? I mean what are the use-cases?

Right, I don't know what use cases covers a boolean that needs to be resolved at registration time. Having a isDisabled function that mimics isEligible would be a more flexible API, imo. For example, it'd enable us to support things similar to the first use case here #68134 (disable when the page is the homepage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants