mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +00:00
Add optional hass object to ha-alert to compute rtl
This commit is contained in:
parent
6f6fc759cc
commit
843aa3acb0
@ -55,7 +55,9 @@ class HassioAddonAudio extends LitElement {
|
||||
>
|
||||
<div class="card-content">
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error"
|
||||
>${this._error}</ha-alert
|
||||
>`
|
||||
: ""}
|
||||
|
||||
<paper-dropdown-menu
|
||||
|
@ -137,14 +137,16 @@ class HassioAddonConfig extends LitElement {
|
||||
.yamlSchema=${ADDON_YAML_SCHEMA}
|
||||
></ha-yaml-editor>`}
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${!this._yamlMode ||
|
||||
(this._canShowSchema && this.addon.schema) ||
|
||||
this._valid
|
||||
? ""
|
||||
: html`
|
||||
<ha-alert alert-type="error">
|
||||
<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this.supervisor.localize(
|
||||
"addon.configuration.options.invalid_yaml"
|
||||
)}
|
||||
|
@ -64,7 +64,9 @@ class HassioAddonNetwork extends LitElement {
|
||||
>
|
||||
<div class="card-content">
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
|
||||
<table>
|
||||
|
@ -40,7 +40,9 @@ class HassioAddonDocumentationDashboard extends LitElement {
|
||||
<div class="content">
|
||||
<ha-card>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
<div class="card-content">
|
||||
${this._content
|
||||
|
@ -144,14 +144,14 @@ class HassioAddonInfo extends LitElement {
|
||||
this.addon.arch
|
||||
)
|
||||
? html`
|
||||
<ha-alert alert-type="warning">
|
||||
<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.supervisor.localize(
|
||||
"addon.dashboard.not_available_arch"
|
||||
)}
|
||||
</ha-alert>
|
||||
`
|
||||
: html`
|
||||
<ha-alert alert-type="warning">
|
||||
<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.supervisor.localize(
|
||||
"addon.dashboard.not_available_arch",
|
||||
"core_version_installed",
|
||||
@ -572,7 +572,9 @@ class HassioAddonInfo extends LitElement {
|
||||
</div>
|
||||
</div>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${!this.addon.version && addonStoreInfo && !this.addon.available
|
||||
? !addonArchIsSupported(
|
||||
@ -580,14 +582,14 @@ class HassioAddonInfo extends LitElement {
|
||||
this.addon.arch
|
||||
)
|
||||
? html`
|
||||
<ha-alert alert-type="warning">
|
||||
<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.supervisor.localize(
|
||||
"addon.dashboard.not_available_arch"
|
||||
)}
|
||||
</ha-alert>
|
||||
`
|
||||
: html`
|
||||
<ha-alert alert-type="warning">
|
||||
<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.supervisor.localize(
|
||||
"addon.dashboard.not_available_version",
|
||||
"core_version_installed",
|
||||
|
@ -36,7 +36,9 @@ class HassioAddonLogs extends LitElement {
|
||||
<h1>${this.addon.name}</h1>
|
||||
<ha-card>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
<div class="card-content">
|
||||
${this._content
|
||||
|
@ -92,7 +92,9 @@ class HassioBackupDialog
|
||||
>
|
||||
</supervisor-backup-content>`}
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
|
||||
<mwc-button
|
||||
|
@ -64,7 +64,9 @@ class HassioCreateBackupDialog extends LitElement {
|
||||
>
|
||||
</supervisor-backup-content>`}
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
<mwc-button slot="secondaryAction" @click=${this.closeDialog}>
|
||||
${this._dialogParams.supervisor.localize("common.close")}
|
||||
|
@ -252,7 +252,7 @@ export class DialogHassioNetwork
|
||||
`
|
||||
: ""}
|
||||
${this._dirty
|
||||
? html`<ha-alert alert-type="warning">
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.supervisor.localize("dialog.network.warning")}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
|
@ -78,7 +78,9 @@ class HassioRepositoriesDialog extends LitElement {
|
||||
)}
|
||||
>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
<div class="form">
|
||||
${repositories.length
|
||||
|
@ -130,7 +130,9 @@ class DialogSupervisorUpdate extends LitElement {
|
||||
)}
|
||||
</p>`}
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
</ha-dialog>
|
||||
`;
|
||||
|
@ -174,6 +174,7 @@ class HassioSupervisorInfo extends LitElement {
|
||||
</ha-settings-row>`
|
||||
: ""
|
||||
: html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
.actionText=${this.supervisor.localize("common.learn_more")}
|
||||
@alert-action-clicked=${this._unsupportedDialog}
|
||||
@ -184,6 +185,7 @@ class HassioSupervisorInfo extends LitElement {
|
||||
</ha-alert>`}
|
||||
${!this.supervisor.supervisor.healthy
|
||||
? html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="error"
|
||||
.actionText=${this.supervisor.localize("common.learn_more")}
|
||||
@alert-action-clicked=${this._unhealthyDialog}
|
||||
|
@ -69,7 +69,9 @@ class HassioSupervisorLog extends LitElement {
|
||||
return html`
|
||||
<ha-card>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error">
|
||||
${this._error}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${this.hass.userData?.showAdvanced
|
||||
? html`
|
||||
|
@ -11,6 +11,8 @@ import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import { HomeAssistant } from "../types";
|
||||
import "./ha-svg-icon";
|
||||
|
||||
const ALERT_ICONS = {
|
||||
@ -29,6 +31,8 @@ declare global {
|
||||
|
||||
@customElement("ha-alert")
|
||||
class HaAlert extends LitElement {
|
||||
@property({ type: Object }) public hass?: HomeAssistant;
|
||||
|
||||
@property() public title = "";
|
||||
|
||||
@property({ attribute: "alert-type" }) public alertType:
|
||||
@ -37,7 +41,7 @@ class HaAlert extends LitElement {
|
||||
| "error"
|
||||
| "success" = "info";
|
||||
|
||||
@property({ attribute: "action-text" }) public actionText = "";
|
||||
@property({ attribute: "action-text" }) public actionText?: string;
|
||||
|
||||
@property({ type: Boolean }) public dismissable = false;
|
||||
|
||||
@ -47,7 +51,7 @@ class HaAlert extends LitElement {
|
||||
return html`
|
||||
<div
|
||||
class="issue-type ${classMap({
|
||||
rtl: this.rtl,
|
||||
rtl: this.hass ? computeRTL(this.hass) : this.rtl,
|
||||
[this.alertType]: true,
|
||||
})}"
|
||||
>
|
||||
|
@ -46,6 +46,7 @@ export class CloudGooglePref extends LitElement {
|
||||
${google_enabled && !this.cloudStatus.google_registered
|
||||
? html`
|
||||
<ha-alert
|
||||
.hass=${this.hass}
|
||||
.title=${this.hass.localize(
|
||||
"ui.panel.config.cloud.account.google.not_configured_title"
|
||||
)}
|
||||
|
@ -64,6 +64,7 @@ export class CloudRemotePref extends LitElement {
|
||||
${!remote_connected && remote_enabled
|
||||
? html`
|
||||
<ha-alert
|
||||
.hass=${this.hass}
|
||||
.title=${this.hass.localize(
|
||||
`ui.panel.config.cloud.account.remote.reconnecting`
|
||||
)}
|
||||
|
@ -23,6 +23,7 @@ class EnergyValidationMessage extends LitElement {
|
||||
return Object.entries(grouped).map(
|
||||
([issueType, gIssues]) => html`
|
||||
<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
.title=${
|
||||
this.hass.localize(
|
||||
|
@ -78,7 +78,7 @@ class HaConfigEnergy extends LitElement {
|
||||
.route=${this.route}
|
||||
.tabs=${configSections.experiences}
|
||||
>
|
||||
<ha-alert>
|
||||
<ha-alert .hass=${this.hass}>
|
||||
After setting up a new device, it can take up to 2 hours for new data
|
||||
to arrive in your energy dashboard.
|
||||
</ha-alert>
|
||||
|
@ -159,7 +159,10 @@ export class ZwaveMigration extends LitElement {
|
||||
)
|
||||
.map(
|
||||
(entityState) =>
|
||||
html`<ha-alert alert-type="warning">
|
||||
html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
>
|
||||
Device ${computeStateName(entityState)}
|
||||
(${entityState.entity_id}) is not ready yet! For
|
||||
the best result, wake the device up if it is
|
||||
@ -252,7 +255,10 @@ export class ZwaveMigration extends LitElement {
|
||||
</p>
|
||||
${this._waitingOnDevices?.map(
|
||||
(device) =>
|
||||
html`<ha-alert alert-type="warning">
|
||||
html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
>
|
||||
Device ${computeDeviceName(device, this.hass)} is
|
||||
not ready yet! For the best result, wake the device
|
||||
up if it is battery powered and wait for this device
|
||||
@ -265,6 +271,7 @@ export class ZwaveMigration extends LitElement {
|
||||
${this._migratedZwaveEntities!.length !==
|
||||
this._migrationData.zwave_entity_ids.length
|
||||
? html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
title="Not all entities can be migrated!"
|
||||
>
|
||||
|
@ -166,7 +166,7 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
</p>
|
||||
${
|
||||
this._error
|
||||
? html`<ha-alert alert-type="error"
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error"
|
||||
>${this._error}</ha-alert
|
||||
>`
|
||||
: ""
|
||||
@ -192,7 +192,9 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
? html`
|
||||
<h3>The device has requested the following security classes:</h3>
|
||||
${this._error
|
||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||
? html`<ha-alert .hass=${this.hass} alert-type="error"
|
||||
>${this._error}</ha-alert
|
||||
>`
|
||||
: ""}
|
||||
<div class="flex-column">
|
||||
${this._requestedGrant?.securityClasses
|
||||
@ -356,6 +358,7 @@ class DialogZWaveJSAddNode extends LitElement {
|
||||
</p>
|
||||
${this._lowSecurity
|
||||
? html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="warning"
|
||||
title="The device was added insecurely"
|
||||
>
|
||||
|
@ -35,7 +35,11 @@ export class HuiErrorCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
}
|
||||
|
||||
return html`<ha-alert alert-type="error" .title=${this._config.error}>
|
||||
return html`<ha-alert
|
||||
.hass=${this.hass}
|
||||
alert-type="error"
|
||||
.title=${this._config.error}
|
||||
>
|
||||
${dumped ? html`<pre>${dumped}</pre>` : ""}
|
||||
</ha-alert>`;
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ export const createEntityNotFoundWarning = (
|
||||
@customElement("hui-warning")
|
||||
export class HuiWarning extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`<ha-alert alert-type="warning"><slot></slot></ha-alert> `;
|
||||
return html`<ha-alert alert-type="warning">
|
||||
<slot></slot>
|
||||
</ha-alert> `;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ export class HuiDialogEditView extends LitElement {
|
||||
? html`
|
||||
${VIEWS_NO_BADGE_SUPPORT.includes(this._type)
|
||||
? html`
|
||||
<ha-alert alert-type="warning">
|
||||
<ha-alert .hass=${this.hass} alert-type="warning">
|
||||
${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.edit_badges.view_no_badges"
|
||||
)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user