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