Align "option" wording and show user-friendly option index in trace timeline (#10059)

This commit is contained in:
Philip Allgaier 2021-09-20 12:59:30 +02:00 committed by GitHub
parent c0f3215340
commit 0adc4b33ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -82,7 +82,7 @@ export class HaTracePathDetails extends LitElement {
] as ChooseActionTraceStep[]; ] as ChooseActionTraceStep[];
if (parentTraceInfo && parentTraceInfo[0]?.result?.choice === "default") { if (parentTraceInfo && parentTraceInfo[0]?.result?.choice === "default") {
return "The default node was executed because no choices matched."; return "The default action was executed because no options matched.";
} }
} }

View File

@ -325,13 +325,15 @@ class ActionRenderer {
if (defaultExecuted) { if (defaultExecuted) {
this._renderEntry(choosePath, `${name}: Default action executed`); this._renderEntry(choosePath, `${name}: Default action executed`);
} else if (chooseTrace.result) { } else if (chooseTrace.result) {
const choiceNumeric =
chooseTrace.result.choice !== "default"
? chooseTrace.result.choice + 1
: undefined;
const choiceConfig = this._getDataFromPath( const choiceConfig = this._getDataFromPath(
`${this.keys[index]}/choose/${chooseTrace.result.choice}` `${this.keys[index]}/choose/${chooseTrace.result.choice}`
) as ChooseActionChoice | undefined; ) as ChooseActionChoice | undefined;
const choiceName = choiceConfig const choiceName = choiceConfig
? `${ ? `${choiceConfig.alias || `Option ${choiceNumeric}`} executed`
choiceConfig.alias || `Choice ${chooseTrace.result.choice}`
} executed`
: `Error: ${chooseTrace.error}`; : `Error: ${chooseTrace.error}`;
this._renderEntry(choosePath, `${name}: ${choiceName}`); this._renderEntry(choosePath, `${name}: ${choiceName}`);
} else { } else {