mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Don't allow history to be picked for backup when db is not in default … (#24402)
This commit is contained in:
parent
1c8284609f
commit
cf288f7cd1
@ -5,6 +5,7 @@ import type { HomeAssistant } from "../types";
|
||||
|
||||
export interface RecorderInfo {
|
||||
backlog: number | null;
|
||||
db_in_default_location: boolean;
|
||||
max_backlog: number;
|
||||
migration_in_progress: boolean;
|
||||
migration_is_live: boolean;
|
||||
|
@ -24,6 +24,7 @@ import { fetchHassioAddonsInfo } from "../../../../../data/hassio/addon";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import "../ha-backup-addons-picker";
|
||||
import type { BackupAddonItem } from "../ha-backup-addons-picker";
|
||||
import { getRecorderInfo } from "../../../../../data/recorder";
|
||||
|
||||
export interface FormData {
|
||||
homeassistant: boolean;
|
||||
@ -75,8 +76,11 @@ class HaBackupConfigData extends LitElement {
|
||||
|
||||
@state() private _showAddons = false;
|
||||
|
||||
@state() private _showDbOption = true;
|
||||
|
||||
protected firstUpdated(changedProperties: PropertyValues): void {
|
||||
super.firstUpdated(changedProperties);
|
||||
this._checkDbOption();
|
||||
if (isComponentLoaded(this.hass, "hassio")) {
|
||||
this._fetchAddons();
|
||||
}
|
||||
@ -98,6 +102,18 @@ class HaBackupConfigData extends LitElement {
|
||||
fireEvent(this, "backup-addons-fetched");
|
||||
}
|
||||
|
||||
private async _checkDbOption() {
|
||||
if (isComponentLoaded(this.hass, "recorder")) {
|
||||
const info = await getRecorderInfo(this.hass.connection);
|
||||
this._showDbOption = info.db_in_default_location;
|
||||
if (!this._showDbOption && this.value?.include_database) {
|
||||
this.value.include_database = false;
|
||||
}
|
||||
} else {
|
||||
this._showDbOption = false;
|
||||
}
|
||||
}
|
||||
|
||||
private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
|
||||
return addons.some((addon) => addon.slug === "local");
|
||||
}
|
||||
@ -179,24 +195,25 @@ class HaBackupConfigData extends LitElement {
|
||||
></ha-switch>
|
||||
</ha-md-list-item>
|
||||
|
||||
<ha-md-list-item>
|
||||
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
|
||||
<span slot="headline">
|
||||
${this.hass.localize("ui.panel.config.backup.data.history")}
|
||||
</span>
|
||||
<span slot="supporting-text">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.data.history_description"
|
||||
)}
|
||||
</span>
|
||||
<ha-switch
|
||||
id="database"
|
||||
slot="end"
|
||||
@change=${this._switchChanged}
|
||||
.checked=${data.database}
|
||||
></ha-switch>
|
||||
</ha-md-list-item>
|
||||
|
||||
${this._showDbOption
|
||||
? html`<ha-md-list-item>
|
||||
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
|
||||
<span slot="headline">
|
||||
${this.hass.localize("ui.panel.config.backup.data.history")}
|
||||
</span>
|
||||
<span slot="supporting-text">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.data.history_description"
|
||||
)}
|
||||
</span>
|
||||
<ha-switch
|
||||
id="database"
|
||||
slot="end"
|
||||
@change=${this._switchChanged}
|
||||
.checked=${data.database}
|
||||
></ha-switch>
|
||||
</ha-md-list-item>`
|
||||
: nothing}
|
||||
${isHassio
|
||||
? html`
|
||||
<ha-md-list-item>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { mdiCalendar, mdiDatabase, mdiPuzzle, mdiUpload } from "@mdi/js";
|
||||
import type { CSSResultGroup } from "lit";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import "../../../../../components/ha-button";
|
||||
import "../../../../../components/ha-card";
|
||||
@ -18,6 +18,8 @@ import {
|
||||
} from "../../../../../data/backup";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../../types";
|
||||
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
|
||||
import { getRecorderInfo } from "../../../../../data/recorder";
|
||||
|
||||
@customElement("ha-backup-overview-settings")
|
||||
class HaBackupBackupsSummary extends LitElement {
|
||||
@ -27,10 +29,26 @@ class HaBackupBackupsSummary extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public agents!: BackupAgent[];
|
||||
|
||||
@state() private _showDbOption = true;
|
||||
|
||||
protected firstUpdated(changedProperties: PropertyValues): void {
|
||||
super.firstUpdated(changedProperties);
|
||||
this._checkDbOption();
|
||||
}
|
||||
|
||||
private _configure() {
|
||||
navigate("/config/backup/settings");
|
||||
}
|
||||
|
||||
private async _checkDbOption() {
|
||||
if (isComponentLoaded(this.hass, "recorder")) {
|
||||
const info = await getRecorderInfo(this.hass.connection);
|
||||
this._showDbOption = info.db_in_default_location;
|
||||
} else {
|
||||
this._showDbOption = false;
|
||||
}
|
||||
}
|
||||
|
||||
private _scheduleDescription(config: BackupConfig): string {
|
||||
const { copies, days } = config.retention;
|
||||
const { recurrence } = config.schedule;
|
||||
@ -214,7 +232,8 @@ class HaBackupBackupsSummary extends LitElement {
|
||||
<ha-md-list-item type="link" href="/config/backup/settings#data">
|
||||
<ha-svg-icon slot="start" .path=${mdiDatabase}></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.config.create_backup.include_database
|
||||
${this._showDbOption &&
|
||||
this.config.create_backup.include_database
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.backup.overview.settings.data_settings_history"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user