Fix Restarting Home Assistant (#12480)

* Fix Restarting Home ASsistant

* Update src/panels/config/core/ha-config-system-navigation.ts

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* Update src/panels/developer-tools/yaml_configuration/developer-yaml-config.ts

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>

* reviews

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Zack Barett 2022-04-27 17:55:04 -05:00 committed by GitHub
parent 2751f8f33b
commit e4f91195d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 9 deletions

View File

@ -6,7 +6,10 @@ import { canShowPage } from "../../../common/config/can_show_page";
import "../../../components/ha-card";
import "../../../components/ha-navigation-list";
import { CloudStatus } from "../../../data/cloud";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import {
showAlertDialog,
showConfirmationDialog,
} from "../../../dialogs/generic/show-dialog-box";
import "../../../layouts/hass-subpage";
import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
@ -82,7 +85,16 @@ class HaConfigSystemNavigation extends LitElement {
"ui.panel.config.system_dashboard.confirm_restart"
),
confirm: () => {
this.hass.callService("homeassistant", "restart");
this.hass
.callService("homeassistant", "restart")
.catch((reason) => {
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.system_dashboard.restart_error"
),
text: reason.message,
});
});
},
});
break;

View File

@ -27,9 +27,9 @@ export class DeveloperYamlConfig extends LitElement {
@state() private _reloadableDomains: string[] = [];
private _validateLog = "";
@state() private _isValid: boolean | null = null;
private _isValid: boolean | null = null;
private _validateLog = "";
protected updated(changedProperties) {
const oldHass = changedProperties.get("hass");
@ -170,10 +170,11 @@ export class DeveloperYamlConfig extends LitElement {
text: this.hass.localize(
"ui.panel.developer-tools.tabs.yaml.section.server_management.confirm_restart"
),
confirmText: this.hass!.localize("ui.common.leave"),
dismissText: this.hass!.localize("ui.common.stay"),
confirm: () => {
this.hass.callService("homeassistant", "restart");
this.hass.callService("homeassistant", "restart").catch((reason) => {
this._isValid = false;
this._validateLog = reason.message;
});
},
});
}

View File

@ -3165,7 +3165,8 @@
},
"system_dashboard": {
"confirm_restart": "Are you sure you want to restart Home Assistant?",
"restart_homeassistant": "Restart Home Assistant"
"restart_homeassistant": "Restart Home Assistant",
"restart_error": "Failed to restart Home Assistant"
}
},
"lovelace": {
@ -4201,7 +4202,8 @@
"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?"
"confirm_stop": "Are you sure you want to stop Home Assistant?",
"restart_error": "Failed to restart Home Assistant"
}
}
}