diff --git a/core/lib/Drupal/Core/Plugin/PluginMultiModeFormInterface.php b/core/lib/Drupal/Core/Plugin/PluginMultiModeFormInterface.php deleted file mode 100644 index a26b6f5..0000000 --- a/core/lib/Drupal/Core/Plugin/PluginMultiModeFormInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - button.offcanvasClose, -#offcanvas > button.offcanvasClose:hover { /* todo: add hover state */ +#offcanvas > button.offcanvasClose:hover { /* @todo add hover state */ position: absolute; right: 15px; /* LTR */ top: 15px; @@ -87,18 +87,18 @@ text-align: right; } #canvas-tray.offCanvasDisplayInProgress { - position: fixed; - display: inline-block; + position: fixed; + display: inline-block; } #canvas-tray.offCanvasDisplayed { - display: inline-block; + display: inline-block; } /** * Buttons. */ -/* style for primary button */ +/* Style for primary button */ #offcanvas .button--primary { width: auto; max-width: 50%; @@ -115,12 +115,12 @@ #offcanvas .button--danger { width: auto; max-width: 50%; - border-radius: none; + border-radius: 0; border: none; background: transparent; } -/* special edit link to flow inline with form items that link to more configuration */ -#offcanvas .edit-link { /* todo add markup and class to template */ +/* Special edit link to flow inline with form items that link to more configuration */ +#offcanvas .edit-link { /* @todo add markup and class to template */ display: inline-block; font-size: 85%; font-weight: bold; @@ -148,7 +148,7 @@ display: block; width: 100%; } -/* reduce the size of descriptions and other elements for scanability */ +/* Reduce the size of descriptions and other elements for scannability */ #offcanvas .description, #offcanvas .machine-name-label, #offcanvas .machine-name-value { @@ -157,7 +157,7 @@ padding-top: .25em; } -/* add a background to checkboxes, radois for contrast */ +/* Add a background to checkboxes, radios for contrast */ /* #offcanvas .radio-wrapper { display: inline-block; @@ -175,9 +175,9 @@ * Fieldsets. */ #offcanvas fieldset { - border: 0px solid transparent; - margin-left:-1em; /* push background to the left edge of the parent */ - margin-right:-1em; /* push background to the right edge of the parent */ + border: 0 solid transparent; + margin-left: -1em; /* Push background to the left edge of the parent */ + margin-right: -1em; /* Push background to the right edge of the parent */ padding-top: 2.5em; padding-left: 1em; padding-bottom: 1em; @@ -186,7 +186,7 @@ #offcanvas fieldset .form-item { display: block; } -/* style fieldset legend similar to Drupal (seven theme) */ +/* Style fieldset legend similar to Drupal (seven theme) */ #offcanvas span.fieldset-legend { text-transform: uppercase; letter-spacing: 0.08em; @@ -216,7 +216,7 @@ margin-bottom: 0; } -#offcanvas span.field-suffix small { /* don't know why it's there. todo: figure out why it's rendering empty and taking space */ +#offcanvas span.field-suffix small { /* Don't know why it's there. @todo figure out why it's rendering empty and taking space */ display: none; } @@ -230,6 +230,3 @@ border-bottom-width: 1px; border-bottom-style: solid; } - - - diff --git a/core/modules/outside_in/css/outside_in.theme.css b/core/modules/outside_in/css/outside_in.theme.css index acd176d..8cfd66e 100644 --- a/core/modules/outside_in/css/outside_in.theme.css +++ b/core/modules/outside_in/css/outside_in.theme.css @@ -84,7 +84,7 @@ #offcanvas input:focus { background-color: #fff; } -/* reduce the size of descriptions and other elements for scanability */ +/* reduce the size of descriptions and other elements for scannability */ #offcanvas .description, #offcanvas .machine-name-label, #offcanvas .machine-name-value { diff --git a/core/modules/outside_in/js/outside_in.js b/core/modules/outside_in/js/outside_in.js index 30e2a3b..ed01e73 100644 --- a/core/modules/outside_in/js/outside_in.js +++ b/core/modules/outside_in/js/outside_in.js @@ -19,7 +19,7 @@ // Bind an event listener to the .outside-in-editable div // This listen for click events and stops default actions of those elements. $('.outside-in-editable').on('click', '.js-outsidein-edit-mode', function (e) { - if (localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false' ? true : false) { + if (localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false') { e.preventDefault(); } }); @@ -86,7 +86,7 @@ */ Drupal.behaviors.outsideinedit = { attach: function (context) { - var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false' ? true : false; + var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false'; if (editMode) { $('.outside-in-editable').addClass('focus'); var itemsToDisable = $('.outside-in-editable a, .outside-in-editable button') diff --git a/core/modules/outside_in/outside_in.module b/core/modules/outside_in/outside_in.module index b87c1ce..9667a57 100644 --- a/core/modules/outside_in/outside_in.module +++ b/core/modules/outside_in/outside_in.module @@ -5,11 +5,9 @@ * Allows configuring blocks and other configuration from the front-end of the site. */ - use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\Xss; +use Drupal\outside_in\Block\BlockEntityOffCanvasForm; /** * Implements hook_help(). @@ -47,7 +45,7 @@ function outside_in_contextual_links_view_alter(&$element, $items) { /** * Implements hook_page_top(). * - * Opens a div for consistant wrapping to all {{ page }} render in all themes. + * Opens a div for consistent wrapping to all {{ page }} render in all themes. */ function outside_in_page_top(array &$page_top) { $page_top['outside_in_tray_open'] = [ @@ -59,7 +57,7 @@ function outside_in_page_top(array &$page_top) { /** * Implements hook_page_bottom(). * - * Closes a div for consistant wrapping to all {{ page }} render in all themes. + * Closes a div for consistent wrapping to all {{ page }} render in all themes. */ function outside_in_page_bottom(array &$page_bottom) { $page_bottom['outside_in_tray_close'] = [ @@ -82,6 +80,16 @@ function outside_in_block_alter(&$definitions) { } /** + * Implements hook_entity_type_build(). + */ +function outside_in_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['block'] + ->setFormClass('offcanvas', BlockEntityOffCanvasForm::class) + ->setLinkTemplate('offcanvas-form', '/admin/structure/block/manage/{block}/offcanvas'); +} + +/** * Implements hook_preprocess_HOOK() for block templates. * * Adds 'outside-in-editable' class to all blocks to allow Javascript to target. diff --git a/core/modules/outside_in/outside_in.routing.yml b/core/modules/outside_in/outside_in.routing.yml new file mode 100644 index 0000000..5c81541 --- /dev/null +++ b/core/modules/outside_in/outside_in.routing.yml @@ -0,0 +1,7 @@ +entity.block.offcanvas_form: + path: '/admin/structure/block/manage/{block}/offcanvas' + defaults: + _entity_form: 'block.offcanvas' + _title: 'Configure block' + requirements: + _permission: 'administer blocks' diff --git a/core/modules/outside_in/outside_in.services.yml b/core/modules/outside_in/outside_in.services.yml index d32143c..9a785e8 100644 --- a/core/modules/outside_in/outside_in.services.yml +++ b/core/modules/outside_in/outside_in.services.yml @@ -5,5 +5,5 @@ services: tags: - { name: render.main_content_renderer, format: drupal_offcanvas } outside_in.block.manager: - class: Drupal\outside_in\OutsideInBlockManager + class: Drupal\outside_in\Block\OutsideInBlockManager arguments: ['@class_resolver'] diff --git a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php b/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php index d61ed4e..ef6f272 100644 --- a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php +++ b/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php @@ -32,7 +32,7 @@ class OpenOffCanvasDialogCommand extends OpenDialogCommand { * on the content of the dialog. If left empty, the settings will be * populated automatically from the current request. */ - public function __construct($title, $content, array $dialog_options = array(), $settings = NULL) { + public function __construct($title, $content, array $dialog_options = [], $settings = NULL) { $dialog_options['modal'] = FALSE; parent::__construct('#drupal-offcanvas', $title, $content, $dialog_options, $settings); } @@ -42,13 +42,13 @@ public function __construct($title, $content, array $dialog_options = array(), $ */ public function render() { $this->dialogOptions['modal'] = FALSE; - return array( + return [ 'command' => 'openOffCanvas', 'selector' => $this->selector, 'settings' => $this->settings, 'data' => $this->getRenderedContent(), 'dialogOptions' => $this->dialogOptions, - ); + ]; } } diff --git a/core/modules/block/src/BlockSidebarForm.php b/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php similarity index 65% rename from core/modules/block/src/BlockSidebarForm.php rename to core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php index d251d83..210b9e5 100644 --- a/core/modules/block/src/BlockSidebarForm.php +++ b/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php @@ -1,17 +1,16 @@ contextRepository = $context_repository; + $this->blockManager = $block_manager; } /** @@ -42,6 +51,7 @@ public function __construct(ContextRepositoryInterface $context_repository) { */ public static function create(ContainerInterface $container) { return new static( + $container->get('outside_in.block.manager'), $container->get('context.repository') ); } @@ -60,13 +70,8 @@ public function form(array $form, FormStateInterface $form_state) { $form['#tree'] = TRUE; $form['#attached']['library'][] = 'block/drupal.block.admin'; - $block_plugin = $this->entity->getPlugin(); - if ($block_plugin instanceof PluginMultiModeFormInterface) { - $form['settings'] = $block_plugin->buildConfigurationFormByMode([], $form_state, 'sidebar'); - } - else { - $form['settings'] = $block_plugin->buildConfigurationForm([], $form_state); - } + $form['settings'] = $this->blockManager->getFormObject($this->entity->getPlugin(), 'sidebar')->buildConfigurationForm([], $form_state); + return $form; } diff --git a/core/modules/outside_in/src/OutsideInBlockManager.php b/core/modules/outside_in/src/Block/OutsideInBlockManager.php similarity index 95% rename from core/modules/outside_in/src/OutsideInBlockManager.php rename to core/modules/outside_in/src/Block/OutsideInBlockManager.php index 227fb1a..f335d79 100644 --- a/core/modules/outside_in/src/OutsideInBlockManager.php +++ b/core/modules/outside_in/src/Block/OutsideInBlockManager.php @@ -1,11 +1,12 @@ request->get('dialogOptions', array()); + $options = $request->request->get('dialogOptions', []); $response->addCommand(new OpenOffCanvasDialogCommand($title, $content, $options)); return $response; diff --git a/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php b/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php index 3ad22a8..2df1e71 100644 --- a/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php +++ b/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php @@ -18,13 +18,13 @@ class OffCanvasDialogTest extends AjaxTestBase { * * @var array */ - public static $modules = array('outside_in'); + public static $modules = ['outside_in']; /** * Test sending AJAX requests to open and manipulate offcanvas dialog. */ public function testDialog() { - $this->drupalLogin($this->drupalCreateUser(array('administer contact forms'))); + $this->drupalLogin($this->drupalCreateUser(['administer contact forms'])); // Ensure the elements render without notices or exceptions. $this->drupalGet('ajax-test/dialog'); @@ -32,20 +32,20 @@ public function testDialog() { $dialog_renderable = AjaxTestController::dialogContents(); $dialog_contents = \Drupal::service('renderer')->renderRoot($dialog_renderable); - $offcanvas_expected_response = array( + $offcanvas_expected_response = [ 'command' => 'openOffCanvas', 'selector' => '#drupal-offcanvas', 'settings' => NULL, 'data' => $dialog_contents, - 'dialogOptions' => array( + 'dialogOptions' => [ 'modal' => FALSE, 'title' => 'AJAX Dialog contents', - ), - ); + ], + ]; // Emulate going to the JS version of the page and check the JSON response. - $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_offcanvas'))); - $this->assertEqual($offcanvas_expected_response, $ajax_result[3], 'Offcanvas dialog JSON response matches.'); + $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_offcanvas']]); + $this->assertEqual($offcanvas_expected_response, $ajax_result[3], 'Off-canvas dialog JSON response matches.'); } } diff --git a/core/modules/outside_in/tests/modules/offcanvas_test/offcanvas_test.info.yml b/core/modules/outside_in/tests/modules/offcanvas_test/offcanvas_test.info.yml index e21810e..8c6cc80 100644 --- a/core/modules/outside_in/tests/modules/offcanvas_test/offcanvas_test.info.yml +++ b/core/modules/outside_in/tests/modules/offcanvas_test/offcanvas_test.info.yml @@ -1,6 +1,6 @@ -name: 'Offcanvas tests' +name: 'Off-canvas tests' type: module -description: 'Provides offcanvas test links.' +description: 'Provides off-canvas test links.' package: Testing version: VERSION core: 8.x diff --git a/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php b/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php index 0e6c526..ecca616 100644 --- a/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php +++ b/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php @@ -9,7 +9,7 @@ /** * @todo. */ -class OffcanvasForm implements PluginFormInterface, OperationAwareFormInterface { +class OffCanvasForm implements PluginFormInterface, OperationAwareFormInterface { /** * @var string diff --git a/core/modules/outside_in/tests/modules/offcanvas_test/src/Plugin/Block/TestBlock.php b/core/modules/outside_in/tests/modules/offcanvas_test/src/Plugin/Block/TestBlock.php index 629a902..2866311 100644 --- a/core/modules/outside_in/tests/modules/offcanvas_test/src/Plugin/Block/TestBlock.php +++ b/core/modules/outside_in/tests/modules/offcanvas_test/src/Plugin/Block/TestBlock.php @@ -11,9 +11,9 @@ * @Block( * id = "offcanvas_links_block", * form = { - * "sidebar" = "\Drupal\offcanvas_test\Form\SidebarForm" + * "offcanvas" = "\Drupal\offcanvas_test\Form\OffCanvasForm" * }, - * admin_label = @Translation("Offcanvas test block") + * admin_label = @Translation("Off-canvas test block") * ) */ class TestBlock extends BlockBase { diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php index fa575dc..a7deb91 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -68,7 +68,7 @@ public function testOffCanvasLinks() { // @todo Should the close have an id? $offcanvas_tray->find('css', '.offcanvasClose')->press(); // Wait for animation to be done. - $this->waitForOffcanvasToClose(); + $this->waitForOffCanvasToClose(); // Make sure canvas doesn't exist after closing. $web_assert->elementNotExists('css', '#offcanvas'); } @@ -80,7 +80,7 @@ public function testOffCanvasLinks() { /** * Waits for Off-canvas tray to close. */ - protected function waitForOffcanvasToClose() { + protected function waitForOffCanvasToClose() { $condition = "(jQuery('#offcanvas').length == 0)"; $this->assertJsCondition($condition, 5000); } diff --git a/core/modules/outside_in/tests/src/Kernel/MultipleBlockFormTest.php b/core/modules/outside_in/tests/src/Kernel/MultipleBlockFormTest.php index 302a145..7f4e694 100644 --- a/core/modules/outside_in/tests/src/Kernel/MultipleBlockFormTest.php +++ b/core/modules/outside_in/tests/src/Kernel/MultipleBlockFormTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\outside_in\Kernel; use Drupal\KernelTests\KernelTestBase; -use Drupal\offcanvas_test\Form\SidebarForm; +use Drupal\offcanvas_test\Form\OffCanvasForm; /** * Tests that blocks can have multiple forms. @@ -24,14 +24,14 @@ public function testMultipleForms() { $block = \Drupal::service('plugin.manager.block')->createInstance('offcanvas_links_block'); $form_object1 = \Drupal::service('outside_in.block.manager')->getFormObject($block, 'default'); - $form_object2 = \Drupal::service('outside_in.block.manager')->getFormObject($block, 'sidebar'); + $form_object2 = \Drupal::service('outside_in.block.manager')->getFormObject($block, 'offcanvas'); // Assert that the block itself is used for the default form. $this->assertSame($block, $form_object1); - $expected_sidebar = new SidebarForm(); - $expected_sidebar->setOperation('sidebar'); - $this->assertEquals($expected_sidebar, $form_object2); + $expected_offcanvas = new OffCanvasForm(); + $expected_offcanvas->setOperation('offcanvas'); + $this->assertEquals($expected_offcanvas, $form_object2); } } diff --git a/core/modules/outside_in/tests/src/Unit/Ajax/AjaxCommandsTest.php b/core/modules/outside_in/tests/src/Unit/Ajax/AjaxCommandsTest.php deleted file mode 100644 index d907b6c..0000000 --- a/core/modules/outside_in/tests/src/Unit/Ajax/AjaxCommandsTest.php +++ /dev/null @@ -1,47 +0,0 @@ -getMockBuilder('Drupal\outside_in\Ajax\OpenOffCanvasDialogCommand') - ->setConstructorArgs(array( - 'Title', '
Text!
', array( - 'url' => 'example', - ), - )) - ->setMethods(array('getRenderedContent')) - ->getMock(); - - // This method calls the render service, which isn't available. We want it - // to do nothing so we mock it to return a known value. - $command->expects($this->once()) - ->method('getRenderedContent') - ->willReturn('rendered content'); - - $expected = array( - 'command' => 'openOffCanvas', - 'selector' => '#drupal-offcanvas', - 'settings' => NULL, - 'data' => 'rendered content', - 'dialogOptions' => array( - 'url' => 'example', - 'title' => 'Title', - 'modal' => FALSE, - ), - ); - $this->assertEquals($expected, $command->render()); - } - -} diff --git a/core/modules/outside_in/tests/src/Unit/Ajax/OpenOffCanvasDialogCommandTest.php b/core/modules/outside_in/tests/src/Unit/Ajax/OpenOffCanvasDialogCommandTest.php new file mode 100644 index 0000000..45ff2a1 --- /dev/null +++ b/core/modules/outside_in/tests/src/Unit/Ajax/OpenOffCanvasDialogCommandTest.php @@ -0,0 +1,34 @@ +Text!', ['url' => 'example']); + + $expected = [ + 'command' => 'openOffCanvas', + 'selector' => '#drupal-offcanvas', + 'settings' => NULL, + 'data' => 'Text!
', + 'dialogOptions' => [ + 'url' => 'example', + 'title' => 'Title', + 'modal' => FALSE, + ], + ]; + $this->assertEquals($expected, $command->render()); + } + +} diff --git a/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php b/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php index a3d7b58..d0f3ccc 100644 --- a/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php +++ b/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php @@ -7,12 +7,12 @@ use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\outside_in\OperationAwareFormInterface; -use Drupal\outside_in\OutsideInBlockManager; +use Drupal\outside_in\Block\OutsideInBlockManager; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; /** - * @coversDefaultClass \Drupal\outside_in\OutsideInBlockManager + * @coversDefaultClass \Drupal\outside_in\Block\OutsideInBlockManager * @group outside_in */ class OutsideInBlockManagerTest extends UnitTestCase { @@ -27,7 +27,7 @@ class OutsideInBlockManagerTest extends UnitTestCase { /** * The manager being tested. * - * @var \Drupal\outside_in\OutsideInBlockManager + * @var \Drupal\outside_in\Block\OutsideInBlockManager */ protected $manager; diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig b/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig deleted file mode 100644 index e69de29..0000000 diff --git a/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig b/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig deleted file mode 100644 index e69de29..0000000