mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Allow data entry flows to hint for additional steps (#49202)
This commit is contained in:
parent
a6d87b7fae
commit
8013eb0e08
@ -158,7 +158,7 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
return await self.async_step_broker()
|
||||
|
||||
async def async_step_broker(self, user_input=None):
|
||||
"""Manage the MQTT options."""
|
||||
"""Manage the MQTT broker configuration."""
|
||||
errors = {}
|
||||
current_config = self.config_entry.data
|
||||
yaml_config = self.hass.data.get(DATA_MQTT_CONFIG, {})
|
||||
@ -201,6 +201,7 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
step_id="broker",
|
||||
data_schema=vol.Schema(fields),
|
||||
errors=errors,
|
||||
last_step=False,
|
||||
)
|
||||
|
||||
async def async_step_options(self, user_input=None):
|
||||
@ -321,6 +322,7 @@ class MQTTOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
step_id="options",
|
||||
data_schema=vol.Schema(fields),
|
||||
errors=errors,
|
||||
last_step=True,
|
||||
)
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ class FlowResultDict(TypedDict, total=False):
|
||||
reason: str
|
||||
context: dict[str, Any]
|
||||
result: Any
|
||||
last_step: bool | None
|
||||
|
||||
|
||||
class FlowManager(abc.ABC):
|
||||
@ -345,6 +346,7 @@ class FlowHandler:
|
||||
data_schema: vol.Schema = None,
|
||||
errors: dict[str, str] | None = None,
|
||||
description_placeholders: dict[str, Any] | None = None,
|
||||
last_step: bool | None = None,
|
||||
) -> FlowResultDict:
|
||||
"""Return the definition of a form to gather user input."""
|
||||
return {
|
||||
@ -355,6 +357,7 @@ class FlowHandler:
|
||||
"data_schema": data_schema,
|
||||
"errors": errors,
|
||||
"description_placeholders": description_placeholders,
|
||||
"last_step": last_step, # Display next or submit button in frontend
|
||||
}
|
||||
|
||||
@callback
|
||||
|
@ -239,6 +239,7 @@ async def test_initialize_flow(hass, client):
|
||||
"show_advanced_options": True,
|
||||
},
|
||||
"errors": {"username": "Should be unique."},
|
||||
"last_step": None,
|
||||
}
|
||||
|
||||
|
||||
@ -375,6 +376,7 @@ async def test_two_step_flow(hass, client):
|
||||
"data_schema": [{"name": "user_title", "type": "string"}],
|
||||
"description_placeholders": None,
|
||||
"errors": None,
|
||||
"last_step": None,
|
||||
}
|
||||
|
||||
with patch.dict(HANDLERS, {"test": TestFlow}):
|
||||
@ -445,6 +447,7 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user):
|
||||
"data_schema": [{"name": "user_title", "type": "string"}],
|
||||
"description_placeholders": None,
|
||||
"errors": None,
|
||||
"last_step": None,
|
||||
}
|
||||
|
||||
hass_admin_user.groups = []
|
||||
@ -612,6 +615,7 @@ async def test_options_flow(hass, client):
|
||||
"data_schema": [{"name": "enabled", "required": True, "type": "boolean"}],
|
||||
"description_placeholders": {"enabled": "Set to true to be true"},
|
||||
"errors": None,
|
||||
"last_step": None,
|
||||
}
|
||||
|
||||
|
||||
@ -660,6 +664,7 @@ async def test_two_step_options_flow(hass, client):
|
||||
"data_schema": [{"name": "enabled", "type": "boolean"}],
|
||||
"description_placeholders": None,
|
||||
"errors": None,
|
||||
"last_step": None,
|
||||
}
|
||||
|
||||
with patch.dict(HANDLERS, {"test": TestFlow}):
|
||||
|
@ -131,6 +131,7 @@ async def test_pin_form_init(pin_form):
|
||||
"handler": DOMAIN,
|
||||
"step_id": "pin",
|
||||
"type": "form",
|
||||
"last_step": None,
|
||||
}
|
||||
assert pin_form == expected
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user