From 9fe4c7978293da804cd28e9be1f04e2774010f9c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 16 Oct 2021 05:38:58 -0700 Subject: [PATCH] Convert all warning classes to ha-alert (#10289) --- .../src/addon-view/info/hassio-addon-info.ts | 29 +++++++++---------- .../action/ha-automation-action-row.ts | 15 ++++++---- .../trigger/ha-automation-trigger-row.ts | 12 +++++--- .../config/devices/ha-config-device-page.ts | 21 +++++++------- .../lovelace/editor/hui-element-editor.ts | 12 +++++--- src/translations/en.json | 2 +- 6 files changed, 50 insertions(+), 41 deletions(-) diff --git a/hassio/src/addon-view/info/hassio-addon-info.ts b/hassio/src/addon-view/info/hassio-addon-info.ts index f37fde8eaf..8d54e25563 100644 --- a/hassio/src/addon-view/info/hassio-addon-info.ts +++ b/hassio/src/addon-view/info/hassio-addon-info.ts @@ -180,24 +180,21 @@ class HassioAddonInfo extends LitElement { : ""} ${!this.addon.protected ? html` - -

${this.supervisor.localize( - "addon.dashboard.protection_mode.title" - )} -

-
- ${this.supervisor.localize("addon.dashboard.protection_mode.content")} -
-
- - ${this.supervisor.localize( + -
- -
- ` + @alert-action-clicked=${this._protectionToggled} + > + ${this.supervisor.localize( + "addon.dashboard.protection_mode.content" + )} + + ` : ""} diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 7685926e49..6e1f316a82 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -12,6 +12,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { handleStructError } from "../../../../common/structs/handle-errors"; import "../../../../components/ha-button-menu"; import "../../../../components/ha-card"; +import "../../../../components/ha-alert"; import "../../../../components/ha-icon-button"; import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; import type { Action } from "../../../../data/script"; @@ -42,7 +43,8 @@ const OPTIONS = [ "device_id", ]; -const getType = (action: Action) => OPTIONS.find((option) => option in action); +const getType = (action: Action | undefined) => + action ? OPTIONS.find((option) => option in action) : undefined; declare global { // for fire event @@ -171,9 +173,12 @@ export default class HaAutomationActionRow extends LitElement { ${this._warnings - ? html`
- ${this.hass.localize("ui.errors.config.editor_not_supported")}: -
+ ? html` ${this._warnings!.length > 0 && this._warnings![0] !== undefined ? html`
    ${this._warnings!.map( @@ -182,7 +187,7 @@ export default class HaAutomationActionRow extends LitElement {
` : ""} ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} -
` + ` : ""} ${yamlMode ? html` diff --git a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts index 3d72c5f404..f5d9125699 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts @@ -12,6 +12,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { handleStructError } from "../../../../common/structs/handle-errors"; import "../../../../components/ha-button-menu"; import "../../../../components/ha-card"; +import "../../../../components/ha-alert"; import "../../../../components/ha-icon-button"; import type { Trigger } from "../../../../data/automation"; import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box"; @@ -121,9 +122,12 @@ export default class HaAutomationTriggerRow extends LitElement { ${this._warnings - ? html`
- ${this.hass.localize("ui.errors.config.editor_not_supported")}: -
+ ? html` ${this._warnings.length && this._warnings[0] !== undefined ? html`
    ${this._warnings.map( @@ -132,7 +136,7 @@ export default class HaAutomationTriggerRow extends LitElement {
` : ""} ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} -
` + ` : ""} ${yamlMode ? html` diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts index 39c9ab79e9..9be745ae4e 100644 --- a/src/panels/config/devices/ha-config-device-page.ts +++ b/src/panels/config/devices/ha-config-device-page.ts @@ -13,6 +13,7 @@ import { slugify } from "../../../common/string/slugify"; import "../../../components/entity/ha-battery-icon"; import "../../../components/ha-icon-button"; import "../../../components/ha-icon-next"; +import "../../../components/ha-alert"; import "../../../components/ha-svg-icon"; import { AreaRegistryEntry } from "../../../data/area_registry"; import { @@ -296,17 +297,15 @@ export class HaConfigDevicePage extends LitElement { ${ device.disabled_by ? html` -
-

- ${this.hass.localize( - "ui.panel.config.devices.enabled_cause", - "cause", - this.hass.localize( - `ui.panel.config.devices.disabled_by.${device.disabled_by}` - ) - )} -

-
+ + ${this.hass.localize( + "ui.panel.config.devices.enabled_cause", + "cause", + this.hass.localize( + `ui.panel.config.devices.disabled_by.${device.disabled_by}` + ) + )} + ${device.disabled_by === "user" ? html`
diff --git a/src/panels/lovelace/editor/hui-element-editor.ts b/src/panels/lovelace/editor/hui-element-editor.ts index 68e0d1875c..3fa6aa3d87 100644 --- a/src/panels/lovelace/editor/hui-element-editor.ts +++ b/src/panels/lovelace/editor/hui-element-editor.ts @@ -15,6 +15,7 @@ import { computeRTL } from "../../../common/util/compute_rtl"; import { deepEqual } from "../../../common/util/deep-equal"; import "../../../components/ha-circular-progress"; import "../../../components/ha-code-editor"; +import "../../../components/ha-alert"; import type { HaCodeEditor } from "../../../components/ha-code-editor"; import type { LovelaceCardConfig, @@ -229,9 +230,12 @@ export abstract class HuiElementEditor extends LitElement { : ""} ${this.hasWarning ? html` -
- ${this.hass.localize("ui.errors.config.editor_not_supported")}: -
+ ${this._warnings!.length > 0 && this._warnings![0] !== undefined ? html`
    ${this._warnings!.map( @@ -240,7 +244,7 @@ export abstract class HuiElementEditor extends LitElement {
` : ""} ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} -
+ ` : ""}
diff --git a/src/translations/en.json b/src/translations/en.json index 5b18237bc1..30caecee09 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -4026,7 +4026,7 @@ "protection_mode": { "title": "Warning: Protection mode is disabled!", "content": "Protection mode on this add-on is disabled! This gives the add-on full access to the entire system, which adds security risks, and could damage your system when used incorrectly. Only disable the protection mode if you know, need AND trust the source of this add-on.", - "enable": "Enable Protection mode" + "enable": "[%key:ui::common::enable%]" }, "capability": { "stage": {