diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 0657f0e..91a5fd4 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -8,6 +8,7 @@ // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -42,6 +43,7 @@ class MessageLookup extends MessageLookupByLibrary { "detail": MessageLookupByLibrary.simpleMessage("detail"), "email": MessageLookupByLibrary.simpleMessage("email"), "execute": MessageLookupByLibrary.simpleMessage("execute"), + "forceDelete": MessageLookupByLibrary.simpleMessage("forceDelete"), "isLeader": MessageLookupByLibrary.simpleMessage("Is Leader"), "languageSettings": MessageLookupByLibrary.simpleMessage("Language Settings"), "name": MessageLookupByLibrary.simpleMessage("name"), diff --git a/lib/generated/intl/messages_zh.dart b/lib/generated/intl/messages_zh.dart index 99e1fdc..5cd8513 100644 --- a/lib/generated/intl/messages_zh.dart +++ b/lib/generated/intl/messages_zh.dart @@ -8,6 +8,7 @@ // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -42,6 +43,7 @@ class MessageLookup extends MessageLookupByLibrary { "detail": MessageLookupByLibrary.simpleMessage("详细信息"), "email": MessageLookupByLibrary.simpleMessage("邮箱"), "execute": MessageLookupByLibrary.simpleMessage("执行"), + "forceDelete": MessageLookupByLibrary.simpleMessage("强制删除"), "isLeader": MessageLookupByLibrary.simpleMessage("是否是主节点"), "languageSettings": MessageLookupByLibrary.simpleMessage("语言设置"), "name": MessageLookupByLibrary.simpleMessage("名称"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 03a9764..ce4d2c7 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -258,6 +258,16 @@ class S { ); } + /// `forceDelete` + String get forceDelete { + return Intl.message( + 'forceDelete', + name: 'forceDelete', + desc: '', + args: [], + ); + } + /// `Is Leader` String get isLeader { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 41a62fc..2fe6b34 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -21,6 +21,7 @@ "detail": "detail", "email": "email", "execute": "execute", + "forceDelete": "forceDelete", "isLeader": "Is Leader", "languageSettings": "Language Settings", "name": "name", diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index 20eac49..f05fb3f 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -21,6 +21,7 @@ "detail": "详细信息", "email": "邮箱", "execute": "执行", + "forceDelete": "强制删除", "isLeader": "是否是主节点", "languageSettings": "语言设置", "name": "名称", diff --git a/lib/ui/bk/bk_page.dart b/lib/ui/bk/bk_page.dart index 3fbc79d..b430218 100644 --- a/lib/ui/bk/bk_page.dart +++ b/lib/ui/bk/bk_page.dart @@ -59,7 +59,7 @@ class _BkPageState extends State { DataCell(Text(itemRow.name)), DataCell(Text(itemRow.host)), DataCell(Text(itemRow.port.toString())), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteBk(itemRow.id); }), ])) diff --git a/lib/ui/code/code_list_page.dart b/lib/ui/code/code_list_page.dart index 859d834..d49bcb0 100644 --- a/lib/ui/code/code_list_page.dart +++ b/lib/ui/code/code_list_page.dart @@ -62,7 +62,7 @@ class _CodeListPageState extends State { DataCell(Text(itemRow.id.toString())), DataCell(Text(itemRow.name)), DataCell(Text(itemRow.code)), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteCode(itemRow.id); }), ])) diff --git a/lib/ui/component/force_delete_button.dart b/lib/ui/component/force_delete_button.dart new file mode 100644 index 0000000..fb782b6 --- /dev/null +++ b/lib/ui/component/force_delete_button.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; +import 'package:paas_dashboard_flutter/generated/l10n.dart'; + +class ForceDeleteButton extends StatefulWidget { + final Function(bool) callback; + + ForceDeleteButton(this.callback); + + @override + State createState() { + return new __ForceDeleteButtonState(callback); + } +} + +class __ForceDeleteButtonState extends State { + bool forceDelete = false; + + final Function(bool) callback; + + __ForceDeleteButtonState(this.callback); + + @override + Widget build(BuildContext context) { + return IconButton( + onPressed: () { + showDialog( + context: context, + builder: (context) { + return StatefulBuilder(builder: (context, setState) { + return AlertDialog( + title: Text( + S.of(context).confirmDeleteQuestion, + textAlign: TextAlign.center, + ), + content: Container( + width: 300, + height: 40, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + SizedBox( + width: 10, + ), //SizedBox + Text(S.of(context).forceDelete), //Text + SizedBox(width: 10), + Checkbox( + value: this.forceDelete, + onChanged: (value) { + setState(() { + if (value == null) { + this.forceDelete = false; + } else { + this.forceDelete = value; + } + }); + }, + ) + ], + ), + ), + actions: [ + TextButton( + child: Text( + S.of(context).cancel, + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text( + S.of(context).confirm, + ), + onPressed: () { + callback.call(forceDelete); + Navigator.of(context).pop(); + }, + ), + ], + ); + }); + }); + }, + icon: Icon(Icons.delete)); + } +} diff --git a/lib/ui/kubernetes/k8s_page.dart b/lib/ui/kubernetes/k8s_page.dart index b7e7f56..8bd4607 100644 --- a/lib/ui/kubernetes/k8s_page.dart +++ b/lib/ui/kubernetes/k8s_page.dart @@ -53,7 +53,7 @@ class _K8sPageState extends State { .map((itemRow) => DataRow(onSelectChanged: (bool? selected) {}, cells: [ DataCell(Text(itemRow.id.toString())), DataCell(Text(itemRow.name)), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteKubernetes(itemRow.id); }), ])) diff --git a/lib/ui/mongo/mongo_page.dart b/lib/ui/mongo/mongo_page.dart index 0238d6a..8610d15 100644 --- a/lib/ui/mongo/mongo_page.dart +++ b/lib/ui/mongo/mongo_page.dart @@ -64,7 +64,7 @@ class _MongoPageState extends State { DataCell(Text(itemRow.name)), DataCell(Text(itemRow.addr)), DataCell(Text(itemRow.username)), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteMongo(itemRow.id); }), ])) diff --git a/lib/ui/mysql/mysql_page.dart b/lib/ui/mysql/mysql_page.dart index 23cdf1b..86a7dda 100644 --- a/lib/ui/mysql/mysql_page.dart +++ b/lib/ui/mysql/mysql_page.dart @@ -66,7 +66,7 @@ class _MysqlPageState extends State { DataCell(Text(itemRow.host)), DataCell(Text(itemRow.port.toString())), DataCell(Text(itemRow.username)), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteMysql(itemRow.id); }), ])) diff --git a/lib/ui/pulsar/pulsar_page.dart b/lib/ui/pulsar/pulsar_page.dart index aba8f34..d95038c 100644 --- a/lib/ui/pulsar/pulsar_page.dart +++ b/lib/ui/pulsar/pulsar_page.dart @@ -47,7 +47,7 @@ class _PulsarPageState extends State { DataCell(Text(itemRow.port.toString())), DataCell(Text(itemRow.functionHost)), DataCell(Text(itemRow.functionPort.toString())), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deletePulsar(itemRow.id); }), ])) diff --git a/lib/ui/pulsar/screen/pulsar_tenant.dart b/lib/ui/pulsar/screen/pulsar_tenant.dart index 1c7057c..d574fed 100644 --- a/lib/ui/pulsar/screen/pulsar_tenant.dart +++ b/lib/ui/pulsar/screen/pulsar_tenant.dart @@ -55,7 +55,7 @@ class PulsarTenantScreenState extends State { DataCell( Text(item.namespace), ), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteNamespace(item.namespace); }), ])); diff --git a/lib/ui/pulsar/widget/pulsar_details.dart b/lib/ui/pulsar/widget/pulsar_details.dart index 496ea1a..8d4f7cd 100644 --- a/lib/ui/pulsar/widget/pulsar_details.dart +++ b/lib/ui/pulsar/widget/pulsar_details.dart @@ -55,7 +55,7 @@ class PulsarTenantsState extends State { DataCell( Text(item.tenant), ), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteTenants(item.tenant); }), ])); diff --git a/lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart b/lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart index 067d3ce..0893caa 100644 --- a/lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart +++ b/lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart @@ -56,7 +56,7 @@ class PulsarPartitionedTopicListWidgetState extends State { DataCell( Text(item.sinkName), ), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteSink(item.sinkName); }), ])); diff --git a/lib/ui/pulsar/widget/pulsar_source_list.dart b/lib/ui/pulsar/widget/pulsar_source_list.dart index 20765a2..f54f598 100644 --- a/lib/ui/pulsar/widget/pulsar_source_list.dart +++ b/lib/ui/pulsar/widget/pulsar_source_list.dart @@ -54,7 +54,7 @@ class PulsarSourceListWidgetState extends State { DataCell( Text(item.sourceName), ), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteSource(item.sourceName); }), ])); diff --git a/lib/ui/pulsar/widget/pulsar_topic_list.dart b/lib/ui/pulsar/widget/pulsar_topic_list.dart index 532730e..96f6725 100644 --- a/lib/ui/pulsar/widget/pulsar_topic_list.dart +++ b/lib/ui/pulsar/widget/pulsar_topic_list.dart @@ -55,7 +55,7 @@ class PulsarTopicListWidgetState extends State { DataCell( Text(item.topic), ), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteTopic(item.topic); }), ])); diff --git a/lib/ui/sql/sql_list_page.dart b/lib/ui/sql/sql_list_page.dart index 85b60fc..2e89725 100644 --- a/lib/ui/sql/sql_list_page.dart +++ b/lib/ui/sql/sql_list_page.dart @@ -62,7 +62,7 @@ class _SqlListPageState extends State { DataCell(Text(itemRow.id.toString())), DataCell(Text(itemRow.name)), DataCell(Text(itemRow.sql)), - DataCellUtil.newDellDataCell(() { + DataCellUtil.newDelDataCell(() { vm.deleteSql(itemRow.id); }), ])) diff --git a/lib/ui/util/data_cell_util.dart b/lib/ui/util/data_cell_util.dart index 9c043f1..a25c09f 100644 --- a/lib/ui/util/data_cell_util.dart +++ b/lib/ui/util/data_cell_util.dart @@ -1,8 +1,13 @@ import 'package:flutter/material.dart'; import 'package:paas_dashboard_flutter/ui/component/delete_button.dart'; +import 'package:paas_dashboard_flutter/ui/component/force_delete_button.dart'; class DataCellUtil { - static DataCell newDellDataCell(VoidCallback voidCallback) { + static DataCell newDelDataCell(VoidCallback voidCallback) { return DataCell(DeleteButton(voidCallback)); } + + static DataCell newForceDelDataCell(Function(bool) callback) { + return DataCell(ForceDeleteButton(callback)); + } }