Issue #3039829 by gease, seanB, alexpott, starshaped, phenaproxima, Wim Leers, lauriii, andrewmacpherson, HeikkiY, mcannon: Remove link to media item from media library view

merge-requests/1119/head
effulgentsia 2019-07-03 12:28:52 -07:00
parent da6392f878
commit 7da933bafc
8 changed files with 761 additions and 54 deletions

View File

@ -414,9 +414,288 @@ display:
weight: 5
context: '0'
menu_name: admin
fields:
media_bulk_form:
id: media_bulk_form
table: media
field: media_bulk_form
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: js-click-to-select-checkbox
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
action_title: Action
include_exclude: exclude
selected_actions: { }
entity_type: media
plugin_id: bulk_form
name:
id: name
table: media_field_data
field: name
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: media
entity_field: name
plugin_id: field
edit_media:
id: edit_media
table: media
field: edit_media
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: true
text: 'Edit {{ name }}'
make_link: true
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: 'Edit {{ name }}'
rel: ''
link_class: media-library-item__edit
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: '0'
element_wrapper_class: ''
element_default_classes: false
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: 'Edit'
output_url_as_text: false
absolute: false
entity_type: media
plugin_id: entity_link_edit
delete_media:
id: delete_media
table: media
field: delete_media
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: true
text: 'Delete {{ name }}'
make_link: true
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: 'Delete {{ name }}'
rel: ''
link_class: media-library-item__remove
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: '0'
element_wrapper_class: ''
element_default_classes: false
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: 'Delete'
output_url_as_text: false
absolute: false
entity_type: media
plugin_id: entity_link_delete
rendered_entity:
id: rendered_entity
table: media
field: rendered_entity
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: media-library-item__content
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
view_mode: media_library
entity_type: media
plugin_id: rendered_entity
defaults:
fields: false
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- url.query_args

View File

@ -51,22 +51,25 @@
.media-library-item .js-click-to-select-checkbox {
position: absolute;
z-index: 1;
top: 5px;
right: 5px; /* LTR */
top: 16px;
left: 16px; /* LTR */
display: block;
}
[dir="rtl"] .media-library-item .js-click-to-select-checkbox {
right: 0;
left: 5px;
right: 16px;
left: auto;
}
.media-library-item__status {
position: absolute;
top: 10px;
left: 2px;
top: 40px;
left: 5px; /* LTR */
pointer-events: none;
}
[dir="rtl"] .media-library-item__status {
right: 5px;
left: auto;
}
.media-library-select-all {
flex-basis: 100%;
@ -85,13 +88,6 @@
cursor: move;
}
/* @todo Remove or re-work in https://www.drupal.org/node/2985168 */
.media-library-widget .media-library-item__name a,
.media-library-view--widget .media-library-item__name a,
.media-library-add-form__selected-media .media-library-item__name a {
pointer-events: none;
}
.media-library-widget-modal .ui-dialog-buttonpane {
display: flex;
align-items: center;
@ -106,3 +102,8 @@
flex-basis: 100%;
}
}
/* @todo Remove in https://www.drupal.org/project/drupal/issues/3064914 */
.views-live-preview .media-library-view div.views-row + div.views-row {
margin-top: 0;
}

View File

