Rename backup strategy (#23329)

* Rename backup strategy

* Feedback
This commit is contained in:
Paul Bottein 2024-12-18 18:02:42 +01:00 committed by GitHub
parent 2d902a0688
commit 40a4255045
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 44 additions and 44 deletions

View File

@ -15,8 +15,8 @@ export const enum BackupScheduleState {
} }
export interface BackupConfig { export interface BackupConfig {
last_attempted_strategy_backup: string | null; last_attempted_automatic_backup: string | null;
last_completed_strategy_backup: string | null; last_completed_automatic_backup: string | null;
create_backup: { create_backup: {
agent_ids: string[]; agent_ids: string[];
include_addons: string[] | null; include_addons: string[] | null;
@ -64,7 +64,7 @@ export interface BackupContent {
size: number; size: number;
agent_ids?: string[]; agent_ids?: string[];
failed_agent_ids?: string[]; failed_agent_ids?: string[];
with_strategy_settings: boolean; with_automatic_settings: boolean;
} }
export interface BackupData { export interface BackupData {
@ -164,11 +164,11 @@ export const generateBackup = (
...params, ...params,
}); });
export const generateBackupWithStrategySettings = ( export const generateBackupWithAutomaticSettings = (
hass: HomeAssistant hass: HomeAssistant
): Promise<void> => ): Promise<void> =>
hass.callWS({ hass.callWS({
type: "backup/generate_with_strategy_settings", type: "backup/generate_with_automatic_settings",
}); });
export const restoreBackup = ( export const restoreBackup = (

View File

@ -24,7 +24,7 @@ export class HaBackupSummaryProgress extends LitElement {
// eslint-disable-next-line arrow-body-style // eslint-disable-next-line arrow-body-style
.filter((backup) => { .filter((backup) => {
// TODO : only show backups with default flag // TODO : only show backups with default flag
return backup.with_strategy_settings; return backup.with_automatic_settings;
}) })
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());

View File

@ -70,8 +70,8 @@ const RECOMMENDED_CONFIG: BackupConfig = {
schedule: { schedule: {
state: BackupScheduleState.DAILY, state: BackupScheduleState.DAILY,
}, },
last_attempted_strategy_backup: null, last_attempted_automatic_backup: null,
last_completed_strategy_backup: null, last_completed_automatic_backup: null,
}; };
@customElement("ha-dialog-backup-onboarding") @customElement("ha-dialog-backup-onboarding")
@ -237,7 +237,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
case "key": case "key":
return "Encryption key"; return "Encryption key";
case "setup": case "setup":
return "Set up your backup strategy"; return "Set up your automatic backups";
case "schedule": case "schedule":
return "Automatic backups"; return "Automatic backups";
case "data": case "data":
@ -279,7 +279,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
src="/static/images/voice-assistant/hi.png" src="/static/images/voice-assistant/hi.png"
alt="Casita Home Assistant logo" alt="Casita Home Assistant logo"
/> />
<h1>Set up your backup strategy</h1> <h1>Set up your automatic backups</h1>
<p class="secondary"> <p class="secondary">
Backups are essential to a reliable smart home. They protect your Backups are essential to a reliable smart home. They protect your
setup against failures and allows you to quickly have a working setup against failures and allows you to quickly have a working
@ -326,7 +326,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
<ha-md-list-item type="button" @click=${this._done}> <ha-md-list-item type="button" @click=${this._done}>
<span slot="headline">Recommended settings</span> <span slot="headline">Recommended settings</span>
<span slot="supporting-text"> <span slot="supporting-text">
Set the proven backup strategy of daily backup. Set the proven settings of daily backup.
</span> </span>
<ha-icon-next slot="end"> </ha-icon-next> <ha-icon-next slot="end"> </ha-icon-next>
</ha-md-list-item> </ha-md-list-item>
@ -368,7 +368,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
return html` return html`
<p> <p>
Home Assistant will upload to these locations when this backup Home Assistant will upload to these locations when this backup
strategy is used. You can use all locations for custom backups. settings are used. You can use all locations for custom backups.
</p> </p>
<ha-backup-config-agents <ha-backup-config-agents
.hass=${this.hass} .hass=${this.hass}

View File

@ -76,7 +76,7 @@ class DialogNewBackup extends LitElement implements HassDialog {
.disabled=${!this._params.config.create_backup.password} .disabled=${!this._params.config.create_backup.password}
> >
<ha-svg-icon slot="start" .path=${mdiCog}></ha-svg-icon> <ha-svg-icon slot="start" .path=${mdiCog}></ha-svg-icon>
<span slot="headline">Use backup strategy</span> <span slot="headline">Use automatic backups</span>
<span slot="supporting-text"> <span slot="supporting-text">
Create a backup with the data and locations you have configured. Create a backup with the data and locations you have configured.
</span> </span>
@ -97,12 +97,12 @@ class DialogNewBackup extends LitElement implements HassDialog {
} }
private async _custom() { private async _custom() {
this._params!.submit?.("custom"); this._params!.submit?.("manual");
this.closeDialog(); this.closeDialog();
} }
private async _default() { private async _default() {
this._params!.submit?.("strategy"); this._params!.submit?.("automatic");
this.closeDialog(); this.closeDialog();
} }

View File

@ -1,7 +1,7 @@
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import type { BackupConfig } from "../../../../data/backup"; import type { BackupConfig } from "../../../../data/backup";
export type NewBackupType = "strategy" | "custom"; export type NewBackupType = "automatic" | "manual";
export interface NewBackupDialogParams { export interface NewBackupDialogParams {
config: BackupConfig; config: BackupConfig;

View File

@ -43,7 +43,7 @@ import {
fetchBackupConfig, fetchBackupConfig,
fetchBackupInfo, fetchBackupInfo,
generateBackup, generateBackup,
generateBackupWithStrategySettings, generateBackupWithAutomaticSettings,
getBackupDownloadUrl, getBackupDownloadUrl,
getPreferredAgentForDownload, getPreferredAgentForDownload,
isLocalAgent, isLocalAgent,
@ -80,9 +80,9 @@ interface BackupRow extends BackupContent {
formatted_type: string; formatted_type: string;
} }
type BackupType = "strategy" | "custom"; type BackupType = "automatic" | "manual";
const TYPE_ORDER: Array<BackupType> = ["strategy", "custom"]; const TYPE_ORDER: Array<BackupType> = ["automatic", "manual"];
@customElement("ha-config-backup-dashboard") @customElement("ha-config-backup-dashboard")
class HaConfigBackupDashboard extends SubscribeMixin(LitElement) { class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
@ -251,7 +251,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
backups.map((backup) => ({ backups.map((backup) => ({
...backup, ...backup,
formatted_type: this._formatBackupType( formatted_type: this._formatBackupType(
backup.with_strategy_settings ? "strategy" : "custom" backup.with_automatic_settings ? "automatic" : "manual"
), ),
})) }))
); );
@ -302,7 +302,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
> >
<ha-button <ha-button
slot="action" slot="action"
@click=${this._configureBackupStrategy} @click=${this._configureAutomaticBackups}
> >
Configure Configure
</ha-button> </ha-button>
@ -317,7 +317,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
> >
<ha-button <ha-button
slot="action" slot="action"
@click=${this._configureBackupStrategy} @click=${this._configureAutomaticBackups}
> >
Configure Configure
</ha-button> </ha-button>
@ -326,16 +326,16 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
: this._needsOnboarding : this._needsOnboarding
? html` ? html`
<ha-backup-summary-card <ha-backup-summary-card
heading="Configure backup strategy" heading="Configure automatic backups"
description="Have a one-click backup automation with selected data and locations." description="Have a one-click backup automation with selected data and locations."
has-action has-action
status="info" status="info"
> >
<ha-button <ha-button
slot="action" slot="action"
@click=${this._setupBackupStrategy} @click=${this._setupAutomaticBackups}
> >
Set up backup strategy Set up automatic backups
</ha-button> </ha-button>
</ha-backup-summary-card> </ha-backup-summary-card>
` `
@ -347,7 +347,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
> >
<ha-button <ha-button
slot="action" slot="action"
@click=${this._configureBackupStrategy} @click=${this._configureAutomaticBackups}
> >
Configure Configure
</ha-button> </ha-button>
@ -522,7 +522,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
return; return;
} }
if (type === "custom") { if (type === "manual") {
const params = await showGenerateBackupDialog(this, {}); const params = await showGenerateBackupDialog(this, {});
if (!params) { if (!params) {
@ -539,8 +539,8 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
await this._fetchBackupInfo(); await this._fetchBackupInfo();
return; return;
} }
if (type === "strategy") { if (type === "automatic") {
await generateBackupWithStrategySettings(this.hass); await generateBackupWithAutomaticSettings(this.hass);
await this._fetchBackupInfo(); await this._fetchBackupInfo();
} }
} }
@ -602,11 +602,11 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
this._dataTable.clearSelection(); this._dataTable.clearSelection();
} }
private _configureBackupStrategy() { private _configureAutomaticBackups() {
navigate("/config/backup/strategy"); navigate("/config/backup/settings");
} }
private async _setupBackupStrategy() { private async _setupAutomaticBackups() {
const success = await showBackupOnboardingDialog(this, { const success = await showBackupOnboardingDialog(this, {
cloudStatus: this.cloudStatus, cloudStatus: this.cloudStatus,
}); });
@ -615,7 +615,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
} }
this._fetchBackupConfig(); this._fetchBackupConfig();
await generateBackupWithStrategySettings(this.hass); await generateBackupWithAutomaticSettings(this.hass);
await this._fetchBackupInfo(); await this._fetchBackupInfo();
} }

