From 1f3c23de2905541a7c9a9f85495c76b227ce9506 Mon Sep 17 00:00:00 2001 From: Zack Barett Date: Thu, 28 Apr 2022 15:43:00 -0500 Subject: [PATCH] Change Restart to be a button, update dialogs (#12499) --- .../core/ha-config-system-navigation.ts | 70 +++++++++---------- .../developer-yaml-config.ts | 8 ++- src/translations/en.json | 9 +-- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index 548cc51e6c..a665215626 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -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")} > - - - - ${this.hass.localize( - "ui.panel.config.system_dashboard.restart_homeassistant" - )} - - + 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} + > ) { - 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 { diff --git a/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts b/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts index 57ca442c49..47ab1f4ff6 100644 --- a/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts +++ b/src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts @@ -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) => { diff --git a/src/translations/en.json b/src/translations/en.json index 64db711526..420e496340 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -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"