this.setState({ showWarning: false })}
+ onConfirm={() => this.handleConfirm()}
+ >
+
+ The type of the previous item ({this.props.lastType}) does not correspond to the type of the entry ({this.state.parsedType}). Do you want to proceed?
+
+
+ ) : null;
+
+ return (
+ <>
+ {addEntryModal}
+ {warningModal}
+ >
+ );
}
}
diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js
index c6c1145530..6981cfcf5c 100644
--- a/src/dashboard/Data/Config/Config.react.js
+++ b/src/dashboard/Data/Config/Config.react.js
@@ -48,6 +48,7 @@ class Config extends TableView {
lastNote: null,
showAddEntryDialog: false,
addEntryParam: '',
+ addEntryLastType: null,
};
this.noteTimeout = null;
}
@@ -122,6 +123,7 @@ class Config extends TableView {
onConfirm={value =>
this.addArrayEntry(this.state.addEntryParam, value)
}
+ lastType={this.state.addEntryLastType}
/>
);
}
@@ -207,6 +209,16 @@ class Config extends TableView {
};
}
+ getEntryType(value) {
+ if (Array.isArray(value)) {
+ return 'array';
+ }
+ if (value === null) {
+ return 'null';
+ }
+ return typeof value;
+ }
+
renderRow(data) {
// Parse modal data
const { value, modalValue, type } = this.parseValueForModal(data.value);
@@ -491,11 +503,25 @@ class Config extends TableView {
}
openAddEntryDialog(param) {
- this.setState({ showAddEntryDialog: true, addEntryParam: param });
+ const params = this.props.config.data.get('params');
+ const arr = params?.get(param);
+ let lastType = null;
+ if (Array.isArray(arr) && arr.length > 0) {
+ lastType = this.getEntryType(arr[arr.length - 1]);
+ }
+ this.setState({
+ showAddEntryDialog: true,
+ addEntryParam: param,
+ addEntryLastType: lastType,
+ });
}
closeAddEntryDialog() {
- this.setState({ showAddEntryDialog: false, addEntryParam: '' });
+ this.setState({
+ showAddEntryDialog: false,
+ addEntryParam: '',
+ addEntryLastType: null,
+ });
}
async addArrayEntry(param, value) {
From 88d4ef2fd25449990d3ecb2ec66c0bd0db4e7049 Mon Sep 17 00:00:00 2001
From: Manuel <5673677+mtrezza@users.noreply.github.com>
Date: Wed, 9 Jul 2025 02:21:35 +0200
Subject: [PATCH 2/5] Refine type mismatch warning
---
.../Data/Config/AddArrayEntryDialog.react.js | 87 ++++++++++++-------
1 file changed, 58 insertions(+), 29 deletions(-)
diff --git a/src/dashboard/Data/Config/AddArrayEntryDialog.react.js b/src/dashboard/Data/Config/AddArrayEntryDialog.react.js
index 082362a01d..8707343c60 100644
--- a/src/dashboard/Data/Config/AddArrayEntryDialog.react.js
+++ b/src/dashboard/Data/Config/AddArrayEntryDialog.react.js
@@ -10,11 +10,17 @@ import Label from 'components/Label/Label.react';
import Modal from 'components/Modal/Modal.react';
import React from 'react';
import TextInput from 'components/TextInput/TextInput.react';
+import Checkbox from 'components/Checkbox/Checkbox.react';
export default class AddArrayEntryDialog extends React.Component {
constructor() {
super();
- this.state = { value: '', showWarning: false, parsedValue: null, parsedType: '' };
+ this.state = {
+ value: '',
+ showMismatchRow: false,
+ mismatchConfirmed: false,
+ parsedType: '',
+ };
this.inputRef = React.createRef();
}
@@ -25,7 +31,13 @@ export default class AddArrayEntryDialog extends React.Component {
}
valid() {
- return this.state.value !== '';
+ if (this.state.value === '') {
+ return false;
+ }
+ if (this.state.showMismatchRow && !this.state.mismatchConfirmed) {
+ return false;
+ }
+ return true;
}
getValue() {
@@ -50,12 +62,28 @@ export default class AddArrayEntryDialog extends React.Component {
const parsed = this.getValue();
const entryType = this.getType(parsed);
const lastType = this.props.lastType;
- if (lastType && entryType !== lastType && !this.state.showWarning) {
- this.setState({ showWarning: true, parsedValue: parsed, parsedType: entryType });
- return;
+
+ if (lastType && entryType !== lastType) {
+ if (!this.state.showMismatchRow) {
+ this.setState({
+ showMismatchRow: true,
+ mismatchConfirmed: false,
+ parsedType: entryType,
+ });
+ return;
+ }
+ if (!this.state.mismatchConfirmed) {
+ return;
+ }
}
+
this.props.onConfirm(parsed);
- this.setState({ showWarning: false, parsedValue: null, parsedType: '' });
+ this.setState({
+ value: '',
+ showMismatchRow: false,
+ mismatchConfirmed: false,
+ parsedType: '',
+ });
}
render() {
@@ -82,34 +110,35 @@ export default class AddArrayEntryDialog extends React.Component {
placeholder={'Enter value'}
ref={this.inputRef}
value={this.state.value}
- onChange={value => this.setState({ value })}
+ onChange={value =>
+ this.setState({
+ value,
+ showMismatchRow: false,
+ mismatchConfirmed: false,
+ })
+ }
/>
}
/>
+ {this.state.showMismatchRow && (
+