Skip to content

Commit

Permalink
pkp#10061 Updated highlights tab to respect the feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jun 15, 2024
1 parent 067db41 commit e89ccbf
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions pages/admin/AdminHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,20 +247,11 @@ public function settings($args, $request)
/**
* Business logic for site settings single/multiple contexts availability
*
* @param PKPRequest $request
*
* @return array [siteComponent, availability (bool)]
* @return array<string,bool> List of tabs, where the key is the tab name and the value its availability
*/
private function siteSettingsAvailability($request)
private function siteSettingsAvailability(): array
{
$tabsSingleContextAvailability = [
'siteSetup',
'languages',
'bulkEmails',
'statistics',
];

$tabs = [
$tabs = array_fill_keys([
'siteSetup',
'siteAppearance',
'sitePlugins',
Expand All @@ -274,27 +265,20 @@ private function siteSettingsAvailability($request)
'siteAppearanceSetup',
'statistics',
'announcements',
];

if (!Config::getVar('features', 'site_announcements')) {
$tabs = array_filter(
$tabs,
function($tab) { return $tab !== 'announcements'; }
);
}

$singleContextSite = (Services::get('context')->getCount() == 1);
], true);

$tabsAvailability = [];
$tabs['announcements'] = (bool) Config::getVar('features', 'site_announcements');
$tabs['highlights'] = (bool) Config::getVar('features', 'highlights');

foreach ($tabs as $tab) {
$tabsAvailability[$tab] = true;
if ($singleContextSite && !in_array($tab, $tabsSingleContextAvailability)) {
$tabsAvailability[$tab] = false;
$isSingleContextSite = Services::get('context')->getCount() < 2;
if ($isSingleContextSite) {
$multipleContextTabs = ['siteSetup', 'languages', 'bulkEmails', 'statistics'];
foreach ($multipleContextTabs as $tab) {
$tabs[$tab] = false;
}
}

return $tabsAvailability;
return $tabs;
}

/**
Expand Down

0 comments on commit e89ccbf

Please sign in to comment.