Skip to content

Commit 60f5140

Browse files
committed
studio: Show GluedTransitionId history for a given firing. #307
1 parent c2fdada commit 60f5140

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

stbx-core/src/Statebox/Core/Lenses.purs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module Statebox.Core.Lenses where
22

33
import Prelude
4-
import Data.Lens (Prism', prism', Lens', lens)
4+
import Data.Lens (Prism', Iso', Lens', lens, prism', re, _Newtype)
5+
import Data.Lens.Iso.Newtype (_Newtype)
56
import Data.Maybe (Maybe(..))
67
import Data.NonEmpty (singleton, head)
78
import Statebox.Core.Transaction (TxSum(..), WiringTx, FiringTx, isExecutionTx)
8-
import Statebox.Core.Types (Firing, GluedTransitionIdRaw)
9+
import Statebox.Core.Types (Firing, GluedTransitionId(..), GluedTransitionIdRaw)
910

1011
--------------------------------------------------------------------------------
1112

@@ -26,5 +27,11 @@ _executionTx = prism' FiringTxInj $ case _ of FiringTxInj x | isExecutionTx x ->
2627
_firing :: Lens' FiringTx Firing
2728
_firing = lens (_.firing) (_ { firing = _ })
2829

29-
_firingPath :: Lens' Firing GluedTransitionIdRaw
30-
_firingPath = lens (_.path >>> head) (\r x -> r { path = singleton x })
30+
_firingPath :: Lens' Firing GluedTransitionId
31+
_firingPath = _firingPathRaw <<< re _GluedTransitionId
32+
33+
_firingPathRaw :: Lens' Firing GluedTransitionIdRaw
34+
_firingPathRaw = lens (_.path >>> head) (\r x -> r { path = singleton x })
35+
36+
_GluedTransitionId :: Iso' GluedTransitionId GluedTransitionIdRaw
37+
_GluedTransitionId = _Newtype

studio/src/View/Transaction.purs

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import Halogen.HTML.Properties (href)
1414
import View.Studio.Model (Action(..))
1515
import View.Studio.Model.Route (WiringFiringInfo, ExecutionTrace)
1616
import Statebox.Client (txUrl)
17-
import Statebox.Core.Transaction (HashStr, TxSum, FiringTx, WiringTx, isExecution)
1817
import Statebox.Core.Lenses (_firingTx, _firing, _firingPath)
18+
import Statebox.Core.Transaction (HashStr, TxSum, FiringTx, WiringTx, isExecution)
19+
import Statebox.Core.Types (TID, GluedTransitionId(..))
1920

2021

2122
firingTxView :: s m. MonadAff m => WiringFiringInfo -> FiringTx -> String \/ ExecutionTrace -> ComponentHTML Action s m
@@ -24,9 +25,12 @@ firingTxView wfi tx executionTrace =
2425
[ p [] [ text $ if isExecution tx.firing then "Execution" else "Firing" ]
2526
, table [] $ txWrapperRows wfi tx <>
2627
firingTxBodyRows wfi tx <>
27-
[ row "trace" $ text $ show $ map (mapMaybe (preview (second <<< _Just <<< _firingTx <<< _firing <<< _firingPath))) executionTrace ] <>
28+
[ row "trace" $ text $ show $ firedTransitions ] <>
2829
[ row "trace raw" $ text (show executionTrace) ]
2930
]
31+
where
32+
firedTransitions :: String \/ Array GluedTransitionId
33+
firedTransitions = map (mapMaybe (preview (second <<< _Just <<< _firingTx <<< _firing <<< _firingPath))) executionTrace
3034

3135
wiringTxView :: s m. MonadAff m => WiringFiringInfo -> WiringTx -> ComponentHTML Action s m
3236
wiringTxView wfi tx =

0 commit comments

Comments
 (0)