Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add widget force delete button #37

Merged
merged 1 commit into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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("名称"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"detail": "detail",
"email": "email",
"execute": "execute",
"forceDelete": "forceDelete",
"isLeader": "Is Leader",
"languageSettings": "Language Settings",
"name": "name",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"detail": "详细信息",
"email": "邮箱",
"execute": "执行",
"forceDelete": "强制删除",
"isLeader": "是否是主节点",
"languageSettings": "语言设置",
"name": "名称",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/bk/bk_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class _BkPageState extends State<BkPage> {
DataCell(Text(itemRow.name)),
DataCell(Text(itemRow.host)),
DataCell(Text(itemRow.port.toString())),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteBk(itemRow.id);
}),
]))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/code/code_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _CodeListPageState extends State<CodeListPage> {
DataCell(Text(itemRow.id.toString())),
DataCell(Text(itemRow.name)),
DataCell(Text(itemRow.code)),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteCode(itemRow.id);
}),
]))
Expand Down
87 changes: 87 additions & 0 deletions lib/ui/component/force_delete_button.dart
Original file line number Diff line number Diff line change
@@ -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<StatefulWidget> createState() {
return new __ForceDeleteButtonState(callback);
}
}

class __ForceDeleteButtonState extends State<ForceDeleteButton> {
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: <Widget>[
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));
}
}
2 changes: 1 addition & 1 deletion lib/ui/kubernetes/k8s_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _K8sPageState extends State<K8sPage> {
.map((itemRow) => DataRow(onSelectChanged: (bool? selected) {}, cells: [
DataCell(Text(itemRow.id.toString())),
DataCell(Text(itemRow.name)),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteKubernetes(itemRow.id);
}),
]))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/mongo/mongo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class _MongoPageState extends State<MongoPage> {
DataCell(Text(itemRow.name)),
DataCell(Text(itemRow.addr)),
DataCell(Text(itemRow.username)),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteMongo(itemRow.id);
}),
]))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/mysql/mysql_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _MysqlPageState extends State<MysqlPage> {
DataCell(Text(itemRow.host)),
DataCell(Text(itemRow.port.toString())),
DataCell(Text(itemRow.username)),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteMysql(itemRow.id);
}),
]))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/pulsar_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class _PulsarPageState extends State<PulsarPage> {
DataCell(Text(itemRow.port.toString())),
DataCell(Text(itemRow.functionHost)),
DataCell(Text(itemRow.functionPort.toString())),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deletePulsar(itemRow.id);
}),
]))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/screen/pulsar_tenant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PulsarTenantScreenState extends State<PulsarTenantScreen> {
DataCell(
Text(item.namespace),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteNamespace(item.namespace);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {
DataCell(
Text(item.tenant),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteTenants(item.tenant);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_partitioned_topic_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PulsarPartitionedTopicListWidgetState extends State<PulsarPartitionedTopic
DataCell(
Text(item.topic),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deletePartitionedTopic(item.topic);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_sink_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PulsarSinkListWidgetState extends State<PulsarSinkListWidget> {
DataCell(
Text(item.sinkName),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteSink(item.sinkName);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_source_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PulsarSourceListWidgetState extends State<PulsarSourceListWidget> {
DataCell(
Text(item.sourceName),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteSource(item.sourceName);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pulsar/widget/pulsar_topic_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PulsarTopicListWidgetState extends State<PulsarTopicListWidget> {
DataCell(
Text(item.topic),
),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteTopic(item.topic);
}),
]));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/sql/sql_list_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _SqlListPageState extends State<SqlListPage> {
DataCell(Text(itemRow.id.toString())),
DataCell(Text(itemRow.name)),
DataCell(Text(itemRow.sql)),
DataCellUtil.newDellDataCell(() {
DataCellUtil.newDelDataCell(() {
vm.deleteSql(itemRow.id);
}),
]))
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/util/data_cell_util.dart
Original file line number Diff line number Diff line change
@@ -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));
}
}