Skip to content

Commit

Permalink
Show error reasons on status page
Browse files Browse the repository at this point in the history
  • Loading branch information
wendevlin committed Jan 29, 2025
1 parent edb8248 commit 62c2406
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
11 changes: 1 addition & 10 deletions src/data/backup_onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@ import type {
RestoreBackupState,
} from "./backup_manager";

type RestoreFailedReason =
| "backup_agent_error"
| "backup_reader_writer_error"
| "password_incorrect"
| "decrypt_on_download_not_supported"
| "backup_manager_error"
| "unknown"
| "unknown_error";

export interface BackupOnboardingInfo {
state: BackupManagerState;
last_non_idle_event?: {
manager_state: BackupManagerState;
stage: RestoreBackupStage | null;
state: RestoreBackupState;
reason: RestoreFailedReason | null;
reason: string | null;
} | null;
}

Expand Down
1 change: 1 addition & 0 deletions src/onboarding/onboarding-restore-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class OnboardingRestoreBackup extends LitElement {
? html`<onboarding-restore-backup-status
.localize=${this.localize}
.backupInfo=${this._backupInfo}
@show-backup-upload=${this._reupload}
></onboarding-restore-backup-status>`
: nothing
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { css, html, LitElement, type CSSResultGroup } from "lit";
import { css, html, LitElement, nothing, type CSSResultGroup } from "lit";
import { customElement, property } from "lit/decorators";
import "../../components/ha-card";
import "../../components/ha-circular-progress";
import "../../components/ha-alert";
import "../../components/ha-button";
import { haStyle } from "../../resources/styles";
import type { LocalizeFunc } from "../../common/translations/localize";
import type { BackupOnboardingInfo } from "../../data/backup_onboarding";
import { fireEvent } from "../../common/dom/fire_event";
import { navigate } from "../../common/navigate";
import { removeSearchParam } from "../../common/url/search-params";

declare global {
interface HASSDomEvents {
Expand Down Expand Up @@ -44,12 +48,42 @@ class OnboardingRestoreBackupStatus extends LitElement {
"ui.panel.page-onboarding.restore.failed_status_description"
)}
</ha-alert>
${this.backupInfo.last_non_idle_event?.reason
? html`
<div class="failed">
<h4>Error:</h4>
${this.backupInfo.last_non_idle_event?.reason}
</div>
`
: nothing}
`}
</div>
${this.backupInfo.state !== "restore_backup"
? html`<div class="card-actions">
<ha-button @click=${this._uploadAnother} class="danger">
${this.localize(
`ui.panel.page-onboarding.restore.details.summary.upload_another`
)}
</ha-button>
<ha-button @click=${this._home} class="danger">
${this.localize(
`ui.panel.page-onboarding.restore.details.summary.home`
)}
</ha-button>
</div>`
: nothing}
</ha-card>
`;
}

private _uploadAnother() {
fireEvent(this, "show-backup-upload");
}

private _home() {
navigate(`${location.pathname}?${removeSearchParam("page")}`);
}

static get styles(): CSSResultGroup {
return [
haStyle,
Expand All @@ -60,6 +94,10 @@ class OnboardingRestoreBackupStatus extends LitElement {
.card-header {
padding-bottom: 8px;
}
.card-actions {
display: flex;
justify-content: flex-end;
}
.loading {
display: flex;
justify-content: center;
Expand All @@ -70,6 +108,10 @@ class OnboardingRestoreBackupStatus extends LitElement {
padding: 0 16px;
font-size: 16px;
}
.failed {
padding: 16px 0;
font-size: 16px;
}
`,
];
}
Expand Down
5 changes: 3 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8170,7 +8170,8 @@
"protection": "[%key:ui::panel::config::backup::details::summary::protection%]",
"protected_encrypted_aes_128": "[%key:ui::panel::config::backup::details::summary::protected_encrypted_aes_128%]",
"protected_not_encrypted": "[%key:ui::panel::config::backup::details::summary::protected_not_encrypted%]",
"upload_another": "Upload another"
"upload_another": "Upload another",
"home": "Home"
},
"restore": {
"title": "[%key:ui::panel::config::backup::details::restore::title%]",
Expand All @@ -8195,7 +8196,7 @@
"in_progress": "Restore in progress",
"in_progress_description": "The restore process is running in the background. Home Assistant will automatically start again once the restore is complete. Please be patient, this can take a while. Do not close or refresh this page.",
"failed": "Restore failed",
"failed_status_description": "It was not able to restore the backup. Please try again.",
"failed_status_description": "The backup could not be restored. Please try again.",
"failed_description": "The last restore attempt failed. Please try it again.",
"failed_wrong_password_description": "The last restore attempt failed, because the encryption key was incorrect. Please try it again.",
"upload_supports": "Supports .TAR files",
Expand Down

0 comments on commit 62c2406

Please sign in to comment.