diff --git a/src/components/ha-alert.ts b/src/components/ha-alert.ts index 8661364e3a..6db2544eb9 100644 --- a/src/components/ha-alert.ts +++ b/src/components/ha-alert.ts @@ -119,10 +119,11 @@ class HaAlert extends LitElement { .main-content { overflow-wrap: anywhere; word-break: break-word; + line-height: normal; margin-left: 8px; margin-right: 0; margin-inline-start: 8px; - margin-inline-end: 0; + margin-inline-end: 8px; } .title { margin-top: 2px; diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 3f27a0bac8..8093caa9e9 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -432,62 +432,6 @@ export class HaAutomationEditor extends PreventUnsavedMixin( class=${this._mode === "yaml" ? "yaml-mode" : ""} @subscribe-automation-config=${this._subscribeAutomationConfig} > -
- ${this._errors || stateObj?.state === UNAVAILABLE - ? html` - ${this._errors || this._validationErrors} - ${stateObj?.state === UNAVAILABLE - ? html`` - : nothing} - ` - : ""} - ${this._blueprintConfig - ? html` - ${this.hass.localize( - "ui.panel.config.automation.editor.confirm_take_control" - )} -
- ${this.hass.localize("ui.common.yes")} - ${this.hass.localize("ui.common.no")} -
-
` - : this._readOnly - ? html`${this.hass.localize( - "ui.panel.config.automation.editor.read_only" - )} - - ${this.hass.localize( - "ui.panel.config.automation.editor.migrate" - )} - - ` - : nothing} -
${this._mode === "gui" ? html`
@@ -499,7 +443,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin( .isWide=${this.isWide} .stateObj=${stateObj} .config=${this._config} - .disabled=${Boolean(this._readOnly)} + .disabled=${this._readOnly} .saving=${this._saving} .dirty=${this._dirty} @value-changed=${this._valueChanged} @@ -513,13 +457,94 @@ export class HaAutomationEditor extends PreventUnsavedMixin( .isWide=${this.isWide} .stateObj=${stateObj} .config=${this._config} - .disabled=${Boolean(this._readOnly)} + .disabled=${this._readOnly} .dirty=${this._dirty} .saving=${this._saving} @value-changed=${this._valueChanged} @save-automation=${this._handleSaveAutomation} @editor-save=${this._handleSaveAutomation} - > + > +
+ ${this._errors || stateObj?.state === UNAVAILABLE + ? html` + ${this._errors || this._validationErrors} + ${stateObj?.state === UNAVAILABLE + ? html`` + : nothing} + ` + : nothing} + ${this._blueprintConfig + ? html` + ${this.hass.localize( + "ui.panel.config.automation.editor.confirm_take_control" + )} +
+ ${this.hass.localize( + "ui.common.yes" + )} + ${this.hass.localize( + "ui.common.no" + )} +
+
` + : this._readOnly + ? html`${this.hass.localize( + "ui.panel.config.automation.editor.read_only" + )} + + ${this.hass.localize( + "ui.panel.config.automation.editor.migrate" + )} + + ` + : nothing} + ${stateObj?.state === "off" + ? html` + + ${this.hass.localize( + "ui.panel.config.automation.editor.disabled" + )} + + ${this.hass.localize( + "ui.panel.config.automation.editor.enable" + )} + + + ` + : nothing} +
+ `}
` @@ -542,7 +567,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin( ` - : ""} + : nothing} .error-wrapper { - position: absolute; - top: 4px; - z-index: 3; + :not(.yaml-mode) > .alert-wrapper { + position: sticky; + top: -24px; + margin-top: -24px; + z-index: 100; width: 100%; display: flex; flex-direction: column; 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); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); border-radius: var(--ha-border-radius-sm); + margin-bottom: 0; } manual-automation-editor { diff --git a/src/panels/config/automation/manual-automation-editor.ts b/src/panels/config/automation/manual-automation-editor.ts index 37c4a11e00..b22ba74c58 100644 --- a/src/panels/config/automation/manual-automation-editor.ts +++ b/src/panels/config/automation/manual-automation-editor.ts @@ -112,20 +112,6 @@ export class HaManualAutomationEditor extends LitElement { private _renderContent() { return html` - ${this.stateObj?.state === "off" - ? html` - - ${this.hass.localize( - "ui.panel.config.automation.editor.disabled" - )} - - ${this.hass.localize( - "ui.panel.config.automation.editor.enable" - )} - - - ` - : nothing} ${this.config.description ? html`
-
${this._renderContent()}
+
+ + ${this._renderContent()} +
{ - if (!this.hass || !this.stateObj) { - return; - } - await this.hass.callService("automation", "turn_on", { - entity_id: this.stateObj.entity_id, - }); - } - private _saveAutomation() { this._closeSidebar(); fireEvent(this, "save-automation"); @@ -656,9 +636,8 @@ export class HaManualAutomationEditor extends LitElement { line-height: 0; } - ha-alert { - display: block; - margin-bottom: 16px; + .description { + margin-top: 16px; } `, ]; diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 584a999fd8..27199efb9a 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -384,60 +384,6 @@ export class HaScriptEditor extends SubscribeMixin(
-
- ${this._errors || stateObj?.state === UNAVAILABLE - ? html` - ${this._errors || this._validationErrors} - ${stateObj?.state === UNAVAILABLE - ? html`` - : nothing} - ` - : nothing} - ${this._blueprintConfig - ? html` - ${this.hass.localize( - "ui.panel.config.script.editor.confirm_take_control" - )} -
- ${this.hass.localize("ui.common.yes")} - ${this.hass.localize("ui.common.no")} -
-
` - : this._readOnly - ? html`${this.hass.localize( - "ui.panel.config.script.editor.read_only" - )} - - ${this.hass.localize( - "ui.panel.config.script.editor.migrate" - )} - - ` - : nothing} -
${this._mode === "gui" ? html`
@@ -467,7 +413,68 @@ export class HaScriptEditor extends SubscribeMixin( @value-changed=${this._valueChanged} @editor-save=${this._handleSaveScript} @save-script=${this._handleSaveScript} - > + > +
+ ${this._errors || stateObj?.state === UNAVAILABLE + ? html` + ${this._errors || this._validationErrors} + ${stateObj?.state === UNAVAILABLE + ? html`` + : nothing} + ` + : nothing} + ${this._blueprintConfig + ? html` + ${this.hass.localize( + "ui.panel.config.script.editor.confirm_take_control" + )} +
+ ${this.hass.localize( + "ui.common.yes" + )} + ${this.hass.localize( + "ui.common.no" + )} +
+
` + : this._readOnly + ? html`${this.hass.localize( + "ui.panel.config.script.editor.read_only" + )} + + ${this.hass.localize( + "ui.panel.config.script.editor.migrate" + )} + + ` + : nothing} +
+ `}
` @@ -1092,6 +1099,26 @@ export class HaScriptEditor extends SubscribeMixin( 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 { max-width: 1540px; padding: 0 12px; diff --git a/src/panels/config/script/manual-script-editor.ts b/src/panels/config/script/manual-script-editor.ts index c699b8f11a..439bd6aad3 100644 --- a/src/panels/config/script/manual-script-editor.ts +++ b/src/panels/config/script/manual-script-editor.ts @@ -201,7 +201,10 @@ export class HaManualScriptEditor extends LitElement { })} >
-
${this._renderContent()}
+
+ + ${this._renderContent()} +