From 0b183353d39ae5306e3333de214857e94d133c31 Mon Sep 17 00:00:00 2001 From: Ari Date: Fri, 17 Jun 2022 14:34:37 -0400 Subject: [PATCH] prettier names --- .../NodeEditor/OptionManager/ActionDevice.tsx | 2 +- webapp/src/types/validators/actions.ts | 1 - webapp/src/utils/formatting.ts | 19 ++++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx b/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx index 22fc2ed..4def2ea 100644 --- a/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/ActionDevice.tsx @@ -66,7 +66,7 @@ export const ActionDeviceState: OptionManager = { update({ [field.name]: v, diff --git a/webapp/src/types/validators/actions.ts b/webapp/src/types/validators/actions.ts index ccb7c6f..f3f18ac 100644 --- a/webapp/src/types/validators/actions.ts +++ b/webapp/src/types/validators/actions.ts @@ -60,7 +60,6 @@ export const DeviceAction = st.intersection([ entity_id: st.optional(st.string()), domain: st.optional(st.string()), }), - st.record(st.string(), st.any()), ]); export const ChooseAction = st.intersection([ diff --git a/webapp/src/utils/formatting.ts b/webapp/src/utils/formatting.ts index 8429818..9a8343b 100644 --- a/webapp/src/utils/formatting.ts +++ b/webapp/src/utils/formatting.ts @@ -58,11 +58,20 @@ export const getDescriptionFromAutomationNode = ( return out; } if (node.platform === "device") { - return node.device_id - ? namer.getDeviceName(node.device_id) - : node.entity_id - ? namer.getEntityName(node.entity_id) - : node.platform; + let out = ""; + if (node.device_id) { + out = namer.getDeviceName(node.device_id); + } + if (!out && node.entity_id) { + out = namer.getEntityName(node.entity_id); + } + if (node.type) { + out += node.type; + } + if (!out) { + out = node.platform; + } + return out; } return node.platform; }