Skip to content

Commit

Permalink
Rename backup strategy (#23329)
Browse files Browse the repository at this point in the history
* Rename backup strategy

* Feedback
  • Loading branch information
piitaya authored Dec 18, 2024
1 parent 2d902a0 commit 40a4255
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions src/data/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const enum BackupScheduleState {
}

export interface BackupConfig {
last_attempted_strategy_backup: string | null;
last_completed_strategy_backup: string | null;
last_attempted_automatic_backup: string | null;
last_completed_automatic_backup: string | null;
create_backup: {
agent_ids: string[];
include_addons: string[] | null;
Expand Down Expand Up @@ -64,7 +64,7 @@ export interface BackupContent {
size: number;
agent_ids?: string[];
failed_agent_ids?: string[];
with_strategy_settings: boolean;
with_automatic_settings: boolean;
}

export interface BackupData {
Expand Down Expand Up @@ -164,11 +164,11 @@ export const generateBackup = (
...params,
});

export const generateBackupWithStrategySettings = (
export const generateBackupWithAutomaticSettings = (
hass: HomeAssistant
): Promise<void> =>
hass.callWS({
type: "backup/generate_with_strategy_settings",
type: "backup/generate_with_automatic_settings",
});

export const restoreBackup = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class HaBackupSummaryProgress extends LitElement {
// eslint-disable-next-line arrow-body-style
.filter((backup) => {
// 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());

Expand Down
12 changes: 6 additions & 6 deletions src/panels/config/backup/dialogs/dialog-backup-onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const RECOMMENDED_CONFIG: BackupConfig = {
schedule: {
state: BackupScheduleState.DAILY,
},
last_attempted_strategy_backup: null,
last_completed_strategy_backup: null,
last_attempted_automatic_backup: null,
last_completed_automatic_backup: null,
};

@customElement("ha-dialog-backup-onboarding")
Expand Down Expand Up @@ -237,7 +237,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
case "key":
return "Encryption key";
case "setup":
return "Set up your backup strategy";
return "Set up your automatic backups";
case "schedule":
return "Automatic backups";
case "data":
Expand Down Expand Up @@ -279,7 +279,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
src="/static/images/voice-assistant/hi.png"
alt="Casita Home Assistant logo"
/>
<h1>Set up your backup strategy</h1>
<h1>Set up your automatic backups</h1>
<p class="secondary">
Backups are essential to a reliable smart home. They protect your
setup against failures and allows you to quickly have a working
Expand Down Expand Up @@ -326,7 +326,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
<ha-md-list-item type="button" @click=${this._done}>
<span slot="headline">Recommended settings</span>
<span slot="supporting-text">
Set the proven backup strategy of daily backup.
Set the proven settings of daily backup.
</span>
<ha-icon-next slot="end"> </ha-icon-next>
</ha-md-list-item>
Expand Down Expand Up @@ -368,7 +368,7 @@ class DialogBackupOnboarding extends LitElement implements HassDialog {
return html`
<p>
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>
<ha-backup-config-agents
.hass=${this.hass}
Expand Down
6 changes: 3 additions & 3 deletions src/panels/config/backup/dialogs/dialog-new-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DialogNewBackup extends LitElement implements HassDialog {
.disabled=${!this._params.config.create_backup.password}
>
<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">
Create a backup with the data and locations you have configured.
</span>
Expand All @@ -97,12 +97,12 @@ class DialogNewBackup extends LitElement implements HassDialog {
}

private async _custom() {
this._params!.submit?.("custom");
this._params!.submit?.("manual");
this.closeDialog();
}

private async _default() {
this._params!.submit?.("strategy");
this._params!.submit?.("automatic");
this.closeDialog();
}

Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/backup/dialogs/show-dialog-new-backup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireEvent } from "../../../../common/dom/fire_event";
import type { BackupConfig } from "../../../../data/backup";

export type NewBackupType = "strategy" | "custom";
export type NewBackupType = "automatic" | "manual";

export interface NewBackupDialogParams {
config: BackupConfig;
Expand Down
34 changes: 17 additions & 17 deletions src/panels/config/backup/ha-config-backup-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
fetchBackupConfig,
fetchBackupInfo,
generateBackup,
generateBackupWithStrategySettings,
generateBackupWithAutomaticSettings,
getBackupDownloadUrl,
getPreferredAgentForDownload,
isLocalAgent,
Expand Down Expand Up @@ -80,9 +80,9 @@ interface BackupRow extends BackupContent {
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")
class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
Expand Down Expand Up @@ -251,7 +251,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
backups.map((backup) => ({
...backup,
formatted_type: this._formatBackupType(
backup.with_strategy_settings ? "strategy" : "custom"
backup.with_automatic_settings ? "automatic" : "manual"
),
}))
);
Expand Down Expand Up @@ -302,7 +302,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
>
<ha-button
slot="action"
@click=${this._configureBackupStrategy}
@click=${this._configureAutomaticBackups}
>
Configure
</ha-button>
Expand All @@ -317,7 +317,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
>
<ha-button
slot="action"
@click=${this._configureBackupStrategy}
@click=${this._configureAutomaticBackups}
>
Configure
</ha-button>
Expand All @@ -326,16 +326,16 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
: this._needsOnboarding
? html`
<ha-backup-summary-card
heading="Configure backup strategy"
heading="Configure automatic backups"
description="Have a one-click backup automation with selected data and locations."
has-action
status="info"
>
<ha-button
slot="action"
@click=${this._setupBackupStrategy}
@click=${this._setupAutomaticBackups}
>
Set up backup strategy
Set up automatic backups
</ha-button>
</ha-backup-summary-card>
`
Expand All @@ -347,7 +347,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
>
<ha-button
slot="action"
@click=${this._configureBackupStrategy}
@click=${this._configureAutomaticBackups}
>
Configure
</ha-button>
Expand Down Expand Up @@ -522,7 +522,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
return;
}

if (type === "custom") {
if (type === "manual") {
const params = await showGenerateBackupDialog(this, {});

if (!params) {
Expand All @@ -539,8 +539,8 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
await this._fetchBackupInfo();
return;
}
if (type === "strategy") {
await generateBackupWithStrategySettings(this.hass);
if (type === "automatic") {
await generateBackupWithAutomaticSettings(this.hass);
await this._fetchBackupInfo();
}
}
Expand Down Expand Up @@ -602,11 +602,11 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
this._dataTable.clearSelection();
}

private _configureBackupStrategy() {
navigate("/config/backup/strategy");
private _configureAutomaticBackups() {
navigate("/config/backup/settings");
}

private async _setupBackupStrategy() {
private async _setupAutomaticBackups() {
const success = await showBackupOnboardingDialog(this, {
cloudStatus: this.cloudStatus,
});
Expand All @@ -615,7 +615,7 @@ class HaConfigBackupDashboard extends SubscribeMixin(LitElement) {
}

this._fetchBackupConfig();
await generateBackupWithStrategySettings(this.hass);
await generateBackupWithAutomaticSettings(this.hass);
await this._fetchBackupInfo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const INITIAL_BACKUP_CONFIG: BackupConfig = {
schedule: {
state: BackupScheduleState.DAILY,
},
last_attempted_strategy_backup: null,
last_completed_strategy_backup: null,
last_attempted_automatic_backup: null,
last_completed_automatic_backup: null,
};

@customElement("ha-config-backup-strategy")
class HaConfigBackupStrategy extends LitElement {
@customElement("ha-config-backup-settings")
class HaConfigBackupSettings extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ attribute: false }) public cloudStatus!: CloudStatus;
Expand Down Expand Up @@ -75,15 +75,15 @@ class HaConfigBackupStrategy extends LitElement {
back-path="/config/backup"
.hass=${this.hass}
.narrow=${this.narrow}
.header=${"Backup strategy"}
.header=${"Automatic backups"}
>
<div class="content">
<ha-card>
<div class="card-header">Automatic backups</div>
<div class="card-content">
<p>
Let Home Assistant take care of your backup strategy by creating
a scheduled backup that also removes older copies.
Let Home Assistant take care of your backups by creating a
scheduled backup that also removes older copies.
</p>
<ha-backup-config-schedule
.hass=${this.hass}
Expand Down Expand Up @@ -249,6 +249,6 @@ class HaConfigBackupStrategy extends LitElement {

declare global {
interface HTMLElementTagNameMap {
"ha-config-backup-strategy": HaConfigBackupStrategy;
"ha-config-backup-settings": HaConfigBackupSettings;
}
}
6 changes: 3 additions & 3 deletions src/panels/config/backup/ha-config-backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class HaConfigBackup extends HassRouterPage {
tag: "ha-config-backup-locations",
load: () => import("./ha-config-backup-locations"),
},
strategy: {
tag: "ha-config-backup-strategy",
load: () => import("./ha-config-backup-strategy"),
settings: {
tag: "ha-config-backup-settings",
load: () => import("./ha-config-backup-settings"),
},
},
};
Expand Down

0 comments on commit 40a4255

Please sign in to comment.