Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -196,7 +196,7 @@ class ViewsUIController extends ControllerBase {
* Returns the form to edit a view.
*
* @param \Drupal\views_ui\ViewUI $view
* The view being deleted.
* The view to be edited.
* @param string|null $display_id
* (optional) The display ID being edited. Defaults to NULL, which will load
* the first available display.

View file

@ -12,6 +12,8 @@ use Drupal\Core\Ajax\OpenModalDialogCommand;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Render\RenderContext;
use Drupal\views_ui\ViewUI;
use Drupal\views\ViewEntityInterface;
use Drupal\views\Ajax;
@ -205,8 +207,21 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
}
$form_state->disableCache();
$form = \Drupal::formBuilder()->buildForm($form_class, $form_state);
// Builds the form in a render context in order to ensure that cacheable
// metadata is bubbled up.
$render_context = new RenderContext();
$callable = function () use ($form_class, &$form_state) {
return \Drupal::formBuilder()->buildForm($form_class, $form_state);
};
$form = $renderer->executeInRenderContext($render_context, $callable);
if (!$render_context->isEmpty()) {
BubbleableMetadata::createFromRenderArray($form)
->merge($render_context->pop())
->applyTo($form);
}
$output = $renderer->renderRoot($form);
drupal_process_attached($form);
// These forms have the title built in, so set the title here:

View file

@ -0,0 +1,92 @@
<?php
/**
* @file
* Contains Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter.
*/
/**
* This file was generated via php core/scripts/generate-proxy-class.php 'Drupal\views_ui\ParamConverter\ViewUIConverter' "core/modules/views_ui/src".
*/
namespace Drupal\views_ui\ProxyClass\ParamConverter {
/**
* Provides a proxy class for \Drupal\views_ui\ParamConverter\ViewUIConverter.
*
* @see \Drupal\Component\ProxyBuilder
*/
class ViewUIConverter implements \Drupal\Core\ParamConverter\ParamConverterInterface
{
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
/**
* The id of the original proxied service.
*
* @var string
*/
protected $drupalProxyOriginalServiceId;
/**
* The real proxied service, after it was lazy loaded.
*
* @var \Drupal\views_ui\ParamConverter\ViewUIConverter
*/
protected $service;
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* Constructs a ProxyClass Drupal proxy object.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
* @param string $drupal_proxy_original_service_id
* The service ID of the original service.
*/
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container, $drupal_proxy_original_service_id)
{
$this->container = $container;
$this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
}
/**
* Lazy loads the real service from the container.
*
* @return object
* Returns the constructed real service.
*/
protected function lazyLoadItself()
{
if (!isset($this->service)) {
$this->service = $this->container->get($this->drupalProxyOriginalServiceId);
}
return $this->service;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults)
{
return $this->lazyLoadItself()->convert($value, $definition, $name, $defaults);
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, \Symfony\Component\Routing\Route $route)
{
return $this->lazyLoadItself()->applies($definition, $name, $route);
}
}
}

View file

