Skip to content

Commit

Permalink
Revert "Add overview settings link to backup settings sections"
Browse files Browse the repository at this point in the history
This reverts commit fad435e.
  • Loading branch information
piitaya committed Dec 20, 2024
1 parent fad435e commit 33df805
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ export type BackupConfigData = {
include_addons?: string[];
};

declare global {
interface HASSDomEvents {
"backup-addons-fetched": void;
}
}

@customElement("ha-backup-config-data")
class HaBackupConfigData extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
Expand Down Expand Up @@ -95,7 +89,6 @@ class HaBackupConfigData extends LitElement {
private async _fetchAddons() {
const { addons } = await fetchHassioAddonsInfo(this.hass);
this._addons = addons;
fireEvent(this, "backup-addons-fetched");
}

private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { customElement, property } from "lit/decorators";
import { navigate } from "../../../../../common/navigate";
import "../../../../../components/ha-button";
import "../../../../../components/ha-card";
import "../../../../../components/ha-icon-next";
import "../../../../../components/ha-md-list";
import "../../../../../components/ha-md-list-item";
import "../../../../../components/ha-svg-icon";
Expand Down Expand Up @@ -104,20 +103,16 @@ class HaBackupBackupsSummary extends LitElement {
<div class="card-header">Automatic backups</div>
<div class="card-content">
<ha-md-list>
<ha-md-list-item
type="link"
href="/config/backup/settings#schedule"
>
<ha-md-list-item>
<ha-svg-icon slot="start" .path=${mdiCalendar}></ha-svg-icon>
<div slot="headline">
${this._scheduleDescription(this.config)}
</div>
<div slot="supporting-text">
Schedule and number of backups to keep
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-md-list-item>
<ha-md-list-item type="link" href="/config/backup/settings#data">
<ha-md-list-item>
<ha-svg-icon slot="start" .path=${mdiDatabase}></ha-svg-icon>
<div slot="headline">
${this.config.create_backup.include_database
Expand All @@ -127,34 +122,27 @@ class HaBackupBackupsSummary extends LitElement {
<div slot="supporting-text">
Home Assistant data that is included
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-md-list-item>
${isHassio
? html`
<ha-md-list-item
type="link"
href="/config/backup/settings#data"
>
<ha-md-list-item>
<ha-svg-icon slot="start" .path=${mdiPuzzle}></ha-svg-icon>
<div slot="headline">
${this._addonsDescription(this.config)}
</div>
<div slot="supporting-text">Add-ons that are included</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-md-list-item>
<ha-md-list-item>
<ha-svg-icon slot="start" .path=${mdiUpload}></ha-svg-icon>
<div slot="headline">
${this._agentsDescription(this.config)}
</div>
<div slot="supporting-text">
Locations where backup is uploaded to
</div>
</ha-md-list-item>
`
: nothing}
<ha-md-list-item
type="link"
href="/config/backup/settings#locations"
>
<ha-svg-icon slot="start" .path=${mdiUpload}></ha-svg-icon>
<div slot="headline">${this._agentsDescription(this.config)}</div>
<div slot="supporting-text">
Locations where backup is uploaded to
</div>
<ha-icon-next slot="end"></ha-icon-next>
</ha-md-list-item>
</ha-md-list>
</div>
<div class="card-actions">
Expand Down
34 changes: 3 additions & 31 deletions src/panels/config/backup/ha-config-backup-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import { debounce } from "../../../common/util/debounce";
import { nextRender } from "../../../common/util/render-status";
import "../../../components/ha-button";
import "../../../components/ha-card";
import "../../../components/ha-icon-next";
Expand Down Expand Up @@ -39,30 +38,6 @@ class HaConfigBackupSettings extends LitElement {
}
}

protected firstUpdated(_changedProperties: PropertyValues): void {
super.firstUpdated(_changedProperties);
this._scrollTo();
}

private async _scrollTo() {
const hash = window.location.hash.substring(1);
if (hash === "locations") {
// Wait for the addons to be loaded before scrolling because the height can change
this.addEventListener("backup-addons-fetched", async () => {
await nextRender();
this._scrolltoHash(hash);
});
return;
}
this._scrolltoHash(hash);
}

private _scrolltoHash(hash: string) {
const element = this.shadowRoot!.getElementById(hash);
element?.scrollIntoView();
history.replaceState(null, "", window.location.pathname);
}

protected render() {
if (!this._config) {
return nothing;
Expand All @@ -76,7 +51,7 @@ class HaConfigBackupSettings extends LitElement {
.header=${"Automatic backups"}
>
<div class="content">
<ha-card id="schedule">
<ha-card>
<div class="card-header">Automatic backups</div>
<div class="card-content">
<p>
Expand All @@ -90,7 +65,7 @@ class HaConfigBackupSettings extends LitElement {
></ha-backup-config-schedule>
</div>
</ha-card>
<ha-card id="data">
<ha-card>
<div class="card-header">Backup data</div>
<div class="card-content">
<ha-backup-config-data
Expand All @@ -103,7 +78,7 @@ class HaConfigBackupSettings extends LitElement {
</div>
</ha-card>
<ha-card class="agents" id="locations">
<ha-card class="agents">
<div class="card-header">Locations</div>
<div class="card-content">
<p>
Expand Down Expand Up @@ -224,9 +199,6 @@ class HaConfigBackupSettings extends LitElement {
}

static styles = css`
ha-card {
scroll-margin-top: 16px;
}
.content {
padding: 28px 20px 0;
max-width: 690px;
Expand Down

0 comments on commit 33df805

Please sign in to comment.