Skip to content

Commit

Permalink
fix(ui): no more validation error at flow creation start
Browse files Browse the repository at this point in the history
closes #1406
  • Loading branch information
brian-mulier-p committed May 30, 2023
1 parent bd18f8c commit 0245753
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions ui/src/components/graph/Topology.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,17 @@
namespace: props.namespace
});
const validation = await store.dispatch("flow/validateFlow", {flow: flowYaml.value});
const validationErrors = validation[0].constraints;
if(validationErrors){
errorToast(t("cannot create topology"), t("invalid flow"), validationErrors);
if(!props.isCreating) {
const validation = await store.dispatch("flow/validateFlow", {flow: flowYaml.value});
const validationErrors = validation[0].constraints;
if (validationErrors) {
singleErrorToast(t("cannot create topology"), t("invalid flow"), validationErrors);
}else {
generateGraph();
}
} else {
generateGraph();
}
generateGraph();
if(!props.isReadOnly) {
let restoredLocalStorageKey;
Expand Down Expand Up @@ -584,35 +589,21 @@
haveChange.value = false;
}
const errorToast = (title, message, detailedError) => {
const errorToastDom = [h("span", {innerHTML: message}),
h(
ElTable,
{
stripe: true,
tableLayout: "auto",
fixed: true,
data: [{detailedError}],
class: ["mt-2"],
size: "small",
},
[
h(ElTableColumn, {prop: "detailedError", label: "Message"})
]
)];
ElNotification({
const singleErrorToast = (title, message, detailedError) => {
store.dispatch("core/showMessage", {
title: title,
message: h("div", errorToastDom),
type: "error",
duration: 0,
dangerouslyUseHTMLString: true,
customClass: "large"
message: message,
content: {
_embedded: {
errors: [{message: detailedError}]
}
},
variant: "error"
});
}
const saveAsDraft = (errorMessage) => {
errorToast(t("save draft.message"), t("invalid flow"), errorMessage);
singleErrorToast(t("save draft.message"), t("invalid flow"), errorMessage);
persistEditorContent(false);
}
Expand Down

0 comments on commit 0245753

Please sign in to comment.