summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2018-01-08 15:17:15 (GMT)
committerxjm2018-01-08 15:17:15 (GMT)
commitb8d018e325905e69914ab745c467f740586e72ec (patch)
treefcad16005dcf21711924bd1e75f7ddcf59017eac
parent9f54d00d40c7674e3259dfeba617fa181039c696 (diff)
Issue #2775131 by chr.fritsch, marcoscano, katzilla, seanB, xjm, gippy, phenaproxima, alexpott, Berdir, lauriii, webflo, dawehner: Media entities should support contextual links
-rw-r--r--core/modules/media/templates/media.html.twig1
-rw-r--r--core/modules/media/tests/src/Functional/MediaContextualLinksTest.php45
-rw-r--r--core/themes/classy/templates/content/media.html.twig1
-rw-r--r--core/themes/stable/templates/content/media.html.twig1
4 files changed, 48 insertions, 0 deletions
diff --git a/core/modules/media/templates/media.html.twig b/core/modules/media/templates/media.html.twig
index 28c0a83..2c2c759 100644
--- a/core/modules/media/templates/media.html.twig
+++ b/core/modules/media/templates/media.html.twig
@@ -32,5 +32,6 @@
*/
#}
<div{{ attributes }}>
+ {{ title_suffix.contextual_links }}
{{ content }}
</div>
diff --git a/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php
new file mode 100644
index 0000000..1d97773
--- /dev/null
+++ b/core/modules/media/tests/src/Functional/MediaContextualLinksTest.php
@@ -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() . ':');
+ }
+
+}
diff --git a/core/themes/classy/templates/content/media.html.twig b/core/themes/classy/templates/content/media.html.twig
index f36975c..24d3d3a 100644
--- a/core/themes/classy/templates/content/media.html.twig
+++ b/core/themes/classy/templates/content/media.html.twig
@@ -21,6 +21,7 @@
]
%}
<article{{ attributes.addClass(classes) }}>
+ {{ title_suffix.contextual_links }}
{% if content %}
{{ content }}
{% endif %}
diff --git a/core/themes/stable/templates/content/media.html.twig b/core/themes/stable/templates/content/media.html.twig
index 769b7be..a8ab444 100644
--- a/core/themes/stable/templates/content/media.html.twig
+++ b/core/themes/stable/templates/content/media.html.twig
@@ -13,6 +13,7 @@
*/
#}
<article{{ attributes }}>
+ {{ title_suffix.contextual_links }}
{% if content %}
{{ content }}
{% endif %}