Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°5619 - Hide newsroom menu when no provider #363

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -49,6 +49,16 @@ public static function MakeNewsroomMenuForNavigationMenu()
return $oMenu;
}

/**
* Check if there is any Newsroom provider configured
* @return boolean
*/
public static function HasProviders()
{
$aProviders = MetaModel::EnumPlugins('iNewsroomProvider');
return count($aProviders) > 0;
}

Molkobain marked this conversation as resolved.
Show resolved Hide resolved
/**
* Prepare parameters for the newsroom JS widget
*
Expand Down
Expand Up @@ -35,6 +35,7 @@
use UIExtKeyWidget;
use UserRights;
use utils;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu\NewsroomMenuFactory;

/**
* Class NavigationMenu
Expand Down Expand Up @@ -269,7 +270,7 @@ public function GetSubBlocks(): array
*/
public function IsNewsroomEnabled(): bool
{
return MetaModel::GetConfig()->Get('newsroom_enabled');
return (MetaModel::GetConfig()->Get('newsroom_enabled') && NewsroomMenuFactory::HasProviders());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it does work on Essential/Professional products though, are you sure this is the root cause?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to #363 (comment) it's "crashing". Don't know what exactly he means with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the second commit it was crashing (during the construction of the iTop WebPage) on Essential/Professional because the (empty) newsroom menu object was not created (because there is not newroom provider on such products).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Denis, I could not reproduce the issue on a Professional package. We would like to be able to reproduce the issue in order to ensure the fix is necessary and correct. Denis will dig further to have a reproduction procedure.

}

/**
Expand Down
Expand Up @@ -48,7 +48,7 @@ public static function MakeStandard()
{

$oNewsroomMenu = null;
if (MetaModel::GetConfig()->Get('newsroom_enabled'))
if (MetaModel::GetConfig()->Get('newsroom_enabled') && NewsroomMenuFactory::HasProviders())
{
$oNewsroomMenu = NewsroomMenuFactory::MakeNewsroomMenuForNavigationMenu();
}
Expand Down