This reverts commit c6a8f81d60.
This commit is contained in:
parent
39ca940dfc
commit
66c7a0b252
|
|
@ -116,7 +116,6 @@ interface Props {
|
|||
useValidationMessage?: boolean;
|
||||
hideEvaluatedValue?: boolean;
|
||||
evaluationSubstitutionType?: EvaluationSubstitutionType;
|
||||
jsError?: string;
|
||||
}
|
||||
|
||||
interface PopoverContentProps {
|
||||
|
|
@ -130,7 +129,6 @@ interface PopoverContentProps {
|
|||
onMouseLeave: () => void;
|
||||
hideEvaluatedValue?: boolean;
|
||||
preparedStatementViewer: boolean;
|
||||
jsError?: string;
|
||||
}
|
||||
|
||||
const PreparedStatementViewerContainer = styled.span`
|
||||
|
|
@ -274,9 +272,7 @@ function PopoverContent(props: PopoverContentProps) {
|
|||
{props.hasError && (
|
||||
<ErrorText>
|
||||
<span className="t--evaluatedPopup-error">
|
||||
{props.jsError && props.jsError.length
|
||||
? props.jsError
|
||||
: props.useValidationMessage && props.error
|
||||
{props.useValidationMessage && props.error
|
||||
? props.error
|
||||
: `This value does not evaluate to type "${props.expected}". Transform it using JS inside '{{ }}'`}
|
||||
</span>
|
||||
|
|
@ -339,7 +335,6 @@ function EvaluatedValuePopup(props: Props) {
|
|||
expected={props.expected}
|
||||
hasError={props.hasError}
|
||||
hideEvaluatedValue={props.hideEvaluatedValue}
|
||||
jsError={props.jsError}
|
||||
onMouseEnter={() => {
|
||||
setContentHovered(true);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ export type EditorStyleProps = {
|
|||
fill?: boolean;
|
||||
useValidationMessage?: boolean;
|
||||
evaluationSubstitutionType?: EvaluationSubstitutionType;
|
||||
jsErrorMessage?: string;
|
||||
};
|
||||
|
||||
export type EditorProps = EditorStyleProps &
|
||||
|
|
@ -358,9 +357,8 @@ class CodeEditor extends Component<Props, State> {
|
|||
useValidationMessage,
|
||||
hideEvaluatedValue,
|
||||
evaluationSubstitutionType,
|
||||
jsErrorMessage,
|
||||
} = this.props;
|
||||
const hasError = !!(meta && meta.error) || !!jsErrorMessage;
|
||||
const hasError = !!(meta && meta.error);
|
||||
let evaluated = evaluatedValue;
|
||||
if (dataTreePath) {
|
||||
evaluated = _.get(dynamicData, dataTreePath);
|
||||
|
|
@ -404,7 +402,6 @@ class CodeEditor extends Component<Props, State> {
|
|||
hasError={hasError}
|
||||
hideEvaluatedValue={hideEvaluatedValue}
|
||||
isOpen={showEvaluatedValue}
|
||||
jsError={jsErrorMessage}
|
||||
theme={theme || EditorTheme.LIGHT}
|
||||
useValidationMessage={useValidationMessage}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ export interface ControlData
|
|||
validationMessage?: string;
|
||||
widgetProperties: any;
|
||||
useValidationMessage?: boolean;
|
||||
jsErrorMessage?: string;
|
||||
}
|
||||
export interface ControlFunctions {
|
||||
onPropertyChange?: (propertyName: string, propertyValue: string) => void;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class CodeEditorControl extends BaseControl<ControlProps> {
|
|||
dataTreePath,
|
||||
evaluatedValue,
|
||||
useValidationMessage,
|
||||
jsErrorMessage,
|
||||
} = this.props;
|
||||
const props: Partial<ControlProps> = {};
|
||||
if (dataTreePath) props.dataTreePath = dataTreePath;
|
||||
|
|
@ -28,7 +27,6 @@ class CodeEditorControl extends BaseControl<ControlProps> {
|
|||
return (
|
||||
<CodeEditor
|
||||
input={{ value: propertyValue, onChange: this.onChange }}
|
||||
jsErrorMessage={jsErrorMessage}
|
||||
meta={{
|
||||
error: isValid ? "" : validationMessage,
|
||||
touched: true,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ export function InputText(props: {
|
|||
additionalAutocomplete?: Record<string, Record<string, unknown>>;
|
||||
theme?: EditorTheme;
|
||||
hideEvaluatedValue?: boolean;
|
||||
jsErrorMessage?: string;
|
||||
}) {
|
||||
const {
|
||||
errorMessage,
|
||||
|
|
@ -35,7 +34,6 @@ export function InputText(props: {
|
|||
dataTreePath,
|
||||
evaluatedValue,
|
||||
hideEvaluatedValue,
|
||||
jsErrorMessage,
|
||||
} = props;
|
||||
|
||||
return (
|
||||
|
|
@ -50,7 +48,6 @@ export function InputText(props: {
|
|||
value: value,
|
||||
onChange: onChange,
|
||||
}}
|
||||
jsErrorMessage={jsErrorMessage}
|
||||
meta={{
|
||||
error: isValid ? "" : errorMessage,
|
||||
touched: true,
|
||||
|
|
@ -78,7 +75,6 @@ class InputTextControl extends BaseControl<InputControlProps> {
|
|||
defaultValue,
|
||||
additionalAutoComplete,
|
||||
hideEvaluatedValue,
|
||||
jsErrorMessage,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
|
|
@ -89,7 +85,6 @@ class InputTextControl extends BaseControl<InputControlProps> {
|
|||
expected={expected}
|
||||
hideEvaluatedValue={hideEvaluatedValue}
|
||||
isValid={isValid}
|
||||
jsErrorMessage={jsErrorMessage}
|
||||
label={label}
|
||||
onChange={this.onTextChange}
|
||||
placeholder={placeholderText}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ enum LOG_TYPE {
|
|||
ACTION_EXECUTION_ERROR,
|
||||
ACTION_EXECUTION_SUCCESS,
|
||||
ENTITY_DELETED,
|
||||
EVAL_ERROR,
|
||||
}
|
||||
|
||||
export default LOG_TYPE;
|
||||
|
|
|
|||
|
|
@ -244,14 +244,9 @@ const PropertyControl = memo((props: Props) => {
|
|||
|
||||
const getPropertyValidation = (
|
||||
propertyName: string,
|
||||
): {
|
||||
isValid: boolean;
|
||||
validationMessage?: string;
|
||||
jsErrorMessage?: string;
|
||||
} => {
|
||||
): { isValid: boolean; validationMessage?: string } => {
|
||||
let isValid = true;
|
||||
let validationMessage = "";
|
||||
let jsErrorMessage = "";
|
||||
if (widgetProperties) {
|
||||
isValid = widgetProperties.invalidProps
|
||||
? !_.has(widgetProperties.invalidProps, propertyName)
|
||||
|
|
@ -259,17 +254,11 @@ const PropertyControl = memo((props: Props) => {
|
|||
const validationMsgPresent =
|
||||
widgetProperties.validationMessages &&
|
||||
_.has(widgetProperties.validationMessages, propertyName);
|
||||
const jsValidationMessagePresent =
|
||||
widgetProperties.jsErrorMessages &&
|
||||
_.has(widgetProperties.jsErrorMessages, propertyName);
|
||||
validationMessage = validationMsgPresent
|
||||
? _.get(widgetProperties.validationMessages, propertyName)
|
||||
: "";
|
||||
jsErrorMessage = jsValidationMessagePresent
|
||||
? _.get(widgetProperties.jsErrorMessages, propertyName)
|
||||
: "";
|
||||
}
|
||||
return { isValid, validationMessage, jsErrorMessage };
|
||||
return { isValid, validationMessage };
|
||||
};
|
||||
|
||||
const { propertyName, label } = props;
|
||||
|
|
@ -281,18 +270,13 @@ const PropertyControl = memo((props: Props) => {
|
|||
`evaluatedValues.${propertyName}`,
|
||||
);
|
||||
|
||||
const {
|
||||
isValid,
|
||||
validationMessage,
|
||||
jsErrorMessage,
|
||||
} = getPropertyValidation(propertyName);
|
||||
const { isValid, validationMessage } = getPropertyValidation(propertyName);
|
||||
const { additionalAutoComplete, ...rest } = props;
|
||||
const config = {
|
||||
...rest,
|
||||
isValid,
|
||||
propertyValue,
|
||||
validationMessage,
|
||||
jsErrorMessage,
|
||||
dataTreePath,
|
||||
evaluatedValue,
|
||||
widgetProperties,
|
||||
|
|
@ -309,7 +293,6 @@ const PropertyControl = memo((props: Props) => {
|
|||
delete config.dataTreePath;
|
||||
delete config.evaluatedValue;
|
||||
delete config.expected;
|
||||
config.jsErrorMessage = "";
|
||||
}
|
||||
|
||||
const isDynamic: boolean = isPathADynamicProperty(
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ const debuggerReducer = createReducer(initialState, {
|
|||
|
||||
const entityId = action.payload.source.id;
|
||||
const id =
|
||||
action.payload.logType === LOG_TYPE.WIDGET_PROPERTY_VALIDATION_ERROR ||
|
||||
action.payload.logType === LOG_TYPE.EVAL_ERROR
|
||||
action.payload.logType === LOG_TYPE.WIDGET_PROPERTY_VALIDATION_ERROR
|
||||
? `${entityId}-${action.payload.source.propertyPath}`
|
||||
: entityId;
|
||||
const previousState = get(state.errors, id, {});
|
||||
|
|
@ -74,8 +73,7 @@ const debuggerReducer = createReducer(initialState, {
|
|||
|
||||
const entityId = action.payload.source.id;
|
||||
const isWidgetErrorLog =
|
||||
action.payload.logType === LOG_TYPE.WIDGET_PROPERTY_VALIDATION_ERROR ||
|
||||
action.payload.logType === LOG_TYPE.EVAL_ERROR;
|
||||
action.payload.logType === LOG_TYPE.WIDGET_PROPERTY_VALIDATION_ERROR;
|
||||
const id = isWidgetErrorLog
|
||||
? `${entityId}-${action.payload.source.propertyPath}`
|
||||
: entityId;
|
||||
|
|
|
|||
|
|
@ -932,18 +932,6 @@ function* executePageLoadAction(pageAction: PageAction) {
|
|||
message += `\nERROR: "${body}"`;
|
||||
}
|
||||
|
||||
AppsmithConsole.error({
|
||||
logType: LOG_TYPE.ACTION_EXECUTION_ERROR,
|
||||
text: `Execution failed with status ${response.data.statusCode}`,
|
||||
source: {
|
||||
type: ENTITY_TYPE.ACTION,
|
||||
name: pageAction.name,
|
||||
id: pageAction.id,
|
||||
},
|
||||
state: response.data?.request ?? null,
|
||||
message: JSON.stringify(body),
|
||||
});
|
||||
|
||||
yield put(
|
||||
executeActionError({
|
||||
actionId: pageAction.id,
|
||||
|
|
|
|||
|
|
@ -27,12 +27,7 @@ function* onWidgetUpdateSaga(payload: LogActionPayload) {
|
|||
const dataTree: DataTree = yield select(getDataTree);
|
||||
const widget = dataTree[payload.source.name];
|
||||
|
||||
if (
|
||||
!isWidget(widget) ||
|
||||
!widget.validationMessages ||
|
||||
!widget.jsErrorMessages
|
||||
)
|
||||
return;
|
||||
if (!isWidget(widget) || !widget.validationMessages) return;
|
||||
|
||||
// Ignore canvas widget updates
|
||||
if (widget.type === WidgetTypes.CANVAS_WIDGET) {
|
||||
|
|
@ -46,17 +41,14 @@ function* onWidgetUpdateSaga(payload: LogActionPayload) {
|
|||
|
||||
const validationMessages = widget.validationMessages;
|
||||
const validationMessage = validationMessages[propertyPath];
|
||||
const jsErrorMessages = widget.jsErrorMessages;
|
||||
const jsErrorMessage = jsErrorMessages[propertyPath];
|
||||
const errors = yield select(getDebuggerErrors);
|
||||
const errorId = `${source.id}-${propertyPath}`;
|
||||
const widgetErrorLog = errors[errorId];
|
||||
if (!widgetErrorLog) return;
|
||||
|
||||
const noError = isEmpty(validationMessage);
|
||||
const noJsError = isEmpty(jsErrorMessage);
|
||||
|
||||
if (noError && noJsError) {
|
||||
if (noError) {
|
||||
delete errors[errorId];
|
||||
|
||||
yield put({
|
||||
|
|
@ -129,7 +121,6 @@ function* debuggerLogSaga(action: ReduxAction<Message>) {
|
|||
yield call(onWidgetUpdateSaga, payload);
|
||||
yield put(debuggerLog(payload));
|
||||
return;
|
||||
case LOG_TYPE.EVAL_ERROR:
|
||||
case LOG_TYPE.WIDGET_PROPERTY_VALIDATION_ERROR:
|
||||
if (payload.source && payload.source.propertyPath) {
|
||||
if (payload.text) {
|
||||
|
|
|
|||
|
|
@ -103,12 +103,6 @@ const evalErrorHandler = (errors: EvalError[]) => {
|
|||
}
|
||||
case EvalErrorTypes.EVAL_ERROR: {
|
||||
log.debug(error);
|
||||
AppsmithConsole.error({
|
||||
logType: LOG_TYPE.EVAL_ERROR,
|
||||
text: `The value at ${error.context?.source.propertyPath} is invalid`,
|
||||
message: error.message,
|
||||
source: error.context?.source,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case EvalErrorTypes.WIDGET_PROPERTY_VALIDATION_ERROR: {
|
||||
|
|
|
|||
|
|
@ -49,14 +49,9 @@ export const getWidgetPropsForPropertyPane = createSelector(
|
|||
}
|
||||
|
||||
if (evaluatedWidget.invalidProps) {
|
||||
const {
|
||||
invalidProps,
|
||||
validationMessages,
|
||||
jsErrorMessages,
|
||||
} = evaluatedWidget;
|
||||
const { invalidProps, validationMessages } = evaluatedWidget;
|
||||
widgetProperties.invalidProps = invalidProps;
|
||||
widgetProperties.validationMessages = validationMessages;
|
||||
widgetProperties.jsErrorMessages = jsErrorMessages;
|
||||
}
|
||||
}
|
||||
return widgetProperties;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ export interface WidgetEvaluatedProps {
|
|||
invalidProps?: Record<string, boolean>;
|
||||
validationMessages?: Record<string, string>;
|
||||
evaluatedValues?: Record<string, any>;
|
||||
jsErrorMessages?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface EntityWithBindings {
|
||||
|
|
|
|||
|
|
@ -391,11 +391,6 @@ export default class DataTreeEvaluator {
|
|||
let evalPropertyValue;
|
||||
const requiresEval =
|
||||
isABindingPath && isDynamicValue(unEvalPropertyValue);
|
||||
_.set(
|
||||
currentTree,
|
||||
`${entityName}.jsErrorMessages.${propertyPath}`,
|
||||
"",
|
||||
);
|
||||
if (requiresEval) {
|
||||
const evaluationSubstitutionType =
|
||||
entity.bindingPaths[propertyPath] ||
|
||||
|
|
@ -406,8 +401,6 @@ export default class DataTreeEvaluator {
|
|||
currentTree,
|
||||
evaluationSubstitutionType,
|
||||
false,
|
||||
undefined,
|
||||
fullPropertyPath,
|
||||
);
|
||||
} catch (e) {
|
||||
this.errors.push({
|
||||
|
|
@ -552,7 +545,6 @@ export default class DataTreeEvaluator {
|
|||
evaluationSubstitutionType: EvaluationSubstitutionType,
|
||||
returnTriggers: boolean,
|
||||
callBackData?: Array<any>,
|
||||
fullPropertyPath?: string,
|
||||
) {
|
||||
// Get the {{binding}} bound values
|
||||
const { stringSegments, jsSnippets } = getDynamicBindings(dynamicBinding);
|
||||
|
|
@ -561,7 +553,6 @@ export default class DataTreeEvaluator {
|
|||
data,
|
||||
jsSnippets[0],
|
||||
callBackData,
|
||||
fullPropertyPath,
|
||||
);
|
||||
return result.triggers;
|
||||
}
|
||||
|
|
@ -573,7 +564,6 @@ export default class DataTreeEvaluator {
|
|||
data,
|
||||
jsSnippet,
|
||||
callBackData,
|
||||
fullPropertyPath,
|
||||
);
|
||||
return result.result;
|
||||
} else {
|
||||
|
|
@ -600,32 +590,17 @@ export default class DataTreeEvaluator {
|
|||
data: DataTree,
|
||||
js: string,
|
||||
callbackData?: Array<any>,
|
||||
fullPropertyPath?: string,
|
||||
): EvalResult {
|
||||
try {
|
||||
return evaluate(js, data, callbackData);
|
||||
} catch (e) {
|
||||
if (fullPropertyPath) {
|
||||
const { propertyPath, entityName } = getEntityNameAndPropertyPath(
|
||||
fullPropertyPath,
|
||||
);
|
||||
_.set(data, `${entityName}.jsErrorMessages.${propertyPath}`, e.message);
|
||||
const entity = data[entityName];
|
||||
if (isWidget(entity)) {
|
||||
this.errors.push({
|
||||
type: EvalErrorTypes.EVAL_ERROR,
|
||||
message: e.message,
|
||||
context: {
|
||||
source: {
|
||||
id: entity.widgetId,
|
||||
name: entity.widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
propertyPath: propertyPath,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
this.errors.push({
|
||||
type: EvalErrorTypes.EVAL_ERROR,
|
||||
message: e.message,
|
||||
context: {
|
||||
binding: js,
|
||||
},
|
||||
});
|
||||
return { result: undefined, triggers: [] };
|
||||
}
|
||||
}
|
||||
|
|
@ -647,7 +622,6 @@ export default class DataTreeEvaluator {
|
|||
EvaluationSubstitutionType.TEMPLATE,
|
||||
true,
|
||||
undefined,
|
||||
fullPropertyPath,
|
||||
);
|
||||
valueToValidate = triggers;
|
||||
}
|
||||
|
|
@ -666,22 +640,19 @@ export default class DataTreeEvaluator {
|
|||
: transformed;
|
||||
const safeEvaluatedValue = removeFunctions(evaluatedValue);
|
||||
_.set(widget, `evaluatedValues.${propertyPath}`, safeEvaluatedValue);
|
||||
const jsError = _.get(widget, `jsErrorMessages.${propertyPath}`);
|
||||
if (!isValid) {
|
||||
if (!jsError) {
|
||||
this.errors.push({
|
||||
type: EvalErrorTypes.WIDGET_PROPERTY_VALIDATION_ERROR,
|
||||
message: message || "",
|
||||
context: {
|
||||
source: {
|
||||
id: widget.widgetId,
|
||||
name: widget.widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
propertyPath: propertyPath,
|
||||
},
|
||||
this.errors.push({
|
||||
type: EvalErrorTypes.WIDGET_PROPERTY_VALIDATION_ERROR,
|
||||
message: message || "",
|
||||
context: {
|
||||
source: {
|
||||
id: widget.widgetId,
|
||||
name: widget.widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
propertyPath: propertyPath,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
_.set(widget, `invalidProps.${propertyPath}`, true);
|
||||
_.set(widget, `validationMessages.${propertyPath}`, message);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user