Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/config/filter_navigation_pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const filterNavigationPages = (
if (page.path === "#external-app-configuration") {
return hass.auth.external?.config.hasSettingsScreen;
}
if (page.adminOnly && !hass.user?.is_admin) {
return false;
}
// Only show Bluetooth page if there are Bluetooth config entries
if (page.component === "bluetooth") {
return options.hasBluetoothConfigEntries ?? false;
Expand Down
4 changes: 0 additions & 4 deletions src/data/quick_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ const generateNavigationConfigSectionCommands = (
hass: HomeAssistant,
filterOptions: NavigationFilterOptions = {}
): BaseNavigationCommand[] => {
if (!hass.user?.is_admin) {
return [];
}

const items: NavigationInfo[] = [];
const allPages = Object.values(configSections).flat();
const visiblePages = filterNavigationPages(hass, allPages, filterOptions);
Expand Down
8 changes: 6 additions & 2 deletions src/dialogs/quick-bar/ha-quick-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ import type { HomeAssistant } from "../../types";
import { isMac } from "../../util/is_mac";
import { showConfirmationDialog } from "../generic/show-dialog-box";
import { showShortcutsDialog } from "../shortcuts/show-shortcuts-dialog";
import type { QuickBarParams, QuickBarSection } from "./show-dialog-quick-bar";
import {
effectiveQuickBarMode,
type QuickBarParams,
type QuickBarSection,
} from "./show-dialog-quick-bar";

const SEPARATOR = "________";

Expand Down Expand Up @@ -100,7 +104,7 @@ export class QuickBar extends LitElement {
this._translationsLoaded = true;
}
this._initialize();
this._selectedSection = params.mode;
this._selectedSection = effectiveQuickBarMode(this.hass.user, params.mode);
this._showHint = params.showHint ?? false;

this._relatedResult = params.contextItem ? params.related : undefined;
Expand Down
15 changes: 15 additions & 0 deletions src/dialogs/quick-bar/show-dialog-quick-bar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent } from "../../common/dom/fire_event";
import type { ItemType, RelatedResult } from "../../data/search";
import type { HomeAssistant } from "../../types";
import { closeDialog } from "../make-dialog-manager";

export type QuickBarSection =
Expand All @@ -22,6 +23,20 @@ export interface QuickBarParams {
related?: RelatedResult;
}

/** Non-admin users cannot scope the bar to command, device, or area (those sections are admin-only). */
export const effectiveQuickBarMode = (
user: HomeAssistant["user"],
mode?: QuickBarSection
): QuickBarSection | undefined => {
if (mode && user?.is_admin) {
return mode;
}
if (mode === "command" || mode === "device" || mode === "area") {
return undefined;
}
return mode;
};

export const loadQuickBar = () => import("./ha-quick-bar");

export const showQuickBar = (
Expand Down
2 changes: 2 additions & 0 deletions src/layouts/hass-tabs-subpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface PageNavigation {
not_component?: string | string[];
core?: boolean;
advancedOnly?: boolean;
/** Hide from non-admin users in filtered navigation and quick bar. */
adminOnly?: boolean;
iconPath?: string;
iconSecondaryPath?: string;
iconViewBox?: string;
Expand Down
8 changes: 5 additions & 3 deletions src/panels/config/dashboard/ha-config-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ const randomTip = (openFn: any, hass: HomeAssistant, narrow: boolean) => {
>`,
};

tips.push(
{
if (hass.user?.is_admin) {
tips.push({
content: hass.localize("ui.tips.key_c_tip", localizeParam),
weight: 1,
narrow: false,
},
});
}
tips.push(
{
content: hass.localize("ui.tips.key_m_tip", localizeParam),
weight: 1,
Expand Down
Loading
Loading