Skip to content

Commit

Permalink
RedundancygroupController:: add sort columns rules as constant
Browse files Browse the repository at this point in the history
Use Translation trait's translate() method
  • Loading branch information
sukhwinder33445 committed Nov 14, 2024
1 parent 10b8e8b commit 98ff289
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions application/controllers/RedundancygroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ class RedundancygroupController extends Controller
/** @var RedundancyGroup */
protected $group;

protected const SORT_RULES = [
'name' => 'host.display_name, service.display_name, redundancy_group.display_name',
'severity' => 'service.state.severity desc, service.state.last_state_change desc, '
. 'host.state.severity desc, host.state.last_state_change desc, '
.'redundancy_group.state.failed desc, redundancy_group.state.last_state_change desc',
'state' => 'service.state.soft_state, host.state.soft_state, redundancy_group.state.failed',
'last_state_change' => 'service.state.last_state_change desc, host.state.last_state_change desc, '
. 'redundancy_group.state.last_state_change desc'
];

public function init(): void
{
// in case of quick actions, param id is not given
Expand All @@ -56,7 +66,7 @@ public function init(): void
$this->group = $query->first();

Check failure on line 66 in application/controllers/RedundancygroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Property Icinga\Module\Icingadb\Controllers\RedundancygroupController::$group (Icinga\Module\Icingadb\Model\RedundancyGroup) does not accept ipl\Orm\Model|null.

Check failure on line 66 in application/controllers/RedundancygroupController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Property Icinga\Module\Icingadb\Controllers\RedundancygroupController::$group (Icinga\Module\Icingadb\Model\RedundancyGroup) does not accept ipl\Orm\Model|null.

if ($this->group === null) {
throw new NotFoundError(t('Redundancy Group not found'));
throw new NotFoundError($this->translate('Redundancy Group not found'));
}

$this->setTitleTab($this->getRequest()->getActionName());
Expand Down Expand Up @@ -99,10 +109,10 @@ public function membersAction(): \Generator
$sortControl = $this->createSortControl(
$nodesQuery,
[
'name' => t('Name'),
'severity desc, last_state_change desc' => t('Severity'),
'state' => t('Current State'),
'last_state_change desc' => t('Last State Change')
self::SORT_RULES['name'] => $this->translate('Name'),
self::SORT_RULES['severity'] => $this->translate('Severity'),
self::SORT_RULES['state'] => $this->translate('Current State'),
self::SORT_RULES['last_state_change'] => $this->translate('Last State Change')
]
);
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl);
Expand Down Expand Up @@ -160,10 +170,10 @@ public function childrenAction()
$sortControl = $this->createSortControl(
$nodesQuery,
[
'name' => t('Name'),
'severity desc, last_state_change desc' => t('Severity'),
'state' => t('Current State'),
'last_state_change desc' => t('Last State Change')
self::SORT_RULES['name'] => $this->translate('Name'),
self::SORT_RULES['severity'] => $this->translate('Severity'),
self::SORT_RULES['state'] => $this->translate('Current State'),
self::SORT_RULES['last_state_change'] => $this->translate('Last State Change')
]
);
$viewModeSwitcher = $this->createViewModeSwitcher($paginationControl, $limitControl);
Expand Down Expand Up @@ -251,22 +261,22 @@ public function searchEditorAction(): void
}

$this->getDocument()->add($editor);
$this->setTitle(t('Adjust Filter'));
$this->setTitle($this->translate('Adjust Filter'));
}

protected function createTabs(): Tabs
{
$tabs = $this->getTabs()
->add('index', [
'label' => t('Redundancy Group'),
'label' => $this->translate('Redundancy Group'),
'url' => Links::redundancyGroup($this->group)
])
->add('members', [
'label' => t('Members'),
'label' => $this->translate('Members'),
'url' => Links::redundancyGroupMembers($this->group)
])
->add('children', [
'label' => t('Children'),
'label' => $this->translate('Children'),
'url' => Links::redundancyGroupChildren($this->group)
]);

Expand Down

0 comments on commit 98ff289

Please sign in to comment.