import { html } from "lit";
import { ConfigEntry } from "../../data/config_entries";
import {
createOptionsFlow,
deleteOptionsFlow,
fetchOptionsFlow,
handleOptionsFlowStep,
} from "../../data/options_flow";
import {
loadDataEntryFlowDialog,
showFlowDialog,
} from "./show-dialog-data-entry-flow";
export const loadOptionsFlowDialog = loadDataEntryFlowDialog;
export const showOptionsFlowDialog = (
element: HTMLElement,
configEntry: ConfigEntry
): void =>
showFlowDialog(
element,
{
startFlowHandler: configEntry.entry_id,
},
{
loadDevicesAndAreas: false,
createFlow: async (hass, handler) => {
const [step] = await Promise.all([
createOptionsFlow(hass, handler),
hass.loadBackendTranslation("options", configEntry.domain),
]);
return step;
},
fetchFlow: async (hass, flowId) => {
const [step] = await Promise.all([
fetchOptionsFlow(hass, flowId),
hass.loadBackendTranslation("options", configEntry.domain),
]);
return step;
},
handleFlowStep: handleOptionsFlowStep,
deleteFlow: deleteOptionsFlow,
renderAbortDescription(hass, step) {
const description = hass.localize(
`component.${configEntry.domain}.options.abort.${step.reason}`,
step.description_placeholders
);
return description
? html`
${hass.localize(`ui.dialogs.options_flow.success.description`)}
`; }, renderShowFormProgressHeader(_hass, _step) { return ""; }, renderShowFormProgressDescription(_hass, _step) { return ""; }, } );