View File

@ -39,12 +39,12 @@ const INITIAL_BACKUP_CONFIG: BackupConfig = {
schedule: { schedule: {
state: BackupScheduleState.DAILY, state: BackupScheduleState.DAILY,
}, },
last_attempted_strategy_backup: null, last_attempted_automatic_backup: null,
last_completed_strategy_backup: null, last_completed_automatic_backup: null,
}; };
@customElement("ha-config-backup-strategy") @customElement("ha-config-backup-settings")
class HaConfigBackupStrategy extends LitElement { class HaConfigBackupSettings extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public cloudStatus!: CloudStatus; @property({ attribute: false }) public cloudStatus!: CloudStatus;
@ -75,15 +75,15 @@ class HaConfigBackupStrategy extends LitElement {
back-path="/config/backup" back-path="/config/backup"
.hass=${this.hass} .hass=${this.hass}
.narrow=${this.narrow} .narrow=${this.narrow}
.header=${"Backup strategy"} .header=${"Automatic backups"}
> >
<div class="content"> <div class="content">
<ha-card> <ha-card>
<div class="card-header">Automatic backups</div> <div class="card-header">Automatic backups</div>
<div class="card-content"> <div class="card-content">
<p> <p>
Let Home Assistant take care of your backup strategy by creating Let Home Assistant take care of your backups by creating a
a scheduled backup that also removes older copies. scheduled backup that also removes older copies.
</p> </p>
<ha-backup-config-schedule <ha-backup-config-schedule
.hass=${this.hass} .hass=${this.hass}
@ -249,6 +249,6 @@ class HaConfigBackupStrategy extends LitElement {
declare global { declare global {
interface HTMLElementTagNameMap { interface HTMLElementTagNameMap {
"ha-config-backup-strategy": HaConfigBackupStrategy; "ha-config-backup-settings": HaConfigBackupSettings;
} }
} }

View File

@ -30,9 +30,9 @@ class HaConfigBackup extends HassRouterPage {
tag: "ha-config-backup-locations", tag: "ha-config-backup-locations",
load: () => import("./ha-config-backup-locations"), load: () => import("./ha-config-backup-locations"),
}, },
strategy: { settings: {
tag: "ha-config-backup-strategy", tag: "ha-config-backup-settings",
load: () => import("./ha-config-backup-strategy"), load: () => import("./ha-config-backup-settings"),
}, },
}, },
}; };