From 041f4e7976cfb7e8c8dd7f6400d6228cf6e3a634 Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Fri, 15 Mar 2024 16:15:26 +0100
Subject: [PATCH] lso result step title is now always the name of the
 provisioning step

the optional label remains, if found to be useful at a later point in time
---
 gso/services/lso_client.py | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/gso/services/lso_client.py b/gso/services/lso_client.py
index 219da5ae..67e4b77c 100644
--- a/gso/services/lso_client.py
+++ b/gso/services/lso_client.py
@@ -124,14 +124,9 @@ def _show_results(state: State) -> FormGenerator:
     if "callback_result" not in state:
         return state
 
-    if "lso_result_title" in state:
-        result_title = state["lso_result_title"]
-    else:
-        result_title = f"Execution for {state['subscription']['product']['name']} completed."
-
     class ConfirmRunPage(FormPage):
         class Config:
-            title: str = result_title
+            title: str = state["lso_result_title"]
 
         if "lso_result_extra_label" in state:
             extra_label: Label = state["lso_result_extra_label"]
@@ -139,7 +134,7 @@ def _show_results(state: State) -> FormGenerator:
         run_results: LongText = ReadOnlyField(json.dumps(state["callback_result"], indent=4))
 
     yield ConfirmRunPage
-    [state.pop(key) for key in ["run_results", "lso_result_title", "lso_result_extra_label"]]
+    [state.pop(key, None) for key in ["run_results", "lso_result_title", "lso_result_extra_label"]]
     return state
 
 
@@ -161,11 +156,8 @@ def lso_interaction(provisioning_step: Step) -> StepList:
     """
     return (
         begin
-        >> callback_step(
-            name=provisioning_step.name,
-            action_step=provisioning_step,
-            validate_step=_evaluate_results,
-        )
+        >> callback_step(name=provisioning_step.name, action_step=provisioning_step, validate_step=_evaluate_results)
+        >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name})
         >> _show_results
     )
 
@@ -188,10 +180,7 @@ def indifferent_lso_interaction(provisioning_step: Step) -> StepList:
     """
     return (
         begin
-        >> callback_step(
-            name=provisioning_step.name,
-            action_step=provisioning_step,
-            validate_step=_ignore_results,
-        )
+        >> callback_step(name=provisioning_step.name, action_step=provisioning_step, validate_step=_ignore_results)
+        >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name})
         >> _show_results
     )
-- 
GitLab