Skip to content

Commit

Permalink
SAML: Improve sorting + Boyscouting
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Jan 29, 2025
1 parent 6037548 commit 1af9e0d
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions components/ILIAS/Saml/classes/class.ilSamlIdpTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function __construct(
private readonly \ILIAS\UI\Factory $ui_factory,
private readonly \ILIAS\UI\Renderer $ui_renderer,
private readonly ilLanguage $lng,
private readonly ilCtrl $ctrl,
private readonly ilCtrlInterface $ctrl,
private readonly \Psr\Http\Message\ServerRequestInterface $http_request,
private readonly \ILIAS\Data\Factory $df,
private readonly string $parent_cmd,
private readonly bool $hasWriteAccess
private readonly bool $has_write_access
) {
$this->idps = ilSamlIdp::getAllIdps();

Expand Down Expand Up @@ -84,8 +84,24 @@ private function getColumnDefinition(): array
'active' => $this->ui_factory
->table()
->column()
->statusIcon($this->lng->txt('active'))
->withIsSortable(true),
->boolean(
$this->lng->txt('status'),
$this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_ok.svg',
$this->lng->txt('active'),
'small'
),
$this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_not_ok.svg',
$this->lng->txt('inactive'),
'small'
)
)
->withIsSortable(true)
->withOrderingLabels(
"{$this->lng->txt('status')}, {$this->lng->txt('active')} {$this->lng->txt('order_option_first')}",
"{$this->lng->txt('status')}, {$this->lng->txt('inactive')} {$this->lng->txt('order_option_first')}"
)
];
}

Expand All @@ -94,7 +110,7 @@ private function getColumnDefinition(): array
*/
private function getActions(): array
{
if (!$this->hasWriteAccess) {
if (!$this->has_write_access) {
return [];
}

Expand All @@ -118,7 +134,7 @@ private function getActions(): array
$this->lng->txt('delete'),
$this->url_builder->withParameter($this->action_parameter_token, 'confirmDeleteIdp'),
$this->row_id_token
),
)
];
}

Expand All @@ -138,7 +154,7 @@ private function getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order):
return ilStr::strCmp($left->getEntityId(), $right->getEntityId());
}

return (int) $left->isActive() <=> (int) $right->isActive();
return (int) $right->isActive() <=> (int) $left->isActive();
});

if ($order_direction === \ILIAS\Data\Order::DESC) {
Expand All @@ -159,16 +175,11 @@ public function getRows(
?array $additional_parameters
): Generator {
foreach ($this->getRecords($range, $order) as $item) {
$record = [
'title' => $item->getEntityId(),
'active' => $this->ui_factory->symbol()->icon()->custom(
ilUtil::getImagePath($item->isActive() ? 'standard/icon_ok.svg' : 'standard/icon_not_ok.svg'),
$item->isActive() ? $this->lng->txt('active') : $this->lng->txt('inactive')
),
];

yield $row_builder
->buildDataRow((string) $item->getIdpId(), $record)
->buildDataRow((string) $item->getIdpId(), [
'title' => $item->getEntityId(),
'active' => $item->isActive()
])
->withDisabledAction(
'activate',
$item->isActive(),
Expand Down

0 comments on commit 1af9e0d

Please sign in to comment.