@ -6,6 +6,8 @@
*/
namespace Drupal\views_ui\Tests;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Tests the UI of generic display path plugin.
@ -149,4 +151,71 @@ class DisplayPathTest extends UITestBase {
$this->assertCacheContext('user.permissions');
}
/**
* Tests the regression in https://www.drupal.org/node/2532490.
*/
public function testDefaultMenuTabRegression() {
$this->container->get('module_installer')->install(['menu_ui', 'menu_link_content', 'toolbar', 'system']);
$admin_user = $this->drupalCreateUser([
'administer views',
'administer blocks',
'bypass node access',
'access user profiles',
'view all revisions',
'administer permissions',
'administer menu',
'link to any page',
'access toolbar',
]);
$this->drupalLogin($admin_user);
$edit = [
'title[0][value]' => 'Menu title',
'link[0][uri]' => '/admin/foo',
'menu_parent' => 'admin:system.admin'
];
$this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, t('Save'));
$menu_items = \Drupal::entityManager()->getStorage('menu_link_content')->getQuery()
->sort('id', 'DESC')
->pager(1)
->execute();
$menu_item = end($menu_items);
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
$menu_link_content = MenuLinkContent::load($menu_item);
$edit = [];
$edit['label'] = $this->randomMachineName(16);
$view_id = $edit['id'] = strtolower($this->randomMachineName(16));
$edit['description'] = $this->randomMachineName(16);
$edit['page[create]'] = TRUE;
$edit['page[path]'] = 'admin/foo';
$this->drupalPostForm('admin/structure/views/add', $edit, t('Save and edit'));
$parameters = new MenuTreeParameters();
$parameters->addCondition('id', $menu_link_content->getPluginId());
$result = \Drupal::menuTree()->load('admin', $parameters);
$plugin_definition = end($result)->link->getPluginDefinition();
$this->assertEqual('view.' . $view_id . '.page_1', $plugin_definition['route_name']);
$this->clickLink(t('No menu'));
$this->drupalPostForm(NULL, [
'menu[type]' => 'default tab',
'menu[title]' => 'Menu title',
], t('Apply'));
$this->assertText('Default tab options');
$this->drupalPostForm(NULL, [
'tab_options[type]' => 'normal',
'tab_options[title]' => 'Parent title',
], t('Apply'));
$this->drupalPostForm(NULL, [], t('Save'));
// Assert that saving the view will not cause an exception.
$this->assertResponse(200);
}
}

View file

@ -50,6 +50,7 @@ class OverrideDisplaysTest extends UITestBase {
// Confirm that the view block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
$this->clickLinkPartialName('Place block');
$this->assertText($view['label']);
// Place the block.
@ -109,6 +110,7 @@ class OverrideDisplaysTest extends UITestBase {
// Confirm that the block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
$this->clickLinkPartialName('Place block');
$this->assertText($view['label']);
// Put the block into the first sidebar region, and make sure it will not

View file

@ -74,4 +74,23 @@ abstract class UITestBase extends ViewTestBase {
return $default;
}
/**
* {@inheritdoc}
*/
protected function drupalGet($path, array $options = array(), array $headers = array()) {
$url = $this->buildUrl($path, $options);
// Ensure that each nojs page is accessible via ajax as well.
if (strpos($url, 'nojs') !== FALSE) {
$url = str_replace('nojs', 'ajax', $url);
$result = $this->drupalGet($url, $options, $headers);
$this->assertResponse(200);
$this->assertHeader('Content-Type', 'application/json');
$this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.');
}
return parent::drupalGet($path, $options, $headers);
}
}

View file

@ -162,7 +162,7 @@ class ViewAddForm extends ViewFormBase {
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
$wizard_type = $form_state->getValue(array('show', 'wizard_key'));
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
$form_state->set('wizard', $wizard_instance->getPluginDefinition());

View file

@ -58,7 +58,6 @@ class ViewDuplicateForm extends ViewFormBase {
$actions['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Duplicate'),
'#submit' => array('::submitForm'),
);
return $actions;
}

View file

@ -122,12 +122,6 @@ class ViewEditForm extends ViewFormBase {
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
$form['#attached']['library'][] = 'views_ui/admin.styling';
$form['#attached']['drupalSettings']['views']['ajax'] = [
'id' => '.views-ajax-body',
'title' => '.views-ajax-title',
'popup' => '.views-ajax-popup',
];
$form += array(
'#prefix' => '',
'#suffix' => '',
@ -220,23 +214,6 @@ class ViewEditForm extends ViewFormBase {
'#type' => 'container',
'tab_content' => $tab_content,
);
// The content of the popup dialog.
$form['ajax-area'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('views-ajax-popup'),
),
);
$form['ajax-area']['ajax-title'] = array(
'#markup' => '<div class="views-ajax-title"></div>',
);
$form['ajax-area']['ajax-body'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('views-ajax-body'),
),
);
}
return $form;
@ -264,8 +241,8 @@ class ViewEditForm extends ViewFormBase {
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state);
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$view = $this->entity;
if ($view->isLocked()) {

View file

@ -10,7 +10,6 @@ namespace Drupal\views_ui;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Timer;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
@ -18,7 +17,6 @@ use Drupal\views\Views;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\views\ViewExecutable;
use Drupal\Core\Database\Database;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\views\Plugin\views\query\Sql;
use Drupal\views\Entity\View;
@ -1336,4 +1334,40 @@ class ViewUI implements ViewEntityInterface {
return $this->storage->hasTrustedData();
}
/**
* {@inheritdoc}
*/
public function addCacheableDependency($other_object) {
$this->storage->addCacheableDependency($other_object);
return $this;
}
/**
* {@inheritdoc}
*/
public function addCacheContexts(array $cache_contexts) {
return $this->storage->addCacheContexts($cache_contexts);
}
/**
* {@inheritdoc}
*/
public function mergeCacheMaxAge($max_age) {
return $this->storage->mergeCacheMaxAge($max_age);
}
/**
* {@inheritdoc}
*/
public function getCacheTagsToInvalidate() {
return $this->storage->getCacheTagsToInvalidate();
}
/**
* {@inheritdoc}
*/
public function addCacheTags(array $cache_tags) {
return $this->storage->addCacheTags($cache_tags);
}
}

