diff --git a/src/Plugin/views/field/CollaboraEdit.php b/src/Plugin/views/field/CollaboraEdit.php index 56bedf4c..92bc2bd7 100644 --- a/src/Plugin/views/field/CollaboraEdit.php +++ b/src/Plugin/views/field/CollaboraEdit.php @@ -5,6 +5,7 @@ namespace Drupal\collabora_online\Plugin\views\field; use Drupal\collabora_online\Cool\CoolUtils; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; @@ -18,18 +19,24 @@ #[ViewsField('media_collabora_edit')] class CollaboraEdit extends LinkBase { - /** - * {@inheritdoc} - */ - protected function getUrlInfo(ResultRow $row): Url|null { - /** @var \Drupal\media\MediaInterface $entity */ - $entity = $this->getEntity($row); + /** + * {@inheritdoc} + */ + protected function getUrlInfo(ResultRow $row): Url|null { + /** @var \Drupal\media\MediaInterface $entity */ + $entity = $this->getEntity($row); - if ($entity === NULL) { - return NULL; - } + if ($entity === NULL) { + return NULL; + } - return CoolUtils::getEditorUrl($entity, TRUE); - } + return CoolUtils::getEditorUrl($entity, TRUE); + } + /** + * {@inheritdoc} + */ + protected function getDefaultLabel(): TranslatableMarkup { + return $this->t('Edit in Collabora Online'); + } } diff --git a/src/Plugin/views/field/CollaboraPreview.php b/src/Plugin/views/field/CollaboraPreview.php index a0d24411..e93817f9 100644 --- a/src/Plugin/views/field/CollaboraPreview.php +++ b/src/Plugin/views/field/CollaboraPreview.php @@ -5,6 +5,7 @@ namespace Drupal\collabora_online\Plugin\views\field; use Drupal\collabora_online\Cool\CoolUtils; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Drupal\views\Attribute\ViewsField; use Drupal\views\Plugin\views\field\LinkBase; @@ -18,18 +19,24 @@ #[ViewsField('media_collabora_preview')] class CollaboraPreview extends LinkBase { - /** - * {@inheritdoc} - */ - protected function getUrlInfo(ResultRow $row): Url|null { - /** @var \Drupal\media\MediaInterface $entity */ - $entity = $this->getEntity($row); + /** + * {@inheritdoc} + */ + protected function getUrlInfo(ResultRow $row): Url|null { + /** @var \Drupal\media\MediaInterface $entity */ + $entity = $this->getEntity($row); - if ($entity === NULL) { - return NULL; - } + if ($entity === NULL) { + return NULL; + } - return CoolUtils::getEditorUrl($entity, FALSE); - } + return CoolUtils::getEditorUrl($entity, FALSE); + } + /** + * {@inheritdoc} + */ + protected function getDefaultLabel(): TranslatableMarkup { + return $this->t('View in Collabora Online'); + } } diff --git a/tests/modules/collabora_online_test/config/optional/views.view.test_collabora_links.yml b/tests/modules/collabora_online_test/config/optional/views.view.test_collabora_links.yml index 58fd87ac..7f79189b 100644 --- a/tests/modules/collabora_online_test/config/optional/views.view.test_collabora_links.yml +++ b/tests/modules/collabora_online_test/config/optional/views.view.test_collabora_links.yml @@ -117,7 +117,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - text: "View in Collabora Online" + text: "" collabora_edit: id: collabora_edit table: media @@ -168,7 +168,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - text: "Edit in Collabora Online" + text: "" pager: type: mini options: