Skip to content

Commit

Permalink
feat: confirm before removing a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lideming committed Jun 7, 2023
1 parent fd067f4 commit fa490c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/I18n/i18n-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
["Add plugin by code", "添加插件代码"],
["Enable", "启用"],
["Disable", "禁用"],
["Are you sure to remove plugin \"{0}\"?", "确定要移除插件 \"{0}\" 吗?"],
["Edit plugin code", "编辑插件代码"],
["Plugin code", "插件代码"],
["Plugin \"{0}\" loading...", "插件 \"{0}\" 加载中……"],
Expand Down
18 changes: 15 additions & 3 deletions src/Plugins/pluginsUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
InputView,
ListView,
ListViewItem,
MessageBox,
TextBtn,
} from "@yuuza/webfx";
import { PluginListItem, plugins } from "./plugins";
Expand Down Expand Up @@ -170,9 +171,20 @@ export class PluginListViewItem extends ListViewItem {
text: () => I`Remove`,
type: "inline",
onActive: () => {
plugins
.removeUserPlugin(this.data.url)
.then(() => this.onChange.invoke());
new MessageBox()
.setTitle(I`Warning`)
.addText(
I`Are you sure to remove plugin "${this.data.name}"?`,
)
.addResultBtns(["cancel", "ok"])
.allowCloseWithResult("cancel")
.showAndWaitResult()
.then((r) => {
if (r !== "ok") return;
plugins
.removeUserPlugin(this.data.url)
.then(() => this.onChange.invoke());
});
},
}),
{
Expand Down

0 comments on commit fa490c4

Please sign in to comment.