Skip to content

Commit

Permalink
Make security admin more easily extensible
Browse files Browse the repository at this point in the history
- fix error if import button is missing
- fix unhandled match case if model class is not member or group
  • Loading branch information
lekoala authored Aug 14, 2023
1 parent 5b09805 commit 6ef5b9b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions code/SecurityAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,16 @@ protected function getGridFieldConfig(): GridFieldConfig
}
/** @var GridFieldImportButton $importButton */
$importButton = $config->getComponentByType(GridFieldImportButton::class);
$modalTitle = match ($this->modelClass) {
Member::class => _t(__CLASS__ . '.IMPORTUSERS', 'Import users'),
Group::class => _t(__CLASS__ . '.IMPORTGROUPS', 'Import groups'),
};
$importButton->setModalTitle($modalTitle);
if ($importButton) {
$modalTitle = match ($this->modelClass) {
Member::class => _t(__CLASS__ . '.IMPORTUSERS', 'Import users'),
Group::class => _t(__CLASS__ . '.IMPORTGROUPS', 'Import groups'),
default => null,
};
if ($modalTitle !== null) {
$importButton->setModalTitle($modalTitle);
}
}
return $config;
}

Expand Down

0 comments on commit 6ef5b9b

Please sign in to comment.