mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Expose history replace in action editor (#17740)
* Expose existing navigation history replace to the UI * Remove navigation_replace from GUI editor * Restore default value
This commit is contained in:
parent
a60a721ea5
commit
d7760c4b7a
@ -140,6 +140,7 @@ export interface CallServiceActionConfig extends BaseActionConfig {
|
|||||||
export interface NavigateActionConfig extends BaseActionConfig {
|
export interface NavigateActionConfig extends BaseActionConfig {
|
||||||
action: "navigate";
|
action: "navigate";
|
||||||
navigation_path: string;
|
navigation_path: string;
|
||||||
|
navigation_replace?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UrlActionConfig extends BaseActionConfig {
|
export interface UrlActionConfig extends BaseActionConfig {
|
||||||
|
@ -109,7 +109,9 @@ export const handleAction = async (
|
|||||||
}
|
}
|
||||||
case "navigate":
|
case "navigate":
|
||||||
if (actionConfig.navigation_path) {
|
if (actionConfig.navigation_path) {
|
||||||
navigate(actionConfig.navigation_path);
|
navigate(actionConfig.navigation_path, {
|
||||||
|
replace: actionConfig.navigation_replace,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
showToast(node, {
|
showToast(node, {
|
||||||
message: hass.localize(
|
message: hass.localize(
|
||||||
|
@ -30,6 +30,15 @@ const DEFAULT_ACTIONS: UiAction[] = [
|
|||||||
"none",
|
"none",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const NAVIGATE_SCHEMA = [
|
||||||
|
{
|
||||||
|
name: "navigation_path",
|
||||||
|
selector: {
|
||||||
|
navigation: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
] as const satisfies readonly HaFormSchema[];
|
||||||
|
|
||||||
const ASSIST_SCHEMA = [
|
const ASSIST_SCHEMA = [
|
||||||
{
|
{
|
||||||
type: "grid",
|
type: "grid",
|
||||||
@ -131,14 +140,14 @@ export class HuiActionEditor extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
${this.config?.action === "navigate"
|
${this.config?.action === "navigate"
|
||||||
? html`
|
? html`
|
||||||
<ha-navigation-picker
|
<ha-form
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.label=${this.hass!.localize(
|
.schema=${NAVIGATE_SCHEMA}
|
||||||
"ui.panel.lovelace.editor.action-editor.navigation_path"
|
.data=${this.config}
|
||||||
)}
|
.computeLabel=${this._computeFormLabel}
|
||||||
.value=${this._navigation_path}
|
@value-changed=${this._formValueChanged}
|
||||||
@value-changed=${this._navigateValueChanged}
|
>
|
||||||
></ha-navigation-picker>
|
</ha-form>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
${this.config?.action === "url"
|
${this.config?.action === "url"
|
||||||
@ -265,16 +274,6 @@ export class HuiActionEditor extends LitElement {
|
|||||||
fireEvent(this, "value-changed", { value });
|
fireEvent(this, "value-changed", { value });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _navigateValueChanged(ev: CustomEvent) {
|
|
||||||
ev.stopPropagation();
|
|
||||||
const value = {
|
|
||||||
...this.config!,
|
|
||||||
navigation_path: ev.detail.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
fireEvent(this, "value-changed", { value });
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
.dropdown {
|
.dropdown {
|
||||||
|
@ -48,6 +48,7 @@ const actionConfigStructService = object({
|
|||||||
const actionConfigStructNavigate = object({
|
const actionConfigStructNavigate = object({
|
||||||
action: literal("navigate"),
|
action: literal("navigate"),
|
||||||
navigation_path: string(),
|
navigation_path: string(),
|
||||||
|
navigation_replace: optional(boolean()),
|
||||||
confirmation: optional(actionConfigStructConfirmation),
|
confirmation: optional(actionConfigStructConfirmation),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user