Skip to content

Commit

Permalink
Add delete confirm to delete button.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj committed Aug 2, 2021
1 parent 6b0d03b commit 7b9170b
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 27 deletions.
13 changes: 12 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"appName": MessageLookupByLibrary.simpleMessage("Paas Dashboard"),
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
"clearBacklog": MessageLookupByLibrary.simpleMessage("Clear Backlog"),
"confirm": MessageLookupByLibrary.simpleMessage("Confirm"),
"confirmDeleteQuestion":
MessageLookupByLibrary.simpleMessage("ConfirmDelete?"),
"delete": MessageLookupByLibrary.simpleMessage("Delete"),
"refresh": MessageLookupByLibrary.simpleMessage("Refresh")
"deleteNamespace":
MessageLookupByLibrary.simpleMessage("Delete Namespace"),
"deleteTenant": MessageLookupByLibrary.simpleMessage("Delete Tenant"),
"deleteTopic": MessageLookupByLibrary.simpleMessage("Delete Topic"),
"namespaceName": MessageLookupByLibrary.simpleMessage("Namespace Name"),
"refresh": MessageLookupByLibrary.simpleMessage("Refresh"),
"tenantName": MessageLookupByLibrary.simpleMessage("Tenant Name"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic Name")
};
}
11 changes: 10 additions & 1 deletion lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"appName": MessageLookupByLibrary.simpleMessage("Paas 仪表盘"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
"clearBacklog": MessageLookupByLibrary.simpleMessage("清理积压"),
"confirm": MessageLookupByLibrary.simpleMessage("确认"),
"confirmDeleteQuestion": MessageLookupByLibrary.simpleMessage("确认删除吗?"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"refresh": MessageLookupByLibrary.simpleMessage("刷新")
"deleteNamespace": MessageLookupByLibrary.simpleMessage("删除命名空间"),
"deleteTenant": MessageLookupByLibrary.simpleMessage("删除租户"),
"deleteTopic": MessageLookupByLibrary.simpleMessage("删除 Topic"),
"namespaceName": MessageLookupByLibrary.simpleMessage("命名空间名称"),
"refresh": MessageLookupByLibrary.simpleMessage("刷新"),
"tenantName": MessageLookupByLibrary.simpleMessage("租户名称"),
"topicName": MessageLookupByLibrary.simpleMessage("Topic 名称")
};
}
90 changes: 90 additions & 0 deletions lib/generated/l10n.dart

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

9 changes: 9 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
"appName": "Paas Dashboard",
"refresh": "Refresh",
"delete": "Delete",
"cancel": "Cancel",
"confirm": "Confirm",
"confirmDeleteQuestion": "ConfirmDelete?",
"tenantName": "Tenant Name",
"deleteTenant": "Delete Tenant",
"namespaceName": "Namespace Name",
"deleteNamespace": "Delete Namespace",
"topicName": "Topic Name",
"deleteTopic": "Delete Topic",
"clearBacklog": "Clear Backlog"
}
9 changes: 9 additions & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
"appName": "Paas 仪表盘",
"refresh": "刷新",
"delete": "删除",
"cancel": "取消",
"confirm": "确认",
"confirmDeleteQuestion": "确认删除吗?",
"tenantName": "租户名称",
"deleteTenant": "删除租户",
"namespaceName": "命名空间名称",
"deleteNamespace": "删除命名空间",
"topicName": "Topic 名称",
"deleteTopic": "删除 Topic",
"clearBacklog": "清理积压"
}
45 changes: 45 additions & 0 deletions lib/ui/component/delete_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';

