diff --git a/core/modules/views_ui/config/install/tour.tour.views-ui.yml b/core/modules/views_ui/config/install/tour.tour.views-ui.yml index 23d4328..1b4e475 100644 --- a/core/modules/views_ui/config/install/tour.tour.views-ui.yml +++ b/core/modules/views_ui/config/install/tour.tour.views-ui.yml @@ -44,7 +44,7 @@ tips: body: 'If this view uses fields, they are listed here. You can click on a field to configure it.' weight: 5 attributes: - data-class: views-ui-display-tab-bucket.fields + data-class: views-ui-display-tab-bucket.field views-ui-filter: id: views-ui-filter plugin: text @@ -52,7 +52,7 @@ tips: body: 'Add filters to limit the results in the output. E.g., to only show content that is published, you would add a filter for Published and select Yes.' weight: 6 attributes: - data-class: views-ui-display-tab-bucket.filter-criteria + data-class: views-ui-display-tab-bucket.filter views-ui-filter-operations: id: views-ui-filter-operations plugin: text @@ -60,7 +60,7 @@ tips: body: 'Add, rearrange or remove filters.' weight: 7 attributes: - data-class: 'views-ui-display-tab-bucket.filter-criteria .dropbutton-widget' + data-class: 'views-ui-display-tab-bucket.filter .dropbutton-widget' views-ui-sorts: id: views-ui-sorts plugin: text @@ -68,7 +68,7 @@ tips: body: 'Control the order in which the results are output. Click on an active sort rule to configure it.' weight: 8 attributes: - data-class: views-ui-display-tab-bucket.sort-criteria + data-class: views-ui-display-tab-bucket.sort views-ui-sorts-operations: id: views-ui-sorts-operations plugin: text @@ -76,7 +76,7 @@ tips: body: 'Add, rearrange or remove sorting rules.' weight: 9 attributes: - data-class: 'views-ui-display-tab-bucket.sort-criteria .dropbutton-widget' + data-class: 'views-ui-display-tab-bucket.sort .dropbutton-widget' views-ui-preview: id: views-ui-preview plugin: text diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index c3c5b8d..5310062 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -395,7 +395,7 @@ Drupal.behaviors.viewsUiPreview = { attach: function (context) { // Only act on the edit view form. - var $contextualFiltersBucket = $(context).find('.views-display-column .views-ui-display-tab-bucket.contextual-filters'); + var $contextualFiltersBucket = $(context).find('.views-display-column .views-ui-display-tab-bucket.argument'); if ($contextualFiltersBucket.length === 0) { return; } diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php index ca29239..eca12a4 100644 --- a/core/modules/views_ui/src/Tests/DisplayTest.php +++ b/core/modules/views_ui/src/Tests/DisplayTest.php @@ -121,16 +121,15 @@ public function testDisplayAreas() { $this->drupalGet('admin/structure/views/view/test_display/edit/display_no_area_test_1'); - // Create a mapping of area type => class. $areas = array( - 'header' => 'header', - 'footer' => 'footer', - 'empty' => 'no-results-behavior', + 'header', + 'footer', + 'empty', ); // Assert that the expected text is found in each area category. - foreach ($areas as $type => $class) { - $element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $class)); + foreach ($areas as $type) { + $element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $type)); $this->assertEqual((string) $element[0], String::format('The selected display type does not use @type plugins', array('@type' => $type))); } } diff --git a/core/modules/views_ui/src/Tests/ViewsUITourTest.php b/core/modules/views_ui/src/Tests/ViewsUITourTest.php index 86533b3..7030cac 100644 --- a/core/modules/views_ui/src/Tests/ViewsUITourTest.php +++ b/core/modules/views_ui/src/Tests/ViewsUITourTest.php @@ -8,6 +8,7 @@ namespace Drupal\views_ui\Tests; use Drupal\tour\Tests\TourTestBase; +use Drupal\language\Entity\ConfigurableLanguage; /** * Tests the Views UI tour. @@ -28,11 +29,11 @@ class ViewsUITourTest extends TourTestBase { * * @var array */ - public static $modules = array('views_ui', 'tour'); + public static $modules = array('views_ui', 'tour', 'language', 'locale'); protected function setUp() { parent::setUp(); - $this->adminUser = $this->drupalCreateUser(array('administer views', 'access tour')); + $this->adminUser = $this->drupalCreateUser(array('administer views', 'access tour', 'administer languages', 'translate interface', 'access administration pages')); $this->drupalLogin($this->adminUser); } @@ -50,4 +51,77 @@ public function testViewsUiTourTips() { $this->assertTourTips(); } + /** + * Tests views_ui tour tip availability in a different language. + */ + public function testViewsUiTourTipsTranslated() { + $langcode = 'nl'; + + // Enable import of translations. By default this is disabled for automated + // tests. + $this->config('locale.settings') + ->set('translation.import_enabled', TRUE) + ->save(); + + // Add Dutch language programmatically. + ConfigurableLanguage::createFromLangcode($langcode)->save(); + // Import a .po file. + $this->importPoFile($this->getPoFile(), array( + 'langcode' => $langcode, + )); + + // Create a basic view that shows all content, with a page and a block + // display. + $view['label'] = $this->randomMachineName(16); + $view['id'] = strtolower($this->randomMachineName(16)); + $view['page[create]'] = 1; + $view['page[path]'] = $this->randomMachineName(16); + // Load the page in dutch. + $this->drupalPostForm($langcode . '/admin/structure/views/add', $view, t('Save and edit')); + $this->assertTourTips(); + } + + /** + * Helper function: import a standalone .po file in a given language. + * + * @param string $contents + * Contents of the .po file to import. + * @param array $options + * (optional) Additional options to pass to the translation import form. + */ + public function importPoFile($contents, array $options = array()) { + $name = tempnam('temporary://', "po_") . '.po'; + file_put_contents($name, $contents); + $options['files[file]'] = $name; + $this->drupalPostForm('admin/config/regional/translate/import', $options, t('Import')); + drupal_unlink($name); + } + + /** + * Helper function that returns a proper .po file. + */ + public function getPoFile() { + return <<< EOF +msgid "" +msgstr "" +"Project-Id-Version: Drupal 8\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\\n" + +msgid "Format" +msgstr "Formaat" + +msgid "Fields" +msgstr "Velden" + +msgid "Sort criteria" +msgstr "Sorteercriteria" + +msgid "Filter criteria" +msgstr "Filtercriteria" +EOF; + } + } diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index cdacd9c..4933a3f 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -556,7 +556,7 @@ public function getDisplayDetails($view, $display) { $build['columns'][$column][$id] = $bucket['build']; $build['columns'][$column][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket'; $build['columns'][$column][$id]['#title'] = !empty($bucket['title']) ? $bucket['title'] : ''; - $build['columns'][$column][$id]['#name'] = !empty($bucket['title']) ? $bucket['title'] : $id; + $build['columns'][$column][$id]['#name'] = $id; } } @@ -932,7 +932,8 @@ public function getFormBucket(ViewUI $view, $type, $display) { $build['#overridden'] = FALSE; $build['#defaulted'] = FALSE; - $build['#name'] = $build['#title'] = $types[$type]['title']; + $build['#name'] = $type; + $build['#title'] = $types[$type]['title']; $rearrange_url = Url::fromRoute('views_ui.form_rearrange', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id'], 'type' => $type]); $class = 'icon compact rearrange';