mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Add automatic backup toggle to OS update (#24995)
This commit is contained in:
parent
14e0666c3a
commit
1dfd937c94
@ -207,7 +207,11 @@ export const computeUpdateStateDisplay = (
|
||||
return hass.formatEntityState(stateObj);
|
||||
};
|
||||
|
||||
export type UpdateType = "addon" | "home_assistant" | "generic";
|
||||
export type UpdateType =
|
||||
| "addon"
|
||||
| "home_assistant"
|
||||
| "home_assistant_os"
|
||||
| "generic";
|
||||
|
||||
export const getUpdateType = (
|
||||
stateObj: UpdateEntity,
|
||||
@ -215,6 +219,7 @@ export const getUpdateType = (
|
||||
): UpdateType => {
|
||||
const entity_id = stateObj.entity_id;
|
||||
const domain = entitySources[entity_id]?.domain;
|
||||
|
||||
if (domain !== "hassio") {
|
||||
return "generic";
|
||||
}
|
||||
@ -224,13 +229,11 @@ export const getUpdateType = (
|
||||
return "home_assistant";
|
||||
}
|
||||
|
||||
if (
|
||||
![
|
||||
HOME_ASSISTANT_CORE_TITLE,
|
||||
HOME_ASSISTANT_SUPERVISOR_TITLE,
|
||||
HOME_ASSISTANT_OS_TITLE,
|
||||
].includes(title)
|
||||
) {
|
||||
if (title === HOME_ASSISTANT_OS_TITLE) {
|
||||
return "home_assistant_os";
|
||||
}
|
||||
|
||||
if (title !== HOME_ASSISTANT_SUPERVISOR_TITLE) {
|
||||
return "addon";
|
||||
}
|
||||
return "generic";
|
||||
|
@ -64,7 +64,8 @@ class MoreInfoUpdate extends LitElement {
|
||||
try {
|
||||
const config = await getSupervisorUpdateConfig(this.hass);
|
||||
|
||||
if (type === "home_assistant") {
|
||||
// for home assistant and OS updates
|
||||
if (this._isHaOrOsUpdate(type)) {
|
||||
this._createBackup = config.core_backup_before_update;
|
||||
return;
|
||||
}
|
||||
@ -83,6 +84,10 @@ class MoreInfoUpdate extends LitElement {
|
||||
this._entitySources = await fetchEntitySourcesWithCache(this.hass);
|
||||
}
|
||||
|
||||
private _isHaOrOsUpdate(type: UpdateType): boolean {
|
||||
return ["home_assistant", "home_assistant_os"].includes(type);
|
||||
}
|
||||
|
||||
private _computeCreateBackupTexts():
|
||||
| { title: string; description?: string }
|
||||
| undefined {
|
||||
@ -97,8 +102,7 @@ class MoreInfoUpdate extends LitElement {
|
||||
? getUpdateType(this.stateObj, this._entitySources)
|
||||
: "generic";
|
||||
|
||||
// Automatic or manual for Home Assistant update
|
||||
if (updateType === "home_assistant") {
|
||||
if (this._isHaOrOsUpdate(updateType)) {
|
||||
const isBackupConfigValid =
|
||||
!!this._backupConfig &&
|
||||
!!this._backupConfig.automatic_backups_configured &&
|
||||
@ -350,11 +354,12 @@ class MoreInfoUpdate extends LitElement {
|
||||
const type = getUpdateType(this.stateObj!, this._entitySources!);
|
||||
if (
|
||||
isComponentLoaded(this.hass, "hassio") &&
|
||||
["home_assistant", "addon"].includes(type)
|
||||
["addon", "home_assistant", "home_assistant_os"].includes(type)
|
||||
) {
|
||||
this._fetchUpdateBackupConfig(type);
|
||||
}
|
||||
if (type === "home_assistant") {
|
||||
|
||||
if (this._isHaOrOsUpdate(type)) {
|
||||
this._fetchBackupConfig();
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user