@ -318,6 +318,7 @@
height: calc(100% - 16px);
content: "";
transition: border-color 0.2s, color 0.2s, background 0.2s;
pointer-events: none;
border: 1px solid #dbdbdb;
}
@ -404,8 +405,8 @@
}
.media-library-item--grid .js-click-to-select-checkbox input {
width: 30px;
height: 30px;
width: 20px;
height: 20px;
}
.media-library-item--grid .js-click-to-select-checkbox .form-item {
@ -446,27 +447,20 @@
font-size: 14px;
}
.media-library-item__name a {
.media-library-item__name {
display: block;
overflow: hidden;
margin: 2px;
white-space: nowrap;
text-decoration: underline;
text-overflow: ellipsis;
}
.media-library-item__attributes:hover .media-library-item__name a,
.media-library-item__name a:focus,
.media-library-item--grid.is-focus .media-library-item__name a,
.media-library-item--grid.checked .media-library-item__name a {
.media-library-item__attributes:hover .media-library-item__name,
.media-library-item--grid.is-focus .media-library-item__name,
.media-library-item--grid.checked .media-library-item__name {
white-space: normal;
}
.media-library-item__name a:focus {
margin: 0;
border: 2px solid;
}
.media-library-item__type {
color: #696969;
font-size: 12px;
@ -497,7 +491,11 @@
.media-library-widget__toggle-weight {
position: absolute;
top: 5px;
right: 5px;
right: 5px; /* LTR */
}
[dir="rtl"] .media-library-widget__toggle-weight {
right: auto;
left: 5px;
}
/* Add negative margin for flex grid. */
@ -510,7 +508,15 @@
margin: 0.75em;
}
/* Media library widget remove button styles. */
/**
* Media library widget edit and delete button styles.
*
* We have to override the .button styles since buttons make heavy use of
* background and border property changes.
*/
.media-library-item__edit,
.media-library-item__edit:hover,
.media-library-item__edit:focus,
.media-library-item__remove,
.media-library-item__remove:hover,
.media-library-item__remove:focus,
@ -523,20 +529,52 @@
position: absolute;
z-index: 1;
top: 10px;
right: 10px;
width: 24px;
height: 24px;
overflow: hidden;
width: 21px;
height: 21px;
margin: 5px;
padding: 0;
transition: 0.2s border-color;
color: transparent;
border: 2px solid #ccc;
border-radius: 20px;
background: url("../../../misc/icons/787878/ex.svg") #fff center no-repeat;
background-size: 16px 16px;
background-size: 13px;
text-shadow: none;
font-size: 0;
}
.media-library-item__edit {
right: 40px; /* LTR */
}
[dir="rtl"] .media-library-item__edit {
right: auto;
left: 40px;
}
.media-library-item__remove {
right: 10px; /* LTR */
}
[dir="rtl"] .media-library-item__remove {
right: auto;
left: 10px;
}
.media-library-item__edit {
background: url("../../../misc/icons/787878/pencil.svg") #fff center no-repeat;
background-size: 13px;
}
.media-library-item__remove,
.media-library-item__remove.button,
.media-library-item__remove.button:first-child,
.media-library-item__remove.button:disabled,
.media-library-item__remove.button:disabled:active,
.media-library-item__remove.button:hover,
.media-library-item__remove.button:focus {
background: url("../../../misc/icons/787878/ex.svg") #fff center no-repeat;
background-size: 13px;
}
.media-library-item__edit:hover,
.media-library-item__edit:focus,
.media-library-item__remove:hover,
.media-library-item__remove:focus,
.media-library-item__remove.button:hover,
@ -655,11 +693,3 @@
[dir="rtl"] .media-library-add-form__remove-button.button:hover {
background-position: left 2px;
}
/* @todo Remove or re-work in https://www.drupal.org/node/2985168 */
.media-library-widget .media-library-item__name a,
.media-library-view--widget .media-library-item__name a,
.media-library-add-form__selected-media .media-library-item__name a {
text-decoration: none;
color: black;
}

View File

@ -218,3 +218,218 @@ function media_library_update_8702() {
$view->save(TRUE);
}
}
/**
* Add edit and delete button to media library view page display.
*/
function media_library_update_8703() {
$view = \Drupal::configFactory()->getEditable('views.view.media_library');
if (!$view->isNew() && $view->get('display.page')) {
// Fetch the fields from the page display, if the fields are not yet
// overridden, get the fields from the default display.
$fields = $view->get('display.page.display_options.fields');
if (!$fields) {
$fields = $view->get('display.default.display_options.fields');
// Override the fields for the page display.
$view->set('display.page.display_options.defaults.fields', FALSE);
}
// Check if the name field already exists and add if it doesn't.
if (!isset($fields['name'])) {
$fields['name'] = [
'id' => 'name',
'table' => 'media_field_data',
'field' => 'name',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'label' => '',
'exclude' => TRUE,
'alter' => [
'alter_text' => FALSE,
'text' => '',
'make_link' => FALSE,
'path' => '',
'absolute' => FALSE,
'external' => FALSE,
'replace_spaces' => FALSE,
'path_case' => 'none',
'trim_whitespace' => FALSE,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => FALSE,
'max_length' => 0,
'word_boundary' => TRUE,
'ellipsis' => TRUE,
'more_link' => FALSE,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => FALSE,
'trim' => FALSE,
'preserve_tags' => '',
'html' => FALSE,
],
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => TRUE,
'empty' => '',
'hide_empty' => FALSE,
'empty_zero' => FALSE,
'hide_alter_empty' => TRUE,
'click_sort_column' => 'value',
'type' => 'string',
'settings' => [
'link_to_entity' => FALSE,
],
'group_column' => 'value',
'group_columns' => [],
'group_rows' => TRUE,
'delta_limit' => 0,
'delta_offset' => 0,
'delta_reversed' => FALSE,
'delta_first_last' => FALSE,
'multi_type' => 'separator',
'separator' => ', ',
'field_api_classes' => FALSE,
'entity_type' => 'media',
'entity_field' => 'name',
'plugin_id' => 'field',
];
}
// Check if the edit link field already exists and add if it doesn't.
if (!isset($fields['edit_media'])) {
$fields['edit_media'] = [
'id' => 'edit_media',
'table' => 'media',
'field' => 'edit_media',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'label' => '',
'exclude' => FALSE,
'alter' => [
'alter_text' => TRUE,
'text' => 'Edit {{ name }}',
'make_link' => TRUE,
'path' => '',
'absolute' => FALSE,
'external' => FALSE,
'replace_spaces' => FALSE,
'path_case' => 'none',
'trim_whitespace' => FALSE,
'alt' => 'Edit {{ name }}',
'rel' => '',
'link_class' => 'media-library-item__edit',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => FALSE,
'max_length' => 0,
'word_boundary' => TRUE,
'ellipsis' => TRUE,
'more_link' => FALSE,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => FALSE,
'trim' => FALSE,
'preserve_tags' => '',
'html' => FALSE,
],
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '0',
'element_wrapper_class' => '',
'element_default_classes' => FALSE,
'empty' => '',
'hide_empty' => FALSE,
'empty_zero' => FALSE,
'hide_alter_empty' => TRUE,
'text' => 'Edit',
'output_url_as_text' => FALSE,
'absolute' => FALSE,
'entity_type' => 'media',
'plugin_id' => 'entity_link_edit',
];
}
// Check if the delete link field already exists and add if it doesn't.
if (!isset($fields['delete_media'])) {
$fields['delete_media'] = [
'id' => 'delete_media',
'table' => 'media',
'field' => 'delete_media',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'label' => '',
'exclude' => FALSE,
'alter' => [
'alter_text' => TRUE,
'text' => 'Delete {{ name }}',
'make_link' => TRUE,
'path' => '',
'absolute' => FALSE,
'external' => FALSE,
'replace_spaces' => FALSE,
'path_case' => 'none',
'trim_whitespace' => FALSE,
'alt' => 'Delete {{ name }}',
'rel' => '',
'link_class' => 'media-library-item__remove',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => FALSE,
'max_length' => 0,
'word_boundary' => TRUE,
'ellipsis' => TRUE,
'more_link' => FALSE,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => FALSE,
'trim' => FALSE,
'preserve_tags' => '',
'html' => FALSE,
],
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '0',
'element_wrapper_class' => '',
'element_default_classes' => FALSE,
'empty' => '',
'hide_empty' => FALSE,
'empty_zero' => FALSE,
'hide_alter_empty' => TRUE,
'text' => 'Delete',
'output_url_as_text' => FALSE,
'absolute' => FALSE,
'entity_type' => 'media',
'plugin_id' => 'entity_link_delete',
];
}
// Move the rendered entity field to the last position for accessibility.
$rendered_entity = $fields['rendered_entity'];
unset($fields['rendered_entity']);
$fields['rendered_entity'] = $rendered_entity;
$view->set('display.page.display_options.fields', $fields)
->save(TRUE);
}
}

