Remove backup toggle from supervisor addon page when update available (#23602)

This commit is contained in:
Bram Kragten 2025-01-06 14:13:07 +01:00 committed by GitHub
parent 63c658e5b9
commit 4cc95938c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 57 deletions

View File

@ -18,10 +18,7 @@ import "../../../src/components/ha-checkbox";
import "../../../src/components/ha-faded";
import "../../../src/components/ha-icon-button";
import "../../../src/components/ha-markdown";
import "../../../src/components/ha-settings-row";
import "../../../src/components/ha-svg-icon";
import "../../../src/components/ha-switch";
import type { HaSwitch } from "../../../src/components/ha-switch";
import type { HassioAddonDetails } from "../../../src/data/hassio/addon";
import {
fetchHassioAddonChangelog,
@ -163,19 +160,6 @@ class UpdateAvailableCard extends LitElement {
)}
</p>
</div>
${["core", "addon"].includes(this._updateType)
? html`
<hr />
<ha-settings-row>
<span slot="heading">
${this.supervisor.localize(
"update_available.create_backup"
)}
</span>
<ha-switch id="create_backup" checked></ha-switch>
</ha-settings-row>
`
: nothing}
`
: html`<ha-circular-progress
aria-label="Updating"
@ -243,19 +227,6 @@ class UpdateAvailableCard extends LitElement {
}
}
get _shouldCreateBackup(): boolean {
if (this._updateType && !["core", "addon"].includes(this._updateType)) {
return false;
}
const createBackupSwitch = this.shadowRoot?.getElementById(
"create-backup"
) as HaSwitch;
if (createBackupSwitch) {
return createBackupSwitch.checked;
}
return true;
}
get _version(): string {
return this._updateType
? this._updateType === "addon"
@ -370,23 +341,14 @@ class UpdateAvailableCard extends LitElement {
}
private async _update() {
if (this._shouldCreateBackup && this.supervisor.info.state === "freeze") {
this._error = this.supervisor.localize("backup.backup_already_running");
return;
}
this._error = undefined;
this._updating = true;
try {
if (this._updateType === "addon") {
await updateHassioAddon(
this.hass,
this.addonSlug!,
this._shouldCreateBackup
);
await updateHassioAddon(this.hass, this.addonSlug!);
} else if (this._updateType === "core") {
await updateCore(this.hass, this._shouldCreateBackup);
await updateCore(this.hass);
} else if (this._updateType === "os") {
await updateOS(this.hass);
} else if (this._updateType === "supervisor") {
@ -436,11 +398,6 @@ class UpdateAvailableCard extends LitElement {
padding-bottom: 8px;
}
ha-settings-row {
padding: 0;
margin-bottom: -16px;
}
hr {
border-color: var(--divider-color);
border-bottom: none;

View File

@ -313,8 +313,7 @@ export const installHassioAddon = async (
export const updateHassioAddon = async (
hass: HomeAssistant,
slug: string,
backup: boolean
slug: string
): Promise<void> => {
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
await hass.callWS({
@ -322,13 +321,11 @@ export const updateHassioAddon = async (
endpoint: `/store/addons/${slug}/update`,
method: "post",
timeout: null,
data: { backup },
});
} else {
await hass.callApi<HassioResponse<void>>(
"POST",
`hassio/addons/${slug}/update`,
{ backup }
`hassio/addons/${slug}/update`
);
}
};

View File

@ -6,18 +6,15 @@ export const restartCore = async (hass: HomeAssistant) => {
await hass.callService("homeassistant", "restart");
};
export const updateCore = async (hass: HomeAssistant, backup: boolean) => {
export const updateCore = async (hass: HomeAssistant) => {
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
await hass.callWS({
type: "supervisor/api",
endpoint: "/core/update",
method: "post",
timeout: null,
data: { backup },
});
} else {
await hass.callApi<HassioResponse<void>>("POST", `hassio/core/update`, {
backup,
});
await hass.callApi<HassioResponse<void>>("POST", "hassio/core/update");
}
};

View File

@ -1270,7 +1270,6 @@
"clear_skipped": "Clear skipped",
"install": "Install",
"update": "Update",
"create_backup": "Create backup before updating",
"auto_update_enabled_title": "Can not skip version",
"auto_update_enabled_text": "Automatic updates for this item have been enabled; skipping it is, therefore, unavailable. You can either install this update now or wait for Home Assistant to do it automatically."
},
@ -8006,7 +8005,6 @@
"update_available": {
"update_name": "Update {name}",
"open_release_notes": "Open release notes",
"create_backup": "Create backup before updating",
"description": "You have {version} installed. Press update to update to version {newest_version}",
"updating": "Updating {name} to version {version}",
"no_update": "No update available for {name}"