mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Set last_step in SchemaCommonFlowHandler (#82616)
* Set last_step in SchemaCommonFlowHandler * Always use boolean * Adjust next_step definition
This commit is contained in:
parent
072bbcf203
commit
ba18571cbe
@ -42,8 +42,8 @@ class SchemaFlowFormStep:
|
|||||||
# The next_step function is called if the schema validates successfully or if no
|
# The next_step function is called if the schema validates successfully or if no
|
||||||
# schema is defined. The next_step function is passed the union of config entry
|
# schema is defined. The next_step function is passed the union of config entry
|
||||||
# options and user input from previous steps.
|
# options and user input from previous steps.
|
||||||
# If next_step returns None, the flow is ended with FlowResultType.CREATE_ENTRY.
|
# If next_step is None, the flow is ended with FlowResultType.CREATE_ENTRY.
|
||||||
next_step: Callable[[dict[str, Any]], str | None] = lambda _: None
|
next_step: Callable[[dict[str, Any]], str] | None = None
|
||||||
|
|
||||||
# Optional function to allow amending a form schema.
|
# Optional function to allow amending a form schema.
|
||||||
# The update_form_schema function is called before async_show_form is called. The
|
# The update_form_schema function is called before async_show_form is called. The
|
||||||
@ -136,12 +136,11 @@ class SchemaCommonFlowHandler:
|
|||||||
next_step_id: str = step_id
|
next_step_id: str = step_id
|
||||||
if user_input is not None or form_step.schema is None:
|
if user_input is not None or form_step.schema is None:
|
||||||
# Get next step
|
# Get next step
|
||||||
next_step_id_or_end_flow = form_step.next_step(self._options)
|
if form_step.next_step is None:
|
||||||
if next_step_id_or_end_flow is None:
|
|
||||||
# Flow done, create entry or update config entry options
|
# Flow done, create entry or update config entry options
|
||||||
return self._handler.async_create_entry(data=self._options)
|
return self._handler.async_create_entry(data=self._options)
|
||||||
|
|
||||||
next_step_id = next_step_id_or_end_flow
|
next_step_id = form_step.next_step(self._options)
|
||||||
|
|
||||||
return self._show_next_step(next_step_id)
|
return self._show_next_step(next_step_id)
|
||||||
|
|
||||||
@ -188,7 +187,10 @@ class SchemaCommonFlowHandler:
|
|||||||
|
|
||||||
# Show form for next step
|
# Show form for next step
|
||||||
return self._handler.async_show_form(
|
return self._handler.async_show_form(
|
||||||
step_id=next_step_id, data_schema=data_schema, errors=errors
|
step_id=next_step_id,
|
||||||
|
data_schema=data_schema,
|
||||||
|
errors=errors,
|
||||||
|
last_step=form_step.next_step is None,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _async_menu_step(
|
async def _async_menu_step(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user