View File

@ -43,7 +43,7 @@
{% endif %}
<div{{ metadata_attributes }}>
<div class="media-library-item__name">
<a href="{{ url }}" rel="bookmark">{{ name }}</a>
{{ name }}
</div>
</div>
{% endif %}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,52 @@
<?php
namespace Drupal\Tests\media_library\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests the media library module updates for the view page display links.
*
* @group media_library
* @group legacy
*/
class MediaLibraryUpdateViewPageDisplayEditDeleteLinkTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
__DIR__ . '/../../../../../media/tests/fixtures/update/drupal-8.4.0-media_installed.php',
__DIR__ . '/../../../fixtures/update/drupal-8.7.2-media_library_installed.php',
];
}
/**
* Tests that the media library view config is updated.
*
* @see media_library_update_8703()
*/
public function testMediaLibraryViewsConfig() {
$config = $this->config('views.view.media_library');
$this->assertNull($config->get('display.page.display_options.defaults.fields'));
$this->assertNull($config->get('display.page.display_options.fields.name'));
$this->assertNull($config->get('display.page.display_options.fields.edit_media'));
$this->assertNull($config->get('display.page.display_options.fields.delete_media'));
$this->runUpdates();
$config = $this->config('views.view.media_library');
$this->assertFalse($config->get('display.page.display_options.defaults.fields'));
$this->assertSame('field', $config->get('display.page.display_options.fields.name.plugin_id'));
$this->assertSame('name', $config->get('display.page.display_options.fields.name.entity_field'));
$this->assertSame('entity_link_edit', $config->get('display.page.display_options.fields.edit_media.plugin_id'));
$this->assertSame('entity_link_delete', $config->get('display.page.display_options.fields.delete_media.plugin_id'));
// Check if the rendered entity is last in the field.
$fields = $config->get('display.page.display_options.fields');
end($fields);
$this->assertSame('rendered_entity', key($fields));
}
}

