Skip to content

Commit

Permalink
Better idea for hiding PK parties.
Browse files Browse the repository at this point in the history
  • Loading branch information
merivale committed May 12, 2021
1 parent d460963 commit fce88a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 12 additions & 4 deletions marlowe-dashboard-client/src/Contract/State.purs
Expand Up @@ -15,7 +15,7 @@ import Capability.Toast (class Toast, addToast)
import Contract.Lenses (_executionState, _marloweParams, _namedActions, _previousSteps, _selectedStep, _tab)
import Contract.Types (Action(..), Input, PreviousStep, PreviousStepState(..), State, Tab(..), scrollContainerRef)
import Control.Monad.Reader (class MonadAsk, asks)
import Data.Array (difference, foldl, head, index, length, mapMaybe)
import Data.Array (difference, filter, foldl, index, length, mapMaybe)
import Data.Either (Either(..))
import Data.Foldable (foldMap, for_)
import Data.FoldableWithIndex (foldlWithIndex)
Expand Down Expand Up @@ -103,8 +103,16 @@ mkInitialState walletDetails currentSlot followerAppId history =
in
flip map mTemplate \template ->
let
parties :: Array Party
parties = Set.toUnfoldable $ getParties contract
isRoleParty party = case party of
Role _ -> true
_ -> false

-- Note we filter out PK parties here. This is because we don't have a design for displaying
-- them anywhere, and because we are currently only using one in a special case (in the Escrow
-- with Collateral contract), where it doesn't make much sense to show it to the user anyway.
-- If we ever want to use PK parties for other purposes, we will need to rethink this.
roleParties :: Array Party
roleParties = filter isRoleParty $ Set.toUnfoldable $ getParties contract

initialState =
{ tab: Tasks
Expand All @@ -114,7 +122,7 @@ mkInitialState walletDetails currentSlot followerAppId history =
, followerAppId
, selectedStep: 0
, metadata: template.metaData
, participants: Map.fromFoldable $ map (\x -> x /\ Nothing) parties
, participants: Map.fromFoldable $ map (\x -> x /\ Nothing) roleParties
, userParties: getUserParties walletDetails marloweParams
, namedActions: mempty
}
Expand Down
10 changes: 2 additions & 8 deletions marlowe-dashboard-client/src/Contract/View.purs
Expand Up @@ -17,7 +17,7 @@ import Data.BigInteger (BigInteger, fromInt, fromString)
import Data.Foldable (foldMap)
import Data.FunctorWithIndex (mapWithIndex)
import Data.Lens ((^.))
import Data.Map (filterKeys, keys, lookup, toUnfoldable) as Map
import Data.Map (keys, lookup, toUnfoldable) as Map
import Data.Maybe (Maybe(..), maybe, maybe')
import Data.Set (Set)
import Data.Set as Set
Expand Down Expand Up @@ -677,13 +677,7 @@ renderBalances state accounts =
-- TODO: Right now we only have one type of Token (ada), but when we support multiple tokens we may want to group by
-- participant and show the different tokens for each participant.
accounts' :: Array (Tuple (Tuple Party Token) BigInteger)
accounts' = Map.toUnfoldable $ Map.filterKeys isRoleAccount accounts

-- Note we are currently filtering out PK accounts. We have no nice way to display them, and we are only using them
-- in one special case where it is confusing to display them anyway.
isRoleAccount (accountId /\ token) = case accountId of
Role _ -> true
_ -> false
accounts' = Map.toUnfoldable accounts
in
div [ classNames [ "text-xs" ] ]
( append
Expand Down

0 comments on commit fce88a0

Please sign in to comment.