Commit a4cd1e93 authored by Ahmed Awan's avatar Ahmed Awan
Browse files

reset `formConfig.errors` if there is no `refreshRequest`

Also consider `this.validationInternal` as errors.

The clearing of `formConfig.errors` on no refresh request seems to work because in `FormDisplay`, we seem to be returning that boolean as a param when there is a change in value that would possibly return errors from the backend.

And of course, `this.validationInternal` contains errors found by the client for individual inputs and is therefore, an essential check to disable run.
parent d4f633e8
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ export default {
            ],
            immutableHistoryMessage:
                "This history is immutable and you cannot run tools in it. Please switch to a different history.",
            formConfigInitialized: false,
        };
    },
    computed: {
@@ -227,7 +228,7 @@ export default {
            switch (true) {
                case !this.canMutateHistory:
                    return this.immutableHistoryMessage;
                case this.formConfig.errors && Object.values(this.formConfig.errors).length > 0:
                case this.hasConfigOrValErrors:
                    return "Please correct errors before running the tool.";
                case this.showExecuting:
                    return "Tool is being executed...";
@@ -259,8 +260,13 @@ export default {
            return this.currentHistory && canMutateHistory(this.currentHistory);
        },
        runButtonDisabled() {
            return this.disabled || !this.canMutateHistory || this.hasConfigOrValErrors;
        },
        /** If there are any backend returned `formConfig.errors` or internal/client checked validation errors. */
        hasConfigOrValErrors() {
            return (
                this.disabled || !this.canMutateHistory || (this.formConfig.errors && Object.values(this.formConfig.errors).length > 0)
                (this.formConfig.errors && Object.values(this.formConfig.errors).length > 0) ||
                this.validationInternal?.length
            );
        },
    },
@@ -294,7 +300,12 @@ export default {
            this.formData = newData;
            if (refreshRequest) {
                this.onUpdate();
            } else if (this.formConfigInitialized && this.hasConfigOrValErrors) {
                // After the first manual change to a form input, for every change, if there isn't a request to refresh,
                // we reset the errors since we haven't received a tool form update via the backend.
                this.formConfig.errors = null;
            }
            this.formConfigInitialized = true;
        },
        onUpdate() {
            this.disabled = true;