mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-11 03:51:07 +00:00
Restore trigger id in overflow menu for trigger (#27702)
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
mdiContentCopy,
|
mdiContentCopy,
|
||||||
mdiContentCut,
|
mdiContentCut,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
|
mdiIdentifier,
|
||||||
mdiPlayCircleOutline,
|
mdiPlayCircleOutline,
|
||||||
mdiPlaylistEdit,
|
mdiPlaylistEdit,
|
||||||
mdiPlusCircleMultipleOutline,
|
mdiPlusCircleMultipleOutline,
|
||||||
@@ -40,6 +41,8 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@property({ type: Number, attribute: "sidebar-key" })
|
@property({ type: Number, attribute: "sidebar-key" })
|
||||||
public sidebarKey?: number;
|
public sidebarKey?: number;
|
||||||
|
|
||||||
|
@state() private _requestShowId = false;
|
||||||
|
|
||||||
@state() private _warnings?: string[];
|
@state() private _warnings?: string[];
|
||||||
|
|
||||||
@query(".sidebar-editor")
|
@query(".sidebar-editor")
|
||||||
@@ -47,6 +50,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
|
|
||||||
protected willUpdate(changedProperties) {
|
protected willUpdate(changedProperties) {
|
||||||
if (changedProperties.has("config")) {
|
if (changedProperties.has("config")) {
|
||||||
|
this._requestShowId = false;
|
||||||
this._warnings = undefined;
|
this._warnings = undefined;
|
||||||
if (this.config) {
|
if (this.config) {
|
||||||
this.yamlMode = this.config.yamlMode;
|
this.yamlMode = this.config.yamlMode;
|
||||||
@@ -101,6 +105,24 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</ha-md-menu-item>
|
</ha-md-menu-item>
|
||||||
|
|
||||||
|
${!this.yamlMode &&
|
||||||
|
!("id" in this.config.config) &&
|
||||||
|
!this._requestShowId
|
||||||
|
? html`<ha-md-menu-item
|
||||||
|
slot="menu-items"
|
||||||
|
.clickAction=${this._showTriggerId}
|
||||||
|
.disabled=${this.disabled || type === "list"}
|
||||||
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiIdentifier}></ha-svg-icon>
|
||||||
|
<div class="overflow-label">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.triggers.edit_id"
|
||||||
|
)}
|
||||||
|
<span class="shortcut-placeholder ${isMac ? "mac" : ""}"></span>
|
||||||
|
</div>
|
||||||
|
</ha-md-menu-item>`
|
||||||
|
: nothing}
|
||||||
|
|
||||||
<ha-md-divider
|
<ha-md-divider
|
||||||
slot="menu-items"
|
slot="menu-items"
|
||||||
role="separator"
|
role="separator"
|
||||||
@@ -250,6 +272,7 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
@value-changed=${this._valueChangedSidebar}
|
@value-changed=${this._valueChangedSidebar}
|
||||||
@yaml-changed=${this._yamlChangedSidebar}
|
@yaml-changed=${this._yamlChangedSidebar}
|
||||||
.uiSupported=${this.config.uiSupported}
|
.uiSupported=${this.config.uiSupported}
|
||||||
|
.showId=${this._requestShowId}
|
||||||
.yamlMode=${this.yamlMode}
|
.yamlMode=${this.yamlMode}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
@ui-mode-not-available=${this._handleUiModeNotAvailable}
|
||||||
@@ -292,6 +315,10 @@ export default class HaAutomationSidebarTrigger extends LitElement {
|
|||||||
fireEvent(this, "toggle-yaml-mode");
|
fireEvent(this, "toggle-yaml-mode");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _showTriggerId = () => {
|
||||||
|
this._requestShowId = true;
|
||||||
|
};
|
||||||
|
|
||||||
static styles = [sidebarEditorStyles, overflowStyles];
|
static styles = [sidebarEditorStyles, overflowStyles];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
@property({ type: Boolean, attribute: "sidebar" }) public inSidebar = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, attribute: "show-id" }) public showId = false;
|
||||||
|
|
||||||
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
@query("ha-yaml-editor") public yamlEditor?: HaYamlEditor;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -36,6 +38,8 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
|
|
||||||
const yamlMode = this.yamlMode || !this.uiSupported;
|
const yamlMode = this.yamlMode || !this.uiSupported;
|
||||||
|
|
||||||
|
const showId = "id" in this.trigger || this.showId;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
@@ -70,20 +74,15 @@ export default class HaAutomationTriggerEditor extends LitElement {
|
|||||||
></ha-yaml-editor>
|
></ha-yaml-editor>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
${!isTriggerList(this.trigger)
|
${showId && !isTriggerList(this.trigger)
|
||||||
? html`
|
? html`
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${`${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.triggers.id"
|
"ui.panel.config.automation.editor.triggers.id"
|
||||||
)} (${this.hass.localize(
|
)}
|
||||||
"ui.panel.config.automation.editor.triggers.optional"
|
|
||||||
)})`}
|
|
||||||
.value=${this.trigger.id || ""}
|
.value=${this.trigger.id || ""}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@change=${this._idChanged}
|
@change=${this._idChanged}
|
||||||
.helper=${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.triggers.id_helper"
|
|
||||||
)}
|
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|||||||
@@ -3945,7 +3945,6 @@
|
|||||||
"add": "Add trigger",
|
"add": "Add trigger",
|
||||||
"empty_search": "No triggers found for {term}",
|
"empty_search": "No triggers found for {term}",
|
||||||
"id": "Trigger ID",
|
"id": "Trigger ID",
|
||||||
"id_helper": "Helps identify each run based on which trigger fired.",
|
|
||||||
"optional": "Optional",
|
"optional": "Optional",
|
||||||
"edit_id": "Edit ID",
|
"edit_id": "Edit ID",
|
||||||
"duplicate": "[%key:ui::common::duplicate%]",
|
"duplicate": "[%key:ui::common::duplicate%]",
|
||||||
|
|||||||
Reference in New Issue
Block a user