mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-02 00:27:49 +01:00
Replace CLI command in install error with link to supervisor logs
Show a confirmation dialog with an "OK" primary button and a "View supervisor logs" secondary button that navigates to the logs page, instead of displaying CLI commands in the error message. Also strip CLI command references from supervisor API error messages. https://claude.ai/code/session_01DxodYC7uLzxc6SDWyx17tk
This commit is contained in:
@@ -21,12 +21,18 @@ export interface HassioStats {
|
||||
export const hassioApiResultExtractor = <T>(response: HassioResponse<T>) =>
|
||||
response.data;
|
||||
|
||||
export const extractApiErrorMessage = (error: any): string =>
|
||||
export const extractApiErrorMessage = (error: any): string => {
|
||||
const msg =
|
||||
typeof error === "object"
|
||||
? typeof error.body === "object"
|
||||
? error.body.message || "Unknown error, see supervisor logs"
|
||||
: error.body || error.message || "Unknown error, see supervisor logs"
|
||||
? error.body.message || "Unknown error"
|
||||
: error.body || error.message || "Unknown error"
|
||||
: error;
|
||||
// Strip CLI command references from supervisor error messages
|
||||
return typeof msg === "string"
|
||||
? msg.replace(/\s*\(check with '[^']*'\)/g, "")
|
||||
: msg;
|
||||
};
|
||||
|
||||
const ignoredStatusCodes = new Set([502, 503, 504]);
|
||||
|
||||
|
||||
@@ -1059,11 +1059,16 @@ class SupervisorAppInfo extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, {
|
||||
showConfirmationDialog(this, {
|
||||
title: this.hass.localize(
|
||||
"ui.panel.config.apps.dashboard.action_error.install"
|
||||
),
|
||||
text: extractApiErrorMessage(err),
|
||||
confirmText: this.hass.localize("ui.common.ok"),
|
||||
dismissText: this.hass.localize(
|
||||
"ui.panel.config.apps.dashboard.action_error.view_supervisor_logs"
|
||||
),
|
||||
cancel: () => navigate("/config/logs?provider=supervisor"),
|
||||
});
|
||||
}
|
||||
button.progress = false;
|
||||
|
||||
@@ -2866,7 +2866,8 @@
|
||||
"get_changelog": "Failed to get changelog",
|
||||
"start_invalid_config": "Invalid configuration",
|
||||
"go_to_config": "Go to configuration",
|
||||
"validate_config": "Failed to validate app configuration"
|
||||
"validate_config": "Failed to validate app configuration",
|
||||
"view_supervisor_logs": "View supervisor logs"
|
||||
},
|
||||
"uninstall_dialog": {
|
||||
"title": "Uninstall {name}?",
|
||||
|
||||
Reference in New Issue
Block a user