From 652e41b74d912a6bc844906e1aaaf617580e45c0 Mon Sep 17 00:00:00 2001 From: Marcos Bento Date: Wed, 5 Jun 2024 15:44:24 +0100 Subject: [PATCH] Disable context menu options for Nodes with Mirror/Aviso attributes Re ECFLOW-1931 --- Viewer/ecflowUI/src/NodeExpression.cpp | 12 ++++++++---- share/ecflow/etc/ecflowview_menus.json | 16 ++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Viewer/ecflowUI/src/NodeExpression.cpp b/Viewer/ecflowUI/src/NodeExpression.cpp index 5839c8c6e..39ca237c7 100644 --- a/Viewer/ecflowUI/src/NodeExpression.cpp +++ b/Viewer/ecflowUI/src/NodeExpression.cpp @@ -110,10 +110,8 @@ bool NodeExpressionParser::isEnvVar(const std::string& str) const { } bool NodeExpressionParser::isNodeHasAttribute(const std::string& str) const { - if (str == "has_triggers" || str == "has_time" || str == "has_date" || str == "locked") - return true; - - return false; + constexpr std::array searchable = {"has_triggers", "has_time", "has_date", "locked", "has_aviso", "has_mirror"}; + return std::find(searchable.begin(), searchable.end(), str) != searchable.end(); } bool NodeExpressionParser::isNodeFlag(const std::string& str) const { @@ -819,6 +817,12 @@ bool NodeAttributeCondition::execute(VItem* item) { else if (nodeAttrName_ == "has_triggers") { return (node->triggerAst() || node->completeAst()); } + else if (nodeAttrName_ == "has_aviso") { + return !node->avisos().empty(); + } + else if (nodeAttrName_ == "has_mirror") { + return !node->mirrors().empty(); + } } return false; diff --git a/share/ecflow/etc/ecflowview_menus.json b/share/ecflow/etc/ecflowview_menus.json index 4d7c601a7..caf6b0650 100644 --- a/share/ecflow/etc/ecflowview_menus.json +++ b/share/ecflow/etc/ecflowview_menus.json @@ -101,7 +101,7 @@ { "menu" : "Node", "name" : "Suspend", - "visible_for" : "not suspended and node", + "visible_for" : "not suspended and node and (not has_mirror)", "command" : "ecflow_client --suspend ", "status_tip" : "__cmd__", "shortcut" : "Ctrl+S" @@ -110,7 +110,7 @@ { "menu" : "Node", "name" : "Resume", - "visible_for" : "suspended and node", + "visible_for" : "suspended and node and (not has_mirror)", "command" : "ecflow_client --resume ", "status_tip" : "__cmd__", "shortcut" : "Ctrl+R" @@ -120,7 +120,7 @@ "menu" : "Node", "name" : "Rerun", "visible_for" : "task", - "enabled_for" : "(not active) and (not submitted)", + "enabled_for" : "(not active) and (not submitted) and (not has_mirror)", "command" : "ecflow_client --force queued ", "status_tip" : "__cmd__", "shortcut" : "Ctrl+U" @@ -130,7 +130,7 @@ "menu" : "Node", "name" : "Set complete", "visible_for" : "task or alias", - "enabled_for" : "submitted or active or unknown or queued or aborted or suspended", + "enabled_for" : "(submitted or active or unknown or queued or aborted or suspended) and (not has_mirror)", "command" : "ecflow_client --force=complete ", "question_for" : "submitted or active", "question" : "Have you checked that the job is not active anymore (jobstatus)?", @@ -143,7 +143,7 @@ "menu" : "Node", "name" : "Set aborted", "visible_for" : "task or alias", - "enabled_for" : "submitted or active or unknown or queued or complete or suspended", + "enabled_for" : "(submitted or active or unknown or queued or complete or suspended) and (not has_mirror)", "command" : "ecflow_client --force=aborted ", "question_for" : "submitted or active", "question" : "Have you checked that the job is not active anymore (jobstatus)?", @@ -156,7 +156,7 @@ "menu" : "Node", "name" : "Execute", "visible_for" : "task or alias", - "enabled_for" : "(not active) and (not submitted)", + "enabled_for" : "(not active) and (not submitted) and (not has_mirror)", "command" : "ecflow_client --run ", "status_tip" : "__cmd__", "shortcut" : "Ctrl+E" @@ -166,7 +166,7 @@ "menu" : "Node", "name" : "Requeue", "visible_for" : "task or suite or family", - "enabled_for" : "(not active) and (not submitted)", + "enabled_for" : "(not active) and (not submitted) and (not has_mirror)", "command" : "ecflow_client --requeue=force ", "warning" : "This command can potentially lead to creating zombies when active nodes are present in the current subtree.", "question" : "Confirm requeuing of ", @@ -179,7 +179,7 @@ "menu" : "Node", "name" : "Requeue aborted", "visible_for" : "suite or family", - "enabled_for" : "aborted or suspended", + "enabled_for" : "aborted or suspended and (not has_mirror)", "command" : "ecflow_client --requeue=abort ", "question" : "Confirm requeuing of aborted tasks from ", "question_control" : "menu.confirm.confirmRequeueAborted",