Skip to content

Commit

Permalink
Merge branch 'dev' into move-local-location-backup-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jan 2, 2025
2 parents 5ed372e + fa672ff commit 9217c91
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class HaBackupConfigData extends LitElement {
const include_addons = data.addons_mode === "custom" ? data.addons : [];

this.value = {
include_homeassistant: data.homeassistant || this.forceHomeAssistant,
include_homeassistant:
data.homeassistant || data.database || this.forceHomeAssistant,
include_addons: include_addons.length ? include_addons : undefined,
include_all_addons: data.addons_mode === "all",
include_database: data.database,
Expand Down Expand Up @@ -168,7 +169,7 @@ class HaBackupConfigData extends LitElement {
slot="end"
@change=${this._switchChanged}
.checked=${data.homeassistant}
.disabled=${this.forceHomeAssistant}
.disabled=${this.forceHomeAssistant || data.database}
></ha-switch>
</ha-md-list-item>
Expand Down Expand Up @@ -296,7 +297,6 @@ class HaBackupConfigData extends LitElement {
...data,
[target.id]: target.checked,
});
fireEvent(this, "value-changed", { value: this.value });
}

private _selectChanged(ev: Event) {
Expand All @@ -309,7 +309,6 @@ class HaBackupConfigData extends LitElement {
if (target.id === "addons_mode") {
this._showAddons = target.value === "custom";
}
fireEvent(this, "value-changed", { value: this.value });
}

private _addonsChanged(ev: CustomEvent) {
Expand All @@ -320,7 +319,6 @@ class HaBackupConfigData extends LitElement {
...data,
addons,
});
fireEvent(this, "value-changed", { value: this.value });
}

static styles = css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ class HaBackupOverviewBackups extends LitElement {
<p>
Backups are essential for a reliable smart home. They help protect
the work you've put into setting up your smart home, and if the
worst happens, you can get back up and running quickly. It is
recommended that you create a backup every day. You should keep
three backups in at least two different locations, one of which
should be off-site.
worst happens, you can get back up and running quickly.
</p>
</div>
<div class="card-actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class HaBackupBackupsSummary extends LitElement {
const { state: schedule } = config.schedule;

if (schedule === BackupScheduleState.NEVER) {
return "Automatic backups are disabled";
return "Automatic backups are not scheduled";
}

let copiesText = "and keep all backups";
Expand Down Expand Up @@ -116,7 +116,7 @@ class HaBackupBackupsSummary extends LitElement {

return html`
<ha-card class="my-backups">
<div class="card-header">Automatic backups</div>
<div class="card-header">Backup settings</div>
<div class="card-content">
<ha-md-list>
<ha-md-list-item
Expand All @@ -128,7 +128,7 @@ class HaBackupBackupsSummary extends LitElement {
${this._scheduleDescription(this.config)}
</div>
<div slot="supporting-text">
Schedule and number of backups to keep
Automatic backup schedule and retention
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-md-list-item>
Expand Down Expand Up @@ -174,7 +174,7 @@ class HaBackupBackupsSummary extends LitElement {
</div>
<div class="card-actions">
<ha-button @click=${this._configure}>
Configure automatic backups
Configure backup settings
</ha-button>
</div>
</ha-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {

public showDialog(params: BackupOnboardingDialogParams): void {
this._params = params;
this._step = STEPS[0];
this._step = params.skipWelcome ? STEPS[1] : STEPS[0];
this._config = RECOMMENDED_CONFIG;

const agents: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog {
? "Save current encryption key"
: this._step === "new"
? "New encryption key"
: "";
: this._step === "done"
? "Save new encryption key"
: "";

return html`
<ha-md-dialog disable-cancel-action open @closed=${this.closeDialog}>
Expand Down Expand Up @@ -166,10 +168,22 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog {
case "new":
return html`
<p>
Keep this encryption key in a safe place, as you will need it to
access your backup, allowing it to be restored. Either record the
All next backups will use the new encryption key. Encryption keeps
your backups private and secure.
</p>
<div class="encryption-key">
<p>${this._newEncryptionKey}</p>
<ha-icon-button
.path=${mdiContentCopy}
@click=${this._copyKeyToClipboard}
></ha-icon-button>
</div>
`;
case "done":
return html`<p>
Keep this new encryption key in a safe place, as you will need it to
access your backups, allowing it to be restored. Either record the
characters below or download them as an emergency kit file.
Encryption keeps your backups private and secure.
</p>
<div class="encryption-key">
<p>${this._newEncryptionKey}</p>
Expand All @@ -189,18 +203,7 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog {
Download
</ha-button>
</ha-md-list-item>
</ha-md-list>
`;
case "done":
return html`
<div class="done">
<img
src="/static/images/voice-assistant/hi.png"
alt="Casita Home Assistant logo"
/>
<p>Encryption key changed</p>
</div>
`;
</ha-md-list>`;
}
return nothing;
}
Expand Down Expand Up @@ -303,13 +306,6 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog {
p {
margin-top: 0;
}
.done {
text-align: center;
font-size: 22px;
font-style: normal;
font-weight: 400;
line-height: 28px;
}
`,
];
}
Expand Down
20 changes: 19 additions & 1 deletion src/panels/config/backup/dialogs/dialog-generate-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,30 @@ class DialogGenerateBackup extends LitElement implements HassDialog {
Create backup
</ha-button>
`
: html`<ha-button @click=${this._nextStep}>Next</ha-button>`}
: html`<ha-button
@click=${this._nextStep}
.disabled=${this._step === "data" && this._noDataSelected}
>Next</ha-button
>`}
</div>
</ha-md-dialog>
`;
}

private get _noDataSelected() {
const hassio = isComponentLoaded(this.hass, "hassio");
if (
this._formData?.data.include_homeassistant ||
this._formData?.data.include_database ||
(hassio && this._formData?.data.include_folders?.length) ||
(hassio && this._formData?.data.include_all_addons) ||
(hassio && this._formData?.data.include_addons?.length)
) {
return false;
}
return true;
}

private _renderData() {
if (!this._formData) {
return nothing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface BackupOnboardingDialogParams {
submit?: (value: boolean) => void;
cancel?: () => void;
cloudStatus?: CloudStatus;
skipWelcome?: boolean;
}

const loadDialog = () => import("./dialog-backup-onboarding");
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/backup/ha-config-backup-backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class HaConfigBackupBackups extends SubscribeMixin(LitElement) {
has-fab
.tabs=${[
{
translationKey: "ui.panel.config.backup.caption",
name: "My backups",
path: `/config/backup/list`,
},
]}
Expand Down
8 changes: 8 additions & 0 deletions src/panels/config/backup/ha-config-backup-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ class HaConfigBackupDetails extends LitElement {
)}
<span slot="supporting-text">Created</span>
</ha-md-list-item>
<ha-md-list-item>
<span slot="headline">
${this._backup.protected
? "Encrypted AES-128"
: "Not encrypted"}
</span>
<span slot="supporting-text">Protected</span>
</ha-md-list-item>
</ha-md-list>
</div>
</ha-card>
Expand Down
27 changes: 15 additions & 12 deletions src/panels/config/backup/ha-config-backup-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ class HaConfigBackupOverview extends LitElement {

private _handleOnboardingButtonClick(ev) {
ev.stopPropagation();
this._setupAutomaticBackup();
this._setupAutomaticBackup(true);
}

private async _setupAutomaticBackup() {
private async _setupAutomaticBackup(skipWelcome = false) {
const success = await showBackupOnboardingDialog(this, {
cloudStatus: this.cloudStatus,
skipWelcome,
});
if (!success) {
return;
Expand Down Expand Up @@ -159,22 +160,24 @@ class HaConfigBackupOverview extends LitElement {
>
</ha-backup-overview-onboarding>
`
: html`
<ha-backup-overview-summary
.hass=${this.hass}
.backups=${this.backups}
.config=${this.config}
.fetching=${this.fetching}
>
</ha-backup-overview-summary>
`}
: this.config
? html`
<ha-backup-overview-summary
.hass=${this.hass}
.backups=${this.backups}
.config=${this.config}
.fetching=${this.fetching}
>
</ha-backup-overview-summary>
`
: nothing}
<ha-backup-overview-backups
.hass=${this.hass}
.backups=${this.backups}
></ha-backup-overview-backups>
${!this._needsOnboarding
${!this._needsOnboarding && this.config
? html`
<ha-backup-overview-settings
.hass=${this.hass}
Expand Down
11 changes: 10 additions & 1 deletion src/panels/config/backup/ha-config-backup-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "../../../components/ha-card";
import "../../../components/ha-icon-button";
import "../../../components/ha-icon-next";
import "../../../components/ha-list-item";
import "../../../components/ha-alert";
import "../../../components/ha-password-field";
import "../../../components/ha-svg-icon";
import type { BackupConfig } from "../../../data/backup";
Expand Down Expand Up @@ -98,7 +99,7 @@ class HaConfigBackupSettings extends LitElement {
back-path="/config/backup"
.hass=${this.hass}
.narrow=${this.narrow}
.header=${"Automatic backups"}
.header=${"Backup settings"}
>
${isComponentLoaded(this.hass, "hassio")
? html`
Expand Down Expand Up @@ -163,6 +164,14 @@ class HaConfigBackupSettings extends LitElement {
.cloudStatus=${this.cloudStatus}
@value-changed=${this._agentsConfigChanged}
></ha-backup-config-agents>
${!this._config.create_backup.agent_ids.length
? html`<ha-alert
alert-type="warning"
title="No location selected"
>You have to select at least one location to create a
backup.</ha-alert
><br />`
: nothing}
</div>
</ha-card>
<ha-card>
Expand Down

0 comments on commit 9217c91

Please sign in to comment.