View File

@ -78,6 +78,7 @@ class MediaLibraryTest extends WebDriverTestBase {
'edit own basic_page content',
'create basic_page content',
'create media',
'update any media',
'delete any media',
'view media',
'administer node form display',
@ -106,6 +107,12 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->pageTextContains('Dog');
$assert_session->pageTextContains('Turtle');
// Verify that the media name does not contain a link.
$assert_session->elementNotExists('css', '.media-library-item__name a');
// Verify that there are links to edit and delete media items.
$assert_session->elementExists('css', '.media-library-item .media-library-item__edit');
$assert_session->elementExists('css', '.media-library-item .media-library-item__remove');
// Test that users can filter by type.
$page->selectFieldOption('Media type', 'Type One');
$page->pressButton('Apply filters');
@ -429,7 +436,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Add or select media');
$this->assertFalse($assert_session->elementExists('css', '.media-library-select-all')->isVisible());
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert that the media type menu is available when more than 1 type is
// configured for the field.
@ -440,7 +447,16 @@ class MediaLibraryTest extends WebDriverTestBase {
$this->assertFalse($menu->hasLink('Type Two'));
$this->assertTrue($menu->hasLink('Type Three'));
$this->assertFalse($menu->hasLink('Type Four'));
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
$assert_session->assertWaitOnAjaxRequest();
// Assert that there are no links in the media library view.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();
$assert_session->assertWaitOnAjaxRequest();
$assert_session->elementNotExists('css', '.media-library-item__name a');
$assert_session->elementNotExists('css', '.media-library-view .media-library-item__edit');
$assert_session->elementNotExists('css', '.media-library-view .media-library-item__remove');
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
$assert_session->assertWaitOnAjaxRequest();
// Assert that the media type menu is available when the target_bundles
@ -454,7 +470,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$this->assertTrue($menu->hasLink('Type Three'));
$this->assertTrue($menu->hasLink('Type Four'));
$this->assertTrue($menu->hasLink('Type Five'));
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert that the media type menu is not available when only 1 type is
// configured for the field.
@ -469,7 +485,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->hiddenFieldValueEquals('media-library-modal-selection', '4');
$assert_session->elementTextContains('css', '.media-library-selected-count', '1 of 1 item selected');
$assert_session->elementNotExists('css', '.media-library-menu');
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert the menu links can be sorted through the widget configuration.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_twin_media"]')->click();
@ -499,7 +515,7 @@ class MediaLibraryTest extends WebDriverTestBase {
return $link->getText();
}, $page->findAll('css', '.media-library-menu a'));
$this->assertSame($link_titles, ['Show Type One media (selected)', 'Show Type Three media', 'Show Type Four media', 'Show Type Two media']);
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert the announcements for media type navigation in the media library.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();
@ -514,7 +530,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->elementExists('named', ['link', 'Type Three'])->keyPress(32);
$assert_session->assertWaitOnAjaxRequest();
$this->assertNotEmpty($assert_session->waitForText('Showing Type Three media.'));
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert media is only visible on the tab for the related media type.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();
@ -529,7 +545,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->pageTextNotContains('Dog');
$assert_session->pageTextNotContains('Bear');
$assert_session->pageTextNotContains('Turtle');
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert the exposed name filter of the view.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();
@ -545,7 +561,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->assertWaitOnAjaxRequest();
$assert_session->pageTextContains('Dog');
$assert_session->pageTextContains('Bear');
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert the media library contains header links to switch between the grid
// and table display.
@ -618,6 +634,11 @@ class MediaLibraryTest extends WebDriverTestBase {
$assert_session->assertWaitOnAjaxRequest();
// Assert the focus is set back on the open button of the media field.
$this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper .js-media-library-open-button").is(":focus")');
// Assert the weight field can be focused via a mouse click.
$assert_session->elementExists('named', ['button', 'Show media item weights'])->click();
$assert_session->elementExists('css', '#field_twin_media-media-library-wrapper .media-library-item__weight')->click();
$assert_session->elementExists('css', '#field_twin_media-media-library-wrapper .js-media-library-widget-toggle-weight')->click();
// Remove the selected item.
$assert_session->elementAttributeContains('css', '.media-library-item__remove', 'aria-label', 'Remove Dog');
$assert_session->elementExists('css', '.media-library-item__remove')->click();
$this->assertNotEmpty($assert_session->waitForText('Removed Dog.'));
@ -791,7 +812,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$this->assertFalse($checkboxes[2]->isChecked());
$this->assertFalse($checkboxes[3]->isChecked());
// Close the dialog, reopen it and assert not is selected again.
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();
$assert_session->assertWaitOnAjaxRequest();
$checkboxes = $page->findAll('css', '.media-library-view .js-click-to-select-checkbox input');
@ -800,7 +821,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$this->assertFalse($checkboxes[1]->isChecked());
$this->assertFalse($checkboxes[2]->isChecked());
$this->assertFalse($checkboxes[3]->isChecked());
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Finally, save the form.
$assert_session->elementExists('css', '.js-media-library-widget-toggle-weight')->click();
@ -1217,7 +1238,7 @@ class MediaLibraryTest extends WebDriverTestBase {
$this->assertJsCondition('jQuery("#media-library-add-form-wrapper :tabbable").is(":focus")');
$assert_session->elementNotExists('css', '.media-library-add-form__fields');
$assert_session->elementExists('css', '.media-library-menu');
$page->find('css', '.ui-dialog-titlebar-close')->click();
$assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();
// Assert uploading multiple files.
$assert_session->elementExists('css', '.media-library-open-button[name^="field_unlimited_media"]')->click();