mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: add back invitation success toast (#5875)
This commit is contained in:
parent
5fbaf664ba
commit
a798b037db
@ -10,6 +10,7 @@ import 'package:appflowy/workspace/presentation/settings/shared/settings_categor
|
||||
import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart';
|
||||
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
|
||||
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/code.pbenum.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:appflowy_popover/appflowy_popover.dart';
|
||||
@ -35,7 +36,8 @@ class WorkspaceMembersPage extends StatelessWidget {
|
||||
return BlocProvider<WorkspaceMemberBloc>(
|
||||
create: (context) => WorkspaceMemberBloc(userProfile: userProfile)
|
||||
..add(const WorkspaceMemberEvent.initial()),
|
||||
child: BlocBuilder<WorkspaceMemberBloc, WorkspaceMemberState>(
|
||||
child: BlocConsumer<WorkspaceMemberBloc, WorkspaceMemberState>(
|
||||
listener: _showResultDialog,
|
||||
builder: (context, state) {
|
||||
return SettingsBody(
|
||||
title: LocaleKeys.settings_appearance_members_title.tr(),
|
||||
@ -160,6 +162,63 @@ class WorkspaceMembersPage extends StatelessWidget {
|
||||
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void _showResultDialog(BuildContext context, WorkspaceMemberState state) {
|
||||
final actionResult = state.actionResult;
|
||||
if (actionResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final actionType = actionResult.actionType;
|
||||
final result = actionResult.result;
|
||||
|
||||
// only show the result dialog when the action is WorkspaceMemberActionType.add
|
||||
if (actionType == WorkspaceMemberActionType.add) {
|
||||
result.fold(
|
||||
(s) {
|
||||
showSnackBarMessage(
|
||||
context,
|
||||
LocaleKeys.settings_appearance_members_addMemberSuccess.tr(),
|
||||
);
|
||||
},
|
||||
(f) {
|
||||
Log.error('add workspace member failed: $f');
|
||||
final message = f.code == ErrorCode.WorkspaceMemberLimitExceeded
|
||||
? LocaleKeys.settings_appearance_members_memberLimitExceeded.tr()
|
||||
: LocaleKeys.settings_appearance_members_failedToAddMember.tr();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => NavigatorOkCancelDialog(message: message),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (actionType == WorkspaceMemberActionType.invite) {
|
||||
result.fold(
|
||||
(s) {
|
||||
showSnackBarMessage(
|
||||
context,
|
||||
LocaleKeys.settings_appearance_members_inviteMemberSuccess.tr(),
|
||||
);
|
||||
},
|
||||
(f) {
|
||||
Log.error('invite workspace member failed: $f');
|
||||
final message = f.code == ErrorCode.WorkspaceMemberLimitExceeded
|
||||
? LocaleKeys.settings_appearance_members_inviteFailedMemberLimit
|
||||
.tr()
|
||||
: LocaleKeys.settings_appearance_members_failedToInviteMember
|
||||
.tr();
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: LocaleKeys
|
||||
.settings_appearance_members_inviteFailedDialogTitle
|
||||
.tr(),
|
||||
description: message,
|
||||
confirmLabel: LocaleKeys.button_ok.tr(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _InviteMember extends StatefulWidget {
|
||||
|
@ -1096,6 +1096,8 @@
|
||||
"one": "{} member",
|
||||
"other": "{} members"
|
||||
},
|
||||
"inviteFailedDialogTitle": "Failed to send invite",
|
||||
"inviteFailedMemberLimit": "Member limit has been reached, please upgrade to invite more members.",
|
||||
"memberLimitExceeded": "Member limit reached, to invite more members, please ",
|
||||
"memberLimitExceededUpgrade": "upgrade",
|
||||
"memberLimitExceededPro": "Member limit reached, if you require more members contact ",
|
||||
|
Loading…
Reference in New Issue
Block a user