Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

fixing #372: transitions makred as potentials even though ... #328

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/TransitionViz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,20 @@ export const TransitionViz: React.FC<{
service,
(s) => s.context.serviceDataMap[s.context.currentSessionId!]?.state,
);
const machine = useSelector(
service,
(s) => s.context.serviceDataMap[s.context.currentSessionId!]?.machine,
);
const delayOptions = useSelector(service, delayOptionsSelector);
const delay = useMemo(
() =>
delayOptions
? getDelayFromEventType(
definition.eventType,
delayOptions,
state?.context,
state?.event,
)
definition.eventType,
delayOptions,
state?.context,
state?.event,
)
: undefined,
[definition.eventType, delayOptions, state],
);
Expand All @@ -98,12 +102,24 @@ export const TransitionViz: React.FC<{
return null;
}

// extra check if the transition might be blocked by the 'in' property...
const isBlocked =
typeof definition.in === "string" && // exists
definition.in.length > 0 && // with non empty content
(
definition.in[0] === "#" // is 'custom id' or path?
? !machine || !state.matches(machine.getStateNodeById(definition.in.substring(1)).path.join(machine.delimiter))
: !state.matches(definition.in)
jbouecke marked this conversation as resolved.
Show resolved Hide resolved
)

const isDisabled =
delay?.delayType === 'DELAYED_INVALID' ||
!state.nextEvents.includes(definition.eventType);

const isPotential =
state.nextEvents.includes(edge.transition.eventType) &&
!!state.configuration.find((sn) => sn === edge.source);
state.nextEvents.includes(definition.eventType) &&
!!state.configuration.find((sn) => sn === edge.source) &&
!isBlocked;

return (
<button
Expand Down