Skip to content

aclResource for UIComponent buttons #20408

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

Merged
merged 4 commits into from
Jan 26, 2019

Conversation

kassner
Copy link
Contributor

@kassner kassner commented Jan 18, 2019

Description

Currently is not possible to hide buttons based on the user role in the admin panel. As the example from this Pull Request, the Create new Order button is always shown, even when the user does not have the permission for it. Clicking on the button gives a permission denied page, as expected.

This PR introduces the possibility of defining an aclResource for UIComponents buttons, the same way that a dataSource can have.

Manual testing scenarios

  1. Create an admin role without the Magento_Sales::create permission;
  2. Assign the created role to a new (or existing) user;
  3. Login on admin panel with the previous user;
  4. Access the sales order grid on admin;
  5. The Create New order button should not be available;

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jan 18, 2019

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @kassner. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Hi @kassner thanks for your contribution! Please see my code review notes.

/**
* @var AuthorizationInterface
*/
protected $authorization;
Copy link
Member

Choose a reason for hiding this comment

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

Please change the access level to private

@@ -116,6 +123,7 @@ public function __construct(
UrlInterface $urlBuilder,
Processor $processor,
UiComponentFactory $uiComponentFactory,
AuthorizationInterface $authorization,
Copy link
Member

Choose a reason for hiding this comment

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

Please add new dependency to constructor as the last optional parameter (backward compatibility)

Copy link
Member

Choose a reason for hiding this comment

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

Please see "Adding constructor parameters" section for details https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/#php

@kassner
Copy link
Contributor Author

kassner commented Jan 18, 2019

@sivaschenko also, are you able to remove the partner label? I'm not assigned to that partner anymore (I left the team on Github, dunno why it still assigned to).

@sivaschenko sivaschenko removed Partner: Vaimo Pull Request is created by partner Vaimo partners-contribution Pull Request is created by Magento Partner labels Jan 19, 2019
@magento-engcom-team magento-engcom-team added this to the Release: 2.3.1 milestone Jan 19, 2019
@magento-engcom-team magento-engcom-team added Partner: Vaimo Pull Request is created by partner Vaimo partners-contribution Pull Request is created by Magento Partner labels Jan 19, 2019
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-3918 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@kassner thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@kassner kassner mentioned this pull request Jan 21, 2019
4 tasks
@magento-engcom-team magento-engcom-team merged commit d0e5afc into magento:2.3-develop Jan 26, 2019
@ghost
Copy link

ghost commented Jan 26, 2019

Hi @kassner, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team
Copy link
Contributor

Hi @kassner. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

@kassner kassner deleted the patch-12 branch June 1, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants