mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Rename 'quick open dialog' to 'quick bar' (#7286)
This commit is contained in:
parent
f7a9ecff21
commit
c219f64322
@ -20,7 +20,7 @@ import { componentsWithService } from "../../common/config/components_with_servi
|
|||||||
import { domainIcon } from "../../common/entity/domain_icon";
|
import { domainIcon } from "../../common/entity/domain_icon";
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import { domainToName } from "../../data/integration";
|
import { domainToName } from "../../data/integration";
|
||||||
import { QuickOpenDialogParams } from "./show-dialog-quick-open";
|
import { QuickBarParams } from "./show-dialog-quick-bar";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { compare } from "../../common/string/compare";
|
import { compare } from "../../common/string/compare";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -29,8 +29,8 @@ interface CommandItem extends ServiceCallRequest {
|
|||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("ha-quick-open-dialog")
|
@customElement("ha-quick-bar")
|
||||||
export class QuickOpenDialog extends LitElement {
|
export class QuickBar extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@internalProperty() private _commandItems: CommandItem[] = [];
|
@internalProperty() private _commandItems: CommandItem[] = [];
|
||||||
@ -41,7 +41,7 @@ export class QuickOpenDialog extends LitElement {
|
|||||||
|
|
||||||
@internalProperty() private _commandMode = false;
|
@internalProperty() private _commandMode = false;
|
||||||
|
|
||||||
public async showDialog(params: QuickOpenDialogParams) {
|
public async showDialog(params: QuickBarParams) {
|
||||||
this._commandMode = params.commandMode || false;
|
this._commandMode = params.commandMode || false;
|
||||||
this._opened = true;
|
this._opened = true;
|
||||||
this._commandItems = this._generateCommandItems();
|
this._commandItems = this._generateCommandItems();
|
||||||
@ -67,7 +67,7 @@ export class QuickOpenDialog extends LitElement {
|
|||||||
class="heading"
|
class="heading"
|
||||||
@value-changed=${this._entityFilterChanged}
|
@value-changed=${this._entityFilterChanged}
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.dialogs.quick-open.filter_placeholder"
|
"ui.dialogs.quick-bar.filter_placeholder"
|
||||||
)}
|
)}
|
||||||
type="search"
|
type="search"
|
||||||
value=${this._commandMode ? `>${this._itemFilter}` : this._itemFilter}
|
value=${this._commandMode ? `>${this._itemFilter}` : this._itemFilter}
|
||||||
@ -138,9 +138,9 @@ export class QuickOpenDialog extends LitElement {
|
|||||||
|
|
||||||
return reloadableDomains.map((domain) => ({
|
return reloadableDomains.map((domain) => ({
|
||||||
text:
|
text:
|
||||||
this.hass.localize(`ui.dialogs.quick-open.commands.reload.${domain}`) ||
|
this.hass.localize(`ui.dialogs.quick-bar.commands.reload.${domain}`) ||
|
||||||
this.hass.localize(
|
this.hass.localize(
|
||||||
"ui.dialogs.quick-open.commands.reload.reload",
|
"ui.dialogs.quick-bar.commands.reload.reload",
|
||||||
"domain",
|
"domain",
|
||||||
domainToName(this.hass.localize, domain)
|
domainToName(this.hass.localize, domain)
|
||||||
),
|
),
|
||||||
@ -220,6 +220,6 @@ export class QuickOpenDialog extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-quick-open-dialog": QuickOpenDialog;
|
"ha-quick-bar": QuickBar;
|
||||||
}
|
}
|
||||||
}
|
}
|
20
src/dialogs/quick-bar/show-dialog-quick-bar.ts
Normal file
20
src/dialogs/quick-bar/show-dialog-quick-bar.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
|
||||||
|
export interface QuickBarParams {
|
||||||
|
entityFilter?: string;
|
||||||
|
commandMode?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const loadQuickBar = () =>
|
||||||
|
import(/* webpackChunkName: "quick-bar-dialog" */ "./ha-quick-bar");
|
||||||
|
|
||||||
|
export const showQuickBar = (
|
||||||
|
element: HTMLElement,
|
||||||
|
dialogParams: QuickBarParams
|
||||||
|
): void => {
|
||||||
|
fireEvent(element, "show-dialog", {
|
||||||
|
dialogTag: "ha-quick-bar",
|
||||||
|
dialogImport: loadQuickBar,
|
||||||
|
dialogParams,
|
||||||
|
});
|
||||||
|
};
|
@ -1,20 +0,0 @@
|
|||||||
import { fireEvent } from "../../common/dom/fire_event";
|
|
||||||
|
|
||||||
export interface QuickOpenDialogParams {
|
|
||||||
entityFilter?: string;
|
|
||||||
commandMode?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const loadQuickOpenDialog = () =>
|
|
||||||
import(/* webpackChunkName: "quick-open-dialog" */ "./ha-quick-open-dialog");
|
|
||||||
|
|
||||||
export const showQuickOpenDialog = (
|
|
||||||
element: HTMLElement,
|
|
||||||
dialogParams: QuickOpenDialogParams
|
|
||||||
): void => {
|
|
||||||
fireEvent(element, "show-dialog", {
|
|
||||||
dialogTag: "ha-quick-open-dialog",
|
|
||||||
dialogImport: loadQuickOpenDialog,
|
|
||||||
dialogParams,
|
|
||||||
});
|
|
||||||
};
|
|
@ -17,10 +17,10 @@ import {
|
|||||||
import "./ha-init-page";
|
import "./ha-init-page";
|
||||||
import "./home-assistant-main";
|
import "./home-assistant-main";
|
||||||
import { storeState } from "../util/ha-pref-storage";
|
import { storeState } from "../util/ha-pref-storage";
|
||||||
import QuickOpenMixin from "../state/quick-open-mixin";
|
import QuickBarMixin from "../state/quick-bar-mixin";
|
||||||
|
|
||||||
@customElement("home-assistant")
|
@customElement("home-assistant")
|
||||||
export class HomeAssistantAppEl extends QuickOpenMixin(HassElement) {
|
export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
|
||||||
@internalProperty() private _route?: Route;
|
@internalProperty() private _route?: Route;
|
||||||
|
|
||||||
@internalProperty() private _error = false;
|
@internalProperty() private _error = false;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import type { Constructor, PropertyValues } from "lit-element";
|
import type { Constructor, PropertyValues } from "lit-element";
|
||||||
import { HassElement } from "./hass-element";
|
import { HassElement } from "./hass-element";
|
||||||
import {
|
import {
|
||||||
QuickOpenDialogParams,
|
QuickBarParams,
|
||||||
showQuickOpenDialog,
|
showQuickBar,
|
||||||
} from "../dialogs/quick-open/show-dialog-quick-open";
|
} from "../dialogs/quick-bar/show-dialog-quick-bar";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
"hass-quick-open": QuickOpenDialogParams;
|
"hass-quick-bar": QuickBarParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,12 +19,12 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
|
|||||||
document.addEventListener("keydown", (e: KeyboardEvent) => {
|
document.addEventListener("keydown", (e: KeyboardEvent) => {
|
||||||
if (e.code === "KeyP" && e.metaKey) {
|
if (e.code === "KeyP" && e.metaKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const eventParams: QuickOpenDialogParams = {};
|
const eventParams: QuickBarParams = {};
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
eventParams.commandMode = true;
|
eventParams.commandMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
showQuickOpenDialog(this, eventParams);
|
showQuickBar(this, eventParams);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -446,7 +446,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dialogs": {
|
"dialogs": {
|
||||||
"quick-open": {
|
"quick-bar": {
|
||||||
"commands": {
|
"commands": {
|
||||||
"reload": {
|
"reload": {
|
||||||
"reload": "[%key:ui::panel::config::server_control::section::reloading::reload%]",
|
"reload": "[%key:ui::panel::config::server_control::section::reloading::reload%]",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user