Skip to content

Commit

Permalink
Allow 'Discovered' flows to have title placeholders (#3106)
Browse files Browse the repository at this point in the history
* Allow 'Discovered' flows to have title placeholders

* Feedback from review
  • Loading branch information
Jc2k authored and balloob committed Apr 21, 2019
1 parent f967b49 commit b3c1bea
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/panels/config/integrations/ha-config-entries-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class HaConfigManagerDashboard extends LocalizeMixin(
<template is="dom-repeat" items="[[progress]]">
<div class="config-entry-row">
<paper-item-body>
[[_computeIntegrationTitle(localize, item.handler)]]
[[_computeActiveFlowTitle(localize, item)]]
</paper-item-body>
<mwc-button on-click="_continueFlow"
>[[localize('ui.panel.config.integrations.configure')]]</mwc-button
Expand Down Expand Up @@ -190,6 +190,23 @@ class HaConfigManagerDashboard extends LocalizeMixin(
return localize(`component.${integration}.config.title`);
}

_computeActiveFlowTitle(localize, integration) {
const placeholders = integration.context.title_placeholders || {};
const placeholderKeys = Object.keys(placeholders);
if (placeholderKeys.length === 0) {
return localize(`component.${integration.handler}.config.title`);
}
const args = [];
placeholderKeys.forEach((key) => {
args.push(key);
args.push(placeholders[key]);
});
return localize(
`component.${integration.handler}.config.flow_title`,
...args
);
}

_computeConfigEntryEntities(hass, configEntry, entities) {
if (!entities) {
return [];
Expand Down

0 comments on commit b3c1bea

Please sign in to comment.