Skip to content

Commit

Permalink
Issue CollaboraOnline#52: Add default label.
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronGilMartinez committed Nov 22, 2024
1 parent a3ca7a9 commit 4dc6554
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
29 changes: 18 additions & 11 deletions src/Plugin/views/field/CollaboraEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
}
29 changes: 18 additions & 11 deletions src/Plugin/views/field/CollaboraPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4dc6554

Please sign in to comment.