From 510b4197ac43645599aa7f3129ae24694000ab0b Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 17 Feb 2021 14:35:50 -0500 Subject: [PATCH 1/3] Mark start node for translation --- .../components/Workflow/WorkflowStartNode.jsx | 40 ++++++++++++------- .../VisualizerGraph.jsx | 14 +++---- .../VisualizerLink.jsx | 3 +- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx index 7735d6c98d..23dbc06481 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowStartNode.jsx @@ -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)`} > - - {/* TODO: We need to be able to handle translated text here */} - - START - + style={{ overflow: 'visible' }} + > + {i18n._(t`START`)} + {showActionTooltip && hovering && ( , ]} - pointX={wfConstants.rootW} - pointY={wfConstants.rootH / 2 + 10} + pointX={startNodeRef.current.offsetWidth} + pointY={startNodeRef.current.offsetHeight / 2 + 10} /> )} diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx index 8f07f037b9..877979e711 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerGraph.jsx @@ -250,7 +250,7 @@ function VisualizerGraph({ i18n, readOnly }) { {nodePositions && [ - , links.map(link => { if ( nodePositions[link.source.id] && @@ -307,6 +301,12 @@ function VisualizerGraph({ i18n, readOnly }) { } return null; }), + , ]} {addingLink && ( { - ref.current.parentNode.appendChild(ref.current); + const startNode = document.getElementById('node-1'); + ref.current.parentNode.insertBefore(ref.current, startNode); setHovering(true); }; From 65c71b812eaa4432586be0d8e77849278c0aa909 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 17 Feb 2021 15:11:51 -0500 Subject: [PATCH 2/3] Mount with contexts now that i18n is used on workflow start node --- .../src/components/Workflow/WorkflowStartNode.test.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/ui_next/src/components/Workflow/WorkflowStartNode.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowStartNode.test.jsx index 5f5284e176..78cf3756dc 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowStartNode.test.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowStartNode.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; import { WorkflowStateContext } from '../../contexts/Workflow'; import WorkflowStartNode from './WorkflowStartNode'; @@ -12,7 +12,7 @@ const nodePositions = { describe('WorkflowStartNode', () => { test('mounts successfully', () => { - const wrapper = mount( + const wrapper = mountWithContexts( { expect(wrapper).toHaveLength(1); }); test('tooltip shown on hover', () => { - const wrapper = mount( + const wrapper = mountWithContexts( From 0345a0c8e201c017c8ac99a7b39a61343e6abe7f Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 2 Mar 2021 15:10:25 -0500 Subject: [PATCH 3/3] Remove Start from linter ignore array --- awx/ui_next/.eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui_next/.eslintrc b/awx/ui_next/.eslintrc index c464701811..f82900134e 100644 --- a/awx/ui_next/.eslintrc +++ b/awx/ui_next/.eslintrc @@ -79,7 +79,7 @@ "theme", "gridColumns" ], - "ignore": ["Ansible", "Tower", "JSON", "YAML", "lg", "START"], + "ignore": ["Ansible", "Tower", "JSON", "YAML", "lg"], "ignoreComponent": [ "code", "Omit",