Show descriptions in script editor (#20765)

* Show descriptions in script editor

* descriptions in blueprints also
This commit is contained in:
karwosts 2024-05-13 05:19:47 -07:00 committed by GitHub
parent d046700d06
commit f5f2a5ad5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 9 deletions

View File

@ -93,6 +93,7 @@ export type ScriptConfig = ManualScriptConfig | BlueprintScriptConfig;
export interface ManualScriptConfig { export interface ManualScriptConfig {
alias: string; alias: string;
description?: string;
sequence: Action | Action[]; sequence: Action | Action[];
icon?: string; icon?: string;
mode?: (typeof MODES)[number]; mode?: (typeof MODES)[number];

View File

@ -1,11 +1,12 @@
import "@material/mwc-button/mwc-button"; import "@material/mwc-button/mwc-button";
import { HassEntity } from "home-assistant-js-websocket"; import { HassEntity } from "home-assistant-js-websocket";
import { html } from "lit"; import { html, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import "../../../components/ha-alert"; import "../../../components/ha-alert";
import { BlueprintAutomationConfig } from "../../../data/automation"; import { BlueprintAutomationConfig } from "../../../data/automation";
import { fetchBlueprints } from "../../../data/blueprint"; import { fetchBlueprints } from "../../../data/blueprint";
import { HaBlueprintGenericEditor } from "../blueprint/blueprint-generic-editor"; import { HaBlueprintGenericEditor } from "../blueprint/blueprint-generic-editor";
import "../../../components/ha-markdown";
@customElement("blueprint-automation-editor") @customElement("blueprint-automation-editor")
export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor { export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
@ -26,7 +27,7 @@ export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
${this.hass.localize("ui.panel.config.automation.editor.migrate")} ${this.hass.localize("ui.panel.config.automation.editor.migrate")}
</mwc-button> </mwc-button>
</ha-alert>` </ha-alert>`
: ""} : nothing}
${this.stateObj?.state === "off" ${this.stateObj?.state === "off"
? html` ? html`
<ha-alert alert-type="info"> <ha-alert alert-type="info">
@ -42,8 +43,12 @@ export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
` `
: ""} : ""}
${this.config.description ${this.config.description
? html`<p class="description">${this.config.description}</p>` ? html`<ha-markdown
: ""} class="description"
breaks
.content=${this.config.description}
></ha-markdown>`
: nothing}
${this.renderCard()} ${this.renderCard()}
`; `;
} }

View File

@ -59,14 +59,14 @@ export class HaManualAutomationEditor extends LitElement {
</mwc-button> </mwc-button>
</ha-alert> </ha-alert>
` `
: ""} : nothing}
${this.config.description ${this.config.description
? html`<ha-markdown ? html`<ha-markdown
class="description" class="description"
breaks breaks
.content=${this.config.description} .content=${this.config.description}
></ha-markdown>` ></ha-markdown>`
: ""} : nothing}
<div class="header"> <div class="header">
<h2 id="triggers-heading" class="name"> <h2 id="triggers-heading" class="name">
${this.hass.localize( ${this.hass.localize(

View File

@ -1,9 +1,11 @@
import { html } from "lit"; import "@material/mwc-button/mwc-button";
import { html, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import "../../../components/ha-alert"; import "../../../components/ha-alert";
import { BlueprintScriptConfig } from "../../../data/script"; import { BlueprintScriptConfig } from "../../../data/script";
import { fetchBlueprints } from "../../../data/blueprint"; import { fetchBlueprints } from "../../../data/blueprint";
import { HaBlueprintGenericEditor } from "../blueprint/blueprint-generic-editor"; import { HaBlueprintGenericEditor } from "../blueprint/blueprint-generic-editor";
import "../../../components/ha-markdown";
@customElement("blueprint-script-editor") @customElement("blueprint-script-editor")
export class HaBlueprintScriptEditor extends HaBlueprintGenericEditor { export class HaBlueprintScriptEditor extends HaBlueprintGenericEditor {
@ -22,7 +24,14 @@ export class HaBlueprintScriptEditor extends HaBlueprintGenericEditor {
${this.hass.localize("ui.panel.config.script.editor.migrate")} ${this.hass.localize("ui.panel.config.script.editor.migrate")}
</mwc-button> </mwc-button>
</ha-alert>` </ha-alert>`
: ""} : nothing}
${this.config.description
? html`<ha-markdown
class="description"
breaks
.content=${this.config.description}
></ha-markdown>`
: nothing}
${this.renderCard()} ${this.renderCard()}
`; `;
} }

View File

@ -6,6 +6,7 @@ import { fireEvent } from "../../../common/dom/fire_event";
import { nestedArrayMove } from "../../../common/util/array-move"; import { nestedArrayMove } from "../../../common/util/array-move";
import "../../../components/ha-card"; import "../../../components/ha-card";
import "../../../components/ha-icon-button"; import "../../../components/ha-icon-button";
import "../../../components/ha-markdown";
import { Action, Fields, ScriptConfig } from "../../../data/script"; import { Action, Fields, ScriptConfig } from "../../../data/script";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
@ -66,7 +67,14 @@ export class HaManualScriptEditor extends LitElement {
${this.hass.localize("ui.panel.config.script.editor.migrate")} ${this.hass.localize("ui.panel.config.script.editor.migrate")}
</mwc-button> </mwc-button>
</ha-alert>` </ha-alert>`
: ""} : nothing}
${this.config.description
? html`<ha-markdown
class="description"
breaks
.content=${this.config.description}
></ha-markdown>`
: nothing}
${this.config.fields ${this.config.fields
? html`<div class="header"> ? html`<div class="header">
<h2 id="fields-heading" class="name"> <h2 id="fields-heading" class="name">