Simplify jewish_calendar reconfigure flow (#128008)
* Simplify jewish_calendar reconfigure flow * Adjustpull/128023/head
parent
dd08381167
commit
3d1e57766a
|
@ -87,7 +87,6 @@ class JewishCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for Jewish calendar."""
|
"""Handle a config flow for Jewish calendar."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
_config_entry: ConfigEntry
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
|
@ -133,25 +132,17 @@ class JewishCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
self._config_entry = self._get_reconfigure_entry()
|
reconfigure_entry = self._get_reconfigure_entry()
|
||||||
return await self.async_step_reconfigure_confirm()
|
|
||||||
|
|
||||||
async def async_step_reconfigure_confirm(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
data_schema=self.add_suggested_values_to_schema(
|
data_schema=self.add_suggested_values_to_schema(
|
||||||
_get_data_schema(self.hass),
|
_get_data_schema(self.hass),
|
||||||
{**self._config_entry.data},
|
reconfigure_entry.data,
|
||||||
),
|
),
|
||||||
step_id="reconfigure_confirm",
|
step_id="reconfigure",
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(reconfigure_entry, data=user_input)
|
||||||
self._config_entry, data=user_input, reason="reconfigure_successful"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class JewishCalendarOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
class JewishCalendarOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
||||||
|
|
|
@ -177,7 +177,7 @@ async def test_reconfigure(
|
||||||
# init user flow
|
# init user flow
|
||||||
result = await mock_config_entry.start_reconfigure_flow(hass)
|
result = await mock_config_entry.start_reconfigure_flow(hass)
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reconfigure_confirm"
|
assert result["step_id"] == "reconfigure"
|
||||||
|
|
||||||
# success
|
# success
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
|
Loading…
Reference in New Issue