Skip to content

Commit

Permalink
fix(ui): Error message on draft save
Browse files Browse the repository at this point in the history
closes #1341
  • Loading branch information
brian-mulier-p committed May 29, 2023
1 parent cbce23c commit 45e0bd4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
40 changes: 29 additions & 11 deletions ui/src/components/graph/Topology.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import {ref, onMounted, nextTick, watch, getCurrentInstance, onBeforeUnmount, computed} from "vue";
import {ref, onMounted, nextTick, watch, getCurrentInstance, onBeforeUnmount, computed, h} from "vue";
import {useStore} from "vuex"
import {VueFlow, useVueFlow, Position, MarkerType} from "@vue-flow/core"
import {Controls, ControlButton} from "@vue-flow/controls"
Expand Down Expand Up @@ -37,6 +37,7 @@
import editor from "../inputs/Editor.vue";
import yamlUtils from "../../utils/yamlUtils";
import {pageFromRoute} from "../../utils/eventsRouter";
import {ElNotification, ElTable, ElTableColumn} from "element-plus";
const {
id,
Expand Down Expand Up @@ -573,15 +574,32 @@
haveChange.value = false;
}
const showDraftPopup = (draftReason) => {
toast.confirm(draftReason + " " + (props.isCreating ? t("save draft.prompt.creation") : t("save draft.prompt.existing", {
namespace: flow.namespace,
id: flow.id
})),
() => {
persistEditorContent(false);
}
);
const saveAsDraft = (errorMessage) => {
const errorToastDom = [h("span", {innerHTML: t("invalid flow")}),
h(
ElTable,
{
stripe: true,
tableLayout: "auto",
fixed: true,
data: [{errorMessage}],
class: ["mt-2"],
size: "small",
},
[
h(ElTableColumn, {prop: "errorMessage", label: "Message"})
]
)];
ElNotification({
title: t("save draft.message"),
message: h("div", errorToastDom),
type: "error",
duration: 0,
dangerouslyUseHTMLString: true,
customClass: "large"
});
persistEditorContent(false);
}
const onEdit = (event) => {
Expand Down Expand Up @@ -832,7 +850,7 @@
flowParsed = YamlUtils.parse(flowYaml.value);
} catch (_) {}
if (validation[0].constraints) {
showDraftPopup(t("save draft.prompt.base"));
saveAsDraft(validation[0].constraints);
return;
}
Expand Down
14 changes: 2 additions & 12 deletions ui/src/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,7 @@
"metric choice": "Please choose a metric and an aggregation",
"of": "of",
"save draft": {
"prompt": {
"base": "The current Flow is not valid. Do you still want to save it as a draft ?",
"http_error": "Unable to validate the Flow due to an HTTP error. Do you want to save the current Flow as draft ?",
"creation": "You will retrieve it on your next Flow creation.",
"existing": "You will retrieve it on your next <code>{namespace}.{id}</code> Flow edition."
},
"message": "Draft saved",
"retrieval": {
"creation": "A Flow creation draft was retrieved, do you want to resume its edition ?",
"existing": "A <code>{flowFullName}</code> Flow draft was retrieved, do you want to resume its edition ?"
Expand Down Expand Up @@ -856,12 +851,7 @@
"metric choice": "Merci de sélectionner une métrique et une agrégation",
"of": "de",
"save draft": {
"prompt": {
"base": "Le Flow actuel est invalide. Voulez-vous le sauvegarder en tant que brouillon ?",
"http_error": "Impossible de valider le Flow en raison d'une erreur HTTP. Voulez-vous sauvegarder le Flow actuel en tant que brouillon ?",
"creation": "Vous le récupérerez à votre prochaine création de Flow.",
"existing": "Vous le récupérerez à votre prochaine édition du Flow <code>{namespace}.{id}</code>."
},
"message": "Brouillon sauvegardé",
"retrieval": {
"creation": "Un brouillon de création de Flow existe, voulez-vous reprendre son édition ?",
"existing": "Un brouillon pour le Flow <code>{flowFullName}</code> existe, voulez-vous reprendre son édition?"
Expand Down

0 comments on commit 45e0bd4

Please sign in to comment.