mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Remove ha-alert actionText (#10646)
This commit is contained in:
parent
0d19f4792f
commit
0ca35d7012
@ -9,7 +9,6 @@ const alerts: {
|
|||||||
description: string | TemplateResult;
|
description: string | TemplateResult;
|
||||||
type: "info" | "warning" | "error" | "success";
|
type: "info" | "warning" | "error" | "success";
|
||||||
dismissable?: boolean;
|
dismissable?: boolean;
|
||||||
action?: string;
|
|
||||||
rtl?: boolean;
|
rtl?: boolean;
|
||||||
iconSlot?: TemplateResult;
|
iconSlot?: TemplateResult;
|
||||||
actionSlot?: TemplateResult;
|
actionSlot?: TemplateResult;
|
||||||
@ -76,13 +75,13 @@ const alerts: {
|
|||||||
title: "Error with action",
|
title: "Error with action",
|
||||||
description: "This is a test error alert with action",
|
description: "This is a test error alert with action",
|
||||||
type: "error",
|
type: "error",
|
||||||
action: "restart",
|
actionSlot: html`<mwc-button slot="action" label="restart"></mwc-button>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Unsaved data",
|
title: "Unsaved data",
|
||||||
description: "You have unsaved data",
|
description: "You have unsaved data",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
action: "save",
|
actionSlot: html`<mwc-button slot="action" label="save"></mwc-button>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Slotted icon",
|
title: "Slotted icon",
|
||||||
@ -106,7 +105,7 @@ const alerts: {
|
|||||||
title: "Error with action",
|
title: "Error with action",
|
||||||
description: "This is a test error alert with action (RTL)",
|
description: "This is a test error alert with action (RTL)",
|
||||||
type: "error",
|
type: "error",
|
||||||
action: "restart",
|
actionSlot: html`<mwc-button slot="action" label="restart"></mwc-button>`,
|
||||||
rtl: true,
|
rtl: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -129,7 +128,6 @@ export class DemoHaAlert extends LitElement {
|
|||||||
.title=${alert.title || ""}
|
.title=${alert.title || ""}
|
||||||
.alertType=${alert.type}
|
.alertType=${alert.type}
|
||||||
.dismissable=${alert.dismissable || false}
|
.dismissable=${alert.dismissable || false}
|
||||||
.actionText=${alert.action || ""}
|
|
||||||
.rtl=${alert.rtl || false}
|
.rtl=${alert.rtl || false}
|
||||||
>
|
>
|
||||||
${alert.iconSlot} ${alert.description} ${alert.actionSlot}
|
${alert.iconSlot} ${alert.description} ${alert.actionSlot}
|
||||||
|
@ -176,11 +176,6 @@ class HaGallery extends PolymerElement {
|
|||||||
this.addEventListener("alert-dismissed-clicked", () =>
|
this.addEventListener("alert-dismissed-clicked", () =>
|
||||||
this.$.notifications.showDialog({ message: "Alert dismissed clicked" })
|
this.$.notifications.showDialog({ message: "Alert dismissed clicked" })
|
||||||
);
|
);
|
||||||
|
|
||||||
this.addEventListener("alert-action-clicked", () =>
|
|
||||||
this.$.notifications.showDialog({ message: "Alert action clicked" })
|
|
||||||
);
|
|
||||||
|
|
||||||
this.addEventListener("hass-more-info", (ev) => {
|
this.addEventListener("hass-more-info", (ev) => {
|
||||||
if (ev.detail.entityId) {
|
if (ev.detail.entityId) {
|
||||||
this.$.notifications.showDialog({
|
this.$.notifications.showDialog({
|
||||||
|
@ -151,14 +151,18 @@ class HassioAddonInfo extends LitElement {
|
|||||||
.title=${this.supervisor.localize(
|
.title=${this.supervisor.localize(
|
||||||
"addon.dashboard.protection_mode.title"
|
"addon.dashboard.protection_mode.title"
|
||||||
)}
|
)}
|
||||||
.actionText=${this.supervisor.localize(
|
|
||||||
"addon.dashboard.protection_mode.enable"
|
|
||||||
)}
|
|
||||||
@alert-action-clicked=${this._protectionToggled}
|
|
||||||
>
|
>
|
||||||
${this.supervisor.localize(
|
${this.supervisor.localize(
|
||||||
"addon.dashboard.protection_mode.content"
|
"addon.dashboard.protection_mode.content"
|
||||||
)}
|
)}
|
||||||
|
<mwc-button
|
||||||
|
slot="action"
|
||||||
|
.label=${this.supervisor.localize(
|
||||||
|
"addon.dashboard.protection_mode.enable"
|
||||||
|
)}
|
||||||
|
@click=${this._protectionToggled}
|
||||||
|
>
|
||||||
|
</mwc-button>
|
||||||
</ha-alert>
|
</ha-alert>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
@ -151,24 +151,28 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
></ha-switch>
|
></ha-switch>
|
||||||
</ha-settings-row>`
|
</ha-settings-row>`
|
||||||
: ""
|
: ""
|
||||||
: html`<ha-alert
|
: html`<ha-alert alert-type="warning">
|
||||||
alert-type="warning"
|
|
||||||
.actionText=${this.supervisor.localize("common.learn_more")}
|
|
||||||
@alert-action-clicked=${this._unsupportedDialog}
|
|
||||||
>
|
|
||||||
${this.supervisor.localize(
|
${this.supervisor.localize(
|
||||||
"system.supervisor.unsupported_title"
|
"system.supervisor.unsupported_title"
|
||||||
)}
|
)}
|
||||||
|
<mwc-button
|
||||||
|
slot="action"
|
||||||
|
.label=${this.supervisor.localize("common.learn_more")}
|
||||||
|
@click=${this._unsupportedDialog}
|
||||||
|
>
|
||||||
|
</mwc-button>
|
||||||
</ha-alert>`}
|
</ha-alert>`}
|
||||||
${!this.supervisor.supervisor.healthy
|
${!this.supervisor.supervisor.healthy
|
||||||
? html`<ha-alert
|
? html`<ha-alert alert-type="error">
|
||||||
alert-type="error"
|
|
||||||
.actionText=${this.supervisor.localize("common.learn_more")}
|
|
||||||
@alert-action-clicked=${this._unhealthyDialog}
|
|
||||||
>
|
|
||||||
${this.supervisor.localize(
|
${this.supervisor.localize(
|
||||||
"system.supervisor.unhealthy_title"
|
"system.supervisor.unhealthy_title"
|
||||||
)}
|
)}
|
||||||
|
<mwc-button
|
||||||
|
slot="action"
|
||||||
|
.label=${this.supervisor.localize("common.learn_more")}
|
||||||
|
@click=${this._unhealthyDialog}
|
||||||
|
>
|
||||||
|
</mwc-button>
|
||||||
</ha-alert>`
|
</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
@ -466,6 +470,9 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
|
ha-alert mwc-button {
|
||||||
|
--mdc-theme-primary: var(--primary-text-color);
|
||||||
|
}
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
|
||||||
import {
|
import {
|
||||||
mdiAlertCircleOutline,
|
mdiAlertCircleOutline,
|
||||||
mdiAlertOutline,
|
mdiAlertOutline,
|
||||||
@ -23,7 +22,6 @@ const ALERT_ICONS = {
|
|||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
"alert-dismissed-clicked": undefined;
|
"alert-dismissed-clicked": undefined;
|
||||||
"alert-action-clicked": undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +35,6 @@ class HaAlert extends LitElement {
|
|||||||
| "error"
|
| "error"
|
||||||
| "success" = "info";
|
| "success" = "info";
|
||||||
|
|
||||||
@property({ attribute: "action-text" }) public actionText = "";
|
|
||||||
|
|
||||||
@property({ type: Boolean }) public dismissable = false;
|
@property({ type: Boolean }) public dismissable = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public rtl = false;
|
@property({ type: Boolean }) public rtl = false;
|
||||||
@ -63,12 +59,7 @@ class HaAlert extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<slot name="action">
|
<slot name="action">
|
||||||
${this.actionText
|
${this.dismissable
|
||||||
? html`<mwc-button
|
|
||||||
@click=${this._action_clicked}
|
|
||||||
.label=${this.actionText}
|
|
||||||
></mwc-button>`
|
|
||||||
: this.dismissable
|
|
||||||
? html`<ha-icon-button
|
? html`<ha-icon-button
|
||||||
@click=${this._dismiss_clicked}
|
@click=${this._dismiss_clicked}
|
||||||
label="Dismiss alert"
|
label="Dismiss alert"
|
||||||
@ -86,10 +77,6 @@ class HaAlert extends LitElement {
|
|||||||
fireEvent(this, "alert-dismissed-clicked");
|
fireEvent(this, "alert-dismissed-clicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _action_clicked() {
|
|
||||||
fireEvent(this, "alert-action-clicked");
|
|
||||||
}
|
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
.issue-type {
|
.issue-type {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -133,6 +120,10 @@ class HaAlert extends LitElement {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.action {
|
||||||
|
width: min-content;
|
||||||
|
--mdc-theme-primary: var(--primary-text-color);
|
||||||
|
}
|
||||||
.main-content {
|
.main-content {
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
@ -140,9 +131,6 @@ class HaAlert extends LitElement {
|
|||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
mwc-button {
|
|
||||||
--mdc-theme-primary: var(--primary-text-color);
|
|
||||||
}
|
|
||||||
ha-icon-button {
|
ha-icon-button {
|
||||||
--mdc-icon-button-size: 36px;
|
--mdc-icon-button-size: 36px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user