mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Add option to delete add-on config on uninstall (#22268)
This commit is contained in:
parent
849cfed669
commit
54320c3dbf
@ -38,6 +38,7 @@ import "../../../../src/components/ha-markdown";
|
||||
import "../../../../src/components/ha-settings-row";
|
||||
import "../../../../src/components/ha-svg-icon";
|
||||
import "../../../../src/components/ha-switch";
|
||||
import type { HaSwitch } from "../../../../src/components/ha-switch";
|
||||
import {
|
||||
AddonCapability,
|
||||
HassioAddonDetails,
|
||||
@ -1119,12 +1120,28 @@ class HassioAddonInfo extends LitElement {
|
||||
private async _uninstallClicked(ev: CustomEvent): Promise<void> {
|
||||
const button = ev.currentTarget as any;
|
||||
button.progress = true;
|
||||
let removeData = false;
|
||||
const _removeDataToggled = (e: Event) => {
|
||||
removeData = (e.target as HaSwitch).checked;
|
||||
};
|
||||
|
||||
const confirmed = await showConfirmationDialog(this, {
|
||||
title: this.supervisor.localize("dialog.uninstall_addon.title", {
|
||||
name: this.addon.name,
|
||||
}),
|
||||
text: this.supervisor.localize("dialog.uninstall_addon.text"),
|
||||
text: html`
|
||||
<ha-formfield
|
||||
.label=${html`<p>
|
||||
${this.supervisor.localize("dialog.uninstall_addon.remove_data")}
|
||||
</p>`}
|
||||
>
|
||||
<ha-switch
|
||||
@change=${_removeDataToggled}
|
||||
.checked=${removeData}
|
||||
haptic
|
||||
></ha-switch>
|
||||
</ha-formfield>
|
||||
`,
|
||||
confirmText: this.supervisor.localize("dialog.uninstall_addon.uninstall"),
|
||||
dismissText: this.supervisor.localize("common.cancel"),
|
||||
destructive: true,
|
||||
@ -1137,7 +1154,7 @@ class HassioAddonInfo extends LitElement {
|
||||
|
||||
this._error = undefined;
|
||||
try {
|
||||
await uninstallHassioAddon(this.hass, this.addon.slug);
|
||||
await uninstallHassioAddon(this.hass, this.addon.slug, removeData);
|
||||
const eventdata = {
|
||||
success: true,
|
||||
response: undefined,
|
||||
|
@ -358,21 +358,24 @@ export const restartHassioAddon = async (
|
||||
|
||||
export const uninstallHassioAddon = async (
|
||||
hass: HomeAssistant,
|
||||
slug: string
|
||||
) => {
|
||||
slug: string,
|
||||
removeData: boolean
|
||||
): Promise<void> => {
|
||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||
await hass.callWS({
|
||||
type: "supervisor/api",
|
||||
endpoint: `/addons/${slug}/uninstall`,
|
||||
method: "post",
|
||||
timeout: null,
|
||||
data: { remove_config: removeData },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await hass.callApi<HassioResponse<void>>(
|
||||
"POST",
|
||||
`hassio/addons/${slug}/uninstall`
|
||||
`hassio/addons/${slug}/uninstall`,
|
||||
{ remove_config: removeData }
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -7754,7 +7754,7 @@
|
||||
},
|
||||
"uninstall_addon": {
|
||||
"title": "Uninstall {name}?",
|
||||
"text": "Its configuration will be permanently deleted.",
|
||||
"remove_data": "Also permanently delete this addon's data",
|
||||
"uninstall": "Uninstall"
|
||||
},
|
||||
"hardware": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user