Skip to content

Commit

Permalink
Backup with db requires config, disabled next if no data is selected (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jan 2, 2025
1 parent 34bcd5e commit fa672ff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 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
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
22 changes: 12 additions & 10 deletions src/panels/config/backup/ha-config-backup-overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,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

0 comments on commit fa672ff

Please sign in to comment.