Add reconfigure config entry (#19794)
parent
42aa18ac16
commit
8b77024fb9
|
@ -10,6 +10,7 @@ export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
|||
supports_options: false,
|
||||
supports_remove_device: false,
|
||||
supports_unload: true,
|
||||
supports_reconfigure: true,
|
||||
pref_disable_new_entities: false,
|
||||
pref_disable_polling: false,
|
||||
disabled_by: null,
|
||||
|
|
|
@ -31,6 +31,7 @@ const createConfigEntry = (
|
|||
supports_options: false,
|
||||
supports_remove_device: false,
|
||||
supports_unload: true,
|
||||
supports_reconfigure: true,
|
||||
disabled_by: null,
|
||||
pref_disable_new_entities: false,
|
||||
pref_disable_polling: false,
|
||||
|
|
|
@ -18,6 +18,7 @@ export interface ConfigEntry {
|
|||
supports_options: boolean;
|
||||
supports_remove_device: boolean;
|
||||
supports_unload: boolean;
|
||||
supports_reconfigure: boolean;
|
||||
pref_disable_new_entities: boolean;
|
||||
pref_disable_polling: boolean;
|
||||
disabled_by: "user" | null;
|
||||
|
|
|
@ -26,13 +26,18 @@ const HEADERS = {
|
|||
"HA-Frontend-Base": `${location.protocol}//${location.host}`,
|
||||
};
|
||||
|
||||
export const createConfigFlow = (hass: HomeAssistant, handler: string) =>
|
||||
export const createConfigFlow = (
|
||||
hass: HomeAssistant,
|
||||
handler: string,
|
||||
entry_id?: string
|
||||
) =>
|
||||
hass.callApi<DataEntryFlowStep>(
|
||||
"POST",
|
||||
"config/config_entries/flow",
|
||||
{
|
||||
handler,
|
||||
show_advanced_options: Boolean(hass.userData?.showAdvanced),
|
||||
entry_id,
|
||||
},
|
||||
HEADERS
|
||||
);
|
||||
|
|
|
@ -23,7 +23,7 @@ export const showConfigFlowDialog = (
|
|||
loadDevicesAndAreas: true,
|
||||
createFlow: async (hass, handler) => {
|
||||
const [step] = await Promise.all([
|
||||
createConfigFlow(hass, handler),
|
||||
createConfigFlow(hass, handler, dialogParams.entryId),
|
||||
hass.loadFragmentTranslation("config"),
|
||||
hass.loadBackendTranslation("config", handler),
|
||||
hass.loadBackendTranslation("selector", handler),
|
||||
|
|
|
@ -139,6 +139,7 @@ export interface DataEntryFlowDialogParams {
|
|||
}) => void;
|
||||
flowConfig: FlowConfig;
|
||||
showAdvanced?: boolean;
|
||||
entryId?: string;
|
||||
dialogParentElement?: HTMLElement;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
mdiRenameBox,
|
||||
mdiShapeOutline,
|
||||
mdiStopCircleOutline,
|
||||
mdiWrench,
|
||||
} from "@mdi/js";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
|
@ -806,6 +807,19 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||
</ha-list-item>
|
||||
</a>`
|
||||
: ""}
|
||||
${!item.disabled_by &&
|
||||
item.supports_reconfigure &&
|
||||
item.source !== "system"
|
||||
? html`<ha-list-item
|
||||
@request-selected=${this._handleReconfigure}
|
||||
graphic="icon"
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.integrations.config_entry.reconfigure"
|
||||
)}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiWrench}></ha-svg-icon>
|
||||
</ha-list-item>`
|
||||
: ""}
|
||||
|
||||
<ha-list-item
|
||||
@request-selected=${this._handleSystemOptions}
|
||||
|
@ -1040,6 +1054,15 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||
);
|
||||
}
|
||||
|
||||
private _handleReconfigure(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||
return;
|
||||
}
|
||||
this._reconfigureIntegration(
|
||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||
);
|
||||
}
|
||||
|
||||
private _handleDelete(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||
return;
|
||||
|
@ -1259,6 +1282,15 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||
});
|
||||
}
|
||||
|
||||
private async _reconfigureIntegration(configEntry: ConfigEntry) {
|
||||
showConfigFlowDialog(this, {
|
||||
startFlowHandler: configEntry.domain,
|
||||
showAdvanced: this.hass.userData?.showAdvanced,
|
||||
manifest: await fetchIntegrationManifest(this.hass, configEntry.domain),
|
||||
entryId: configEntry.entry_id,
|
||||
});
|
||||
}
|
||||
|
||||
private async _editEntryName(configEntry: ConfigEntry) {
|
||||
const newName = await showPromptDialog(this, {
|
||||
title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
|
||||
|
|
|
@ -3959,6 +3959,7 @@
|
|||
"delete_confirm_title": "Delete {title}?",
|
||||
"delete_confirm_text": "Its devices and entities will be permanently deleted.",
|
||||
"enable_debug_logging": "Enable debug logging",
|
||||
"reconfigure": "Reconfigure",
|
||||
"reload": "Reload",
|
||||
"restart_confirm": "Restart Home Assistant to finish removing this integration",
|
||||
"reload_confirm": "The integration was reloaded",
|
||||
|
|
Loading…
Reference in New Issue