Skip to content

Commit a7f0a41

Browse files
FredLL-AvaigaFred Lefévère-Laoide
andauthored
display unsupported data in datanode with error message (#1951)
resolves #1916 resolves #1948 Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
1 parent 7bd62af commit a7f0a41

File tree

2 files changed

+35
-40
lines changed

2 files changed

+35
-40
lines changed

frontend/taipy/src/ScenarioSelector.tsx

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import InputLabel from "@mui/material/InputLabel";
2828
import MenuItem from "@mui/material/MenuItem";
2929
import Dialog from "@mui/material/Dialog";
3030
import Select from "@mui/material/Select";
31+
import Stack from "@mui/material/Stack";
3132
import TextField from "@mui/material/TextField";
3233
import Typography from "@mui/material/Typography";
3334
import { Close, DeleteOutline, Add, EditOutlined } from "@mui/icons-material";
@@ -107,7 +108,7 @@ const emptyScenario: ScenarioDict = {
107108
properties: [],
108109
};
109110

110-
const ActionContentSx = { mr: 2, ml: 2 };
111+
const ActionContentSx = { mr: 2, ml: 2, width: "100%" };
111112

112113
const DialogContentSx = {
113114
maxHeight: "calc(100vh - 256px)",
@@ -126,10 +127,6 @@ const SquareButtonSx = {
126127
aspectRatio: "1",
127128
};
128129

129-
const CancelBtnSx = {
130-
mr: 2,
131-
};
132-
133130
const IconButtonSx = {
134131
p: 0,
135132
};
@@ -370,36 +367,28 @@ const ScenarioEditDialog = ({ scenario, submit, open, actionEdit, configs, close
370367
</DialogContent>
371368

372369
<DialogActions>
373-
<Grid container justifyContent="space-between" sx={ActionContentSx}>
370+
<Stack direction="row" justifyContent="space-between" sx={ActionContentSx}>
374371
{actionEdit && (
375-
<Grid size={6}>
376-
<Button
377-
variant="outlined"
378-
color="error"
379-
onClick={onConfirmDialogOpen}
380-
disabled={!scenario || !scenario[ScFProps.deletable]}
381-
>
382-
Delete
383-
</Button>
384-
</Grid>
372+
<Button
373+
variant="outlined"
374+
color="error"
375+
onClick={onConfirmDialogOpen}
376+
disabled={!scenario || !scenario[ScFProps.deletable]}
377+
>
378+
Delete
379+
</Button>
385380
)}
386-
<Grid container size={actionEdit ? 6 : 12} justifyContent="flex-end">
387-
<Grid sx={CancelBtnSx}>
388-
<Button variant="outlined" color="inherit" onClick={close}>
389-
Cancel
390-
</Button>
391-
</Grid>
392-
<Grid>
393-
<Button
394-
variant="contained"
395-
type="submit"
396-
disabled={!form.values.config || !form.values.name}
397-
>
398-
{actionEdit ? "Apply" : "Create"}
399-
</Button>
400-
</Grid>
401-
</Grid>
402-
</Grid>
381+
<Button variant="outlined" color="inherit" onClick={close}>
382+
Cancel
383+
</Button>
384+
<Button
385+
variant="contained"
386+
type="submit"
387+
disabled={!form.values.config || !form.values.name}
388+
>
389+
{actionEdit ? "Apply" : "Create"}
390+
</Button>
391+
</Stack>
403392
</DialogActions>
404393
</form>
405394
</Dialog>
@@ -489,26 +478,26 @@ const ScenarioSelector = (props: ScenarioSelectorProps) => {
489478
const openEditDialog = useCallback(
490479
(e: React.MouseEvent<HTMLElement>) => {
491480
e.stopPropagation();
492-
const { id: scenId } = e.currentTarget?.dataset || {};
481+
const { id: scId } = e.currentTarget?.dataset || {};
493482
const varName = getUpdateVar(updateScVars, "sc_id");
494-
scenId &&
483+
scId &&
495484
props.onScenarioSelect &&
496-
dispatch(createSendActionNameAction(props.id, module, props.onScenarioSelect, varName, scenId));
485+
dispatch(createSendActionNameAction(props.id, module, props.onScenarioSelect, varName, scId));
497486
setOpen(true);
498487
setActionEdit(true);
499488
},
500489
[props.onScenarioSelect, props.id, dispatch, module, updateScVars]
501490
);
502491

503-
const EditScenario = useCallback(
492+
const editScenario = useCallback(
504493
(props: EditProps) => (
505494
<Tooltip title={props.active ? "Edit Scenario" : "Can't edit Scenario"}>
506495
<span>
507496
<IconButton
508497
data-id={props.id}
509498
onClick={openEditDialog}
510499
sx={tinyEditIconButtonSx}
511-
disabled={props.active}
500+
disabled={!props.active}
512501
>
513502
<EditOutlined />
514503
</IconButton>
@@ -526,7 +515,7 @@ const ScenarioSelector = (props: ScenarioSelectorProps) => {
526515
entities={props.innerScenarios}
527516
leafType={NodeType.SCENARIO}
528517
lovPropertyName="innerScenarios"
529-
editComponent={EditScenario}
518+
editComponent={editScenario}
530519
showPins={showPins}
531520
multiple={multiple}
532521
updateCoreVars={updateScVars}

taipy/gui_core/_adapters.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,17 @@ def __get_data(self, dn: DataNode):
206206
)
207207
if isinstance(value, float) and math.isnan(value):
208208
value = None
209+
error = None
210+
if val_type not in ("date", "int", "float", "string"):
211+
try:
212+
json.dumps(value)
213+
except Exception as e:
214+
error = f"Unsupported data: {e}."
209215
return (
210216
value,
211217
val_type,
212218
None,
213-
None,
219+
error,
214220
)
215221
except Exception as e:
216222
return (None, None, None, f"read data_node: {e}")

0 commit comments

Comments
 (0)