Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: owner can delete spaces created by other users (#6672)
Ahad Patela9a784f0f039
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/space_more_popup.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/space_more_popup.dartindex d7eb5330aa..588dee5398 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/space_more_popup.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/space_more_popup.dart@@ -1,8 +1,10 @@import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/shared/af_role_pb_extension.dart';import 'package:appflowy/shared/icon_emoji_picker/flowy_icon_emoji_picker.dart';import 'package:appflowy/shared/icon_emoji_picker/tab.dart';import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart';+import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/space_action_type.dart';import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';@@ -147,13 +149,24 @@ class SpaceMoreActionTypeWrapper extends CustomActionCell {final spaces = spaceBloc.state.spaces;final currentSpace = spaceBloc.state.currentSpace;+ final isOwner = context+ .read<UserWorkspaceBloc?>()+ ?.state+ .currentWorkspaceMember+ ?.role+ .isOwner ??+ false;+ final isPageCreator =+ currentSpace?.createdBy == context.read<UserProfilePB>().id;+ final allowToDelete = isOwner || isPageCreator;+bool disable = false;var message = '';if (inner == SpaceMoreActionType.delete) {if (spaces.length <= 1) {disable = true;message = LocaleKeys.space_unableToDeleteLastSpace.tr();- } else if (currentSpace?.createdBy != context.read<UserProfilePB>().id) {+ } else if (!allowToDelete) {disable = true;message = LocaleKeys.space_unableToDeleteSpaceNotCreatedByYou.tr();}