Mark start node for translation

This commit is contained in:
mabashian
2021-02-17 14:35:50 -05:00
parent c9ec0d31f1
commit 510b4197ac
3 changed files with 35 additions and 22 deletions

View File

@@ -8,7 +8,6 @@ import {
WorkflowDispatchContext,
WorkflowStateContext,
} from '../../contexts/Workflow';
import { constants as wfConstants } from './WorkflowUtils';
import WorkflowActionTooltip from './WorkflowActionTooltip';
import WorkflowActionTooltipItem from './WorkflowActionTooltipItem';
@@ -16,8 +15,25 @@ const StartG = styled.g`
pointer-events: ${props => (props.ignorePointerEvents ? 'none' : 'auto')};
`;
const StartForeignObject = styled.foreignObject`
overflow: visible;
`;
const StartDiv = styled.div`
background-color: #0279bc;
color: white;
width: max-content;
min-width: 80px;
height: 40px;
border-radius: 0.35em;
text-align: center;
line-height: 40px;
padding: 0px 10px;
`;
function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) {
const ref = useRef(null);
const startNodeRef = useRef(null);
const [hovering, setHovering] = useState(false);
const dispatch = useContext(WorkflowDispatchContext);
const { addingLink, nodePositions } = useContext(WorkflowStateContext);
@@ -36,18 +52,14 @@ function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) {
ref={ref}
transform={`translate(${nodePositions[1].x},0)`}
>
<rect
fill="#0279BC"
height={wfConstants.rootH}
rx="2"
ry="2"
width={wfConstants.rootW}
<StartForeignObject
height="1"
width="1"
y="10"
/>
{/* TODO: We need to be able to handle translated text here */}
<text x="13" y="30" dy=".35em" fill="white">
START
</text>
style={{ overflow: 'visible' }}
>
<StartDiv ref={startNodeRef}>{i18n._(t`START`)}</StartDiv>
</StartForeignObject>
{showActionTooltip && hovering && (
<WorkflowActionTooltip
actions={[
@@ -65,8 +77,8 @@ function WorkflowStartNode({ i18n, onUpdateHelpText, showActionTooltip }) {
<PlusIcon />
</WorkflowActionTooltipItem>,
]}
pointX={wfConstants.rootW}
pointY={wfConstants.rootH / 2 + 10}
pointX={startNodeRef.current.offsetWidth}
pointY={startNodeRef.current.offsetHeight / 2 + 10}
/>
)}
</StartG>

View File

@@ -250,7 +250,7 @@ function VisualizerGraph({ i18n, readOnly }) {
</defs>
<rect
height="100%"
id="workflow-backround"
id="workflow-background"
opacity="0"
width="100%"
{...(addingLink && {
@@ -267,12 +267,6 @@ function VisualizerGraph({ i18n, readOnly }) {
/>
<g id="workflow-g" ref={gRef}>
{nodePositions && [
<WorkflowStartNode
key="start"
showActionTooltip={!readOnly}
onUpdateHelpText={setHelpText}
readOnly={readOnly}
/>,
links.map(link => {
if (
nodePositions[link.source.id] &&
@@ -307,6 +301,12 @@ function VisualizerGraph({ i18n, readOnly }) {
}
return null;
}),
<WorkflowStartNode
key="start"
showActionTooltip={!readOnly}
onUpdateHelpText={setHelpText}
readOnly={readOnly}
/>,
]}
{addingLink && (
<PotentialLink

View File

@@ -94,7 +94,8 @@ function VisualizerLink({
];
const handleLinkMouseEnter = () => {
ref.current.parentNode.appendChild(ref.current);
const startNode = document.getElementById('node-1');
ref.current.parentNode.insertBefore(ref.current, startNode);
setHovering(true);
};