From f3f89287865857d95a01b69dad03e7db61f30976 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Sat, 29 Jun 2024 21:52:35 +0200 Subject: [PATCH 1/4] Make `default_panel_view` a `_by_host` option --- lib/galaxy/config/schemas/config_schema.yml | 1 + lib/galaxy/tool_util/toolbox/base.py | 9 ++++++--- lib/galaxy/webapps/galaxy/api/tools.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/config/schemas/config_schema.yml b/lib/galaxy/config/schemas/config_schema.yml index e18dc2aa28e8..aa7f4891936d 100644 --- a/lib/galaxy/config/schemas/config_schema.yml +++ b/lib/galaxy/config/schemas/config_schema.yml @@ -2903,6 +2903,7 @@ mapping: type: str default: default required: false + per_host: true desc: | Default tool panel view for the current Galaxy configuration. This should refer to an id of a panel view defined using the panel_views or panel_views_dir configuration options or an diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index f70d2978b4f2..03eae4522a4d 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -156,7 +156,7 @@ def __init__( Create a toolbox from the config files named by `config_filenames`, using `tool_root_dir` as the base directory for finding individual tool config files. """ - self._default_panel_view = default_panel_view + self.__default_panel_view = default_panel_view # The _dynamic_tool_confs list contains dictionaries storing # information about the tools defined in each shed-related # shed_tool_conf.xml file. @@ -238,6 +238,9 @@ def to_model(self) -> ToolPanelViewModel: if save_integrated_tool_panel: self._save_integrated_tool_panel() + def _default_panel_view(self, trans): + return self.app.config.config_value_for_host("default_panel_view", trans.host) or self.__default_panel_view + def create_tool(self, config_file, tool_shed_repository=None, guid=None, **kwds): raise NotImplementedError() @@ -1275,7 +1278,7 @@ def find_section_id(self, tool_panel_section_id): def tool_panel_contents(self, trans, view=None, **kwds): """Filter tool_panel contents for displaying for user.""" if view is None: - view = self._default_panel_view + view = self._default_panel_view(trans) if view not in self._tool_panel_view_rendered: raise RequestParameterInvalidException(f"No panel view {view} found.") filter_method = self._build_filter_method(trans) @@ -1338,7 +1341,7 @@ def to_panel_view(self, trans, view="default_panel_view", **kwds): {section_id: { section but with .tools=List[all tool ids] }, ...}} """ if view == "default_panel_view": - view = self._default_panel_view + view = self._default_panel_view(trans) view_contents: Dict[str, Dict] = {} panel_elts = self.tool_panel_contents(trans, view=view, **kwds) for elt in panel_elts: diff --git a/lib/galaxy/webapps/galaxy/api/tools.py b/lib/galaxy/webapps/galaxy/api/tools.py index 38f346bffe8e..ea78cd9f5696 100644 --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -185,7 +185,7 @@ def panel_views(self, trans: GalaxyWebTransaction, **kwds): """ rval = {} - rval["default_panel_view"] = self.app.toolbox._default_panel_view + rval["default_panel_view"] = self.app.toolbox._default_panel_view(trans) rval["views"] = self.app.toolbox.panel_view_dicts() return rval From 1111822e181d9c76705a44ccfaacfcad699b0f99 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 1 Jul 2024 01:03:05 -0400 Subject: [PATCH 2/4] Fix unit test. --- lib/galaxy/tool_util/toolbox/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index 03eae4522a4d..3f50c28cecea 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -239,7 +239,12 @@ def to_model(self) -> ToolPanelViewModel: self._save_integrated_tool_panel() def _default_panel_view(self, trans): - return self.app.config.config_value_for_host("default_panel_view", trans.host) or self.__default_panel_view + config = self.app.config + if hasattr(config, "config_value_for_host"): + config_value = config.config_value_for_host("default_panel_view", trans.host) + else: + config_value = getattr(config, "default_panel_view", None) + return config_value or self.__default_panel_view def create_tool(self, config_file, tool_shed_repository=None, guid=None, **kwds): raise NotImplementedError() From edb81e257412bffada3335e6b98e8b8d23b3c080 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:09:27 +0200 Subject: [PATCH 3/4] detect markdown changes before notifying --- .../Workflow/Editor/Actions/stepActions.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/client/src/components/Workflow/Editor/Actions/stepActions.ts b/client/src/components/Workflow/Editor/Actions/stepActions.ts index d8035b0ea171..42877b2651d4 100644 --- a/client/src/components/Workflow/Editor/Actions/stepActions.ts +++ b/client/src/components/Workflow/Editor/Actions/stepActions.ts @@ -87,8 +87,11 @@ export class LazySetLabelAction extends LazyMutateStepAction<"label"> { run() { const markdown = this.stateStore.report.markdown ?? ""; const newMarkdown = replaceLabel(markdown, this.labelType, this.fromValue as string, this.toValue as string); - this.stateStore.report.markdown = newMarkdown; - this.toast(this.fromValue ?? "", this.toValue ?? ""); + + if (markdown !== newMarkdown) { + this.stateStore.report.markdown = newMarkdown; + this.toast(this.fromValue ?? "", this.toValue ?? ""); + } } undo() { @@ -96,8 +99,11 @@ export class LazySetLabelAction extends LazyMutateStepAction<"label"> { const markdown = this.stateStore.report.markdown ?? ""; const newMarkdown = replaceLabel(markdown, this.labelType, this.toValue as string, this.fromValue as string); - this.stateStore.report.markdown = newMarkdown; - this.toast(this.toValue ?? "", this.fromValue ?? ""); + + if (markdown !== newMarkdown) { + this.stateStore.report.markdown = newMarkdown; + this.toast(this.toValue ?? "", this.fromValue ?? ""); + } } redo() { @@ -139,8 +145,11 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out run() { const markdown = this.stateStore.report.markdown ?? ""; const newMarkdown = replaceLabel(markdown, "output", this.fromLabel, this.toLabel); - this.stateStore.report.markdown = newMarkdown; - this.toast(this.fromLabel ?? "", this.toLabel ?? ""); + + if (newMarkdown !== markdown) { + this.stateStore.report.markdown = newMarkdown; + this.toast(this.fromLabel ?? "", this.toLabel ?? ""); + } } undo() { @@ -148,9 +157,11 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out const markdown = this.stateStore.report.markdown ?? ""; const newMarkdown = replaceLabel(markdown, "output", this.toLabel, this.fromLabel); - this.stateStore.report.markdown = newMarkdown; - this.toast(this.toLabel ?? "", this.fromLabel ?? ""); + if (newMarkdown !== markdown) { + this.stateStore.report.markdown = newMarkdown; + this.toast(this.toLabel ?? "", this.fromLabel ?? ""); + } } redo() { From 43bbe77eb7bbc5a001e98b3f46a7d91c041c0b71 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:46:44 +0200 Subject: [PATCH 4/4] refactor out repeated functionality --- .../Workflow/Editor/Actions/stepActions.ts | 60 +++++++------------ 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/client/src/components/Workflow/Editor/Actions/stepActions.ts b/client/src/components/Workflow/Editor/Actions/stepActions.ts index 42877b2651d4..9e29437040ab 100644 --- a/client/src/components/Workflow/Editor/Actions/stepActions.ts +++ b/client/src/components/Workflow/Editor/Actions/stepActions.ts @@ -54,6 +54,22 @@ export class LazyMutateStepAction extends LazyUndoRedoActi } } +function onLabelSet( + classInstance: LazySetLabelAction | LazySetOutputLabelAction, + from: string | null | undefined, + to: string | null | undefined +) { + const markdown = classInstance.stateStore.report.markdown ?? ""; + const newMarkdown = replaceLabel(markdown, classInstance.labelType, from, to); + + if (markdown !== newMarkdown) { + classInstance.stateStore.report.markdown = newMarkdown; + classInstance.success( + `${classInstance.labelTypeTitle} label updated from "${from}" to "${to}" in workflow report.` + ); + } +} + export class LazySetLabelAction extends LazyMutateStepAction<"label"> { labelType: "input" | "step"; labelTypeTitle: "Input" | "Step"; @@ -80,30 +96,13 @@ export class LazySetLabelAction extends LazyMutateStepAction<"label"> { this.success = useToast().success; } - private toast(from: string, to: string) { - this.success(`${this.labelTypeTitle} label updated from "${from}" to "${to}" in workflow report.`); - } - run() { - const markdown = this.stateStore.report.markdown ?? ""; - const newMarkdown = replaceLabel(markdown, this.labelType, this.fromValue as string, this.toValue as string); - - if (markdown !== newMarkdown) { - this.stateStore.report.markdown = newMarkdown; - this.toast(this.fromValue ?? "", this.toValue ?? ""); - } + onLabelSet(this, this.fromValue, this.toValue); } undo() { super.undo(); - - const markdown = this.stateStore.report.markdown ?? ""; - const newMarkdown = replaceLabel(markdown, this.labelType, this.toValue as string, this.fromValue as string); - - if (markdown !== newMarkdown) { - this.stateStore.report.markdown = newMarkdown; - this.toast(this.toValue ?? "", this.fromValue ?? ""); - } + onLabelSet(this, this.toValue, this.fromValue); } redo() { @@ -117,6 +116,8 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out fromLabel; toLabel; stateStore; + labelType = "output" as const; + labelTypeTitle = "Output" as const; constructor( stepStore: WorkflowStepStore, @@ -138,30 +139,13 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out this.success = useToast().success; } - private toast(from: string, to: string) { - this.success(`Output label updated from "${from}" to "${to}" in workflow report.`); - } - run() { - const markdown = this.stateStore.report.markdown ?? ""; - const newMarkdown = replaceLabel(markdown, "output", this.fromLabel, this.toLabel); - - if (newMarkdown !== markdown) { - this.stateStore.report.markdown = newMarkdown; - this.toast(this.fromLabel ?? "", this.toLabel ?? ""); - } + onLabelSet(this, this.fromLabel, this.toLabel); } undo() { super.undo(); - - const markdown = this.stateStore.report.markdown ?? ""; - const newMarkdown = replaceLabel(markdown, "output", this.toLabel, this.fromLabel); - - if (newMarkdown !== markdown) { - this.stateStore.report.markdown = newMarkdown; - this.toast(this.toLabel ?? "", this.fromLabel ?? ""); - } + onLabelSet(this, this.toLabel, this.fromLabel); } redo() {