mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 12:13:33 +08:00
Apply static tool panel exclusions at the root globally.
Makes it really clean to just exclude a bunch of tools across the whole panel, previously you'd need to deep tracking of what sections to exclude them from which might vary from Galaxy to Galaxy for instance.
This commit is contained in:
@@ -145,7 +145,7 @@ class StaticToolBoxView(BaseModel, HasItems):
|
||||
description: Optional[str]
|
||||
view_type: StaticToolBoxViewTypeEnum = Field(alias="type")
|
||||
items: List[RootContent]
|
||||
excludes: Optional[List[Exclusions]]
|
||||
excludes: OptionalExclusionList
|
||||
|
||||
@staticmethod
|
||||
def from_dict(as_dict):
|
||||
|
||||
@@ -5,6 +5,7 @@ from .definitions import (
|
||||
ExcludeTool,
|
||||
ExcludeToolRegex,
|
||||
ExcludeTypes,
|
||||
Exclusions,
|
||||
Section,
|
||||
StaticToolBoxView,
|
||||
Workflow,
|
||||
@@ -65,8 +66,9 @@ class StaticToolPanelView(ToolPanelView):
|
||||
def apply_view(self, base_tool_panel: ToolPanelElements, toolbox_registry: ToolBoxRegistry) -> ToolPanelElements:
|
||||
|
||||
def apply_filter(definition, elems):
|
||||
if definition.excludes:
|
||||
elems.apply_filter(build_filter(definition.excludes))
|
||||
excludes = self._all_excludes(definition)
|
||||
if excludes:
|
||||
elems.apply_filter(build_filter(excludes))
|
||||
|
||||
def definition_with_items_to_panel(definition, allow_sections: bool = True):
|
||||
new_panel = ToolPanelElements()
|
||||
@@ -145,13 +147,20 @@ class StaticToolPanelView(ToolPanelView):
|
||||
else:
|
||||
raise AssertionError("Unknown static toolbox configuration element encountered.")
|
||||
|
||||
if definition.excludes:
|
||||
new_panel.apply_filter(build_filter(definition.excludes))
|
||||
excludes = self._all_excludes(definition)
|
||||
if excludes:
|
||||
new_panel.apply_filter(build_filter(excludes))
|
||||
|
||||
return new_panel
|
||||
|
||||
return definition_with_items_to_panel(self._definition)
|
||||
|
||||
def _all_excludes(self, has_excludes):
|
||||
excludes = has_excludes.excludes or []
|
||||
if has_excludes != self._definition and self._definition.excludes:
|
||||
excludes.extend(self._definition.excludes)
|
||||
return excludes
|
||||
|
||||
def to_model(self) -> ToolPanelViewModel:
|
||||
model_id = self._definition.id
|
||||
name = self._definition.name
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
name: Globally Applied Filters
|
||||
type: activity
|
||||
items:
|
||||
- section: test
|
||||
excludes:
|
||||
- tool_id_regex: 'multi_data_.*'
|
||||
- tool_id_regex: '.*_text_option'
|
||||
@@ -95,6 +95,10 @@ class PanelViewsFromDirectoryIntegrationTestCase(integration_util.IntegrationTes
|
||||
assert len(index_as_list) == 2
|
||||
assert model_classes(index_as_list) == ["ToolSection", "ToolSection"]
|
||||
|
||||
def test_global_filters(self):
|
||||
index = self.galaxy_interactor.get("tools", data=dict(in_panel=True, view="custom_11"))
|
||||
verify_custom_regex_filtered(index)
|
||||
|
||||
|
||||
class PanelViewsFromConfigIntegrationTestCase(integration_util.IntegrationTestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user