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