View file

@ -0,0 +1,57 @@
{#
/**
* @file
* Default theme implementation for Views UI build group filter form.
*
* Available variables:
* - form: A render element representing the form. Contains the following:
* - form_description: The exposed filter's description.
* - expose_button: The button to toggle the expose filter form.
* - group_button: Toggle options between single and grouped filters.
* - label: A filter label input field.
* - description: A filter description field.
* - value: The filters available values.
* - optional: A checkbox to require this filter or not.
* - remember: A checkbox to remember selected filter value(s) (per user).
* - widget: Radio Buttons to select the filter widget.
* - add_group: A button to add another row to the table.
* - more: A details element for additional field exposed filter fields.
* - table: A rendered table element of the group filter form.
*
* @see template_preprocess_views_ui_build_group_filter_form()
*
* @ingroup themeable
*/
#}
{{ form.form_description }}
{{ form.expose_button }}
{{ form.group_button }}
<div class="views-left-40">
{{ form.optional }}
{{ form.remember }}
</div>
<div class="views-right-60">
{{ form.widget }}
{{ form.label }}
{{ form.description }}
</div>
{#
Render the rest of the form elements excluding elements that are rendered
elsewhere.
#}
{{ form|without(
'form_description',
'expose_button',
'group_button',
'optional',
'remember',
'widget',
'label',
'description',
'add_group',
'more'
)
}}
{{ table }}
{{ form.add_group }}
{{ form.more }}

View file

@ -8,12 +8,8 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\views\Views;
use Drupal\views\ViewExecutable;
use Drupal\views_ui\ViewUI;
use Drupal\views\Analyzer;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Component\Utility\Xss;
/**
@ -97,7 +93,6 @@ function views_ui_theme() {
'views_ui_build_group_filter_form' => array(
'render element' => 'form',
'file' => 'views_ui.theme.inc',
'function' => 'theme_views_ui_build_group_filter_form',
),
// On behalf of a plugin
@ -129,7 +124,7 @@ function views_ui_preprocess_views_view(&$variables) {
// Render title for the admin preview.
if (!empty($view->live_preview)) {
$variables['title'] = Xss::filterAdmin($view->getTitle());
$variables['title']['#markup'] = $view->getTitle();
}
if (!empty($view->live_preview) && \Drupal::moduleHandler()->moduleExists('contextual')) {

View file

@ -65,35 +65,18 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) {
}
/**
* Theme the build group filter form.
* Prepares variables for Views UI build group filter form templates.
*
* @ingroup themeable
* Default template: views-ui-build-group-filter-form.html.twig.
*
* @param array $variables
* An associative array containing:
* - form: A render element representing the form.
*/
function theme_views_ui_build_group_filter_form($variables) {
function template_preprocess_views_ui_build_group_filter_form(&$variables) {
$form = $variables['form'];
$more = drupal_render($form['more']);
$output = drupal_render($form['form_description']);
$output .= drupal_render($form['expose_button']);
$output .= drupal_render($form['group_button']);
if (isset($form['required'])) {
$output .= drupal_render($form['required']);
}
$output .= drupal_render($form['operator']);
$output .= drupal_render($form['value']);
$output .= '<div class="views-left-40">';
$output .= drupal_render($form['optional']);
$output .= drupal_render($form['remember']);
$output .= '</div>';
$output .= '<div class="views-right-60">';
$output .= drupal_render($form['widget']);
$output .= drupal_render($form['label']);
$output .= drupal_render($form['description']);
$output .= '</div>';
// Prepare table of options.
$header = array(
t('Default'),
t('Weight'),
@ -103,14 +86,14 @@ function theme_views_ui_build_group_filter_form($variables) {
t('Operations'),
);
// Prepare default selectors.
$form_state = new FormState();
$form['default_group'] = Element\Radios::processRadios($form['default_group'], $form_state, $form);
$form['default_group_multiple'] = Element\Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form);
$form['default_group']['All']['#title'] = '';
hide($form['default_group_multiple']['All']);
$rows[] = array(
drupal_render($form['default_group']['All']),
['data' => $form['default_group']['All']],
'',
array(
'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('&lt;Any&gt;') : t('- Any -'),
@ -118,6 +101,9 @@ function theme_views_ui_build_group_filter_form($variables) {
'class' => array('class' => 'any-default-radios-row'),
),
);
// Remove the 'All' default_group form element because it's added to the
// table row.
unset($variables['form']['default_group']['All']);
foreach (Element::children($form['group_items']) as $group_id) {
$form['group_items'][$group_id]['value']['#title'] = '';
@ -125,6 +111,10 @@ function theme_views_ui_build_group_filter_form($variables) {
$form['default_group'][$group_id],
$form['default_group_multiple'][$group_id],
];
// Remove these fields from the form since they are moved into the table.
unset($variables['form']['default_group'][$group_id]);
unset($variables['form']['default_group_multiple'][$group_id]);
$link = [
'#type' => 'link',
'#url' => Url::fromRoute('<none>', [], [
@ -145,15 +135,15 @@ function theme_views_ui_build_group_filter_form($variables) {
$remove = [$form['group_items'][$group_id]['remove'], $link];
$data = array(
'default' => ['data' => $default],
'weight' => drupal_render($form['group_items'][$group_id]['weight']),
'title' => drupal_render($form['group_items'][$group_id]['title']),
'operator' => drupal_render($form['group_items'][$group_id]['operator']),
'value' => drupal_render($form['group_items'][$group_id]['value']),
'weight' => ['data' => $form['group_items'][$group_id]['weight']],
'title' => ['data' => $form['group_items'][$group_id]['title']],
'operator' => ['data' => $form['group_items'][$group_id]['operator']],
'value' => ['data' => $form['group_items'][$group_id]['value']],
'remove' => ['data' => $remove],
);
$rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable'));
}
$table = array(
$variables['table'] = array(
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
@ -170,11 +160,8 @@ function theme_views_ui_build_group_filter_form($variables) {
),
);
// Render the "Add another item" button below the table.
$add_another = drupal_render($form['add_group']);
$render_form = drupal_render_children($form);
return $output . $render_form . drupal_render($table) . $add_another . $more;
// Hide fields used in table.
unset($variables['form']['group_items']);
}
/**