Commit a12c564d authored by alexpott's avatar alexpott

Issue #2836384 by chr.fritsch, phenaproxima, Munavijayalakshmi: Field UIs...

Issue #2836384 by chr.fritsch, phenaproxima, Munavijayalakshmi: Field UIs operations array is broken for entities with restricted access
parent 7292b487
......@@ -161,6 +161,9 @@ public function getDefaultOperations(EntityInterface $entity) {
'title' => $this->t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-edit-form"),
'attributes' => [
'title' => $this->t('Edit field settings.')
],
];
}
if ($entity->access('delete') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-delete-form")) {
......@@ -168,6 +171,9 @@ public function getDefaultOperations(EntityInterface $entity) {
'title' => $this->t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-delete-form"),
'attributes' => [
'title' => $this->t('Delete field.')
],
];
}
......@@ -177,8 +183,6 @@ public function getDefaultOperations(EntityInterface $entity) {
'attributes' => ['title' => $this->t('Edit storage settings.')],
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-storage-edit-form"),
];
$operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
$operations['delete']['attributes']['title'] = $this->t('Delete field.');
return $operations;
}
......
......@@ -5,8 +5,17 @@
* Field UI test module.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Field\FieldConfigInterface;
/**
* Implements hook_ENTITY_TYPE_access().
*/
function field_ui_test_field_config_access(FieldConfigInterface $field) {
return AccessResult::forbiddenIf($field->getName() == 'highlander');
}
/**
* Implements hook_form_FORM_BASE_ID_alter().
......
<?php
namespace Drupal\Tests\field_ui\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the Manage Display page of a fieldable entity type.
*
* @group field_ui
*/
class ManageFieldsTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'field_ui',
'field_ui_test',
'node',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$account = $this->drupalCreateUser(['administer node fields']);
$this->drupalLogin($account);
$this->config('system.logging')
->set('error_level', ERROR_REPORTING_DISPLAY_ALL)
->save();
}
public function testFieldDropButtonOperations() {
$node_type = $this->drupalCreateContentType();
/** @var \Drupal\field\FieldStorageConfigInterface $storage */
$storage = $this->container->get('entity_type.manager')
->getStorage('field_storage_config')
->create([
'type' => 'string',
'field_name' => 'highlander',
'entity_type' => 'node',
]);
$storage->save();
$this->container->get('entity_type.manager')
->getStorage('field_config')
->create([
'field_storage' => $storage,
'bundle' => $node_type->id(),
])
->save();
$this->drupalGet('/admin/structure/types/manage/' . $node_type->id() . '/fields');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment