Migrate integrations a-d to generic flowhandler (#111861)
This commit is contained in:
parent
ba4120d779
commit
6fe28d3764
111 changed files with 841 additions and 758 deletions
|
@ -8,8 +8,7 @@ from aioazuredevops.client import DevOpsClient
|
|||
import aiohttp
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
|
||||
|
||||
|
@ -27,7 +26,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def _show_setup_form(
|
||||
self, errors: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Show the setup form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
|
@ -41,7 +40,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
errors=errors or {},
|
||||
)
|
||||
|
||||
async def _show_reauth_form(self, errors: dict[str, str]) -> FlowResult:
|
||||
async def _show_reauth_form(self, errors: dict[str, str]) -> ConfigFlowResult:
|
||||
"""Show the reauth form to the user."""
|
||||
return self.async_show_form(
|
||||
step_id="reauth",
|
||||
|
@ -75,7 +74,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, str] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initiated by the user."""
|
||||
if user_input is None:
|
||||
return await self._show_setup_form()
|
||||
|
@ -92,7 +91,9 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
return await self._show_setup_form(errors)
|
||||
return self._async_create_entry()
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
if entry_data.get(CONF_ORG) and entry_data.get(CONF_PROJECT):
|
||||
self._organization = entry_data[CONF_ORG]
|
||||
|
@ -121,7 +122,7 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
def _async_create_entry(self) -> FlowResult:
|
||||
def _async_create_entry(self) -> ConfigFlowResult:
|
||||
"""Handle create entry."""
|
||||
return self.async_create_entry(
|
||||
title=f"{self._organization}/{self._project}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue