From 615de48290bc125aa55a704f9918ed14c26e9e19 Mon Sep 17 00:00:00 2001 From: Brian Canini <canini.16@osu.edu> Date: Wed, 4 Mar 2020 11:00:49 -0500 Subject: [PATCH] Updating drupal/media_entity_browser (2.0.0-alpha1 => 2.0.0-alpha2) --- composer.json | 4 +- composer.lock | 96 ++++- vendor/composer/installed.json | 97 ++++- web/modules/media_entity_browser/README.txt | 42 ++ ...y_browser.browser.media_entity_browser.yml | 25 +- ...ser.browser.media_entity_browser_modal.yml | 41 ++ .../views.view.media_entity_browser.yml | 8 +- .../css/media_entity_browser.view.css | 34 +- .../media_entity_browser/images/check.svg | 1 + .../js/media_entity_browser.entity_embed.js | 30 -- .../js/media_entity_browser.view.js | 20 +- .../media_entity_browser.info.yml | 14 +- .../media_entity_browser.install | 28 ++ .../media_entity_browser.libraries.yml | 7 - .../media_entity_browser.module | 47 --- .../README.txt | 55 +++ ...ser.media_entity_browser_media_library.yml | 41 ++ ...iew.media_entity_browser_media_library.yml | 399 ++++++++++++++++++ ...edia_entity_browser_media_library.view.css | 20 + ...media_entity_browser_media_library.view.js | 38 ++ ...edia_entity_browser_media_library.info.yml | 33 ++ ...entity_browser_media_library.libraries.yml | 9 + .../media_entity_browser_media_library.module | 31 ++ .../MediaEntityBrowserMediaLibraryTest.php | 67 +++ .../MediaEntityBrowserTest.php | 21 +- 25 files changed, 1054 insertions(+), 154 deletions(-) create mode 100644 web/modules/media_entity_browser/README.txt create mode 100644 web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser_modal.yml create mode 100644 web/modules/media_entity_browser/images/check.svg delete mode 100644 web/modules/media_entity_browser/js/media_entity_browser.entity_embed.js create mode 100644 web/modules/media_entity_browser/media_entity_browser.install create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/README.txt create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/config/install/entity_browser.browser.media_entity_browser_media_library.yml create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/config/install/views.view.media_entity_browser_media_library.yml create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/css/media_entity_browser_media_library.view.css create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/js/media_entity_browser_media_library.view.js create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.info.yml create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.libraries.yml create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.module create mode 100644 web/modules/media_entity_browser/media_entity_browser_media_library/tests/src/FunctionalJavascript/MediaEntityBrowserMediaLibraryTest.php diff --git a/composer.json b/composer.json index 8de26d8ad5..6003ec4064 100644 --- a/composer.json +++ b/composer.json @@ -136,7 +136,7 @@ "drupal/linkit": "5.0-beta10", "drupal/magnific_popup": "1.3", "drupal/mathjax": "^2.7", - "drupal/media_entity_browser": "2.0-alpha1", + "drupal/media_entity_browser": "2.0-alpha2", "drupal/media_entity_twitter": "2.0-alpha2", "drupal/menu_block": "1.4", "drupal/menu_block_title": "^1.1", @@ -316,4 +316,4 @@ "php": "7.0.8" } } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index e304ef53bb..053cd7fab5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9cebdfa2dca9a89bb18005ed1f9db499", + "content-hash": "4e17e4d19566ec34a9555a0eafcdb2f7", "packages": [ { "name": "alchemy/zippy", @@ -4326,6 +4326,76 @@ "irc": "irc://irc.freenode.org/drupal-contribute" } }, + { + "name": "drupal/entity_browser_entity_form", + "version": "1.4.0", + "require": { + "drupal/core": "~8.0", + "drupal/entity_browser": "self.version", + "drupal/inline_entity_form": "*" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + }, + "drupal": { + "version": "8.x-1.4", + "datestamp": "1528140780", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Berdir", + "homepage": "https://www.drupal.org/user/214652" + }, + { + "name": "Dave Reid", + "homepage": "https://www.drupal.org/user/53892" + }, + { + "name": "Devin Carlson", + "homepage": "https://www.drupal.org/user/290182" + }, + { + "name": "Drupal Media Team", + "homepage": "https://www.drupal.org/user/3260690" + }, + { + "name": "Primsi", + "homepage": "https://www.drupal.org/user/282629" + }, + { + "name": "marcingy", + "homepage": "https://www.drupal.org/user/77320" + }, + { + "name": "oknate", + "homepage": "https://www.drupal.org/user/471638" + }, + { + "name": "samuel.mortenson", + "homepage": "https://www.drupal.org/user/2582268" + }, + { + "name": "slashrsm", + "homepage": "https://www.drupal.org/user/744628" + } + ], + "description": "Entity browser inline entity form integration.", + "homepage": "https://www.drupal.org/project/entity_browser", + "support": { + "source": "https://git.drupalcode.org/project/entity_browser" + } + }, { "name": "drupal/entity_clone", "version": "1.0.0-beta3", @@ -5486,25 +5556,29 @@ }, { "name": "drupal/media_entity_browser", - "version": "2.0.0-alpha1", + "version": "2.0.0-alpha2", "source": { "type": "git", "url": "https://git.drupalcode.org/project/media_entity_browser.git", - "reference": "8.x-2.0-alpha1" + "reference": "8.x-2.0-alpha2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/media_entity_browser-8.x-2.0-alpha1.zip", - "reference": "8.x-2.0-alpha1", - "shasum": "d0de87059165dc7cda4ed1832b13c5846be9386b" + "url": "https://ftp.drupal.org/files/projects/media_entity_browser-8.x-2.0-alpha2.zip", + "reference": "8.x-2.0-alpha2", + "shasum": "41fea535c0770caa2fc4eca7216bbafb796b4d17" }, "require": { "drupal/core": "*", - "drupal/entity_browser": "*" + "drupal/entity_browser": "*", + "drupal/entity_browser_entity_form": "*", + "drupal/inline_entity_form": "*" }, "require-dev": { "drupal/ctools": "*", "drupal/entity_browser": "^2", + "drupal/entity_browser_entity_form": "^2", + "drupal/inline_entity_form": "^1", "drupal/video_embed_field": "^2" }, "type": "drupal-module", @@ -5513,8 +5587,8 @@ "dev-2.x": "2.x-dev" }, "drupal": { - "version": "8.x-2.0-alpha1", - "datestamp": "1510532885", + "version": "8.x-2.0-alpha2", + "datestamp": "1558337585", "security-coverage": { "status": "not-covered", "message": "Alpha releases are not covered by Drupal security advisories." @@ -5543,10 +5617,10 @@ "homepage": "https://www.drupal.org/user/1068918" } ], - "description": "This module provides an Entity Browser for Media Entity.", + "description": "This module provides an Entity Browser for Media.", "homepage": "https://www.drupal.org/project/media_entity_browser", "support": { - "source": "http://cgit.drupalcode.org/media_entity_browser" + "source": "https://git.drupalcode.org/project/media_entity_browser" } }, { diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 899a4506a1..f8412f66f8 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -4456,6 +4456,77 @@ "irc": "irc://irc.freenode.org/drupal-contribute" } }, + { + "name": "drupal/entity_browser_entity_form", + "version": "1.4.0", + "version_normalized": "1.4.0.0", + "require": { + "drupal/core": "~8.0", + "drupal/entity_browser": "self.version", + "drupal/inline_entity_form": "*" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + }, + "drupal": { + "version": "8.x-1.4", + "datestamp": "1528140780", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Berdir", + "homepage": "https://www.drupal.org/user/214652" + }, + { + "name": "Dave Reid", + "homepage": "https://www.drupal.org/user/53892" + }, + { + "name": "Devin Carlson", + "homepage": "https://www.drupal.org/user/290182" + }, + { + "name": "Drupal Media Team", + "homepage": "https://www.drupal.org/user/3260690" + }, + { + "name": "Primsi", + "homepage": "https://www.drupal.org/user/282629" + }, + { + "name": "marcingy", + "homepage": "https://www.drupal.org/user/77320" + }, + { + "name": "oknate", + "homepage": "https://www.drupal.org/user/471638" + }, + { + "name": "samuel.mortenson", + "homepage": "https://www.drupal.org/user/2582268" + }, + { + "name": "slashrsm", + "homepage": "https://www.drupal.org/user/744628" + } + ], + "description": "Entity browser inline entity form integration.", + "homepage": "https://www.drupal.org/project/entity_browser", + "support": { + "source": "https://git.drupalcode.org/project/entity_browser" + } + }, { "name": "drupal/entity_clone", "version": "1.0.0-beta3", @@ -5656,26 +5727,30 @@ }, { "name": "drupal/media_entity_browser", - "version": "2.0.0-alpha1", - "version_normalized": "2.0.0.0-alpha1", + "version": "2.0.0-alpha2", + "version_normalized": "2.0.0.0-alpha2", "source": { "type": "git", "url": "https://git.drupalcode.org/project/media_entity_browser.git", - "reference": "8.x-2.0-alpha1" + "reference": "8.x-2.0-alpha2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/media_entity_browser-8.x-2.0-alpha1.zip", - "reference": "8.x-2.0-alpha1", - "shasum": "d0de87059165dc7cda4ed1832b13c5846be9386b" + "url": "https://ftp.drupal.org/files/projects/media_entity_browser-8.x-2.0-alpha2.zip", + "reference": "8.x-2.0-alpha2", + "shasum": "41fea535c0770caa2fc4eca7216bbafb796b4d17" }, "require": { "drupal/core": "*", - "drupal/entity_browser": "*" + "drupal/entity_browser": "*", + "drupal/entity_browser_entity_form": "*", + "drupal/inline_entity_form": "*" }, "require-dev": { "drupal/ctools": "*", "drupal/entity_browser": "^2", + "drupal/entity_browser_entity_form": "^2", + "drupal/inline_entity_form": "^1", "drupal/video_embed_field": "^2" }, "type": "drupal-module", @@ -5684,8 +5759,8 @@ "dev-2.x": "2.x-dev" }, "drupal": { - "version": "8.x-2.0-alpha1", - "datestamp": "1510532885", + "version": "8.x-2.0-alpha2", + "datestamp": "1558337585", "security-coverage": { "status": "not-covered", "message": "Alpha releases are not covered by Drupal security advisories." @@ -5715,10 +5790,10 @@ "homepage": "https://www.drupal.org/user/1068918" } ], - "description": "This module provides an Entity Browser for Media Entity.", + "description": "This module provides an Entity Browser for Media.", "homepage": "https://www.drupal.org/project/media_entity_browser", "support": { - "source": "http://cgit.drupalcode.org/media_entity_browser" + "source": "https://git.drupalcode.org/project/media_entity_browser" } }, { diff --git a/web/modules/media_entity_browser/README.txt b/web/modules/media_entity_browser/README.txt new file mode 100644 index 0000000000..bf477753dc --- /dev/null +++ b/web/modules/media_entity_browser/README.txt @@ -0,0 +1,42 @@ +# Media Entity Browser +=== +Provides a default Entity Browser for Media types, inspired by +File Entity Browser. + +## Requirements + +- Inline Entity Form +- Entity Browser +- Entity Embed +- Media + +## Installation + +- Download Inline Entity Form from Drupal.org +- Download Entity Embed from Drupal.org +- Download Entity Browser from Drupal.org +- Download Media Entity Browser from Drupal.org +- Enable core Media +- Enable Media Entity Browser + +## Usage + +This module is largely a set of configuration files to provide a basic Entity +Browser for Media - with some custom styling and interaction for the Browser +view. As such the documentation for Entity Browser and Media in general will +explain how to customise the installed Media Entity Browsers. + +https://drupal-media.gitbooks.io/drupal8-guide/content/modules/entity_browser/intro.html + +Once installed, changes to the configuration are managed outside of this module. + +### Configuration + +On installation the Browser isn't visible. You need to add it to an Entity +Embed button for use though the WYSIWYG or to an Media Entity Reference Fields +with the Inline Entity Form - Complex field widget. + +- For WYSIWYG Entity Embedding use the iFrame Browser +(/admin/config/content/entity_browser/media_entity_browser). +- For Media Entity Reference Fields use the Modal Browser +(/admin/config/content/entity_browser/media_entity_browser). diff --git a/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser.yml b/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser.yml index 6e3d5a0f4b..9da1815371 100644 --- a/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser.yml +++ b/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser.yml @@ -4,15 +4,16 @@ dependencies: config: - views.view.media_entity_browser module: + - entity_browser_entity_form - views name: media_entity_browser label: 'Media Entity Browser' display: iframe display_configuration: width: '1070' - height: '840' - link_text: 'Select entities' - auto_open: false + height: '500' + link_text: 'Select media' + auto_open: true selection_display: no_display selection_display_configuration: { } widget_selector: tabs @@ -21,8 +22,20 @@ widgets: 6586703a-6976-4124-8a49-cbb07ceaa3b1: settings: view: media_entity_browser - view_display: entity_browser_1 + view_display: media_browser_all + submit_text: 'Select media' + auto_select: false uuid: 6586703a-6976-4124-8a49-cbb07ceaa3b1 - weight: 1 - label: view + weight: -9 + label: 'Choose existing media' id: view + ecb3940b-e53b-4bc5-acb5-930d8780ea2f: + settings: + entity_type: media + bundle: image + form_mode: default + submit_text: 'Save image' + uuid: ecb3940b-e53b-4bc5-acb5-930d8780ea2f + weight: -10 + label: 'Upload new image' + id: entity_form diff --git a/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser_modal.yml b/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser_modal.yml new file mode 100644 index 0000000000..0f34805f04 --- /dev/null +++ b/web/modules/media_entity_browser/config/install/entity_browser.browser.media_entity_browser_modal.yml @@ -0,0 +1,41 @@ +langcode: en +status: true +dependencies: + config: + - views.view.media_entity_browser + module: + - entity_browser_entity_form + - views +name: media_entity_browser_modal +label: 'Media Entity Browser (Modal)' +display: modal +display_configuration: + width: '1070' + height: '500' + link_text: 'Select media' + auto_open: true +selection_display: no_display +selection_display_configuration: { } +widget_selector: tabs +widget_selector_configuration: { } +widgets: + fc729026-c85f-4561-acd5-38d4082b69fb: + settings: + view: media_entity_browser + view_display: media_browser_all + submit_text: 'Select media' + auto_select: false + uuid: fc729026-c85f-4561-acd5-38d4082b69fb + weight: -9 + label: 'Choose existing media' + id: view + 9769d4e4-1f9c-4313-8b01-fe8cff8aa5a1: + settings: + entity_type: media + bundle: image + form_mode: default + submit_text: 'Save image' + uuid: 9769d4e4-1f9c-4313-8b01-fe8cff8aa5a1 + weight: -10 + label: 'Upload new image' + id: entity_form diff --git a/web/modules/media_entity_browser/config/install/views.view.media_entity_browser.yml b/web/modules/media_entity_browser/config/install/views.view.media_entity_browser.yml index 7c8702ec63..7e4d707f04 100644 --- a/web/modules/media_entity_browser/config/install/views.view.media_entity_browser.yml +++ b/web/modules/media_entity_browser/config/install/views.view.media_entity_browser.yml @@ -504,6 +504,8 @@ display: operator: AND groups: 1: AND + css_class: view-media-entity-browser-view + use_ajax: true cache_metadata: max-age: -1 contexts: @@ -513,10 +515,10 @@ display: - url.query_args - user.permissions tags: { } - entity_browser_1: + media_browser_all: display_plugin: entity_browser - id: entity_browser_1 - display_title: 'Entity browser' + id: media_browser_all + display_title: 'Media browser' position: 1 display_options: display_extenders: { } diff --git a/web/modules/media_entity_browser/css/media_entity_browser.view.css b/web/modules/media_entity_browser/css/media_entity_browser.view.css index 0b6da8a468..453d993b16 100644 --- a/web/modules/media_entity_browser/css/media_entity_browser.view.css +++ b/web/modules/media_entity_browser/css/media_entity_browser.view.css @@ -2,15 +2,15 @@ * @media-entity media_entity_browser.view.css */ -.view-media-entity-browser .pager { +.view-media-entity-browser-view .pager { padding: 20px; } -.view-media-entity-browser .view-content { +.view-media-entity-browser-view .view-content { overflow: hidden; } -.view-media-entity-browser .views-row { +.view-media-entity-browser-view .views-row { box-sizing: border-box; position: relative; width: 100%; @@ -21,33 +21,33 @@ } @media screen and (min-width:37.5em) { /* 600px */ - .view-media-entity-browser .views-row { + .view-media-entity-browser-view .views-row { width: 50%; float: left; } } @media screen and (min-width:62.5em) { /* 1000px */ - .view-media-entity-browser .views-row { + .view-media-entity-browser-view .views-row { width: 33.333%; } } -.view-media-entity-browser .views-row.checked { +.view-media-entity-browser-view .views-row.checked { border: 2px solid #37802f; } -.view-media-entity-browser .views-row img { +.view-media-entity-browser-view .views-row img { vertical-align: bottom; width: 100%; height: auto; } -.view-media-entity-browser .views-row img::selection { +.view-media-entity-browser-view .views-row img::selection { background: transparent; } -.view-media-entity-browser .views-row .views-field-entity-browser-select { +.view-media-entity-browser-view .views-row .views-field-entity-browser-select { position: absolute !important; height: 1px; width: 1px; @@ -55,20 +55,20 @@ clip: rect(1px, 1px, 1px, 1px); } -.view-media-entity-browser .views-row:after { +.view-media-entity-browser-view .views-row:after { content: " "; width: 100%; height: 100%; top: 0; left: 0; position: absolute; - background: transparent url("/core/misc/icons/73b355/check.svg") no-repeat center center; + background: transparent url("../images/check.svg") no-repeat center center; background-size: 0; -webkit-transition: all 0.2s; transition: all 0.2s; } -.view-media-entity-browser .views-row.checked:after { +.view-media-entity-browser-view .views-row.checked:after { background-size: 80px 80px; } @@ -112,13 +112,3 @@ input[type="submit"][name="filter"] { margin-left: 10px; margin-top: 30px; } - -.media-entity-browser-actions { - position: fixed; - bottom: 0; - z-index: 2; - padding: 10px; - width: 100%; - background: white; - border-top: 1px solid #b8b8b8; -} diff --git a/web/modules/media_entity_browser/images/check.svg b/web/modules/media_entity_browser/images/check.svg new file mode 100644 index 0000000000..566cbc4c8e --- /dev/null +++ b/web/modules/media_entity_browser/images/check.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#73b355"><path d="M6.464 13.676c-.194.194-.513.194-.707 0l-4.96-4.955c-.194-.193-.194-.513 0-.707l1.405-1.407c.194-.195.512-.195.707 0l2.849 2.848c.194.193.513.193.707 0l6.629-6.626c.195-.194.514-.194.707 0l1.404 1.404c.193.194.193.513 0 .707l-8.741 8.736z"/></svg> \ No newline at end of file diff --git a/web/modules/media_entity_browser/js/media_entity_browser.entity_embed.js b/web/modules/media_entity_browser/js/media_entity_browser.entity_embed.js deleted file mode 100644 index 4f72f7d35d..0000000000 --- a/web/modules/media_entity_browser/js/media_entity_browser.entity_embed.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file media_entity_browser.entity_embed.js - */ -(function ($, Drupal) { - - "use strict"; - - /** - * Registers behaviours related to Entity Embed integrations. - */ - Drupal.behaviors.MediaEntityBrowserEntityEmbed = { - attach: function (context) { - // Add an event handler that triggers a click inside the iFrame when our - // duped element is clicked. - $('.entity-browser-modal-submit').once('entity-browser-modal').click(function (e) { - $('.entity-embed-dialog iframe').contents().find('.is-entity-browser-submit').click(); - e.preventDefault(); - e.stopPropagation(); - }); - - // On iFrame load, hide the real nested "Select Files" button. - $('body').once('entity-browser-modal').on('entityBrowserIFrameAppend', function () { - $(this).find('.entity-embed-dialog iframe').load(function () { - $(this).contents().find('.is-entity-browser-submit').hide(); - }); - }); - } - }; - -}(jQuery, Drupal)); diff --git a/web/modules/media_entity_browser/js/media_entity_browser.view.js b/web/modules/media_entity_browser/js/media_entity_browser.view.js index 70e1f1783d..9365dc5f3f 100644 --- a/web/modules/media_entity_browser/js/media_entity_browser.view.js +++ b/web/modules/media_entity_browser/js/media_entity_browser.view.js @@ -7,16 +7,34 @@ "use strict"; + /** + * Update the class of a row based on the status of a checkbox. + * + * @param {object} $row + * @param {object} $input + */ + function updateClasses($row, $input) { + $row[$input.prop('checked') ? 'addClass' : 'removeClass']('checked'); + } + /** * Attaches the behavior of the media entity browser view. */ Drupal.behaviors.mediaEntityBrowserView = { attach: function (context, settings) { + // Run through each row to add the default classes. + $('.views-row', context).each(function() { + var $row = $(this); + var $input = $row.find('.views-field-entity-browser-select input'); + updateClasses($row, $input); + }); + + // Add a checked class when clicked. $('.views-row', context).once().click(function () { var $row = $(this); var $input = $row.find('.views-field-entity-browser-select input'); $input.prop('checked', !$input.prop('checked')); - $row[$input.prop('checked') ? 'addClass' : 'removeClass']('checked'); + updateClasses($row, $input); }); } }; diff --git a/web/modules/media_entity_browser/media_entity_browser.info.yml b/web/modules/media_entity_browser/media_entity_browser.info.yml index 254032fa91..4e92893b86 100644 --- a/web/modules/media_entity_browser/media_entity_browser.info.yml +++ b/web/modules/media_entity_browser/media_entity_browser.info.yml @@ -1,18 +1,22 @@ name: Media Entity Browser type: module -description: 'This module provides an Entity Browser for Media Entity.' +description: 'This module provides an Entity Browser for Media.' package: Media # core: '8.x' dependencies: + - inline_entity_form:inline_entity_form - entity_browser:entity_browser + - entity_browser:entity_browser_entity_form - drupal:media - drupal:views test_dependencies: + - inline_entity_form (>=8.x-1.x) - entity_browser (>=8.x-2.x) + - entity_browser:entity_browser_entity_form (>=8.x-2.x) + - video_embed_field:video_embed_field (>=8.x-2.x) - drupal:media (>=8.4) - - video_embed_field (>=8.x-2.x) - ctools:ctools # To export this config, make sure config_devel is installed, cache is rebuilt @@ -23,8 +27,8 @@ config_devel: - entity_browser.browser.media_entity_browser - embed.button.media_entity_embed -# Information added by Drupal.org packaging script on 2017-11-13 -version: '8.x-2.0-alpha1' +# Information added by Drupal.org packaging script on 2019-05-20 +version: '8.x-2.0-alpha2' core: '8.x' project: 'media_entity_browser' -datestamp: 1510532897 +datestamp: 1558337596 diff --git a/web/modules/media_entity_browser/media_entity_browser.install b/web/modules/media_entity_browser/media_entity_browser.install new file mode 100644 index 0000000000..3857c066e9 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser.install @@ -0,0 +1,28 @@ +<?php + +/** + * @file + * Install file for media entity browser module. + */ + +use Drupal\image\Entity\ImageStyle; + +/** + * Implements hook_uninstall(). + */ +function media_entity_browser_uninstall() { + $imageStyle = ImageStyle::load('media_entity_browser_thumbnail'); + if (!empty($imageStyle)) { + $imageStyle->delete(); + } +} + +/** + * Update default configuration for new Views CSS class. + */ +function media_entity_browser_update_8100() { + $config_factory = \Drupal::configFactory(); + $config = $config_factory->getEditable('views.view.media_entity_browser'); + $config->set('display.default.display_options.css_class', 'view-media-entity-browser-view'); + $config->save(); +} diff --git a/web/modules/media_entity_browser/media_entity_browser.libraries.yml b/web/modules/media_entity_browser/media_entity_browser.libraries.yml index 5dc2710ef6..0d98e98ebc 100644 --- a/web/modules/media_entity_browser/media_entity_browser.libraries.yml +++ b/web/modules/media_entity_browser/media_entity_browser.libraries.yml @@ -7,10 +7,3 @@ view: dependencies: - core/jquery - core/drupal - -entity_embed: - js: - js/media_entity_browser.entity_embed.js: {} - dependencies: - - core/jquery - - core/drupal diff --git a/web/modules/media_entity_browser/media_entity_browser.module b/web/modules/media_entity_browser/media_entity_browser.module index dbbe6a5af3..81f87a7272 100644 --- a/web/modules/media_entity_browser/media_entity_browser.module +++ b/web/modules/media_entity_browser/media_entity_browser.module @@ -5,8 +5,6 @@ * The module file for media_entity_browser. */ -use Drupal\Core\Form\FormStateInterface; - /** * Implements hook_preprocess_views_view(). */ @@ -15,48 +13,3 @@ function media_entity_browser_preprocess_views_view(&$variables) { $variables['view_array']['#attached']['library'][] = 'media_entity_browser/view'; } } - -/** - * Implements hook_form_alter(). - */ -function media_entity_browser_form_alter(&$form, FormStateInterface &$form_state, $form_id) { - // @todo, detect entity browsers specifically using the MEB. - if (strpos($form_id, 'entity_browser') === 0 && !empty($form['widget']['view'])) { - // Style the submit button. - $form['actions']['submit']['#value'] = t('Select Media'); - $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target'; - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - */ -function media_entity_browser_form_entity_embed_dialog_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { - // @todo, work around some issues in entity browser. - if ($embed_button = $form_state->get('embed_button')) { - $browser = $embed_button->getTypePlugin()->getConfigurationValue('entity_browser'); - // Check that we're using file_browser. @todo, check the browser by the view - // instead of hard-coding browser IDs. - if (in_array($browser, ['media_browser', 'media_entity_browser'])) { - // Override the first step of the form, if we're using media_browser. - if ($form['actions']['save_modal']['#ajax']['callback'] == '::submitSelectStep') { - // Add a library which handles our special "Select Media" button. - $form['#attached']['library'][] = 'media_entity_browser/entity_embed'; - - // Visually hide the "Next" button. - $form['actions']['save_modal']['#attributes']['class'][] = 'visually-hidden'; - $form['actions']['save_modal']['#weight'] = 1; - - // Add a button that matches our normal UX, which clicks the hidden button - // within the modal's iFrame. - $form['actions']['save_modal_alt'] = [ - '#type' => 'submit', - '#value' => t('Select Media'), - '#attributes' => ['class' => ['entity-browser-modal-submit']], - '#button_type' => 'primary', - '#weight' => 0, - ]; - } - } - } -} diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/README.txt b/web/modules/media_entity_browser/media_entity_browser_media_library/README.txt new file mode 100644 index 0000000000..2e4bda1010 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/README.txt @@ -0,0 +1,55 @@ +# Media Entity Browser (Media Library) +=== + +Provides an additional Entity Browser that leverages the +work done in the new Core Media Library. It is recommended to update existing +Entity Browsers to use the Media Entity Browser Media Library view. + +As Media Library is still experimental this is an optional setting for users. + +The UX for this view matches the Media Library UX as closely as possible +and is designed to fill the gap in WYSIWYG support until core catches up. Follow +https://www.drupal.org/project/drupal/issues/2801307 for core progress. + +Once core provides support for WYSIWYG embedding this module will be deprecated. + +## Requirements + +- Inline Entity Form +- Entity Browser +- Entity Embed +- Media +- Media Library + +## Installation + +- Download Inline Entity Form from Drupal.org +- Download Entity Embed from Drupal.org +- Download Entity Browser from Drupal.org +- Download Media Entity Browser from Drupal.org +- Enable core Media +- Enable core Media Library (optional) +- Enable Media Entity Browser Media Library + +## Usage + +This module is largely a set of configuration files to provide a basic WYSIWYG +Entity Browser for Media. As such the documentation for Entity Browser and Media +in general will explain how to customise the installed Media Entity Browsers. + +https://drupal-media.gitbooks.io/drupal8-guide/content/modules/entity_browser/intro.html + +Once installed, changes to the configuration are managed outside of this module. + +### Configuration + +On installation the Browser isn't visible. You need to add it to an Entity +Embed button for use though the WYSIWYG. + +- For WYSIWYG Entity Embedding use the iFrame Browser +(/admin/config/content/entity_browser/media_entity_browser). + +Media Entity Reference Fields should use core Media Library directly. From the +Manage Form Display tab of your fielded entity select the "Media Library" +widget instead of the "Entity Browser" widget. The Media Library widget provides +a much nicer UX for fields. diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/entity_browser.browser.media_entity_browser_media_library.yml b/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/entity_browser.browser.media_entity_browser_media_library.yml new file mode 100644 index 0000000000..a8fd2ecf39 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/entity_browser.browser.media_entity_browser_media_library.yml @@ -0,0 +1,41 @@ +langcode: en +status: true +dependencies: + config: + - views.view.media_entity_browser_media_library + module: + - entity_browser_entity_form + - views +name: media_entity_browser_media_library +label: 'Media Entity Browser (Media Library)' +display: iframe +display_configuration: + width: '1070' + height: '500' + link_text: 'Select media' + auto_open: true +selection_display: no_display +selection_display_configuration: { } +widget_selector: tabs +widget_selector_configuration: { } +widgets: + 552cfb05-063f-47a9-81d1-e1260fc8a402: + settings: + view: media_entity_browser_media_library + view_display: media_browser_all + submit_text: 'Select media' + auto_select: false + uuid: 552cfb05-063f-47a9-81d1-e1260fc8a402 + weight: -9 + label: 'Choose existing media' + id: view + 7e4422b4-dbe9-40f6-9b74-e2bf31b98ae8: + settings: + entity_type: media + bundle: image + form_mode: default + submit_text: 'Save image' + uuid: 7e4422b4-dbe9-40f6-9b74-e2bf31b98ae8 + weight: -10 + label: 'Upload new image' + id: entity_form diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/views.view.media_entity_browser_media_library.yml b/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/views.view.media_entity_browser_media_library.yml new file mode 100644 index 0000000000..ac87be7581 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/config/install/views.view.media_entity_browser_media_library.yml @@ -0,0 +1,399 @@ +langcode: und +status: true +dependencies: + config: + - core.entity_view_mode.media.media_library + module: + - entity_browser + - media + - user +id: media_entity_browser_media_library +label: 'Media Browser (Media Library)' +module: views +description: '' +tag: '' +base_table: media_field_data +base_field: mid +core: 8.x +display: + default: + display_plugin: default + id: default + display_title: Master + position: 0 + display_options: + access: + type: perm + options: + perm: 'access media overview' + cache: + type: tag + options: { } + query: + type: views_query + options: + disable_sql_rewrite: false + distinct: false + replica: false + query_comment: '' + query_tags: { } + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: false + sort_asc_label: Asc + sort_desc_label: Desc + pager: + type: full + options: + items_per_page: 25 + offset: 0 + id: 0 + total_pages: null + tags: + previous: '‹ Previous' + next: 'Next ›' + first: '« First' + last: 'Last »' + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 25, 50' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + quantity: 9 + style: + type: default + options: + grouping: { } + row_class: 'media-library-item js-media-library-item js-click-to-select' + default_row_class: true + row: + type: fields + options: + inline: { } + separator: '' + hide_empty: false + default_field_elements: true + fields: + 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: div + 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 + entity_browser_select: + id: entity_browser_select + table: media + field: entity_browser_select + 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 + entity_type: media + plugin_id: entity_browser_select + filters: + status: + id: status + table: media_field_data + field: status + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: '0' + group: 1 + exposed: true + expose: + operator_id: '' + label: 'True' + description: null + use_operator: false + operator: status_op + identifier: status + required: true + remember: false + multiple: false + remember_roles: + authenticated: authenticated + is_grouped: true + group_info: + label: Published + description: '' + identifier: status + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: + 1: + title: Published + operator: '=' + value: '1' + 2: + title: Unpublished + operator: '=' + value: '0' + entity_type: media + entity_field: status + plugin_id: boolean + name: + id: name + table: media_field_data + field: name + relationship: none + group_type: group + admin_label: '' + operator: contains + value: '' + group: 1 + exposed: true + expose: + operator_id: name_op + label: Name + description: '' + use_operator: false + operator: name_op + identifier: name + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + editor: '0' + publisher: '0' + administrator: '0' + placeholder: '' + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + entity_type: media + entity_field: name + plugin_id: string + bundle: + id: bundle + table: media_field_data + field: bundle + relationship: none + group_type: group + admin_label: '' + operator: in + value: { } + group: 1 + exposed: true + expose: + operator_id: bundle_op + label: 'Media type' + description: '' + use_operator: false + operator: bundle_op + identifier: provider + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + anonymous: '0' + editor: '0' + publisher: '0' + administrator: '0' + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + entity_type: media + entity_field: bundle + plugin_id: bundle + sorts: + created: + id: created + table: media_field_data + field: created + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: true + expose: + label: 'Newest first' + granularity: second + entity_type: media + entity_field: created + plugin_id: date + name: + id: name + table: media_field_data + field: name + relationship: none + group_type: group + admin_label: '' + order: ASC + exposed: true + expose: + label: 'Name (A-Z)' + entity_type: media + entity_field: name + plugin_id: standard + name_1: + id: name_1 + table: media_field_data + field: name + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: true + expose: + label: 'Name (Z-A)' + entity_type: media + entity_field: name + plugin_id: standard + header: { } + footer: { } + empty: { } + relationships: { } + arguments: { } + display_extenders: { } + filter_groups: + operator: AND + groups: + 1: AND + css_class: 'media-library-view js-media-library-view' + use_ajax: true + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_interface' + - url + - url.query_args + - 'url.query_args:sort_by' + - user.permissions + tags: { } + media_browser_all: + display_plugin: entity_browser + id: media_browser_all + display_title: 'Media browser' + position: 1 + display_options: + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_interface' + - url + - url.query_args + - 'url.query_args:sort_by' + - user.permissions + tags: { } \ No newline at end of file diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/css/media_entity_browser_media_library.view.css b/web/modules/media_entity_browser/media_entity_browser_media_library/css/media_entity_browser_media_library.view.css new file mode 100644 index 0000000000..6545219d19 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/css/media_entity_browser_media_library.view.css @@ -0,0 +1,20 @@ +/** + * @media-entity media_entity_browser.view.css + */ + +.media-library-select-all { + display: none; +} + +.media-library-view > .view-content { + display: flex; + flex-wrap: wrap; +} + +.media-library-view > .pager { + margin-top: 2rem; +} + +.media-library-item__content { + min-height: 74px; +} diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/js/media_entity_browser_media_library.view.js b/web/modules/media_entity_browser/media_entity_browser_media_library/js/media_entity_browser_media_library.view.js new file mode 100644 index 0000000000..3faecdd299 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/js/media_entity_browser_media_library.view.js @@ -0,0 +1,38 @@ +/** + * @file + * Defines the behavior of the media entity browser view. + */ + +(function ($, Drupal) { + + "use strict"; + + /** + * Attaches the behavior of the media entity browser view. + */ + Drupal.behaviors.mediaEntityBrowserView = { + attach: function (context) { + const $view = $('.js-media-library-view', context).once('media-library-remaining'); + $view + .find('.js-media-library-item input[type="checkbox"]') + .on('change', function () { + const $checkboxes = $view.find('.js-media-library-item input[type="checkbox"]'); + // Only one checkbox can be checked at a time. + if ($checkboxes.filter(':checked').length === 1) { + $checkboxes + .not(':checked') + .prop('disabled', true) + .closest('.js-media-library-item') + .addClass('media-library-item--disabled'); + } + else { + $checkboxes + .prop('disabled', false) + .closest('.js-media-library-item') + .removeClass('media-library-item--disabled'); + } + }); + } + }; + +}(jQuery, Drupal)); diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.info.yml b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.info.yml new file mode 100644 index 0000000000..61a2d3522a --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.info.yml @@ -0,0 +1,33 @@ +name: Media Entity Browser (Media Library) +type: module +description: 'This module provides an Entity Browser for Media which integrates with the Media Library' +package: Media +# core: '8.x' + +dependencies: + - inline_entity_form:inline_entity_form + - entity_browser:entity_browser + - entity_browser:entity_browser_entity_form + - drupal:media + - drupal:media_library + - drupal:views + +test_dependencies: + - inline_entity_form (>=8.x-1.x) + - entity_browser (>=8.x-2.x) + - entity_browser:entity_browser_entity_form (>=8.x-2.x) + - drupal:media (>=8.6) + - drupal:media_library (>=8.6) + - ctools:ctools + +# To export this config, make sure config_devel is installed, cache is rebuilt +# then run "drush config-devel-export media_entity_browser_media_library". +config_devel: + - views.view.media_entity_browser_media_library + - entity_browser.browser.media_entity_browser_media_library + +# Information added by Drupal.org packaging script on 2019-05-20 +version: '8.x-2.0-alpha2' +core: '8.x' +project: 'media_entity_browser' +datestamp: 1558337596 diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.libraries.yml b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.libraries.yml new file mode 100644 index 0000000000..fa9c95dab7 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.libraries.yml @@ -0,0 +1,9 @@ +view: + css: + theme: + css/media_entity_browser_media_library.view.css: {} + js: + js/media_entity_browser_media_library.view.js: {} + dependencies: + - core/jquery + - core/drupal diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.module b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.module new file mode 100644 index 0000000000..10bc9be476 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/media_entity_browser_media_library.module @@ -0,0 +1,31 @@ +<?php + +/** + * @file + * The module file for media_entity_browser. + */ + +use Drupal\Core\Form\FormStateInterface; + +/** + * Implements hook_preprocess_views_view(). + */ +function media_entity_browser_media_library_preprocess_views_view(&$variables) { + if ($variables['view']->id() === 'media_entity_browser_media_library') { + $variables['view_array']['#attached']['library'][] = 'media_library/view'; + $variables['view_array']['#attached']['library'][] = 'media_entity_browser_media_library/view'; + } +} + +/** + * Implements hook_form_alter(). + */ +function media_entity_browser_media_library_form_alter(array &$form, FormStateInterface $form_state, $form_id) { + if ($form_id === 'views_exposed_form') { + $view = $form_state->get('view'); + // Add after build to fix views exposed filter's submit button. + if ($view->id() === 'media_entity_browser_media_library') { + $form['#after_build'][] = '_media_library_views_form_media_library_after_build'; + } + } +} diff --git a/web/modules/media_entity_browser/media_entity_browser_media_library/tests/src/FunctionalJavascript/MediaEntityBrowserMediaLibraryTest.php b/web/modules/media_entity_browser/media_entity_browser_media_library/tests/src/FunctionalJavascript/MediaEntityBrowserMediaLibraryTest.php new file mode 100644 index 0000000000..2a4e7258e5 --- /dev/null +++ b/web/modules/media_entity_browser/media_entity_browser_media_library/tests/src/FunctionalJavascript/MediaEntityBrowserMediaLibraryTest.php @@ -0,0 +1,67 @@ +<?php + +namespace Drupal\Tests\media_entity_browser_media_library\FunctionalJavascript; + +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\media\Entity\Media; +use Drupal\Tests\media\Traits\MediaTypeCreationTrait; + +/** + * A test for the media entity browser with media library. + * + * @group media_entity_browser + */ +class MediaEntityBrowserMediaLibraryTest extends WebDriverTestBase { + + use MediaTypeCreationTrait; + /** + * Modules to install. + * + * @var array + */ + public static $modules = [ + 'media', + 'inline_entity_form', + 'entity_browser', + 'entity_browser_entity_form', + 'media_entity_browser', + 'media_entity_browser_media_library', + 'media_library', + 'video_embed_media', + 'ctools', + ]; + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp(); + $this->drupalLogin($this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions()))); + $this->createMediaType('video_embed_field', [ + 'label' => 'Video', + 'bundle' => 'video', + ]); + + Media::create([ + 'bundle' => 'video', + 'field_media_video_embed_field' => [['value' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ']], + ])->save(); + } + + /** + * Test the media entity browser. + */ + public function testMediaBrowser() { + $this->drupalGet('entity-browser/iframe/media_entity_browser_media_library'); + $this->clickLink('Choose existing media'); + $this->assertSession()->assertWaitOnAjaxRequest(); + + $this->assertSession()->elementExists('css', '.media-library-view'); + $this->assertSession()->elementExists('css', '.media-library-item__preview'); + + $this->assertSession()->elementNotExists('css', '.js-click-to-select.checked'); + $this->getSession()->getPage()->find('css', '.js-click-to-select')->press(); + $this->assertSession()->elementExists('css', '.js-click-to-select.checked'); + } + +} diff --git a/web/modules/media_entity_browser/tests/src/FunctionalJavascript/MediaEntityBrowserTest.php b/web/modules/media_entity_browser/tests/src/FunctionalJavascript/MediaEntityBrowserTest.php index a950b8a433..75e1dca72e 100644 --- a/web/modules/media_entity_browser/tests/src/FunctionalJavascript/MediaEntityBrowserTest.php +++ b/web/modules/media_entity_browser/tests/src/FunctionalJavascript/MediaEntityBrowserTest.php @@ -2,19 +2,18 @@ namespace Drupal\Tests\media_entity_browser\FunctionalJavascript; -use Drupal\FunctionalJavascriptTests\JavascriptTestBase; +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\media\Entity\Media; -use Drupal\media\Entity\MediaType; -use Drupal\Tests\media\Functional\MediaFunctionalTestCreateMediaTypeTrait; +use Drupal\Tests\media\Traits\MediaTypeCreationTrait; /** * A test for the media entity browser. * * @group media_entity_browser */ -class MediaEntityBrowserTest extends JavascriptTestBase { +class MediaEntityBrowserTest extends WebDriverTestBase { - use MediaFunctionalTestCreateMediaTypeTrait; + use MediaTypeCreationTrait; /** * Modules to install. * @@ -22,7 +21,9 @@ class MediaEntityBrowserTest extends JavascriptTestBase { */ public static $modules = [ 'media', + 'inline_entity_form', 'entity_browser', + 'entity_browser_entity_form', 'media_entity_browser', 'video_embed_media', 'ctools', @@ -34,10 +35,10 @@ class MediaEntityBrowserTest extends JavascriptTestBase { public function setUp() { parent::setUp(); $this->drupalLogin($this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions()))); - $this->createMediaType([ + $this->createMediaType('video_embed_field', [ 'label' => 'Video', 'bundle' => 'video', - ], 'video_embed_field'); + ]); Media::create([ 'bundle' => 'video', @@ -50,15 +51,17 @@ public function setUp() { */ public function testMediaBrowser() { $this->drupalGet('entity-browser/iframe/media_entity_browser'); + $this->clickLink('Choose existing media'); + $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->elementExists('css', '.view-media-entity-browser'); + $this->assertSession()->elementExists('css', '.view-media-entity-browser-view'); $this->assertSession()->elementExists('css', '.image-style-media-entity-browser-thumbnail'); $this->assertSession()->elementNotExists('css', '.views-row.checked'); $this->getSession()->getPage()->find('css', '.views-row')->press(); $this->assertSession()->elementExists('css', '.views-row.checked'); - $this->assertSession()->buttonExists('Select entities'); + $this->assertSession()->buttonExists('Select media'); } } -- GitLab