Issue #2775131 by chr.fritsch, marcoscano, katzilla, seanB, xjm, gippy, phenaproxima, alexpott, Berdir, lauriii, webflo, dawehner: Media entities should support contextual links
parent
d039f07cb7
commit
1da5a5ccb3
|
@ -26,11 +26,16 @@
|
||||||
* - title_attributes: Same as attributes, except applied to the main title
|
* - title_attributes: Same as attributes, except applied to the main title
|
||||||
* tag that appears in the template.
|
* tag that appears in the template.
|
||||||
*
|
*
|
||||||
|
* Note that we print {{ title_suffix }} even though the title is not included.
|
||||||
|
* This is intentional, once contextual links are embedded in the "title_suffix"
|
||||||
|
* variable. See #2775131 for more information on the background about this.
|
||||||
|
*
|
||||||
* @see template_preprocess_media()
|
* @see template_preprocess_media()
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
#}
|
#}
|
||||||
<div{{ attributes }}>
|
<div{{ attributes }}>
|
||||||
|
{{ title_suffix }}
|
||||||
{{ content }}
|
{{ content }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\media\Functional;
|
||||||
|
|
||||||
|
use Drupal\media\Entity\Media;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests views contextual links on media items.
|
||||||
|
*
|
||||||
|
* @group media
|
||||||
|
*/
|
||||||
|
class MediaContextualLinksTest extends MediaFunctionalTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static $modules = [
|
||||||
|
'contextual',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests contextual links.
|
||||||
|
*/
|
||||||
|
public function testMediaContextualLinks() {
|
||||||
|
// Create a media type.
|
||||||
|
$mediaType = $this->createMediaType();
|
||||||
|
|
||||||
|
// Create a media item.
|
||||||
|
$media = Media::create([
|
||||||
|
'bundle' => $mediaType->id(),
|
||||||
|
'name' => 'Unnamed',
|
||||||
|
]);
|
||||||
|
$media->save();
|
||||||
|
|
||||||
|
$user = $this->drupalCreateUser([
|
||||||
|
'administer media',
|
||||||
|
'access contextual links',
|
||||||
|
]);
|
||||||
|
$this->drupalLogin($user);
|
||||||
|
|
||||||
|
$this->drupalGet('media/' . $media->id());
|
||||||
|
$this->assertSession()->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'media:media=' . $media->id() . ':');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,10 @@
|
||||||
* - name: Name of the media.
|
* - name: Name of the media.
|
||||||
* - content: Media content.
|
* - content: Media content.
|
||||||
*
|
*
|
||||||
|
* Note that we print {{ title_suffix }} even though the title is not included.
|
||||||
|
* This is intentional, once contextual links are embedded in the "title_suffix"
|
||||||
|
* variable. See #2775131 for more information on the background about this.
|
||||||
|
*
|
||||||
* @see template_preprocess_media()
|
* @see template_preprocess_media()
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
|
@ -21,6 +25,7 @@
|
||||||
]
|
]
|
||||||
%}
|
%}
|
||||||
<article{{ attributes.addClass(classes) }}>
|
<article{{ attributes.addClass(classes) }}>
|
||||||
|
{{ title_suffix }}
|
||||||
{% if content %}
|
{% if content %}
|
||||||
{{ content }}
|
{{ content }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -7,12 +7,17 @@
|
||||||
* - name: Name of the media.
|
* - name: Name of the media.
|
||||||
* - content: Media content.
|
* - content: Media content.
|
||||||
*
|
*
|
||||||
|
* Note that we print {{ title_suffix }} even though the title is not included.
|
||||||
|
* This is intentional, once contextual links are embedded in the "title_suffix"
|
||||||
|
* variable. See #2775131 for more information on the background about this.
|
||||||
|
*
|
||||||
* @see template_preprocess_media()
|
* @see template_preprocess_media()
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
#}
|
#}
|
||||||
<article{{ attributes }}>
|
<article{{ attributes }}>
|
||||||
|
{{ title_suffix }}
|
||||||
{% if content %}
|
{% if content %}
|
||||||
{{ content }}
|
{{ content }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue