From b5c90626409ff6ae1a070c666b25bd4a91a44e71 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Fri, 6 Dec 2024 14:51:32 +0100 Subject: [PATCH] Remove superfluous trait `NoSujectLink` and its uses --- library/Icingadb/Common/NoSubjectLink.php | 35 ------------------- .../Widget/ItemList/BaseCommentListItem.php | 4 +-- .../Widget/ItemList/BaseDowntimeListItem.php | 4 +-- .../Widget/ItemList/BaseHistoryListItem.php | 2 +- .../ItemList/BaseNotificationListItem.php | 29 +++++---------- .../Icingadb/Widget/ItemList/CommentList.php | 2 -- .../Icingadb/Widget/ItemList/DowntimeList.php | 2 -- .../Icingadb/Widget/ItemList/HistoryList.php | 2 -- .../Widget/ItemList/HostListItemDetailed.php | 1 - .../Widget/ItemList/NotificationList.php | 2 -- 10 files changed, 14 insertions(+), 69 deletions(-) delete mode 100644 library/Icingadb/Common/NoSubjectLink.php diff --git a/library/Icingadb/Common/NoSubjectLink.php b/library/Icingadb/Common/NoSubjectLink.php deleted file mode 100644 index 76c9a84dc..000000000 --- a/library/Icingadb/Common/NoSubjectLink.php +++ /dev/null @@ -1,35 +0,0 @@ -noSubjectLink = $state; - - return $this; - } - - /** - * Get whether a list item's subject should be a link - * - * @return bool - */ - public function getNoSubjectLink(): bool - { - return $this->noSubjectLink; - } -} diff --git a/library/Icingadb/Widget/ItemList/BaseCommentListItem.php b/library/Icingadb/Widget/ItemList/BaseCommentListItem.php index ea8381da8..836d9c5a2 100644 --- a/library/Icingadb/Widget/ItemList/BaseCommentListItem.php +++ b/library/Icingadb/Widget/ItemList/BaseCommentListItem.php @@ -26,12 +26,12 @@ protected function getObject(): Comment protected function wantSubjectLink(): bool { - return ! $this->list->getNoSubjectLink(); + return true; } protected function wantObjectLink(): bool { - return ! $this->list->getObjectLinkDisabled(); + return true; } protected function init(): void diff --git a/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php b/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php index 8ff88e1d1..d3c963f55 100644 --- a/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php +++ b/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php @@ -29,12 +29,12 @@ protected function getObject(): Downtime protected function wantSubjectLink(): bool { - return ! $this->list->getNoSubjectLink(); + return true; } protected function wantObjectLink(): bool { - return ! $this->list->getObjectLinkDisabled(); + return true; } protected function init(): void diff --git a/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php b/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php index e79890a0c..3f79d89e6 100644 --- a/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php +++ b/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php @@ -32,6 +32,6 @@ protected function getObject(): History protected function wantSubjectLink(): bool { - return ! $this->list->getNoSubjectLink(); + return true; } } diff --git a/library/Icingadb/Widget/ItemList/BaseNotificationListItem.php b/library/Icingadb/Widget/ItemList/BaseNotificationListItem.php index b538ac4ab..2eb50a8de 100644 --- a/library/Icingadb/Widget/ItemList/BaseNotificationListItem.php +++ b/library/Icingadb/Widget/ItemList/BaseNotificationListItem.php @@ -8,27 +8,25 @@ use Icinga\Module\Icingadb\Common\HostStates; use Icinga\Module\Icingadb\Common\Icons; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Common\ServiceLink; use Icinga\Module\Icingadb\Common\ServiceStates; use Icinga\Module\Icingadb\Util\PluginOutput; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; use Icinga\Module\Icingadb\Widget\StateChange; -use ipl\Stdlib\Filter; -use ipl\Web\Common\BaseListItem; -use ipl\Web\Widget\EmptyState; -use ipl\Web\Widget\TimeAgo; use InvalidArgumentException; use ipl\Html\BaseHtmlElement; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Stdlib\Filter; +use ipl\Web\Common\BaseListItem; +use ipl\Web\Widget\EmptyState; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; +use ipl\Web\Widget\TimeAgo; abstract class BaseNotificationListItem extends BaseListItem { use HostLink; - use NoSubjectLink; use ServiceLink; /** @var NotificationList */ @@ -36,7 +34,6 @@ abstract class BaseNotificationListItem extends BaseListItem protected function init(): void { - $this->setNoSubjectLink($this->list->getNoSubjectLink()); $this->list->addDetailFilterAttribute($this, Filter::equal('id', bin2hex($this->item->history->id))); } @@ -159,19 +156,11 @@ protected function assembleVisual(BaseHtmlElement $visual): void protected function assembleTitle(BaseHtmlElement $title): void { - if ($this->getNoSubjectLink()) { - $title->addHtml(HtmlElement::create( - 'span', - ['class' => 'subject'], - sprintf(self::phraseForType($this->item->type), ucfirst($this->item->object_type)) - )); - } else { - $title->addHtml(new Link( - sprintf(self::phraseForType($this->item->type), ucfirst($this->item->object_type)), - Links::event($this->item->history), - ['class' => 'subject'] - )); - } + $title->addHtml(new Link( + sprintf(self::phraseForType($this->item->type), ucfirst($this->item->object_type)), + Links::event($this->item->history), + ['class' => 'subject'] + )); if ($this->item->object_type === 'host') { $link = $this->createHostLink($this->item->host, true); diff --git a/library/Icingadb/Widget/ItemList/CommentList.php b/library/Icingadb/Widget/ItemList/CommentList.php index 66303e007..1f338b475 100644 --- a/library/Icingadb/Widget/ItemList/CommentList.php +++ b/library/Icingadb/Widget/ItemList/CommentList.php @@ -6,7 +6,6 @@ use Icinga\Module\Icingadb\Common\DetailActions; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Common\ObjectLinkDisabled; use Icinga\Module\Icingadb\Common\TicketLinks; use Icinga\Module\Icingadb\Common\ViewMode; @@ -15,7 +14,6 @@ class CommentList extends BaseItemList { - use NoSubjectLink; use ObjectLinkDisabled; use ViewMode; use TicketLinks; diff --git a/library/Icingadb/Widget/ItemList/DowntimeList.php b/library/Icingadb/Widget/ItemList/DowntimeList.php index 9ecccd073..e54cecef8 100644 --- a/library/Icingadb/Widget/ItemList/DowntimeList.php +++ b/library/Icingadb/Widget/ItemList/DowntimeList.php @@ -6,7 +6,6 @@ use Icinga\Module\Icingadb\Common\DetailActions; use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Common\ObjectLinkDisabled; use Icinga\Module\Icingadb\Common\TicketLinks; use Icinga\Module\Icingadb\Common\ViewMode; @@ -15,7 +14,6 @@ class DowntimeList extends BaseItemList { - use NoSubjectLink; use ObjectLinkDisabled; use ViewMode; use TicketLinks; diff --git a/library/Icingadb/Widget/ItemList/HistoryList.php b/library/Icingadb/Widget/ItemList/HistoryList.php index 049c117b7..0af68769b 100644 --- a/library/Icingadb/Widget/ItemList/HistoryList.php +++ b/library/Icingadb/Widget/ItemList/HistoryList.php @@ -6,7 +6,6 @@ use Icinga\Module\Icingadb\Common\DetailActions; use Icinga\Module\Icingadb\Common\LoadMore; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Common\TicketLinks; use Icinga\Module\Icingadb\Common\ViewMode; use ipl\Orm\ResultSet; @@ -15,7 +14,6 @@ class HistoryList extends BaseItemList { - use NoSubjectLink; use ViewMode; use LoadMore; use TicketLinks; diff --git a/library/Icingadb/Widget/ItemList/HostListItemDetailed.php b/library/Icingadb/Widget/ItemList/HostListItemDetailed.php index 38df6d2fb..d68ed1fdb 100644 --- a/library/Icingadb/Widget/ItemList/HostListItemDetailed.php +++ b/library/Icingadb/Widget/ItemList/HostListItemDetailed.php @@ -48,7 +48,6 @@ protected function assembleFooter(BaseHtmlElement $footer): void ); $comment = (new CommentList([$COMMENTTOREMOVE])) //TODO: remove it - ->setNoSubjectLink() ->setObjectLinkDisabled() ->setDetailActionsDisabled(); diff --git a/library/Icingadb/Widget/ItemList/NotificationList.php b/library/Icingadb/Widget/ItemList/NotificationList.php index 70955b75e..d1874aa97 100644 --- a/library/Icingadb/Widget/ItemList/NotificationList.php +++ b/library/Icingadb/Widget/ItemList/NotificationList.php @@ -6,7 +6,6 @@ use Icinga\Module\Icingadb\Common\DetailActions; use Icinga\Module\Icingadb\Common\LoadMore; -use Icinga\Module\Icingadb\Common\NoSubjectLink; use Icinga\Module\Icingadb\Common\ViewMode; use ipl\Orm\ResultSet; use ipl\Web\Common\BaseItemList; @@ -14,7 +13,6 @@ class NotificationList extends BaseItemList { - use NoSubjectLink; use ViewMode; use LoadMore; use DetailActions;