mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 10:59:50 +00:00
Move automation and script ha-alerts to main flow (#26735)
Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com>
This commit is contained in:
@@ -119,10 +119,11 @@ class HaAlert extends LitElement {
|
|||||||
.main-content {
|
.main-content {
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
line-height: normal;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
margin-inline-start: 8px;
|
margin-inline-start: 8px;
|
||||||
margin-inline-end: 0;
|
margin-inline-end: 8px;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
|
|||||||
@@ -432,62 +432,6 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
class=${this._mode === "yaml" ? "yaml-mode" : ""}
|
class=${this._mode === "yaml" ? "yaml-mode" : ""}
|
||||||
@subscribe-automation-config=${this._subscribeAutomationConfig}
|
@subscribe-automation-config=${this._subscribeAutomationConfig}
|
||||||
>
|
>
|
||||||
<div class="error-wrapper">
|
|
||||||
${this._errors || stateObj?.state === UNAVAILABLE
|
|
||||||
? html`<ha-alert
|
|
||||||
alert-type="error"
|
|
||||||
.title=${stateObj?.state === UNAVAILABLE
|
|
||||||
? this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.unavailable"
|
|
||||||
)
|
|
||||||
: undefined}
|
|
||||||
>
|
|
||||||
${this._errors || this._validationErrors}
|
|
||||||
${stateObj?.state === UNAVAILABLE
|
|
||||||
? html`<ha-svg-icon
|
|
||||||
slot="icon"
|
|
||||||
.path=${mdiRobotConfused}
|
|
||||||
></ha-svg-icon>`
|
|
||||||
: nothing}
|
|
||||||
</ha-alert>`
|
|
||||||
: ""}
|
|
||||||
${this._blueprintConfig
|
|
||||||
? html`<ha-alert alert-type="info">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.confirm_take_control"
|
|
||||||
)}
|
|
||||||
<div slot="action" style="display: flex;">
|
|
||||||
<ha-button
|
|
||||||
appearance="plain"
|
|
||||||
@click=${this._takeControlSave}
|
|
||||||
>${this.hass.localize("ui.common.yes")}</ha-button
|
|
||||||
>
|
|
||||||
<ha-button
|
|
||||||
appearance="plain"
|
|
||||||
@click=${this._revertBlueprint}
|
|
||||||
>${this.hass.localize("ui.common.no")}</ha-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</ha-alert>`
|
|
||||||
: this._readOnly
|
|
||||||
? html`<ha-alert alert-type="warning" dismissable
|
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.read_only"
|
|
||||||
)}
|
|
||||||
<ha-button
|
|
||||||
appearance="filled"
|
|
||||||
size="small"
|
|
||||||
variant="warning"
|
|
||||||
slot="action"
|
|
||||||
@click=${this._duplicate}
|
|
||||||
>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.migrate"
|
|
||||||
)}
|
|
||||||
</ha-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
</div>
|
|
||||||
${this._mode === "gui"
|
${this._mode === "gui"
|
||||||
? html`
|
? html`
|
||||||
<div>
|
<div>
|
||||||
@@ -499,7 +443,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
.isWide=${this.isWide}
|
.isWide=${this.isWide}
|
||||||
.stateObj=${stateObj}
|
.stateObj=${stateObj}
|
||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${Boolean(this._readOnly)}
|
.disabled=${this._readOnly}
|
||||||
.saving=${this._saving}
|
.saving=${this._saving}
|
||||||
.dirty=${this._dirty}
|
.dirty=${this._dirty}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@@ -513,13 +457,94 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
.isWide=${this.isWide}
|
.isWide=${this.isWide}
|
||||||
.stateObj=${stateObj}
|
.stateObj=${stateObj}
|
||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${Boolean(this._readOnly)}
|
.disabled=${this._readOnly}
|
||||||
.dirty=${this._dirty}
|
.dirty=${this._dirty}
|
||||||
.saving=${this._saving}
|
.saving=${this._saving}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@save-automation=${this._handleSaveAutomation}
|
@save-automation=${this._handleSaveAutomation}
|
||||||
@editor-save=${this._handleSaveAutomation}
|
@editor-save=${this._handleSaveAutomation}
|
||||||
></manual-automation-editor>
|
>
|
||||||
|
<div class="alert-wrapper" slot="alerts">
|
||||||
|
${this._errors || stateObj?.state === UNAVAILABLE
|
||||||
|
? html`<ha-alert
|
||||||
|
alert-type="error"
|
||||||
|
.title=${stateObj?.state === UNAVAILABLE
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.unavailable"
|
||||||
|
)
|
||||||
|
: undefined}
|
||||||
|
>
|
||||||
|
${this._errors || this._validationErrors}
|
||||||
|
${stateObj?.state === UNAVAILABLE
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiRobotConfused}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: nothing}
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
|
${this._blueprintConfig
|
||||||
|
? html`<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.confirm_take_control"
|
||||||
|
)}
|
||||||
|
<div slot="action" style="display: flex;">
|
||||||
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._takeControlSave}
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.common.yes"
|
||||||
|
)}</ha-button
|
||||||
|
>
|
||||||
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._revertBlueprint}
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.common.no"
|
||||||
|
)}</ha-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</ha-alert>`
|
||||||
|
: this._readOnly
|
||||||
|
? html`<ha-alert
|
||||||
|
alert-type="warning"
|
||||||
|
dismissable
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.read_only"
|
||||||
|
)}
|
||||||
|
<ha-button
|
||||||
|
appearance="filled"
|
||||||
|
size="small"
|
||||||
|
variant="warning"
|
||||||
|
slot="action"
|
||||||
|
@click=${this._duplicate}
|
||||||
|
>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.migrate"
|
||||||
|
)}
|
||||||
|
</ha-button>
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
|
${stateObj?.state === "off"
|
||||||
|
? html`
|
||||||
|
<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.disabled"
|
||||||
|
)}
|
||||||
|
<ha-button
|
||||||
|
size="small"
|
||||||
|
slot="action"
|
||||||
|
@click=${this._toggle}
|
||||||
|
>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.enable"
|
||||||
|
)}
|
||||||
|
</ha-button>
|
||||||
|
</ha-alert>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
|
</manual-automation-editor>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -542,7 +567,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
</ha-button>
|
</ha-button>
|
||||||
</ha-alert>
|
</ha-alert>
|
||||||
`
|
`
|
||||||
: ""}
|
: nothing}
|
||||||
<ha-yaml-editor
|
<ha-yaml-editor
|
||||||
copy-clipboard
|
copy-clipboard
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -1156,20 +1181,23 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
:not(.yaml-mode) > .error-wrapper {
|
:not(.yaml-mode) > .alert-wrapper {
|
||||||
position: absolute;
|
position: sticky;
|
||||||
top: 4px;
|
top: -24px;
|
||||||
z-index: 3;
|
margin-top: -24px;
|
||||||
|
z-index: 100;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:not(.yaml-mode) > .error-wrapper ha-alert {
|
:not(.yaml-mode) > .alert-wrapper ha-alert {
|
||||||
background-color: var(--card-background-color);
|
background-color: var(--card-background-color);
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
border-radius: var(--ha-border-radius-sm);
|
border-radius: var(--ha-border-radius-sm);
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
manual-automation-editor {
|
manual-automation-editor {
|
||||||
|
|||||||
@@ -112,20 +112,6 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
|
|
||||||
private _renderContent() {
|
private _renderContent() {
|
||||||
return html`
|
return html`
|
||||||
${this.stateObj?.state === "off"
|
|
||||||
? html`
|
|
||||||
<ha-alert alert-type="info">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.disabled"
|
|
||||||
)}
|
|
||||||
<ha-button size="small" slot="action" @click=${this._enable}>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.enable"
|
|
||||||
)}
|
|
||||||
</ha-button>
|
|
||||||
</ha-alert>
|
|
||||||
`
|
|
||||||
: nothing}
|
|
||||||
${this.config.description
|
${this.config.description
|
||||||
? html`<ha-markdown
|
? html`<ha-markdown
|
||||||
class="description"
|
class="description"
|
||||||
@@ -279,7 +265,10 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content">${this._renderContent()}</div>
|
<div class="content">
|
||||||
|
<slot name="alerts"></slot>
|
||||||
|
${this._renderContent()}
|
||||||
|
</div>
|
||||||
<ha-fab
|
<ha-fab
|
||||||
slot="fab"
|
slot="fab"
|
||||||
class=${this.dirty ? "dirty" : ""}
|
class=${this.dirty ? "dirty" : ""}
|
||||||
@@ -386,15 +375,6 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _enable(): Promise<void> {
|
|
||||||
if (!this.hass || !this.stateObj) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.hass.callService("automation", "turn_on", {
|
|
||||||
entity_id: this.stateObj.entity_id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private _saveAutomation() {
|
private _saveAutomation() {
|
||||||
this._closeSidebar();
|
this._closeSidebar();
|
||||||
fireEvent(this, "save-automation");
|
fireEvent(this, "save-automation");
|
||||||
@@ -656,9 +636,8 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
line-height: 0;
|
line-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-alert {
|
.description {
|
||||||
display: block;
|
margin-top: 16px;
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -384,60 +384,6 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<div class=${this._mode === "yaml" ? "yaml-mode" : ""}>
|
<div class=${this._mode === "yaml" ? "yaml-mode" : ""}>
|
||||||
<div class="error-wrapper">
|
|
||||||
${this._errors || stateObj?.state === UNAVAILABLE
|
|
||||||
? html`<ha-alert
|
|
||||||
alert-type="error"
|
|
||||||
.title=${stateObj?.state === UNAVAILABLE
|
|
||||||
? this.hass.localize(
|
|
||||||
"ui.panel.config.script.editor.unavailable"
|
|
||||||
)
|
|
||||||
: undefined}
|
|
||||||
>
|
|
||||||
${this._errors || this._validationErrors}
|
|
||||||
${stateObj?.state === UNAVAILABLE
|
|
||||||
? html`<ha-svg-icon
|
|
||||||
slot="icon"
|
|
||||||
.path=${mdiRobotConfused}
|
|
||||||
></ha-svg-icon>`
|
|
||||||
: nothing}
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${this._blueprintConfig
|
|
||||||
? html`<ha-alert alert-type="info">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.script.editor.confirm_take_control"
|
|
||||||
)}
|
|
||||||
<div slot="action" style="display: flex;">
|
|
||||||
<ha-button
|
|
||||||
appearance="plain"
|
|
||||||
@click=${this._takeControlSave}
|
|
||||||
>${this.hass.localize("ui.common.yes")}</ha-button
|
|
||||||
>
|
|
||||||
<ha-button
|
|
||||||
appearance="plain"
|
|
||||||
@click=${this._revertBlueprint}
|
|
||||||
>${this.hass.localize("ui.common.no")}</ha-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</ha-alert>`
|
|
||||||
: this._readOnly
|
|
||||||
? html`<ha-alert alert-type="warning" dismissable
|
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.script.editor.read_only"
|
|
||||||
)}
|
|
||||||
<ha-button
|
|
||||||
appearance="plain"
|
|
||||||
slot="action"
|
|
||||||
@click=${this._duplicate}
|
|
||||||
>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.script.editor.migrate"
|
|
||||||
)}
|
|
||||||
</ha-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
</div>
|
|
||||||
${this._mode === "gui"
|
${this._mode === "gui"
|
||||||
? html`
|
? html`
|
||||||
<div>
|
<div>
|
||||||
@@ -467,7 +413,68 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@editor-save=${this._handleSaveScript}
|
@editor-save=${this._handleSaveScript}
|
||||||
@save-script=${this._handleSaveScript}
|
@save-script=${this._handleSaveScript}
|
||||||
></manual-script-editor>
|
>
|
||||||
|
<div class="alert-wrapper" slot="alerts">
|
||||||
|
${this._errors || stateObj?.state === UNAVAILABLE
|
||||||
|
? html`<ha-alert
|
||||||
|
alert-type="error"
|
||||||
|
.title=${stateObj?.state === UNAVAILABLE
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.unavailable"
|
||||||
|
)
|
||||||
|
: undefined}
|
||||||
|
>
|
||||||
|
${this._errors || this._validationErrors}
|
||||||
|
${stateObj?.state === UNAVAILABLE
|
||||||
|
? html`<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiRobotConfused}
|
||||||
|
></ha-svg-icon>`
|
||||||
|
: nothing}
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
|
${this._blueprintConfig
|
||||||
|
? html`<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.confirm_take_control"
|
||||||
|
)}
|
||||||
|
<div slot="action" style="display: flex;">
|
||||||
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._takeControlSave}
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.common.yes"
|
||||||
|
)}</ha-button
|
||||||
|
>
|
||||||
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._revertBlueprint}
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.common.no"
|
||||||
|
)}</ha-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</ha-alert>`
|
||||||
|
: this._readOnly
|
||||||
|
? html`<ha-alert
|
||||||
|
alert-type="warning"
|
||||||
|
dismissable
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.read_only"
|
||||||
|
)}
|
||||||
|
<ha-button
|
||||||
|
appearance="plain"
|
||||||
|
slot="action"
|
||||||
|
@click=${this._duplicate}
|
||||||
|
>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.migrate"
|
||||||
|
)}
|
||||||
|
</ha-button>
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
|
</div>
|
||||||
|
</manual-script-editor>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -1092,6 +1099,26 @@ export class HaScriptEditor extends SubscribeMixin(
|
|||||||
border-radius: var(--ha-border-radius-sm);
|
border-radius: var(--ha-border-radius-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert-wrapper {
|
||||||
|
position: sticky;
|
||||||
|
top: -24px;
|
||||||
|
margin-top: -24px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
z-index: 100;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-wrapper ha-alert {
|
||||||
|
background-color: var(--card-background-color);
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||||
|
border-radius: var(--ha-border-radius-sm);
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
manual-script-editor {
|
manual-script-editor {
|
||||||
max-width: 1540px;
|
max-width: 1540px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
|
|||||||
@@ -201,7 +201,10 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="content">${this._renderContent()}</div>
|
<div class="content">
|
||||||
|
<slot name="alerts"></slot>
|
||||||
|
${this._renderContent()}
|
||||||
|
</div>
|
||||||
<ha-fab
|
<ha-fab
|
||||||
slot="fab"
|
slot="fab"
|
||||||
class=${this.dirty ? "dirty" : ""}
|
class=${this.dirty ? "dirty" : ""}
|
||||||
@@ -522,6 +525,10 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
font-weight: var(--ha-font-weight-normal);
|
font-weight: var(--ha-font-weight-normal);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user