From 60f51400d50c71e7322b8e4bd05a76e6b2286284 Mon Sep 17 00:00:00 2001 From: Erik Post Date: Wed, 22 Jan 2020 00:00:59 +0100 Subject: [PATCH] studio: Show GluedTransitionId history for a given firing. #307 --- stbx-core/src/Statebox/Core/Lenses.purs | 15 +++++++++++---- studio/src/View/Transaction.purs | 8 ++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/stbx-core/src/Statebox/Core/Lenses.purs b/stbx-core/src/Statebox/Core/Lenses.purs index 7f0e7b14..7c6e807d 100644 --- a/stbx-core/src/Statebox/Core/Lenses.purs +++ b/stbx-core/src/Statebox/Core/Lenses.purs @@ -1,11 +1,12 @@ module Statebox.Core.Lenses where import Prelude -import Data.Lens (Prism', prism', Lens', lens) +import Data.Lens (Prism', Iso', Lens', lens, prism', re, _Newtype) +import Data.Lens.Iso.Newtype (_Newtype) import Data.Maybe (Maybe(..)) import Data.NonEmpty (singleton, head) import Statebox.Core.Transaction (TxSum(..), WiringTx, FiringTx, isExecutionTx) -import Statebox.Core.Types (Firing, GluedTransitionIdRaw) +import Statebox.Core.Types (Firing, GluedTransitionId(..), GluedTransitionIdRaw) -------------------------------------------------------------------------------- @@ -26,5 +27,11 @@ _executionTx = prism' FiringTxInj $ case _ of FiringTxInj x | isExecutionTx x -> _firing :: Lens' FiringTx Firing _firing = lens (_.firing) (_ { firing = _ }) -_firingPath :: Lens' Firing GluedTransitionIdRaw -_firingPath = lens (_.path >>> head) (\r x -> r { path = singleton x }) +_firingPath :: Lens' Firing GluedTransitionId +_firingPath = _firingPathRaw <<< re _GluedTransitionId + +_firingPathRaw :: Lens' Firing GluedTransitionIdRaw +_firingPathRaw = lens (_.path >>> head) (\r x -> r { path = singleton x }) + +_GluedTransitionId :: Iso' GluedTransitionId GluedTransitionIdRaw +_GluedTransitionId = _Newtype diff --git a/studio/src/View/Transaction.purs b/studio/src/View/Transaction.purs index 5020358b..52423233 100644 --- a/studio/src/View/Transaction.purs +++ b/studio/src/View/Transaction.purs @@ -14,8 +14,9 @@ import Halogen.HTML.Properties (href) import View.Studio.Model (Action(..)) import View.Studio.Model.Route (WiringFiringInfo, ExecutionTrace) import Statebox.Client (txUrl) -import Statebox.Core.Transaction (HashStr, TxSum, FiringTx, WiringTx, isExecution) import Statebox.Core.Lenses (_firingTx, _firing, _firingPath) +import Statebox.Core.Transaction (HashStr, TxSum, FiringTx, WiringTx, isExecution) +import Statebox.Core.Types (TID, GluedTransitionId(..)) firingTxView :: ∀ s m. MonadAff m => WiringFiringInfo -> FiringTx -> String \/ ExecutionTrace -> ComponentHTML Action s m @@ -24,9 +25,12 @@ firingTxView wfi tx executionTrace = [ p [] [ text $ if isExecution tx.firing then "Execution" else "Firing" ] , table [] $ txWrapperRows wfi tx <> firingTxBodyRows wfi tx <> - [ row "trace" $ text $ show $ map (mapMaybe (preview (second <<< _Just <<< _firingTx <<< _firing <<< _firingPath))) executionTrace ] <> + [ row "trace" $ text $ show $ firedTransitions ] <> [ row "trace raw" $ text (show executionTrace) ] ] + where + firedTransitions :: String \/ Array GluedTransitionId + firedTransitions = map (mapMaybe (preview (second <<< _Just <<< _firingTx <<< _firing <<< _firingPath))) executionTrace wiringTxView :: ∀ s m. MonadAff m => WiringFiringInfo -> WiringTx -> ComponentHTML Action s m wiringTxView wfi tx =