updated messages

This commit is contained in:
ari committed 2022-06-30 20:37:51 -04:00
1 parent 7488ecc3ae
commit 9a171c880e
2 files changed
+33 -23

No files matched your search

+13 -4
View File
@@ -37,10 +37,19 @@ export const makeOnEditAutomationConditions =
() =>
openModal({
single: true,
node: {
condition: "and",
conditions,
},
node:
conditions.length > 1
? {
condition: "and",
conditions,
}
: conditions.length === 1
? conditions[0]
: {
condition: "state",
entity_id: "",
state: "",
},
allowedTypes: ["condition"],
update: (c: AutomationCondition) => {
if (c.condition === "and") {
+20 -19
View File
@@ -36,29 +36,30 @@ export const NodeEditor: FC<NodeEditorProps> = ({
// alias
const isModified = state.isModified;
const isReady = state.isReady();
const areYouSureNotReady = async (what: string) => {
if (isModified) {
try {
await confirm({
description: `This node is has some unsaved work, are you sure you want to ${what}?`,
});
} catch (_: any) {
return false;
}
}
const areYouSureNotReady = async (
what: string,
checkModified: boolean = false
) => {
const notes: string[] = [];
if (!isReady) {
try {
await confirm({
description: `This node is missing some values, are you sure you want to ${what}?`,
});
} catch (_: any) {
return false;
}
notes.push("This node is missing some values");
}
if (state.isErrored) {
notes.push("This node contains errors");
}
if (checkModified && isModified) {
notes.push("This node is has some unsaved work");
}
if (notes.length > 0) {
try {
await confirm({
description: `This node contains errors, are you sure you want to ${what}?`,
description: (
<ul>
{notes.map((n, i) => (
<li key={i}>{n}</li>
))}
</ul>
),
});
} catch (_: any) {
return false;
@@ -126,7 +127,7 @@ export const NodeEditor: FC<NodeEditorProps> = ({
<Button
className="node-editor--footer--close"
onClick={() =>
areYouSureNotReady("close").then((ok) => ok && onClose())
areYouSureNotReady("close", true).then((ok) => ok && onClose())
}
>
Close