Skip to content

Fixed Issue #14633 Sub-admin role related issue in order view page in magento 2 admin #20903

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

Closed
wants to merge 1 commit into from
Closed

Conversation

GovindaSharma
Copy link
Contributor

Fixed Issue #14633 Sub-admin role related issue in order view page in magento 2 admin

Description (*)

Fixed Issue #14633 Sub-admin role related issue in order view page in magento 2 admin

Fixed Issues (if relevant)

  1. magento/magento2 Sub-admin role related issue in order view page in magento 2 admin #14633: Sub-admin role related issue in order view page in magento 2 admin
  2. ...

Manual testing scenarios (*)

I have created one sub admin user from Magento admin. This user can only view orders, add a comment and operate on shipping. I gave some permissions for sub admin user. Please check the below image:
screenshotacl

So as you can see I have disabled Invoice and Credit memo role of this sub-admin.
But when I logged in as sub admin and go to order view page.Sometime Pop will come with "Something Went Wrong" and sometimes js error comes in console

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-engcom-team
Copy link
Contributor

Hi @GovindaSharma. 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.

Thanks for the pull requests @GovindaSharma ! Please take a look at the code review notes. Please apply the fixes not only on the commented line but use the same approach for all the files in the pull request in general.

@@ -35,7 +47,10 @@ public function getTabTitle()
*/
public function canShowTab()
{
return true;
if($this->authorization->isAllowed('Magento_Sales::invoice'))
Copy link
Member

Choose a reason for hiding this comment

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

it is fine to shorten this construction to return $this->authorization->isAllowed('Magento_Sales::creditmemo');

* @param \Magento\Framework\AuthorizationInterface|null $authorization
*/

public function __construct(
Copy link
Member

Choose a reason for hiding this comment

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

Please consider that parent class has constructor
(\Magento\Framework\View\Element\AbstractBlock::__construct), please ensure you call it.

public function __construct(
\Magento\Framework\AuthorizationInterface $authorization = null
){
$this->authorization = $authorization?: \Magento\Framework\App\ObjectManager::getInstance()->get(Magento\Framework\AuthorizationInterface::class);
Copy link
Member

Choose a reason for hiding this comment

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

Please declare the property

* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Context $context,
\Magento\Framework\Registry $coreRegistry,
\Magento\Framework\AuthorizationInterface $authorization = null,
Copy link
Member

Choose a reason for hiding this comment

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

New constructor parameters should be at the end of the list (after $data in this case)

@GovindaSharma
Copy link
Contributor Author

hi @sivaschenko i have updated all the changes suggested by you.Please check and let me know on this
Thank You

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.

Thanks for updates @GovindaSharma ! Please see my code review notes.

/**
* @var Magento\Framework\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

/**
* @var Magento\Framework\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

/**
* @var Magento\Framework\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

array $data = [],
\Magento\Framework\AuthorizationInterface $authorization = null)
{
$this->authorization = $authorization ? : \Magento\Framework\App\ObjectManager::getInstance ()->get ( Magento\Framework\AuthorizationInterface::class );
Copy link
Member

Choose a reason for hiding this comment

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

Please fix code style/formatting for all files

@sivaschenko
Copy link
Member

Hi @GovindaSharma it would be great if you can squash all changes to one commit with a meaningful name after the update.

@GovindaSharma
Copy link
Contributor Author

Hi @sivaschenko sure i will do and update you.
Thanks

Update Creditmemos.php

Update Shipments.php

Update Creditmemos.php

Update Invoices.php

Update Invoices.php

Update Creditmemos.php

Update Shipments.php

Update Creditmemos.php

Update Invoices.php

Update Creditmemos.php

Update Creditmemos.php

Made Requested Changes
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.

@GovindaSharma thanks for updates. Please fix code style and use meaningful commit message, i.e. '#20903: Fixed Issue #14633 Sub-admin role related issue in order view page in magento 2 admin'

@sidolov
Copy link
Contributor

sidolov commented Mar 8, 2019

@GovindaSharma , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Mar 8, 2019
@ghost
Copy link

ghost commented Mar 8, 2019

Hi @GovindaSharma, 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.

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.

4 participants