Skip to content

Commit

Permalink
Revert bridge to Switch naming change
Browse files Browse the repository at this point in the history
  • Loading branch information
jhurst502 committed May 5, 2022
1 parent 31b3af9 commit 194b5d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
27 changes: 15 additions & 12 deletions src/components/LabEditorGUI/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ const UncontrolledDiagram = ({ menuType, setMenuType, textBoxPosition, setTextBo
onClick: () => {
if (schema.nodes.find(nodes => nodes.id === selectedNode)) {
const node: Node<any> = schema.nodes.find(nodes => nodes.id === selectedNode) as Node<any>;
// TODO this position does not always align the text box under the node
setTextBoxPosition([node.coordinates[0] + rect.left - 50, node.coordinates[1] + rect.top + 90]);
const element = document!.getElementById(node.id);
setTextBoxPosition([element!.getBoundingClientRect().left, element!.getBoundingClientRect().top]);
toggleRenameTextBox(true);
setNodeToRename(node.id);
setNewNodeName(node.content as string);
Expand Down Expand Up @@ -510,10 +510,11 @@ const UncontrolledDiagram = ({ menuType, setMenuType, textBoxPosition, setTextBo
if (((event.clientX - rect.left) >= node.coordinates[0] && (event.clientX - rect.left) - 20 <= node.coordinates[0] + 50)
&& ((event.clientY - rect.top) >= node.coordinates[1] && (event.clientY - rect.top) - 20 <= node.coordinates[1] + 100)) {
if (node.nodeType === 'vm') {
setTextBoxPosition([node.coordinates[0] + rect.left - 50, node.coordinates[1] + rect.top + 90]);
const element = document!.getElementById(node.id);
setTextBoxPosition([element!.getBoundingClientRect().left, element!.getBoundingClientRect().top]);
toggleRenameTextBox(true);
setNodeToRename(node.id);
setNewNodeName(node.content as string);
toggleRenameTextBox(true);
}
}
}
Expand Down Expand Up @@ -553,14 +554,16 @@ const UncontrolledDiagram = ({ menuType, setMenuType, textBoxPosition, setTextBo
<SelectSwitch addSwitch={addNewSwitch} close={() => setSelectSwitchVisible(false)}/>}
<Diagram schema={schema} onChange={onChange} />
{renameTextBox &&
<form onSubmit={handleSubmit} style={{position:'absolute', left:`${textBoxPosition[0]}px`, top:`${textBoxPosition[1]}px`, zIndex:1000}}>
<input
type='text'
value={newNodeName}
onChange={handleInputChange}
/>
<input type='submit' style={{display: 'none'}}/>
</form>}
<div style={{}}>
<form onSubmit={handleSubmit} style={{position:'fixed', left:`${textBoxPosition[0]}px`, top:`${textBoxPosition[1]}px`, zIndex:1000}}>
<input
type='text'
value={newNodeName}
onChange={handleInputChange}
/>
<input type='submit' style={{display: 'none'}}/>
</form>
</div>}}
</div>
</ContextContainer>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/LabEditorGUI/VmNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const VmNode = ({id, inputs, content}: NodeParameters) => {
}))}
</div>
<img src={VmSVG} alt='VM' draggable={false} style={{height: '50px', userSelect:'none', pointerEvents:'none'}}/>
<div style={{display:'flex', justifyContent:'center'}}>
<div id={id} style={{display:'flex', justifyContent:'center'}}>
<h5>{content}</h5>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/LabEditor/LabEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function LabEditor({match: {params: {moduleId, labId}}}: Props) {

setEditing(false);
setMessage({message: 'Successfully Saved', variant: 'success'});
if(!labId) {
if(!labId && response !== undefined) {
setRedirect(RoutePaths.EditLab.replace(':moduleId', String(moduleId)).replace(':labId', String(response.id)));
}
} catch (e) {
Expand Down

0 comments on commit 194b5d4

Please sign in to comment.