(
target,
{ deleteConfig = false, deleteData = false, skipConfirm = false } = {},
)
| 571 | }; |
| 572 | |
| 573 | const uninstall = async ( |
| 574 | target, |
| 575 | { deleteConfig = false, deleteData = false, skipConfirm = false } = {}, |
| 576 | ) => { |
| 577 | if (!target?.id || !target?.kind) return; |
| 578 | |
| 579 | if (!skipConfirm) { |
| 580 | requestUninstall(target); |
| 581 | return; |
| 582 | } |
| 583 | |
| 584 | const isFailed = target.kind === "failed"; |
| 585 | const options = { |
| 586 | delete_config: deleteConfig, |
| 587 | delete_data: deleteData, |
| 588 | }; |
| 589 | |
| 590 | toast(`${tm("messages.uninstalling")} ${target.id}`, "primary"); |
| 591 | |
| 592 | try { |
| 593 | const res = isFailed |
| 594 | ? await pluginApi.uninstallFailed(target.id, options) |
| 595 | : await pluginApi.uninstall(target.id, options); |
| 596 | if (res.data.status === "error") { |
| 597 | toast(res.data.message, "error"); |
| 598 | return; |
| 599 | } |
| 600 | if (!isFailed) { |
| 601 | Object.assign(extension_data, res.data); |
| 602 | } |
| 603 | toast(res.data.message, "success"); |
| 604 | await getExtensions(); |
| 605 | } catch (err) { |
| 606 | toast(resolveErrorMessage(err, tm("messages.operationFailed")), "error"); |
| 607 | } |
| 608 | }; |
| 609 | |
| 610 | const requestUninstallPlugin = (name) => { |
| 611 | if (!name) return; |
no test coverage detected