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 {
|
||||
action: "navigate";
|
||||
navigation_path: string;
|
||||
navigation_replace?: boolean;
|
||||
}
|
||||
|
||||
export interface UrlActionConfig extends BaseActionConfig {
|
||||
|
@ -109,7 +109,9 @@ export const handleAction = async (
|
||||
}
|
||||
case "navigate":
|
||||
if (actionConfig.navigation_path) {
|
||||
navigate(actionConfig.navigation_path);
|
||||
navigate(actionConfig.navigation_path, {
|
||||
replace: actionConfig.navigation_replace,
|
||||
});
|
||||
} else {
|
||||
showToast(node, {
|
||||
message: hass.localize(
|
||||
|
@ -30,6 +30,15 @@ const DEFAULT_ACTIONS: UiAction[] = [
|
||||
"none",
|
||||
];
|
||||
|
||||
const NAVIGATE_SCHEMA = [
|
||||
{
|
||||
name: "navigation_path",
|
||||
selector: {
|
||||
navigation: {},
|
||||
},
|
||||
},
|
||||
] as const satisfies readonly HaFormSchema[];
|
||||
|
||||
const ASSIST_SCHEMA = [
|
||||
{
|
||||
type: "grid",
|
||||
@ -131,14 +140,14 @@ export class HuiActionEditor extends LitElement {
|
||||
</div>
|
||||
${this.config?.action === "navigate"
|
||||
? html`
|
||||
<ha-navigation-picker
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.editor.action-editor.navigation_path"
|
||||
)}
|
||||
.value=${this._navigation_path}
|
||||
@value-changed=${this._navigateValueChanged}
|
||||
></ha-navigation-picker>
|
||||
.schema=${NAVIGATE_SCHEMA}
|
||||
.data=${this.config}
|
||||
.computeLabel=${this._computeFormLabel}
|
||||
@value-changed=${this._formValueChanged}
|
||||
>
|
||||
</ha-form>
|
||||
`
|
||||
: nothing}
|
||||
${this.config?.action === "url"
|
||||
@ -265,16 +274,6 @@ export class HuiActionEditor extends LitElement {
|
||||
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 {
|
||||
return css`
|
||||
.dropdown {
|
||||
|
@ -48,6 +48,7 @@ const actionConfigStructService = object({
|
||||
const actionConfigStructNavigate = object({
|
||||
action: literal("navigate"),
|
||||
navigation_path: string(),
|
||||
navigation_replace: optional(boolean()),
|
||||
confirmation: optional(actionConfigStructConfirmation),
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user