Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed FE-2739 #339

Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# TBD

- [FP-2739](https://movai.atlassian.net/browse/FP-2739): Port properties of the node templates are turning to strings after editing them

# v1.2.5

- [FP-2879](https://movai.atlassian.net/browse/FP-2879): Closing last tab keeps bookmarks
Expand Down
11 changes: 10 additions & 1 deletion src/editors/Node/view/Node.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ export const Node = (props, ref) => {
);

const updateIOPortInputs = useCallback(
(value, ioConfigName, direction, ioPortKey, paramName) => {
(target, ioConfigName, direction, ioPortKey, paramName) => {
// Can be either a checkbox event or a text/number change event
let value = target.type === "checkbox" ? target.checked : target.value;

// Make sure if the input is a number, we save a number to Redis
// TO improve: backend can do this type validation
if (target.type === "number") {
value = parseFloat(value);
}

instance.current.setPortParameter(
ioConfigName,
direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback } from "react";
import Grid from "@material-ui/core/Grid";
import Circle from "@material-ui/icons/FiberManualRecord";
import TextField from "@material-ui/core/TextField";
import Checkbox from "@material-ui/core/Checkbox";

import { parametersStyles } from "./styles";

Expand All @@ -22,7 +23,7 @@ const Parameters = props => {
const handleOnChange = useCallback(
evt => {
handleIOPortsInputs(
evt.target.value,
evt.target,
rowDataName,
direction,
ioPort,
Expand All @@ -32,20 +33,37 @@ const Parameters = props => {
[rowDataName, direction, ioPort, param, handleIOPortsInputs]
);

const inputType = () => {
// TODO: Ports data should provide which type the frontend should render
// and not this harcoded string
if (["latch", "Oneshot"].includes(param)) {
return <Checkbox
type={"checkbox"}
defaultChecked={paramValue}
onChange={handleOnChange}
/>;
}
else {
return <TextField
type={["Frequency", "queue_size"].includes(param) ? "number" : "text"}
inputProps={{ "data-testid": "input_parameter" }}
disabled={!editable}
defaultValue={paramValue}
className={classes.input}
onChange={handleOnChange}
/>;
}

}

return (
<Grid className={classes.gridContainer}>
<Grid item xs={3} className={classes.titleColumn}>
<Circle className={classes.circle} />
{`${param}:`}
</Grid>
<Grid item xs={9}>
<TextField
inputProps={{ "data-testid": "input_parameter" }}
disabled={!editable}
defaultValue={paramValue}
className={classes.input}
onChange={handleOnChange}
/>
{inputType()}
</Grid>
</Grid>
);
Expand Down
Loading