mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
Add reconfigure config entry (#19794)
This commit is contained in:
parent
42aa18ac16
commit
8b77024fb9
@ -10,6 +10,7 @@ export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
|||||||
supports_options: false,
|
supports_options: false,
|
||||||
supports_remove_device: false,
|
supports_remove_device: false,
|
||||||
supports_unload: true,
|
supports_unload: true,
|
||||||
|
supports_reconfigure: true,
|
||||||
pref_disable_new_entities: false,
|
pref_disable_new_entities: false,
|
||||||
pref_disable_polling: false,
|
pref_disable_polling: false,
|
||||||
disabled_by: null,
|
disabled_by: null,
|
||||||
|
@ -31,6 +31,7 @@ const createConfigEntry = (
|
|||||||
supports_options: false,
|
supports_options: false,
|
||||||
supports_remove_device: false,
|
supports_remove_device: false,
|
||||||
supports_unload: true,
|
supports_unload: true,
|
||||||
|
supports_reconfigure: true,
|
||||||
disabled_by: null,
|
disabled_by: null,
|
||||||
pref_disable_new_entities: false,
|
pref_disable_new_entities: false,
|
||||||
pref_disable_polling: false,
|
pref_disable_polling: false,
|
||||||
|
@ -18,6 +18,7 @@ export interface ConfigEntry {
|
|||||||
supports_options: boolean;
|
supports_options: boolean;
|
||||||
supports_remove_device: boolean;
|
supports_remove_device: boolean;
|
||||||
supports_unload: boolean;
|
supports_unload: boolean;
|
||||||
|
supports_reconfigure: boolean;
|
||||||
pref_disable_new_entities: boolean;
|
pref_disable_new_entities: boolean;
|
||||||
pref_disable_polling: boolean;
|
pref_disable_polling: boolean;
|
||||||
disabled_by: "user" | null;
|
disabled_by: "user" | null;
|
||||||
|
@ -26,13 +26,18 @@ const HEADERS = {
|
|||||||
"HA-Frontend-Base": `${location.protocol}//${location.host}`,
|
"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>(
|
hass.callApi<DataEntryFlowStep>(
|
||||||
"POST",
|
"POST",
|
||||||
"config/config_entries/flow",
|
"config/config_entries/flow",
|
||||||
{
|
{
|
||||||
handler,
|
handler,
|
||||||
show_advanced_options: Boolean(hass.userData?.showAdvanced),
|
show_advanced_options: Boolean(hass.userData?.showAdvanced),
|
||||||
|
entry_id,
|
||||||
},
|
},
|
||||||
HEADERS
|
HEADERS
|
||||||
);
|
);
|
||||||
|
@ -23,7 +23,7 @@ export const showConfigFlowDialog = (
|
|||||||
loadDevicesAndAreas: true,
|
loadDevicesAndAreas: true,
|
||||||
createFlow: async (hass, handler) => {
|
createFlow: async (hass, handler) => {
|
||||||
const [step] = await Promise.all([
|
const [step] = await Promise.all([
|
||||||
createConfigFlow(hass, handler),
|
createConfigFlow(hass, handler, dialogParams.entryId),
|
||||||
hass.loadFragmentTranslation("config"),
|
hass.loadFragmentTranslation("config"),
|
||||||
hass.loadBackendTranslation("config", handler),
|
hass.loadBackendTranslation("config", handler),
|
||||||
hass.loadBackendTranslation("selector", handler),
|
hass.loadBackendTranslation("selector", handler),
|
||||||
|
@ -139,6 +139,7 @@ export interface DataEntryFlowDialogParams {
|
|||||||
}) => void;
|
}) => void;
|
||||||
flowConfig: FlowConfig;
|
flowConfig: FlowConfig;
|
||||||
showAdvanced?: boolean;
|
showAdvanced?: boolean;
|
||||||
|
entryId?: string;
|
||||||
dialogParentElement?: HTMLElement;
|
dialogParentElement?: HTMLElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
mdiRenameBox,
|
mdiRenameBox,
|
||||||
mdiShapeOutline,
|
mdiShapeOutline,
|
||||||
mdiStopCircleOutline,
|
mdiStopCircleOutline,
|
||||||
|
mdiWrench,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
@ -806,6 +807,19 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
</a>`
|
</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
|
<ha-list-item
|
||||||
@request-selected=${this._handleSystemOptions}
|
@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 {
|
private _handleDelete(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||||
return;
|
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) {
|
private async _editEntryName(configEntry: ConfigEntry) {
|
||||||
const newName = await showPromptDialog(this, {
|
const newName = await showPromptDialog(this, {
|
||||||
title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
|
title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
|
||||||
|
@ -3959,6 +3959,7 @@
|
|||||||
"delete_confirm_title": "Delete {title}?",
|
"delete_confirm_title": "Delete {title}?",
|
||||||
"delete_confirm_text": "Its devices and entities will be permanently deleted.",
|
"delete_confirm_text": "Its devices and entities will be permanently deleted.",
|
||||||
"enable_debug_logging": "Enable debug logging",
|
"enable_debug_logging": "Enable debug logging",
|
||||||
|
"reconfigure": "Reconfigure",
|
||||||
"reload": "Reload",
|
"reload": "Reload",
|
||||||
"restart_confirm": "Restart Home Assistant to finish removing this integration",
|
"restart_confirm": "Restart Home Assistant to finish removing this integration",
|
||||||
"reload_confirm": "The integration was reloaded",
|
"reload_confirm": "The integration was reloaded",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user