mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Remove backup toggle from supervisor addon page when update available (#23602)
This commit is contained in:
parent
63c658e5b9
commit
4cc95938c8
@ -18,10 +18,7 @@ import "../../../src/components/ha-checkbox";
|
|||||||
import "../../../src/components/ha-faded";
|
import "../../../src/components/ha-faded";
|
||||||
import "../../../src/components/ha-icon-button";
|
import "../../../src/components/ha-icon-button";
|
||||||
import "../../../src/components/ha-markdown";
|
import "../../../src/components/ha-markdown";
|
||||||
import "../../../src/components/ha-settings-row";
|
|
||||||
import "../../../src/components/ha-svg-icon";
|
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 type { HassioAddonDetails } from "../../../src/data/hassio/addon";
|
||||||
import {
|
import {
|
||||||
fetchHassioAddonChangelog,
|
fetchHassioAddonChangelog,
|
||||||
@ -163,19 +160,6 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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
|
: html`<ha-circular-progress
|
||||||
aria-label="Updating"
|
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 {
|
get _version(): string {
|
||||||
return this._updateType
|
return this._updateType
|
||||||
? this._updateType === "addon"
|
? this._updateType === "addon"
|
||||||
@ -370,23 +341,14 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _update() {
|
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._error = undefined;
|
||||||
this._updating = true;
|
this._updating = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this._updateType === "addon") {
|
if (this._updateType === "addon") {
|
||||||
await updateHassioAddon(
|
await updateHassioAddon(this.hass, this.addonSlug!);
|
||||||
this.hass,
|
|
||||||
this.addonSlug!,
|
|
||||||
this._shouldCreateBackup
|
|
||||||
);
|
|
||||||
} else if (this._updateType === "core") {
|
} else if (this._updateType === "core") {
|
||||||
await updateCore(this.hass, this._shouldCreateBackup);
|
await updateCore(this.hass);
|
||||||
} else if (this._updateType === "os") {
|
} else if (this._updateType === "os") {
|
||||||
await updateOS(this.hass);
|
await updateOS(this.hass);
|
||||||
} else if (this._updateType === "supervisor") {
|
} else if (this._updateType === "supervisor") {
|
||||||
@ -436,11 +398,6 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ha-settings-row {
|
|
||||||
padding: 0;
|
|
||||||
margin-bottom: -16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
border-color: var(--divider-color);
|
border-color: var(--divider-color);
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
@ -313,8 +313,7 @@ export const installHassioAddon = async (
|
|||||||
|
|
||||||
export const updateHassioAddon = async (
|
export const updateHassioAddon = async (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
slug: string,
|
slug: string
|
||||||
backup: boolean
|
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||||
await hass.callWS({
|
await hass.callWS({
|
||||||
@ -322,13 +321,11 @@ export const updateHassioAddon = async (
|
|||||||
endpoint: `/store/addons/${slug}/update`,
|
endpoint: `/store/addons/${slug}/update`,
|
||||||
method: "post",
|
method: "post",
|
||||||
timeout: null,
|
timeout: null,
|
||||||
data: { backup },
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await hass.callApi<HassioResponse<void>>(
|
await hass.callApi<HassioResponse<void>>(
|
||||||
"POST",
|
"POST",
|
||||||
`hassio/addons/${slug}/update`,
|
`hassio/addons/${slug}/update`
|
||||||
{ backup }
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,18 +6,15 @@ export const restartCore = async (hass: HomeAssistant) => {
|
|||||||
await hass.callService("homeassistant", "restart");
|
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)) {
|
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||||
await hass.callWS({
|
await hass.callWS({
|
||||||
type: "supervisor/api",
|
type: "supervisor/api",
|
||||||
endpoint: "/core/update",
|
endpoint: "/core/update",
|
||||||
method: "post",
|
method: "post",
|
||||||
timeout: null,
|
timeout: null,
|
||||||
data: { backup },
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await hass.callApi<HassioResponse<void>>("POST", `hassio/core/update`, {
|
await hass.callApi<HassioResponse<void>>("POST", "hassio/core/update");
|
||||||
backup,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1270,7 +1270,6 @@
|
|||||||
"clear_skipped": "Clear skipped",
|
"clear_skipped": "Clear skipped",
|
||||||
"install": "Install",
|
"install": "Install",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"create_backup": "Create backup before updating",
|
|
||||||
"auto_update_enabled_title": "Can not skip version",
|
"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."
|
"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_available": {
|
||||||
"update_name": "Update {name}",
|
"update_name": "Update {name}",
|
||||||
"open_release_notes": "Open release notes",
|
"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}",
|
"description": "You have {version} installed. Press update to update to version {newest_version}",
|
||||||
"updating": "Updating {name} to version {version}",
|
"updating": "Updating {name} to version {version}",
|
||||||
"no_update": "No update available for {name}"
|
"no_update": "No update available for {name}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user