mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Change Restart to be a button, update dialogs (#12499)
This commit is contained in:
parent
bdfb17d957
commit
1f3c23de29
@ -1,5 +1,3 @@
|
||||
import { ActionDetail } from "@material/mwc-list";
|
||||
import { mdiDotsVertical } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { canShowPage } from "../../../common/config/can_show_page";
|
||||
@ -44,22 +42,18 @@ class HaConfigSystemNavigation extends LitElement {
|
||||
back-path="/config"
|
||||
.header=${this.hass.localize("ui.panel.config.dashboard.system.main")}
|
||||
>
|
||||
<ha-button-menu
|
||||
corner="BOTTOM_START"
|
||||
@action=${this._handleAction}
|
||||
<mwc-button
|
||||
slot="toolbar-icon"
|
||||
>
|
||||
<ha-icon-button
|
||||
slot="trigger"
|
||||
.label=${this.hass.localize("ui.common.overflow_menu")}
|
||||
.path=${mdiDotsVertical}
|
||||
></ha-icon-button>
|
||||
<mwc-list-item>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_homeassistant"
|
||||
)}
|
||||
</mwc-list-item>
|
||||
</ha-button-menu>
|
||||
class="warning"
|
||||
.label=${this.narrow
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_homeassistant_short"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_homeassistant"
|
||||
)}
|
||||
@click=${this._restart}
|
||||
></mwc-button>
|
||||
<ha-config-section
|
||||
.narrow=${this.narrow}
|
||||
.isWide=${this.isWide}
|
||||
@ -77,28 +71,28 @@ class HaConfigSystemNavigation extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _handleAction(ev: CustomEvent<ActionDetail>) {
|
||||
switch (ev.detail.index) {
|
||||
case 0:
|
||||
showConfirmationDialog(this, {
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.confirm_restart"
|
||||
),
|
||||
confirm: () => {
|
||||
this.hass
|
||||
.callService("homeassistant", "restart")
|
||||
.catch((reason) => {
|
||||
showAlertDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_error"
|
||||
),
|
||||
text: reason.message,
|
||||
});
|
||||
});
|
||||
},
|
||||
private _restart() {
|
||||
showConfirmationDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.confirm_restart_title"
|
||||
),
|
||||
text: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.confirm_restart_text"
|
||||
),
|
||||
confirmText: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_homeassistant_short"
|
||||
),
|
||||
confirm: () => {
|
||||
this.hass.callService("homeassistant", "restart").catch((reason) => {
|
||||
showAlertDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.system_dashboard.restart_error"
|
||||
),
|
||||
text: reason.message,
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
@ -167,8 +167,14 @@ export class DeveloperYamlConfig extends LitElement {
|
||||
|
||||
private _restart() {
|
||||
showConfirmationDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart_title"
|
||||
),
|
||||
text: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart"
|
||||
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart_text"
|
||||
),
|
||||
confirmText: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.yaml.section.server_management.restart"
|
||||
),
|
||||
confirm: () => {
|
||||
this.hass.callService("homeassistant", "restart").catch((reason) => {
|
||||
|
@ -3170,8 +3170,10 @@
|
||||
"supervisor_stats": "Supervisor Stats"
|
||||
},
|
||||
"system_dashboard": {
|
||||
"confirm_restart": "Are you sure you want to restart Home Assistant?",
|
||||
"confirm_restart_text": "Restarting Home Assistant will stop all your active dashboards, automations and scripts.",
|
||||
"confirm_restart_title": "Restart Home Assistant?",
|
||||
"restart_homeassistant": "Restart Home Assistant",
|
||||
"restart_homeassistant_short": "Restart",
|
||||
"restart_error": "Failed to restart Home Assistant"
|
||||
}
|
||||
},
|
||||
@ -4203,10 +4205,9 @@
|
||||
},
|
||||
"server_management": {
|
||||
"heading": "Home Assistant",
|
||||
"introduction": "Restarting Home Assistant will stop your dashboard and automations. After the reboot, each configuration will be reloaded.",
|
||||
"confirm_restart_text": "Restarting Home Assistant will stop all your active dashboards, automations and scripts.",
|
||||
"confirm_restart_title": "Restart Home Assistant?",
|
||||
"restart": "Restart",
|
||||
"restart_home_assistant": "Restart Home Assistant",
|
||||
"confirm_restart": "Are you sure you want to restart Home Assistant?",
|
||||
"stop": "Stop",
|
||||
"confirm_stop": "Are you sure you want to stop Home Assistant?",
|
||||
"restart_error": "Failed to restart Home Assistant"
|
||||
|
Loading…
x
Reference in New Issue
Block a user