@@ -98,26 +151,22 @@ class DialogEditSidebar extends LitElement {
.path=${mdiClose}
@click=${this.closeDialog}
>
- ${dialogTitle}
+ ${dialogTitle}
+ ${!this._migrateToUserData
+ ? html`${this.hass.localize("ui.sidebar.edit_subtitle")}`
+ : nothing}
-
-
-
-
+ ${this._renderContent()}
${this.hass.localize("ui.common.cancel")}
-
+
${this.hass.localize("ui.common.save")}
@@ -131,8 +180,27 @@ class DialogEditSidebar extends LitElement {
this._hidden = [...hidden];
}
- private _save(): void {
- this._saveCallback?.(this._order ?? [], this._hidden ?? []);
+ private async _save() {
+ if (this._migrateToUserData) {
+ const confirmation = await showConfirmationDialog(this, {
+ destructive: true,
+ text: this.hass.localize("ui.sidebar.migrate_to_user_data"),
+ });
+ if (!confirmation) {
+ return;
+ }
+ }
+
+ try {
+ await saveFrontendUserData(this.hass.connection, "sidebar", {
+ panelOrder: this._order!,
+ hiddenPanels: this._hidden!,
+ });
+ } catch (err: any) {
+ this._error = err.message || err;
+ return;
+ }
+
this.closeDialog();
}
@@ -149,6 +217,12 @@ class DialogEditSidebar extends LitElement {
min-height: 100%;
}
}
+
+ ha-fade-in {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ }
`;
}
diff --git a/src/dialogs/sidebar/show-dialog-edit-sidebar.ts b/src/dialogs/sidebar/show-dialog-edit-sidebar.ts
index 4a88bafd6b..dc8ce5b1ea 100644
--- a/src/dialogs/sidebar/show-dialog-edit-sidebar.ts
+++ b/src/dialogs/sidebar/show-dialog-edit-sidebar.ts
@@ -1,18 +1,11 @@
import { fireEvent } from "../../common/dom/fire_event";
-export interface EditSidebarDialogParams {
- saveCallback: (order: string[], hidden: string[]) => void;
-}
-
export const loadEditSidebarDialog = () => import("./dialog-edit-sidebar");
-export const showEditSidebarDialog = (
- element: HTMLElement,
- dialogParams: EditSidebarDialogParams
-): void => {
+export const showEditSidebarDialog = (element: HTMLElement): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-edit-sidebar",
dialogImport: loadEditSidebarDialog,
- dialogParams,
+ dialogParams: {},
});
};
diff --git a/src/layouts/home-assistant-main.ts b/src/layouts/home-assistant-main.ts
index 75d5a54765..16656921c8 100644
--- a/src/layouts/home-assistant-main.ts
+++ b/src/layouts/home-assistant-main.ts
@@ -5,31 +5,23 @@ import type { HASSDomEvent } from "../common/dom/fire_event";
import { fireEvent } from "../common/dom/fire_event";
import { listenMediaQuery } from "../common/dom/media_query";
import { toggleAttribute } from "../common/dom/toggle_attribute";
+import { computeRTLDirection } from "../common/util/compute_rtl";
import "../components/ha-drawer";
import { showNotificationDrawer } from "../dialogs/notifications/show-notification-drawer";
import type { HomeAssistant, Route } from "../types";
import "./partial-panel-resolver";
-import { computeRTLDirection } from "../common/util/compute_rtl";
-import { storage } from "../common/decorators/storage";
declare global {
// for fire event
interface HASSDomEvents {
"hass-toggle-menu": undefined | { open?: boolean };
- "hass-edit-sidebar": EditSideBarEvent;
"hass-show-notifications": undefined;
}
interface HTMLElementEventMap {
- "hass-edit-sidebar": HASSDomEvent;
"hass-toggle-menu": HASSDomEvent;
}
}
-interface EditSideBarEvent {
- order: string[];
- hidden: string[];
-}
-
@customElement("home-assistant-main")
export class HomeAssistantMain extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -44,22 +36,6 @@ export class HomeAssistantMain extends LitElement {
@state() private _drawerOpen = false;
- @state()
- @storage({
- key: "sidebarPanelOrder",
- state: true,
- subscribe: true,
- })
- private _panelOrder: string[] = [];
-
- @state()
- @storage({
- key: "sidebarHiddenPanels",
- state: true,
- subscribe: true,
- })
- private _hiddenPanels: string[] = [];
-
constructor() {
super();
listenMediaQuery("(max-width: 870px)", (matches) => {
@@ -81,8 +57,6 @@ export class HomeAssistantMain extends LitElement {
.hass=${this.hass}
.narrow=${sidebarNarrow}
.route=${this.route}
- .panelOrder=${this._panelOrder}
- .hiddenPanels=${this._hiddenPanels}
.alwaysExpand=${sidebarNarrow || this.hass.dockedSidebar === "docked"}
>
) => {
- this._panelOrder = ev.detail.order;
- this._hiddenPanels = ev.detail.hidden;
- }
- );
-
this.addEventListener("hass-toggle-menu", (ev) => {
if (this._sidebarEditMode) {
return;
diff --git a/src/panels/profile/ha-profile-section-general.ts b/src/panels/profile/ha-profile-section-general.ts
index a14043f625..46cbc1c268 100644
--- a/src/panels/profile/ha-profile-section-general.ts
+++ b/src/panels/profile/ha-profile-section-general.ts
@@ -150,6 +150,23 @@ class HaProfileSectionGeneral extends LitElement {
.narrow=${this.narrow}
.hass=${this.hass}
>
+
+
+ ${this.hass.localize(
+ "ui.panel.profile.customize_sidebar.header"
+ )}
+
+
+ ${this.hass.localize(
+ "ui.panel.profile.customize_sidebar.description"
+ )}
+
+
+ ${this.hass.localize(
+ "ui.panel.profile.customize_sidebar.button"
+ )}
+
+
${this.hass.user!.is_admin
? html`
-
-
- ${this.hass.localize(
- "ui.panel.profile.customize_sidebar.header"
- )}
-
-
- ${this.hass.localize(
- "ui.panel.profile.customize_sidebar.description"
- )}
-
-
- ${this.hass.localize(
- "ui.panel.profile.customize_sidebar.button"
- )}
-
-
${this.hass.dockedSidebar !== "auto" || !this.narrow
? html`
{
- fireEvent(this, "hass-edit-sidebar", {
- order,
- hidden,
- });
- };
-
private _handleLogOut() {
showConfirmationDialog(this, {
title: this.hass.localize("ui.panel.profile.logout_title"),
diff --git a/src/translations/en.json b/src/translations/en.json
index 725074c0ca..ff6bd50f71 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -2019,7 +2019,9 @@
"sidebar": {
"external_app_configuration": "App settings",
"sidebar_toggle": "Sidebar toggle",
- "edit_sidebar": "Edit sidebar"
+ "edit_sidebar": "Edit sidebar",
+ "edit_subtitle": "Synced on all devices",
+ "migrate_to_user_data": "This will change the sidebar on all the devices you are logged into. To create a sidebar per device, you should use a different user for that device."
},
"panel": {
"my": {