class DeleteButton extends StatelessWidget {
final VoidCallback voidCallback;

DeleteButton(this.voidCallback);

@override
Widget build(BuildContext context) {
return IconButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
S.of(context).confirmDeleteQuestion,
textAlign: TextAlign.center,
),
actions: <Widget>[
TextButton(
child: Text(
S.of(context).cancel,
),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text(
S.of(context).confirm,
),
onPressed: () {
voidCallback.call();
Navigator.of(context).pop();
},
),
],
);
});
},
icon: Icon(Icons.delete));
}
}
14 changes: 6 additions & 8 deletions lib/ui/pulsar/screen/pulsar_namespace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
import 'package:paas_dashboard_flutter/ui/util/data_cell_util.dart';
import 'package:paas_dashboard_flutter/ui/util/form_util.dart';
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_namespace_view_model.dart';
Expand Down Expand Up @@ -64,19 +65,16 @@ class PulsarNamespaceScreenState extends State<PulsarNamespaceScreen> {
DataCell(
Text(item.topic),
),
DataCell(TextButton(
child: Text('Delete'),
onPressed: () {
vm.deleteTopic(item.topic);
},
)),
DataCellUtil.newDellDataCell(() {
vm.deleteTopic(item.topic);
}),
]));
var topicsTable = SingleChildScrollView(
child: PaginatedDataTable(
showCheckboxColumn: false,
columns: [
DataColumn(label: Text('Topic Name')),
DataColumn(label: Text('Delete Topic')),
DataColumn(label: Text(S.of(context).topicName)),
DataColumn(label: Text(S.of(context).deleteTopic)),
],
source: vm),
);
Expand Down
14 changes: 6 additions & 8 deletions lib/ui/pulsar/screen/pulsar_tenant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
import 'package:paas_dashboard_flutter/ui/util/data_cell_util.dart';
import 'package:paas_dashboard_flutter/ui/util/form_util.dart';
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_tenant_view_model.dart';
Expand Down Expand Up @@ -64,12 +65,9 @@ class PulsarTenantScreenState extends State<PulsarTenantScreen> {
DataCell(
Text(item.namespace),
),
DataCell(TextButton(
child: Text(S.of(context).delete),
onPressed: () {
vm.deleteNamespace(item.namespace);
},
)),
DataCellUtil.newDellDataCell(() {
vm.deleteNamespace(item.namespace);
}),
]));
var formButton = createNamespace(context);
var refreshButton = TextButton(
Expand Down Expand Up @@ -101,8 +99,8 @@ class PulsarTenantScreenState extends State<PulsarTenantScreen> {
child: PaginatedDataTable(
showCheckboxColumn: false,
columns: [
DataColumn(label: Text('Namespace Name')),
DataColumn(label: Text('Delete namespace')),
DataColumn(label: Text(S.of(context).namespaceName)),
DataColumn(label: Text(S.of(context).deleteNamespace)),
],
source: vm),
),
Expand Down
16 changes: 7 additions & 9 deletions lib/ui/pulsar/tab/pulsar_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
import 'package:paas_dashboard_flutter/ui/util/data_cell_util.dart';
import 'package:paas_dashboard_flutter/ui/util/form_util.dart';
import 'package:paas_dashboard_flutter/ui/util/spinner_util.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_instance_view_model.dart';
Expand Down Expand Up @@ -64,12 +65,9 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {
DataCell(
Text(item.tenant),
),
DataCell(TextButton(
child: Text(S.of(context).delete),
onPressed: () {
vm.deleteTenants(item.tenant);
},
)),
DataCellUtil.newDellDataCell(() {
vm.deleteTenants(item.tenant);
})
]));
var formButton = createTenant(context, vm.host, vm.port);
var refreshButton = TextButton(
Expand Down Expand Up @@ -101,8 +99,8 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {
child: PaginatedDataTable(
showCheckboxColumn: false,
columns: [
DataColumn(label: Text('TenantName')),
DataColumn(label: Text('Delete tenant')),
DataColumn(label: Text(S.of(context).tenantName)),
DataColumn(label: Text(S.of(context).deleteTenant)),
],
source: vm),
)
Expand All @@ -113,7 +111,7 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {

ButtonStyleButton createTenant(BuildContext context, String host, int port) {
final vm = Provider.of<PulsarInstanceViewModel>(context, listen: false);
var list = [FormFieldDef('Tenant Name')];
var list = [FormFieldDef(S.of(context).tenantName)];
return FormUtil.createButton1("Pulsar Tenant", list, context,
(tenant) async {
vm.createTenant(tenant);
Expand Down
8 changes: 8 additions & 0 deletions lib/ui/util/data_cell_util.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/ui/component/delete_button.dart';

class DataCellUtil {
static DataCell newDellDataCell(VoidCallback voidCallback) {
return DataCell(DeleteButton(voidCallback));
}
}

0 comments on commit 7b9170b

Please sign in to comment.