Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/panels/config/config-entries/ha-config-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class HaConfigFlow extends
paper-dialog {
max-width: 500px;
}
ha-markdown {
word-break: break-word;
}
ha-markdown a {
color: var(--primary-color);
}
ha-markdown img:first-child:last-child {
display: block;
margin: 0 auto;
Expand Down Expand Up @@ -62,19 +68,15 @@ class HaConfigFlow extends
<div class='init-spinner'><paper-spinner active></paper-spinner></div>
</template>
<template is="dom-if" if="[[_step]]">
<template is="dom-if" if="[[_equals(_step.type, 'abort')]]">
<ha-markdown content="[[_computeStepAbortedReason(localize, _step)]]"></ha-markdown>
</template>

<template is="dom-if" if="[[_equals(_step.type, 'create_entry')]]">
<p>Created config for [[_step.title]]</p>
</template>

<template is="dom-if" if="[[_equals(_step.type, 'form')]]">
<template is="dom-if" if="[[_computeStepDescription(localize, _step)]]">
<ha-markdown content="[[_computeStepDescription(localize, _step)]]" allow-svg></ha-markdown>
</template>
<template is="dom-if" if="[[_computeStepDescription(localize, _step)]]">
<ha-markdown content="[[_computeStepDescription(localize, _step)]]" allow-svg></ha-markdown>
</template>

<template is="dom-if" if="[[_equals(_step.type, 'form')]]">
<ha-form
data="{{_stepData}}"
on-data-changed='_increaseCounter'
Expand Down Expand Up @@ -270,21 +272,26 @@ class HaConfigFlow extends
}
}

_computeStepAbortedReason(localize, step) {
return localize(`component.${step.handler}.config.abort.${step.reason}`);
}

_computeStepTitle(localize, step) {
return localize(`component.${step.handler}.config.step.${step.step_id}.title`);
}

_computeStepDescription(localize, step) {
const args = [`component.${step.handler}.config.step.${step.step_id}.description`];
const args = [];
if (step.type === 'form') {
args.push(`component.${step.handler}.config.step.${step.step_id}.description`);
} else if (step.type === 'abort') {
args.push(`component.${step.handler}.config.abort.${step.reason}`);
} else if (step.type === 'create_entry') {
args.push(`component.${step.handler}.config.create_entry.${step.description || 'default'}`);
}

const placeholders = step.description_placeholders || {};
Object.keys(placeholders).forEach((key) => {
args.push(key);
args.push(placeholders[key]);
});

return localize(...args);
}

Expand Down