Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions hassio/src/update-available/update-available-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/data/hassio/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,19 @@ 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({
type: "supervisor/api",
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`
);
}
};
Expand Down
7 changes: 2 additions & 5 deletions src/data/supervisor/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
};
2 changes: 0 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down Expand Up @@ -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}"
Expand Down
Loading