Sfoglia il codice sorgente

Fix blank menu labels in options flow

HA validates that async_step_{step_id} exists for whatever step_id
a menu returns, so async_step_init cannot own the menu directly under
step_id="init" without the frontend treating it as a silent virtual
step (no translation lookup). Added async_step_configure to own the
menu; async_step_init delegates to it immediately.
ZiB 4 mesi fa
parent
commit
8abc1a0657

+ 6 - 1
custom_components/room_cal_ha/config_flow.py

@@ -159,9 +159,14 @@ class RoomCalOptionsFlow(OptionsFlow):
 
 
   async def async_step_init(
   async def async_step_init(
     self, user_input: dict[str, Any] | None = None
     self, user_input: dict[str, Any] | None = None
+  ) -> ConfigFlowResult:
+    return await self.async_step_configure()
+
+  async def async_step_configure(
+    self, user_input: dict[str, Any] | None = None
   ) -> ConfigFlowResult:
   ) -> ConfigFlowResult:
     return self.async_show_menu(
     return self.async_show_menu(
-      step_id="init",
+      step_id="configure",
       menu_options=["sync_mode", "defaults", "locks"],
       menu_options=["sync_mode", "defaults", "locks"],
     )
     )
 
 

+ 1 - 1
custom_components/room_cal_ha/strings.json

@@ -34,7 +34,7 @@
   },
   },
   "options": {
   "options": {
     "step": {
     "step": {
-      "init": {
+      "configure": {
         "menu_options": {
         "menu_options": {
           "sync_mode": "Sync Mode & Connection",
           "sync_mode": "Sync Mode & Connection",
           "defaults": "Reservation Defaults",
           "defaults": "Reservation Defaults",

+ 1 - 1
custom_components/room_cal_ha/translations/en.json

@@ -34,7 +34,7 @@
   },
   },
   "options": {
   "options": {
     "step": {
     "step": {
-      "init": {
+      "configure": {
         "menu_options": {
         "menu_options": {
           "sync_mode": "Sync Mode & Connection",
           "sync_mode": "Sync Mode & Connection",
           "defaults": "Reservation Defaults",
           "defaults": "Reservation Defaults",

+ 2 - 2
tests/test_config_flow.py

@@ -42,7 +42,7 @@ async def _options_init(hass: HomeAssistant, mock_entry):
   mock_entry.add_to_hass(hass)
   mock_entry.add_to_hass(hass)
   result = await hass.config_entries.options.async_init(mock_entry.entry_id)
   result = await hass.config_entries.options.async_init(mock_entry.entry_id)
   assert result["type"] == "menu"
   assert result["type"] == "menu"
-  assert result["step_id"] == "init"
+  assert result["step_id"] == "configure"
   return result
   return result
 
 
 
 
@@ -91,7 +91,7 @@ async def test_user_step_creates_entry_with_room_name(hass: HomeAssistant):
 async def test_options_init_shows_menu(hass: HomeAssistant, mock_entry):
 async def test_options_init_shows_menu(hass: HomeAssistant, mock_entry):
   result = await _options_init(hass, mock_entry)
   result = await _options_init(hass, mock_entry)
   assert result["type"] == "menu"
   assert result["type"] == "menu"
-  assert result["step_id"] == "init"
+  assert result["step_id"] == "configure"
 
 
 
 
 async def test_options_init_sync_leads_to_sync_mode(hass: HomeAssistant, mock_entry):
 async def test_options_init_sync_leads_to_sync_mode(hass: HomeAssistant, mock_entry):