mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Allow to filter marketplace by module ID (#6436)
This commit is contained in:
parent
36c4cff0a0
commit
5c5a73dce0
@ -103,7 +103,7 @@ class InstalledModuleControls extends Menu
|
||||
$this->addEntry(new MenuLink([
|
||||
'id' => 'info',
|
||||
'label' => Yii::t('AdminModule.base', 'Show in Marketplace'),
|
||||
'url' => ['/marketplace/browse', 'keyword' => $this->module->id, 'tags' => ''],
|
||||
'url' => ['/marketplace/browse', 'id' => $this->module->id],
|
||||
'icon' => 'info-circle',
|
||||
'sortOrder' => 600,
|
||||
]));
|
||||
|
@ -17,6 +17,7 @@ use Yii;
|
||||
class FilterService
|
||||
{
|
||||
private Module $module;
|
||||
private string $moduleId;
|
||||
private int $categoryId;
|
||||
private array $tags;
|
||||
|
||||
@ -24,6 +25,8 @@ class FilterService
|
||||
{
|
||||
$this->module = $module;
|
||||
|
||||
$this->moduleId = $moduleId ?? Yii::$app->request->get('id', '');
|
||||
|
||||
$this->categoryId = $categoryId ?? Yii::$app->request->get('categoryId', 0);
|
||||
|
||||
if (is_array($tags)) {
|
||||
@ -36,7 +39,25 @@ class FilterService
|
||||
|
||||
public function isFiltered(): bool
|
||||
{
|
||||
return $this->isFilteredByCategory() && $this->isFilteredByTags();
|
||||
return $this->isFilteredById() &&
|
||||
$this->isFilteredByCategory() &&
|
||||
$this->isFilteredByTags();
|
||||
}
|
||||
|
||||
public function isFilteredById(): bool
|
||||
{
|
||||
if (empty($this->moduleId)) {
|
||||
// All modules
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->moduleId === $this->module->id) {
|
||||
// Force tags to "All" on filter by module ID
|
||||
$this->tags = [];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isFilteredByCategory(): bool
|
||||
|
@ -82,7 +82,7 @@ class ModuleFilters extends DirectoryFilters
|
||||
{
|
||||
switch ($filter) {
|
||||
case 'tags':
|
||||
return 'uninstalled';
|
||||
return self::isFilteredById() ? '' : 'uninstalled';
|
||||
}
|
||||
|
||||
return parent::getDefaultValue($filter);
|
||||
@ -129,4 +129,9 @@ class ModuleFilters extends DirectoryFilters
|
||||
return $this->render('module-update-info', $info);
|
||||
}
|
||||
|
||||
public static function isFilteredById(): bool
|
||||
{
|
||||
return Yii::$app->request->get('id', '') !== '';
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user