From 4ef7e339f64550b5a0b67a64b460b1de403b2c34 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Tue, 29 Oct 2024 16:08:13 +0100 Subject: [PATCH] fix: resolve JM's review --- library/Icingadb/Common/StateBadges.php | 6 +++--- .../Model/Behavior/HasProblematicParent.php | 14 +++++--------- .../Icingadb/Widget/DependencyNodeStatistics.php | 3 +-- public/css/list/redundancy-group-list-item.less | 5 ++--- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/library/Icingadb/Common/StateBadges.php b/library/Icingadb/Common/StateBadges.php index d9b5c45b9..b55eeeb3a 100644 --- a/library/Icingadb/Common/StateBadges.php +++ b/library/Icingadb/Common/StateBadges.php @@ -88,9 +88,9 @@ protected function getStateInt(string $state): int /** * Get the badge URL * - * @return Url + * @return ?Url */ - public function getUrl(): Url + public function getUrl(): ?Url { return $this->url; } @@ -117,7 +117,7 @@ public function setUrl(Url $url): self * * @return Link */ - public function createLink($content, Filter\Rule $filter = null): Link + protected function createLink($content, Filter\Rule $filter = null): Link { $url = clone $this->getUrl(); diff --git a/library/Icingadb/Model/Behavior/HasProblematicParent.php b/library/Icingadb/Model/Behavior/HasProblematicParent.php index 9f2f691d9..aabf60068 100644 --- a/library/Icingadb/Model/Behavior/HasProblematicParent.php +++ b/library/Icingadb/Model/Behavior/HasProblematicParent.php @@ -37,8 +37,8 @@ public function rewriteColumn($column, ?string $relation = null): ?AliasedExpres $resolver = $this->query->getResolver(); if ($relation !== null) { - $serviceTableAlias = str_replace('.', '_', $relation); - $column = $serviceTableAlias . "_$column"; + $serviceTableAlias = $resolver->getAlias($resolver->resolveRelation($relation)->getTarget()); + $column = $resolver->qualifyColumnAlias($column, $serviceTableAlias); } else { $serviceTableAlias = $resolver->getAlias($this->query->getModel()); } @@ -48,18 +48,14 @@ public function rewriteColumn($column, ?string $relation = null): ?AliasedExpres ->setDb($this->query->getDb()) ->setModel($subQueryModel) ->columns([new Expression('1')]) - ->with([ - 'from', - 'to', - 'dependency' - ]) + ->utilize('from') ->limit(1) ->filter(Filter::any( Filter::equal('to.redundancy_group.state.failed', 'y'), Filter::equal('dependency.state.failed', 'y') )); - $subQueryResolver = $subQuery->getResolver(); + $subQueryResolver = $subQuery->getResolver()->setAliasPrefix('hpp_'); $subQueryTarget = $subQueryResolver->resolveRelation($subQueryModel->getTableName() . '.from')->getTarget(); $targetForeignKey = $subQueryResolver->qualifyColumn( 'service_id', @@ -90,7 +86,7 @@ public function rewriteColumnDefinition(ColumnDefinition $def, string $relation) { } - public function rewriteCondition(Filter\Condition $condition, $relation = null): void + public function rewriteCondition(Filter\Condition $condition, $relation = null) { $column = substr($condition->getColumn(), strlen($relation ?? '')); diff --git a/library/Icingadb/Widget/DependencyNodeStatistics.php b/library/Icingadb/Widget/DependencyNodeStatistics.php index d8dca91ae..7916e7239 100644 --- a/library/Icingadb/Widget/DependencyNodeStatistics.php +++ b/library/Icingadb/Widget/DependencyNodeStatistics.php @@ -5,7 +5,6 @@ namespace Icinga\Module\Icingadb\Widget; use Icinga\Chart\Donut; -use Icinga\Module\Dependencies\Model\DependencyNodeSummary; use Icinga\Module\Icingadb\Model\RedundancyGroupSummary; use Icinga\Module\Icingadb\Widget\Detail\ObjectStatistics; use ipl\Html\Text; @@ -17,7 +16,7 @@ */ class DependencyNodeStatistics extends ObjectStatistics { - /** @var RedundancyGroupSummary|DependencyNodeSummary Dependency node summary*/ + /** @var RedundancyGroupSummary Dependency node summary*/ protected $summary; public function __construct($summary) diff --git a/public/css/list/redundancy-group-list-item.less b/public/css/list/redundancy-group-list-item.less index 3c6093549..86139084d 100644 --- a/public/css/list/redundancy-group-list-item.less +++ b/public/css/list/redundancy-group-list-item.less @@ -1,7 +1,6 @@ .redundancy-group-list-item { .caption { - .object-statistics { - justify-content: end; - } + display: flex; + justify-content: end; } }