Add descriptions for config flow in Habitica integration (#131461)

This commit is contained in:
Manu 2024-11-26 10:42:03 +01:00 committed by GitHub
parent 04b8a686dc
commit d587e71f8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 4 deletions

View File

@ -25,7 +25,15 @@ from homeassistant.helpers.selector import (
TextSelectorType, TextSelectorType,
) )
from .const import CONF_API_USER, DEFAULT_URL, DOMAIN from .const import (
CONF_API_USER,
DEFAULT_URL,
DOMAIN,
FORGOT_PASSWORD_URL,
HABITICANS_URL,
SIGN_UP_URL,
SITE_DATA_URL,
)
STEP_ADVANCED_DATA_SCHEMA = vol.Schema( STEP_ADVANCED_DATA_SCHEMA = vol.Schema(
{ {
@ -69,6 +77,10 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
return self.async_show_menu( return self.async_show_menu(
step_id="user", step_id="user",
menu_options=["login", "advanced"], menu_options=["login", "advanced"],
description_placeholders={
"signup": SIGN_UP_URL,
"habiticans": HABITICANS_URL,
},
) )
async def async_step_login( async def async_step_login(
@ -125,6 +137,7 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
data_schema=STEP_LOGIN_DATA_SCHEMA, suggested_values=user_input data_schema=STEP_LOGIN_DATA_SCHEMA, suggested_values=user_input
), ),
errors=errors, errors=errors,
description_placeholders={"forgot_password": FORGOT_PASSWORD_URL},
) )
async def async_step_advanced( async def async_step_advanced(
@ -175,4 +188,8 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
data_schema=STEP_ADVANCED_DATA_SCHEMA, suggested_values=user_input data_schema=STEP_ADVANCED_DATA_SCHEMA, suggested_values=user_input
), ),
errors=errors, errors=errors,
description_placeholders={
"site_data": SITE_DATA_URL,
"default_url": DEFAULT_URL,
},
) )

View File

@ -6,6 +6,11 @@ CONF_API_USER = "api_user"
DEFAULT_URL = "https://habitica.com" DEFAULT_URL = "https://habitica.com"
ASSETS_URL = "https://habitica-assets.s3.amazonaws.com/mobileApp/images/" ASSETS_URL = "https://habitica-assets.s3.amazonaws.com/mobileApp/images/"
SITE_DATA_URL = "https://habitica.com/user/settings/siteData"
FORGOT_PASSWORD_URL = "https://habitica.com/forgot-password"
SIGN_UP_URL = "https://habitica.com/register"
HABITICANS_URL = "https://habitica.com/static/img/home-main@3x.ffc32b12.png"
DOMAIN = "habitica" DOMAIN = "habitica"
# service constants # service constants

View File

@ -15,26 +15,39 @@
}, },
"step": { "step": {
"user": { "user": {
"title": "Habitica - Gamify your life",
"menu_options": { "menu_options": {
"login": "Login to Habitica", "login": "Login to Habitica",
"advanced": "Login to other instances" "advanced": "Login to other instances"
}, },
"description": "Connect your Habitica profile to allow monitoring of your user's profile and tasks." "description": "![Habiticans]({habiticans}) Connect your Habitica account to keep track of your adventurer's stats, progress, and manage your to-dos and daily tasks.\n\n[Don't have a Habitica account? Sign up here.]({signup})"
}, },
"login": { "login": {
"title": "[%key:component::habitica::config::step::user::menu_options::login%]",
"data": { "data": {
"username": "Email or username (case-sensitive)", "username": "Email or username (case-sensitive)",
"password": "[%key:common::config_flow::data::password%]" "password": "[%key:common::config_flow::data::password%]"
} },
"data_description": {
"username": "Email or username (case-sensitive) to connect Home Assistant to your Habitica account",
"password": "Password for the account to connect Home Assistant to Habitica"
},
"description": "Enter your login details to start using Habitica with Home Assistant\n\n[Forgot your password?]({forgot_password})"
}, },
"advanced": { "advanced": {
"title": "[%key:component::habitica::config::step::user::menu_options::advanced%]",
"data": { "data": {
"url": "[%key:common::config_flow::data::url%]", "url": "[%key:common::config_flow::data::url%]",
"api_user": "User ID", "api_user": "User ID",
"api_key": "API Token", "api_key": "API Token",
"verify_ssl": "[%key:common::config_flow::data::verify_ssl%]" "verify_ssl": "[%key:common::config_flow::data::verify_ssl%]"
}, },
"description": "You can retrieve your `User ID` and `API Token` from **Settings -> Site Data** on Habitica or the instance you want to connect to" "data_description": {
"url": "URL of the Habitica installation to connect to. Defaults to `{default_url}`",
"api_user": "User ID of your Habitica account",
"api_key": "API Token of the Habitica account"
},
"description": "You can retrieve your `User ID` and `API Token` from [**Settings -> Site Data**]({site_data}) on Habitica or the instance you want to connect to"
} }
} }
}, },