Added tooltip to delete user button if user is admin

This commit is contained in:
Andrew 2023-05-08 12:26:52 +07:00
parent b755d60939
commit 0c1b4eb885

View file

@ -799,16 +799,28 @@ class UsersListPanel extends GetView<UserListPanelController> {
final isAdmin = final isAdmin =
adminList.any((element) => element.id == user.id); adminList.any((element) => element.id == user.id);
if (isAdmin) return const SizedBox();
return ElevatedButton.icon( final isCurrentUser =
user.accessToken == ApiController.to.token;
if (isCurrentUser) return const SizedBox();
final btn = ElevatedButton.icon(
onPressed: () => controller.deleteUser(user), onPressed: () => controller.deleteUser(user),
icon: const Icon(Icons.delete_forever), icon: const Icon(Icons.delete_forever),
label: const Text("Delete user"), label: const Text("Delete user"),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.redAccent, backgroundColor: Colors.redAccent,
), ),
);
if (isAdmin) {
return Tooltip(
message: "Please note that this user is an admin",
child: btn,
).paddingAll(8).expanded(); ).paddingAll(8).expanded();
}
return btn.paddingAll(8).expanded();
}, },
), ),
], ],