From 93fe1ff2c33081aed96a188fc5033dd53410d776 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 2 Jan 2025 14:10:33 +0100 Subject: [PATCH 1/2] move local location backup setting --- .../backup/ha-config-backup-overview.ts | 53 +++++-------------- .../backup/ha-config-backup-settings.ts | 33 ++++++++++++ src/translations/en.json | 2 +- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/panels/config/backup/ha-config-backup-overview.ts b/src/panels/config/backup/ha-config-backup-overview.ts index bc86bc8cc229..be4d5c1aa7fa 100644 --- a/src/panels/config/backup/ha-config-backup-overview.ts +++ b/src/panels/config/backup/ha-config-backup-overview.ts @@ -1,8 +1,7 @@ -import { mdiDotsVertical, mdiHarddisk, mdiPlus, mdiUpload } from "@mdi/js"; +import { mdiDotsVertical, mdiPlus, mdiUpload } from "@mdi/js"; import type { CSSResultGroup, TemplateResult } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property } from "lit/decorators"; -import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { fireEvent } from "../../../common/dom/fire_event"; import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event"; import "../../../components/ha-button"; @@ -33,7 +32,6 @@ import "./components/overview/ha-backup-overview-settings"; import "./components/overview/ha-backup-overview-summary"; import { showBackupOnboardingDialog } from "./dialogs/show-dialog-backup_onboarding"; import { showGenerateBackupDialog } from "./dialogs/show-dialog-generate-backup"; -import { showLocalBackupLocationDialog } from "./dialogs/show-dialog-local-backup-location"; import { showNewBackupDialog } from "./dialogs/show-dialog-new-backup"; import { showUploadBackupDialog } from "./dialogs/show-dialog-upload-backup"; @@ -63,14 +61,6 @@ class HaConfigBackupOverview extends LitElement { await showUploadBackupDialog(this, {}); } - private async _changeLocalLocation(ev) { - if (!shouldHandleRequestSelectedEvent(ev)) { - return; - } - - showLocalBackupLocationDialog(this, {}); - } - private _handleOnboardingButtonClick(ev) { ev.stopPropagation(); this._setupAutomaticBackup(); @@ -134,8 +124,6 @@ class HaConfigBackupOverview extends LitElement { const backupInProgress = "state" in this.manager && this.manager.state === "in_progress"; - const isHassio = isComponentLoaded(this.hass, "hassio"); - return html` -
- - - ${isHassio - ? html` - - Change local location - ` - : nothing} - - - Upload backup - - -
+ + + + + Upload backup + +
${backupInProgress ? html` diff --git a/src/panels/config/backup/ha-config-backup-settings.ts b/src/panels/config/backup/ha-config-backup-settings.ts index e4b7326adaa7..e617d7a5528f 100644 --- a/src/panels/config/backup/ha-config-backup-settings.ts +++ b/src/panels/config/backup/ha-config-backup-settings.ts @@ -1,6 +1,7 @@ import type { PropertyValues } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; +import { mdiDotsVertical, mdiHarddisk } from "@mdi/js"; import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { fireEvent } from "../../../common/dom/fire_event"; import { debounce } from "../../../common/util/debounce"; @@ -20,6 +21,8 @@ import type { BackupConfigData } from "./components/config/ha-backup-config-data import "./components/config/ha-backup-config-encryption-key"; import "./components/config/ha-backup-config-schedule"; import type { BackupConfigSchedule } from "./components/config/ha-backup-config-schedule"; +import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event"; +import { showLocalBackupLocationDialog } from "./dialogs/show-dialog-local-backup-location"; @customElement("ha-config-backup-settings") class HaConfigBackupSettings extends LitElement { @@ -93,6 +96,28 @@ class HaConfigBackupSettings extends LitElement { .narrow=${this.narrow} .header=${"Automatic backups"} > + ${isComponentLoaded(this.hass, "hassio") + ? html` + + + + + Change default action location + + + ` + : nothing} +
Automatic backups
@@ -157,6 +182,14 @@ class HaConfigBackupSettings extends LitElement { `; } + private async _changeLocalLocation(ev) { + if (!shouldHandleRequestSelectedEvent(ev)) { + return; + } + + showLocalBackupLocationDialog(this, {}); + } + private _scheduleConfigChanged(ev) { const value = ev.detail.value as BackupConfigSchedule; this._config = { diff --git a/src/translations/en.json b/src/translations/en.json index 876ceaceec24..ef2321facdae 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2216,7 +2216,7 @@ }, "dialogs": { "local_backup_location": { - "title": "Change local backup location", + "title": "Change default local backup location", "description": "Change the default location where local backups are stored on your Home Assistant instance.", "note": "This location will be used when you create a backup using the supervisor actions in an automation for example.", "options": { From 5ed372e39e25a166142b0e688260b353abcb0bb9 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 2 Jan 2025 14:11:44 +0100 Subject: [PATCH 2/2] Update ha-config-backup-settings.ts --- src/panels/config/backup/ha-config-backup-settings.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/panels/config/backup/ha-config-backup-settings.ts b/src/panels/config/backup/ha-config-backup-settings.ts index e617d7a5528f..9375c7789ce1 100644 --- a/src/panels/config/backup/ha-config-backup-settings.ts +++ b/src/panels/config/backup/ha-config-backup-settings.ts @@ -1,15 +1,20 @@ +import { mdiDotsVertical, mdiHarddisk } from "@mdi/js"; import type { PropertyValues } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; -import { mdiDotsVertical, mdiHarddisk } from "@mdi/js"; import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { fireEvent } from "../../../common/dom/fire_event"; +import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event"; import { debounce } from "../../../common/util/debounce"; import { nextRender } from "../../../common/util/render-status"; import "../../../components/ha-button"; +import "../../../components/ha-button-menu"; import "../../../components/ha-card"; +import "../../../components/ha-icon-button"; import "../../../components/ha-icon-next"; +import "../../../components/ha-list-item"; import "../../../components/ha-password-field"; +import "../../../components/ha-svg-icon"; import type { BackupConfig } from "../../../data/backup"; import { updateBackupConfig } from "../../../data/backup"; import type { CloudStatus } from "../../../data/cloud"; @@ -21,7 +26,6 @@ import type { BackupConfigData } from "./components/config/ha-backup-config-data import "./components/config/ha-backup-config-encryption-key"; import "./components/config/ha-backup-config-schedule"; import type { BackupConfigSchedule } from "./components/config/ha-backup-config-schedule"; -import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event"; import { showLocalBackupLocationDialog } from "./dialogs/show-dialog-local-backup-location"; @customElement("ha-config-backup-settings")