Skip to content

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.

feat: implement section breadcrumb and new share menu design (#8012)

Lucas88a3e9edddbe
diff --git a/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/page_access_level_repository.dart b/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/page_access_level_repository.dart
index c91ea152c2..aefe238ac7 100644
--- a/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/page_access_level_repository.dart
+++ b/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/page_access_level_repository.dart
@@ -1,4 +1,4 @@
-import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';
+import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_result/appflowy_result.dart';
@@ -21,4 +21,9 @@ abstract class PageAccessLevelRepository {
Future<FlowyResult<ShareAccessLevel, FlowyError>> getAccessLevel(
String pageId,
);
+
+ /// Gets the section type of the shared section.
+ Future<FlowyResult<SharedSectionType, FlowyError>> getSectionType(
+ String pageId,
+ );
}
diff --git a/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/rust_page_access_level_repository_impl.dart b/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/rust_page_access_level_repository_impl.dart
index bb94959d96..e4c9c025e8 100644
--- a/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/rust_page_access_level_repository_impl.dart
+++ b/frontend/appflowy_flutter/lib/features/page_access_level/data/repositories/rust_page_access_level_repository_impl.dart
@@ -1,5 +1,5 @@
import 'package:appflowy/features/page_access_level/data/repositories/page_access_level_repository.dart';
-import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';
+import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy/features/util/extensions.dart';
import 'package:appflowy/user/application/user_service.dart';
import 'package:appflowy/workspace/application/view/view_service.dart';
@@ -102,16 +102,40 @@ class RustPageAccessLevelRepositoryImpl implements PageAccessLevelRepository {
.shareAccessLevel ??
ShareAccessLevel.readAndWrite;
- Log.debug('current user access level: $accessLevel');
+ Log.debug('current user access level: $accessLevel, in page: $pageId');
return FlowyResult.success(accessLevel);
},
(failure) {
- Log.error('failed to get user access level: $failure');
+ Log.error(
+ 'failed to get user access level: $failure, in page: $pageId',
+ );
// return the read and write access level if the user is not found
return FlowyResult.success(ShareAccessLevel.readAndWrite);
},
);
}
+
+ @override
+ Future<FlowyResult<SharedSectionType, FlowyError>> getSectionType(
+ String pageId,
+ ) async {
+ final request = ViewIdPB(value: pageId);
+ final result = await FolderEventGetSharedViewSection(request).send();
+ return result.fold(
+ (success) {
+ final sectionType = success.section.sharedSectionType;
+ Log.debug('shared section type: $sectionType, in page: $pageId');
+ return FlowyResult.success(sectionType);
+ },
+ (failure) {
+ Log.error(
+ 'failed to get shared section type: $failure, in page: $pageId',
+ );
+
+ return FlowyResult.failure(failure);
+ },
+ );
+ }
}
diff --git a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_bloc.dart b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_bloc.dart
index dd22ff4860..14f80c8463 100644
--- a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_bloc.dart
+++ b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_bloc.dart
@@ -4,7 +4,7 @@ import 'package:appflowy/features/page_access_level/data/repositories/page_acces
import 'package:appflowy/features/page_access_level/data/repositories/rust_page_access_level_repository_impl.dart';
import 'package:appflowy/features/page_access_level/logic/page_access_level_event.dart';
import 'package:appflowy/features/page_access_level/logic/page_access_level_state.dart';
-import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';
+import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
@@ -18,6 +18,7 @@ class PageAccessLevelBloc
extends Bloc<PageAccessLevelEvent, PageAccessLevelState> {
PageAccessLevelBloc({
required this.view,
+ this.ignorePageAccessLevel = false,
PageAccessLevelRepository? repository,
}) : repository = repository ?? RustPageAccessLevelRepositoryImpl(),
listener = ViewListener(viewId: view.id),
@@ -26,6 +27,7 @@ class PageAccessLevelBloc
on<PageAccessLevelLockEvent>(_onLock);
on<PageAccessLevelUnlockEvent>(_onUnlock);
on<PageAccessLevelUpdateLockStatusEvent>(_onUpdateLockStatus);
+ on<PageAccessLevelUpdateSectionTypeEvent>(_onUpdateSectionType);
}
final ViewPB view;
@@ -37,6 +39,10 @@ class PageAccessLevelBloc
// Used to listen for view updates.
late final ViewListener listener;
+ // should ignore the page access level
+ // in the row details page, we don't need to check the page access level
+ final bool ignorePageAccessLevel;
+
@override
Future<void> close() async {
await listener.stop();
@@ -47,19 +53,28 @@ class PageAccessLevelBloc
PageAccessLevelInitialEvent event,
Emitter<PageAccessLevelState> emit,
) async {
+ // lock status
listener.start(
onViewUpdated: (view) async {
add(PageAccessLevelEvent.updateLockStatus(view.isLocked));
},
);
- if (!FeatureFlag.sharedSection.isOn) {
+ // section type
+ final sectionTypeResult = await repository.getSectionType(view.id);
+ final sectionType = sectionTypeResult.fold(
+ (sectionType) => sectionType,
+ (_) => SharedSectionType.public,
+ );
+
+ if (!FeatureFlag.sharedSection.isOn || ignorePageAccessLevel) {
emit(
state.copyWith(
view: view,
isLocked: view.isLocked,
isLoadingLockStatus: false,
accessLevel: ShareAccessLevel.fullAccess,
+ sectionType: sectionType,
),
);
return;
@@ -80,6 +95,7 @@ class PageAccessLevelBloc
(accessLevel) => accessLevel,
(_) => ShareAccessLevel.readOnly,
),
+ sectionType: sectionType,
),
);
}
@@ -133,4 +149,15 @@ class PageAccessLevelBloc
),
);
}
+
+ void _onUpdateSectionType(
+ PageAccessLevelUpdateSectionTypeEvent event,
+ Emitter<PageAccessLevelState> emit,
+ ) {
+ emit(
+ state.copyWith(
+ sectionType: event.sectionType,
+ ),
+ );
+ }
}
diff --git a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_event.dart b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_event.dart
index c4538a7a05..8a1d004fcb 100644
--- a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_event.dart
+++ b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_event.dart
@@ -1,3 +1,5 @@
+import 'package:appflowy/features/share_tab/data/models/models.dart';
+
/// Base class for all PageAccessLevel events
sealed class PageAccessLevelEvent {
const PageAccessLevelEvent();
@@ -17,6 +19,11 @@ sealed class PageAccessLevelEvent {
bool isLocked, {
int? lockCounter,
}) = PageAccessLevelUpdateLockStatusEvent;
+
+ /// Update the section type in the state.
+ const factory PageAccessLevelEvent.updateSectionType(
+ SharedSectionType sectionType,
+ ) = PageAccessLevelUpdateSectionTypeEvent;
}
class PageAccessLevelInitialEvent extends PageAccessLevelEvent {
@@ -40,3 +47,9 @@ class PageAccessLevelUpdateLockStatusEvent extends PageAccessLevelEvent {
final bool isLocked;
final int? lockCounter;
}
+
+class PageAccessLevelUpdateSectionTypeEvent extends PageAccessLevelEvent {
+ const PageAccessLevelUpdateSectionTypeEvent(this.sectionType);
+
+ final SharedSectionType sectionType;
+}
diff --git a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_state.dart b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_state.dart
index 6b51450ac6..b674820a30 100644
--- a/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_state.dart
+++ b/frontend/appflowy_flutter/lib/features/page_access_level/logic/page_access_level_state.dart
@@ -1,4 +1,4 @@
-import 'package:appflowy/features/share_tab/data/models/share_access_level.dart';
+import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
@@ -7,6 +7,7 @@ class PageAccessLevelState {
view: view,
isLocked: false,
lockCounter: 0,
+ sectionType: SharedSectionType.public,
accessLevel: ShareAccessLevel
.readAndWrite, // replace it with readOnly if we support offline.
);
@@ -16,6 +17,8 @@ class PageAccessLevelState {
required this.isLocked,
required this.lockCounter,
required this.accessLevel,
+ required this.sectionType,
+ this.myRole,
this.isLoadingLockStatus = true,
});
@@ -24,6 +27,13 @@ class PageAccessLevelState {
final int lockCounter;
final bool isLoadingLockStatus;
final ShareAccessLevel accessLevel;
+ final SharedSectionType sectionType;
+ final ShareRole? myRole;
+
+ bool get isPublic => sectionType == SharedSectionType.public;
+ bool get isPrivate => sectionType == SharedSectionType.private;
+ bool get isShared => sectionType == SharedSectionType.shared;
+ bool get shouldHideSpace => myRole == ShareRole.guest;
bool get isEditable {
if (!FeatureFlag.sharedSection.isOn) {
@@ -41,6 +51,8 @@ class PageAccessLevelState {
int? lockCounter,
bool? isLoadingLockStatus,
ShareAccessLevel? accessLevel,
+ SharedSectionType? sectionType,
+ ShareRole? myRole,
}) {
return PageAccessLevelState(
view: view ?? this.view,
@@ -48,6 +60,8 @@ class PageAccessLevelState {
lockCounter: lockCounter ?? this.lockCounter,
isLoadingLockStatus: isLoadingLockStatus ?? this.isLoadingLockStatus,
accessLevel: accessLevel ?? this.accessLevel,
+ sectionType: sectionType ?? this.sectionType,
+ myRole: myRole ?? this.myRole,
);
}
@@ -59,7 +73,9 @@ class PageAccessLevelState {
other.isLocked == isLocked &&
other.lockCounter == lockCounter &&
other.isLoadingLockStatus == isLoadingLockStatus &&
- other.accessLevel == accessLevel;
+ other.accessLevel == accessLevel &&
+ other.sectionType == sectionType &&
+ other.myRole == myRole;
}
@override
@@ -70,11 +86,13 @@ class PageAccessLevelState {
lockCounter,
isLoadingLockStatus,
accessLevel,
+ sectionType,
+ myRole,
);
}
@override
String toString() {
- return 'PageAccessLevelState(view: $view, isLocked: $isLocked, lockCounter: $lockCounter, isLoadingLockStatus: $isLoadingLockStatus, accessLevel: $accessLevel)';
+ return 'PageAccessLevelState(view: $view, isLocked: $isLocked, lockCounter: $lockCounter, isLoadingLockStatus: $isLoadingLockStatus, accessLevel: $accessLevel, sectionType: $sectionType, myRole: $myRole)';
}
}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart
index 93b5234c57..8bd44cff63 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/models.dart
@@ -2,3 +2,4 @@ export 'share_access_level.dart';
export 'share_popover_group_id.dart';
export 'share_role.dart';
export 'shared_user.dart';
+export 'share_section_type.dart';
\ No newline at end of file
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart
index 7c802fc512..38b7012430 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_access_level.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -15,7 +16,7 @@ enum ShareAccessLevel {
/// Full access (edit, share, remove, etc.) and can add new users.
fullAccess;
- String get i18n {
+ String get title {
switch (this) {
case ShareAccessLevel.readOnly:
return LocaleKeys.shareTab_accessLevel_view.tr();
@@ -27,5 +28,30 @@ enum ShareAccessLevel {
return LocaleKeys.shareTab_accessLevel_fullAccess.tr();
}
}
-}
+ String get subtitle {
+ switch (this) {
+ case ShareAccessLevel.readOnly:
+ return 'Can\'t make changes';
+ case ShareAccessLevel.readAndComment:
+ return 'Can make any changes';
+ case ShareAccessLevel.readAndWrite:
+ return 'Can make any changes';
+ case ShareAccessLevel.fullAccess:
+ return 'Can make any changes';
+ }
+ }
+
+ FlowySvgData get icon {
+ switch (this) {
+ case ShareAccessLevel.readOnly:
+ return FlowySvgs.access_level_view_m;
+ case ShareAccessLevel.readAndComment:
+ return FlowySvgs.access_level_edit_m;
+ case ShareAccessLevel.readAndWrite:
+ return FlowySvgs.access_level_edit_m;
+ case ShareAccessLevel.fullAccess:
+ return FlowySvgs.access_level_edit_m;
+ }
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_section_type.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_section_type.dart
new file mode 100644
index 0000000000..61abd440e4
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/models/share_section_type.dart
@@ -0,0 +1,10 @@
+/// The type of the shared section.
+///
+/// - public: the shared section is public, anyone in the workspace can view/edit it.
+/// - shared: the shared section is shared, anyone in the shared section can view/edit it.
+/// - private: the shared section is private, only the users in the shared section can view/edit it.
+enum SharedSectionType {
+ public,
+ shared,
+ private;
+}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository_impl.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository_impl.dart
index 944ca88d57..221f516988 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository_impl.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/local_share_with_user_repository_impl.dart
@@ -13,8 +13,8 @@ class LocalShareWithUserRepositoryImpl extends ShareWithUserRepository {
final SharedUsers _sharedUsers = [
SharedUser(
- name: 'Lucas Xu',
- accessLevel: ShareAccessLevel.readOnly,
+ name: 'Lucas Xu - Long long long long long name',
+ accessLevel: ShareAccessLevel.fullAccess,
role: ShareRole.guest,
avatarUrl: 'https://avatar.iran.liara.run/public',
),
@@ -22,7 +22,7 @@ class LocalShareWithUserRepositoryImpl extends ShareWithUserRepository {
name: 'Vivian Wang',
accessLevel: ShareAccessLevel.readAndWrite,
- role: ShareRole.member,
+ role: ShareRole.guest,
avatarUrl: 'https://avatar.iran.liara.run/public/girl',
),
SharedUser(
@@ -34,7 +34,7 @@ class LocalShareWithUserRepositoryImpl extends ShareWithUserRepository {
),
SharedUser(
- name: 'Guest User 1',
+ name: 'Guest User 1 - Long long long long long name',
accessLevel: ShareAccessLevel.readOnly,
role: ShareRole.guest,
avatarUrl: 'https://avatar.iran.liara.run/public/boy/10',
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository_impl.dart b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository_impl.dart
index 327890b562..c70f210819 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository_impl.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/data/repositories/rust_share_with_user_repository_impl.dart
@@ -23,12 +23,12 @@ class RustShareWithUserRepositoryImpl extends ShareWithUserRepository {
return result.fold(
(success) {
- Log.debug('get shared users: $success');
+ Log.debug('get shared users success: $success');
return FlowySuccess(success.sharedUsers);
},
(failure) {
- Log.error('getUsersInSharedPage: $failure');
+ Log.error('get shared users failed: $failure');
return FlowyFailure(failure);
},
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart
index 39d65b55bb..258cc416e4 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/share_tab.dart
@@ -150,8 +150,9 @@ class _ShareTabState extends State<ShareTab> {
},
onRemoveAccess: (user) {
// show a dialog to confirm the action when removing self access
+ final shareTabBloc = context.read<ShareTabBloc>();
final removingSelf =
- user.email == context.read<ShareTabBloc>().state.currentUser?.email;
+ user.email == shareTabBloc.state.currentUser?.email;
if (removingSelf) {
showConfirmDialog(
context: context,
@@ -160,15 +161,15 @@ class _ShareTabState extends State<ShareTab> {
style: ConfirmPopupStyle.cancelAndOk,
confirmLabel: 'Remove',
onConfirm: () {
- context.read<ShareTabBloc>().add(
- ShareTabEvent.removeUsers(emails: [user.email]),
- );
+ shareTabBloc.add(
+ ShareTabEvent.removeUsers(emails: [user.email]),
+ );
},
);
} else {
- context.read<ShareTabBloc>().add(
- ShareTabEvent.removeUsers(emails: [user.email]),
- );
+ shareTabBloc.add(
+ ShareTabEvent.removeUsers(emails: [user.email]),
+ );
}
},
);
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart
index 3a33170a66..fe1572436b 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/access_level_list_widget.dart
@@ -77,7 +77,7 @@ class AccessLevelListWidget extends StatelessWidget {
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
return AFMenu(
- width: supportedAccessLevels.isNotEmpty ? 240 : 160,
+ width: supportedAccessLevels.isNotEmpty ? 260 : 160,
children: [
// Display all available access level options
if (supportedAccessLevels.isNotEmpty) ...[
@@ -115,9 +115,15 @@ class AccessLevelListWidget extends StatelessWidget {
required VoidCallback onTap,
}) {
return AFTextMenuItem(
- title: accessLevel.i18n,
+ title: accessLevel.title,
+ subtitle: accessLevel.subtitle,
+
showSelectedBackground: false,
selected: selectedAccessLevel == accessLevel,
+ leading: FlowySvg(
+ accessLevel.icon,
+ blendMode: null,
+ ),
// Show a checkmark icon for the currently selected access level
trailing: selectedAccessLevel == accessLevel
? FlowySvg(
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart
index 0e88b2a0ca..5b33f89962 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/edit_access_level_widget.dart
@@ -85,7 +85,7 @@ class _EditAccessLevelWidgetState extends State<EditAccessLevelWidget> {
return Row(
children: [
Text(
- widget.selectedAccessLevel.i18n,
+ widget.selectedAccessLevel.title,
style: theme.textStyle.body.standard(
color: disabled
? theme.textColorScheme.secondary
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart
index 565f267018..c475167fa9 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_group_widget.dart
@@ -43,7 +43,7 @@ class SharedGroupWidget extends StatelessWidget {
workspaceName: group.name,
iconSize: 32.0,
emojiSize: 24.0,
- fontSize: 24.0,
+ fontSize: 16.0,
onSelected: (r) {},
borderRadius: 8.0,
showBorder: false,
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart
index 631f66c583..4a3f3e1917 100644
--- a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/shared_user_widget.dart
@@ -2,6 +2,7 @@ import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy/features/share_tab/presentation/widgets/access_level_list_widget.dart';
import 'package:appflowy/features/share_tab/presentation/widgets/edit_access_level_widget.dart';
import 'package:appflowy/features/share_tab/presentation/widgets/guest_tag.dart';
+import 'package:appflowy/features/share_tab/presentation/widgets/turn_into_member_widget.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -50,6 +51,7 @@ class SharedUserWidget extends StatelessWidget {
final isCurrentUser = user.email == currentUser.email;
return Row(
+ mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
@@ -63,10 +65,13 @@ class SharedUserWidget extends StatelessWidget {
// if the user is the current user, show '(You)'
if (isCurrentUser) ...[
HSpace(theme.spacing.xs),
- Text(
- LocaleKeys.shareTab_you.tr(),
- style: theme.textStyle.caption.standard(
- color: theme.textColorScheme.secondary,
+ Flexible(
+ child: Text(
+ LocaleKeys.shareTab_you.tr(),
+ style: theme.textStyle.caption.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ overflow: TextOverflow.ellipsis,
),
),
],
@@ -101,15 +106,18 @@ class SharedUserWidget extends StatelessWidget {
// Owner: all access levels
final supportedAccessLevels = switch (user.role) {
ShareRole.guest => [
- ShareAccessLevel.readAndWrite,
ShareAccessLevel.readOnly,
+ ShareAccessLevel.readAndWrite,
],
ShareRole.member => [ShareAccessLevel.fullAccess],
ShareRole.owner => [ShareAccessLevel.fullAccess],
};
+
+ Widget editAccessWidget;
+
// The current guest user can't edit the access level of the other user
- if (isCurrentUser) {
- return EditAccessLevelWidget(
+ if (isCurrentUser && currentUser.role == ShareRole.guest) {
+ editAccessWidget = EditAccessLevelWidget(
selectedAccessLevel: user.accessLevel,
supportedAccessLevels: [],
additionalUserManagementOptions: [
@@ -117,25 +125,39 @@ class SharedUserWidget extends StatelessWidget {
],
callbacks: callbacks ?? AccessLevelListCallbacks.none(),
);
+ } else if (currentUser.role == ShareRole.guest ||
+ user.role == ShareRole.member ||
+ user.role == ShareRole.owner) {
+ editAccessWidget = AFGhostTextButton.disabled(
+ text: user.accessLevel.title,
+ textStyle: theme.textStyle.body.standard(
+ color: theme.textColorScheme.secondary,
+ ),
+ );
+ } else {
+ editAccessWidget = EditAccessLevelWidget(
+ selectedAccessLevel: user.accessLevel,
+ supportedAccessLevels: supportedAccessLevels,
+ additionalUserManagementOptions: [
+ AdditionalUserManagementOptions.removeAccess,
+ ],
+ callbacks: callbacks ?? AccessLevelListCallbacks.none(),
+ );
}
- return currentUser.role == ShareRole.guest ||
- user.role == ShareRole.member ||
- user.role == ShareRole.owner
- ? AFGhostTextButton.disabled(
- text: user.accessLevel.i18n,
- textStyle: theme.textStyle.body.standard(
- color: theme.textColorScheme.secondary,
- ),
- )
- : EditAccessLevelWidget(
- selectedAccessLevel: user.accessLevel,
- supportedAccessLevels: supportedAccessLevels,
- additionalUserManagementOptions: [
- AdditionalUserManagementOptions.turnIntoMember,
- AdditionalUserManagementOptions.removeAccess,
- ],
- callbacks: callbacks ?? AccessLevelListCallbacks.none(),
- );
+ if (user.role == ShareRole.guest) {
+ return Row(
+ children: [
+ TurnIntoMemberWidget(
+ onTap: () {
+ callbacks?.onTurnIntoMember.call();
+ },
+ ),
+ editAccessWidget,
+ ],
+ );
+ }
+
+ return editAccessWidget;
}
}
diff --git a/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/turn_into_member_widget.dart b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/turn_into_member_widget.dart
new file mode 100644
index 0000000000..ec41e846a2
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/share_tab/presentation/widgets/turn_into_member_widget.dart
@@ -0,0 +1,24 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:flutter/material.dart';
+
+class TurnIntoMemberWidget extends StatelessWidget {
+ const TurnIntoMemberWidget({
+ super.key,
+ required this.onTap,
+ });
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = AppFlowyTheme.of(context);
+ return AFGhostButton.normal(
+ onTap: onTap,
+ padding: EdgeInsets.all(theme.spacing.s),
+ builder: (context, isHovering, disabled) {
+ return FlowySvg(FlowySvgs.turn_into_member_m);
+ },
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/util/extensions.dart b/frontend/appflowy_flutter/lib/features/util/extensions.dart
index 22ae2b0502..c99372f484 100644
--- a/frontend/appflowy_flutter/lib/features/util/extensions.dart
+++ b/frontend/appflowy_flutter/lib/features/util/extensions.dart
@@ -109,3 +109,18 @@ extension ShareRoleExtension on ShareRole {
}
}
}
+
+extension SharedSectionTypeExtension on folder.SharedViewSectionPB {
+ SharedSectionType get sharedSectionType {
+ switch (this) {
+ case folder.SharedViewSectionPB.PublicSection:
+ return SharedSectionType.public;
+ case folder.SharedViewSectionPB.PrivateSection:
+ return SharedSectionType.private;
+ case folder.SharedViewSectionPB.SharedSection:
+ return SharedSectionType.shared;
+ default:
+ throw Exception('Unknown shared section type: $this');
+ }
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/features/view_management/README.md b/frontend/appflowy_flutter/lib/features/view_management/README.md
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/appflowy_flutter/lib/features/view_management/logic/view_event.dart b/frontend/appflowy_flutter/lib/features/view_management/logic/view_event.dart
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/view_management/logic/view_event.dart
@@ -0,0 +1 @@
+
diff --git a/frontend/appflowy_flutter/lib/features/view_management/logic/view_management_bloc.dart b/frontend/appflowy_flutter/lib/features/view_management/logic/view_management_bloc.dart
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/view_management/logic/view_management_bloc.dart
@@ -0,0 +1 @@
+
diff --git a/frontend/appflowy_flutter/lib/features/view_management/logic/view_state.dart b/frontend/appflowy_flutter/lib/features/view_management/logic/view_state.dart
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/features/view_management/logic/view_state.dart
@@ -0,0 +1 @@
+
diff --git a/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart b/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
index ab781eaa57..1079755216 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/board/presentation/board_page.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:appflowy/features/page_access_level/logic/page_access_level_bloc.dart';
+import 'package:appflowy/features/workspace/logic/workspace_bloc.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/database/board/mobile_board_page.dart';
@@ -17,7 +18,6 @@ import 'package:appflowy/plugins/database/widgets/row/row_detail.dart';
import 'package:appflowy/shared/conditional_listenable_builder.dart';
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy/util/field_type_extension.dart';
-import 'package:appflowy/features/workspace/logic/workspace_bloc.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_board/appflowy_board.dart';
@@ -397,8 +397,10 @@ class _BoardContentState extends State<_BoardContent> {
value: cardContext.read<BoardActionsCubit>(),
),
BlocProvider(
- create: (_) => PageAccessLevelBloc(view: widget.view)
- ..add(PageAccessLevelEvent.initial()),
+ create: (_) => PageAccessLevelBloc(
+ view: widget.view,
+ ignorePageAccessLevel: true,
+ )..add(PageAccessLevelEvent.initial()),
),
],
child:
diff --git a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart
index eb18cb0b38..e834391bc7 100755
--- a/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/grid/presentation/grid_page.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:appflowy/features/page_access_level/logic/page_access_level_bloc.dart';
+import 'package:appflowy/features/workspace/logic/workspace_bloc.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
@@ -12,7 +13,6 @@ import 'package:appflowy/plugins/database/widgets/cell/editable_cell_builder.dar
import 'package:appflowy/shared/flowy_error_page.dart';
import 'package:appflowy/workspace/application/action_navigation/action_navigation_bloc.dart';
import 'package:appflowy/workspace/application/action_navigation/navigation_action.dart';
-import 'package:appflowy/features/workspace/logic/workspace_bloc.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
index d81bf25836..51be86d0a7 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/view_title_bar.dart
@@ -1,9 +1,11 @@
import 'package:appflowy/features/page_access_level/logic/page_access_level_bloc.dart';
+import 'package:appflowy/features/share_tab/data/models/share_section_type.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/shared/icon_emoji_picker/tab.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/workspace/application/sidebar/space/space_bloc.dart';
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/application/view_title/view_title_bar_bloc.dart';
@@ -13,6 +15,8 @@ import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/space_ic
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy/workspace/presentation/widgets/rename_view_popover.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
+import 'package:appflowy_ui/appflowy_ui.dart';
+import 'package:collection/collection.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
@@ -33,7 +37,11 @@ class ViewTitleBar extends StatelessWidget {
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
- BlocProvider(create: (_) => ViewTitleBarBloc(view: view)),
+ BlocProvider(
+ create: (_) => ViewTitleBarBloc(
+ view: view,
+ ),
+ ),
BlocProvider(
create: (_) => PageAccessLevelBloc(view: view)
..add(const PageAccessLevelEvent.initial()),
@@ -43,8 +51,29 @@ class ViewTitleBar extends StatelessWidget {
buildWhen: (previous, current) =>
previous.isLoadingLockStatus != current.isLoadingLockStatus,
builder: (context, pageAccessLevelState) {
- return BlocBuilder<ViewTitleBarBloc, ViewTitleBarState>(
+ return BlocConsumer<ViewTitleBarBloc, ViewTitleBarState>(
+ listener: (context, state) {
+ // update the page section type when the space permission is changed
+ final spacePermission = state.ancestors
+ .firstWhereOrNull(
+ (ancestor) => ancestor.isSpace,
+ )
+ ?.spacePermission;
+ if (spacePermission == null) {
+ return;
+ }
+ final sectionType = switch (spacePermission) {
+ SpacePermission.publicToAll => SharedSectionType.public,
+ SpacePermission.private => SharedSectionType.private,
+ };
+ if (!context.read<PageAccessLevelBloc>().state.isShared) {
+ context.read<PageAccessLevelBloc>().add(
+ PageAccessLevelEvent.updateSectionType(sectionType),
+ );
+ }
+ },
builder: (context, state) {
+ final theme = AppFlowyTheme.of(context);
final ancestors = state.ancestors;
if (ancestors.isEmpty) {
return const SizedBox.shrink();
@@ -60,7 +89,9 @@ class ViewTitleBar extends StatelessWidget {
ancestors,
state.isDeleted,
pageAccessLevelState.isEditable,
+ pageAccessLevelState,
),
+ HSpace(theme.spacing.m),
_buildLockPageStatus(context),
],
),
@@ -101,7 +132,10 @@ class ViewTitleBar extends StatelessWidget {
List<ViewPB> views,
bool isDeleted,
bool isEditable,
+ PageAccessLevelState pageAccessLevelState,
) {
+ final theme = AppFlowyTheme.of(context);
+
if (isDeleted) {
return _buildDeletedTitle(context, views.last);
}
@@ -160,6 +194,19 @@ class ViewTitleBar extends StatelessWidget {
children.add(const FlowySvg(FlowySvgs.title_bar_divider_s));
}
}
+
+ // add the section icon in the breadcrumb
+ children.addAll([
+ HSpace(theme.spacing.xs),
+ BlocBuilder<PageAccessLevelBloc, PageAccessLevelState>(
+ buildWhen: (previous, current) =>
+ previous.sectionType != current.sectionType,
+ builder: (context, state) {
+ return _buildSectionIcon(context, state);
+ },
+ ),
+ ]);
+
return children;
}
@@ -179,6 +226,47 @@ class ViewTitleBar extends StatelessWidget {
),
];
}
+
+ Widget _buildSectionIcon(
+ BuildContext context,
+ PageAccessLevelState pageAccessLevelState,
+ ) {
+ final theme = AppFlowyTheme.of(context);
+
+ final iconName = switch (pageAccessLevelState.sectionType) {
+ SharedSectionType.public => FlowySvgs.public_section_icon_m,
+ SharedSectionType.private => FlowySvgs.private_section_icon_m,
+ SharedSectionType.shared => FlowySvgs.shared_section_icon_m,
+ };
+
+ final icon = FlowySvg(
+ iconName,
+ color: theme.iconColorScheme.tertiary,
+ size: Size.square(20),
+ );
+
+ final text = switch (pageAccessLevelState.sectionType) {
+ SharedSectionType.public => 'Team space',
+ SharedSectionType.private => 'Private',
+ SharedSectionType.shared => 'Shared',
+ };
+
+ return Row(
+ textBaseline: TextBaseline.alphabetic,
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ children: [
+ HSpace(theme.spacing.xs),
+ icon,
+ const HSpace(4.0), // ask designer to provide the spacing
+ Text(
+ text,
+ style: theme.textStyle.caption
+ .enhanced(color: theme.textColorScheme.tertiary),
+ ),
+ HSpace(theme.spacing.xs),
+ ],
+ );
+ }
}
class TrashBreadcrumb extends StatelessWidget {
diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart
index 46fa3e49bf..c1aa8306fe 100644
--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/access_level_list_widget_test.dart
@@ -33,20 +33,20 @@ void main() {
);
// Check all access level options are present
- expect(find.text(ShareAccessLevel.fullAccess.i18n), findsOneWidget);
- expect(find.text(ShareAccessLevel.readAndWrite.i18n), findsOneWidget);
- expect(find.text(ShareAccessLevel.readAndComment.i18n), findsOneWidget);
- expect(find.text(ShareAccessLevel.readOnly.i18n), findsOneWidget);
+ expect(find.text(ShareAccessLevel.fullAccess.title), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readAndWrite.title), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readAndComment.title), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readOnly.title), findsOneWidget);
// Check that the selected access level is visually marked
final selectedTile = tester
.widgetList<AFTextMenuItem>(find.byType(AFTextMenuItem))
.where((item) => item.selected);
expect(selectedTile.length, 1);
- expect(selectedTile.first.title, ShareAccessLevel.readAndWrite.i18n);
+ expect(selectedTile.first.title, ShareAccessLevel.readAndWrite.title);
// Tap on another access level
- await tester.tap(find.text(ShareAccessLevel.readOnly.i18n));
+ await tester.tap(find.text(ShareAccessLevel.readOnly.title));
await tester.pumpAndSettle();
expect(selectedLevel, ShareAccessLevel.readOnly);
diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart
index 69101f5559..a1fb9534cc 100644
--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/edit_access_level_widget_test.dart
@@ -25,9 +25,9 @@ void main() {
),
);
// Check selected access level is shown
- expect(find.text(ShareAccessLevel.readOnly.i18n), findsOneWidget);
+ expect(find.text(ShareAccessLevel.readOnly.title), findsOneWidget);
// Tap to open popover
- await tester.tap(find.text(ShareAccessLevel.readOnly.i18n));
+ await tester.tap(find.text(ShareAccessLevel.readOnly.title));
await tester.pumpAndSettle();
});
});
diff --git a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart
index 84944eb6cb..a79a66edfa 100644
--- a/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart
+++ b/frontend/appflowy_flutter/test/widget_test/lib/features/share_tab/shared_user_widget_test.dart
@@ -2,6 +2,7 @@ import 'package:appflowy/features/share_tab/data/models/models.dart';
import 'package:appflowy/features/share_tab/presentation/widgets/shared_user_widget.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:easy_localization/easy_localization.dart';
+import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../widget_test_wrapper.dart';
@@ -39,9 +40,11 @@ void main() {
);
await tester.pumpWidget(
WidgetTestWrapper(
- child: SharedUserWidget(
- user: user,
- currentUser: user,
+ child: IntrinsicWidth(
+ child: SharedUserWidget(
+ user: user,
+ currentUser: user,
+ ),
),
),
);
diff --git a/frontend/resources/flowy_icons/20x/access_level_edit.svg b/frontend/resources/flowy_icons/20x/access_level_edit.svg
new file mode 100644
index 0000000000..b57ce88097
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/access_level_edit.svg
@@ -0,0 +1,3 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.91797 5.7627C10.2674 7.92417 12.0879 9.57661 14.3473 9.79589M11.0285 4.62701L4.35601 11.4325C4.10407 11.691 3.86025 12.2 3.81149 12.5524L3.51078 15.0898C3.40513 16.0061 4.08782 16.6326 5.03057 16.476L7.64754 16.0453C8.01326 15.9826 8.52527 15.7242 8.77722 15.4579L15.4497 8.65237C16.6037 7.47766 17.1239 6.13848 15.3278 4.50171C13.5398 2.8806 12.1825 3.45229 11.0285 4.62701Z" stroke="#21232A" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/access_level_view.svg b/frontend/resources/flowy_icons/20x/access_level_view.svg
new file mode 100644
index 0000000000..826941ba89
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/access_level_view.svg
@@ -0,0 +1,4 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M3.04375 10.2437C2.98542 10.0866 2.98542 9.91372 3.04375 9.75656C3.61191 8.37893 4.57633 7.20102 5.81475 6.37216C7.05317 5.54331 8.50981 5.10083 10 5.10083C11.4902 5.10083 12.9468 5.54331 14.1852 6.37216C15.4237 7.20102 16.3881 8.37893 16.9562 9.75656C17.0146 9.91372 17.0146 10.0866 16.9562 10.2437C16.3881 11.6214 15.4237 12.7993 14.1852 13.6281C12.9468 14.457 11.4902 14.8995 10 14.8995C8.50981 14.8995 7.05317 14.457 5.81475 13.6281C4.57633 12.7993 3.61191 11.6214 3.04375 10.2437Z" stroke="#21232A" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M10 12.1C11.1597 12.1 12.0999 11.1599 12.0999 10.0002C12.0999 8.84041 11.1597 7.90026 10 7.90026C8.84026 7.90026 7.90011 8.84041 7.90011 10.0002C7.90011 11.1599 8.84026 12.1 10 12.1Z" stroke="#21232A" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/private_section_icon.svg b/frontend/resources/flowy_icons/20x/private_section_icon.svg
new file mode 100644
index 0000000000..a1215d0282
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/private_section_icon.svg
@@ -0,0 +1,3 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M6.9092 6.4H6.4092H6.9092ZM9.4546 8.8V9.3V8.8ZM9.56806 16.5C9.8442 16.5 10.0681 16.2761 10.0681 16C10.0681 15.7239 9.8442 15.5 9.56806 15.5V16.5ZM11.0895 11.3539C11.3629 11.3922 11.6157 11.2016 11.6541 10.9282C11.6925 10.6547 11.5019 10.4019 11.2284 10.3636L11.0895 11.3539ZM15 14C15 14.2761 15.2239 14.5 15.5 14.5C15.7761 14.5 16 14.2761 16 14H15ZM12 14C12 14.2761 12.2239 14.5 12.5 14.5C12.7761 14.5 13 14.2761 13 14H12ZM16.4239 16.3827L15.9619 16.1913L16.4239 16.3827ZM16.4239 14.6173L15.9619 14.8087L16.4239 14.6173ZM6.9092 6.4H6.4092C6.4092 7.17893 6.73765 7.91957 7.31172 8.46085L7.65473 8.09706L7.99774 7.73326C7.61711 7.37437 7.4092 6.8941 7.4092 6.4H6.9092ZM7.65473 8.09706L7.31172 8.46085C7.8848 9.00119 8.65609 9.3 9.4546 9.3V8.8V8.3C8.90295 8.3 8.37938 8.0931 7.99774 7.73326L7.65473 8.09706ZM9.4546 8.8V9.3C10.2531 9.3 11.0244 9.00119 11.5975 8.46085L11.2545 8.09706L10.9115 7.73326C10.5298 8.0931 10.0063 8.3 9.4546 8.3V8.8ZM11.2545 8.09706L11.5975 8.46085C12.1716 7.91957 12.5 7.17893 12.5 6.4H12H11.5C11.5 6.8941 11.2921 7.37437 10.9115 7.73326L11.2545 8.09706ZM12 6.4H12.5C12.5 5.62107 12.1716 4.88043 11.5975 4.33915L11.2545 4.70294L10.9115 5.06673C11.2921 5.42563 11.5 5.9059 11.5 6.4H12ZM11.2545 4.70294L11.5975 4.33915C11.0244 3.79881 10.2531 3.5 9.4546 3.5V4V4.5C10.0063 4.5 10.5298 4.7069 10.9115 5.06673L11.2545 4.70294ZM9.4546 4V3.5C8.65609 3.5 7.8848 3.79881 7.31172 4.33915L7.65473 4.70294L7.99774 5.06673C8.37938 4.7069 8.90295 4.5 9.4546 4.5V4ZM7.65473 4.70294L7.31172 4.33915C6.73765 4.88043 6.4092 5.62107 6.4092 6.4H6.9092H7.4092C7.4092 5.9059 7.61711 5.42563 7.99774 5.06673L7.65473 4.70294ZM9.56806 16V15.5C8.19033 15.5 7.17717 15.4271 6.43265 15.3008C5.6837 15.1737 5.24162 14.9982 4.97787 14.8182C4.52432 14.5086 4.5 14.1291 4.5 13.375H4H3.5C3.5 14.0707 3.47568 15.0036 4.41414 15.6441C4.8464 15.9392 5.44834 16.1481 6.2654 16.2867C7.0869 16.426 8.16175 16.5 9.56806 16.5V16ZM4 13.375H4.5C4.5 12.9571 4.87794 12.4266 5.84406 11.9711C6.77127 11.534 8.08734 11.25 9.56806 11.25V10.75V10.25C7.97362 10.25 6.50567 10.5536 5.41763 11.0666C4.36851 11.5612 3.5 12.3432 3.5 13.375H4ZM9.56806 10.75V11.25C10.0981 11.25 10.6089 11.2864 11.0895 11.3539L11.1589 10.8587L11.2284 10.3636C10.7008 10.2895 10.1436 10.25 9.56806 10.25V10.75ZM15.5 12.5H15V14H15.5H16V12.5H15.5ZM12.5 14H13V12.5H12.5H12V14H12.5ZM14 11V11.5C14.5523 11.5 15 11.9477 15 12.5H15.5H16C16 11.3954 15.1046 10.5 14 10.5V11ZM14 11V10.5C12.8954 10.5 12 11.3954 12 12.5H12.5H13C13 11.9477 13.4477 11.5 14 11.5V11ZM13 14V14.5H15V14V13.5H13V14ZM15 17V16.5H13V17V17.5H15V17ZM13 17V16.5C12.7602 16.5 12.6054 16.4997 12.4869 16.4916C12.3729 16.4839 12.3295 16.4706 12.3087 16.4619L12.1173 16.9239L11.926 17.3858C12.0889 17.4533 12.2539 17.4781 12.4188 17.4893C12.5792 17.5003 12.7739 17.5 13 17.5V17ZM11.5 15.5H11C11 15.7261 10.9997 15.9208 11.0107 16.0812C11.0219 16.2461 11.0467 16.4111 11.1142 16.574L11.5761 16.3827L12.0381 16.1913C12.0294 16.1705 12.0161 16.1271 12.0084 16.0131C12.0003 15.8946 12 15.7398 12 15.5H11.5ZM12.1173 16.9239L12.3087 16.4619C12.1861 16.4112 12.0888 16.3139 12.0381 16.1913L11.5761 16.3827L11.1142 16.574C11.2664 16.9416 11.5584 17.2336 11.926 17.3858L12.1173 16.9239ZM16.5 15.5H16C16 15.7398 15.9997 15.8946 15.9916 16.0131C15.9839 16.1271 15.9706 16.1705 15.9619 16.1913L16.4239 16.3827L16.8858 16.574C16.9533 16.4111 16.9781 16.2461 16.9893 16.0812C17.0003 15.9208 17 15.7261 17 15.5H16.5ZM15 17V17.5C15.2261 17.5 15.4208 17.5003 15.5812 17.4893C15.7461 17.4781 15.9111 17.4533 16.074 17.3858L15.8827 16.9239L15.6913 16.4619C15.6705 16.4706 15.6271 16.4839 15.5131 16.4916C15.3946 16.4997 15.2398 16.5 15 16.5V17ZM16.4239 16.3827L15.9619 16.1913C15.9112 16.3139 15.8139 16.4112 15.6913 16.4619L15.8827 16.9239L16.074 17.3858C16.4416 17.2336 16.7336 16.9416 16.8858 16.574L16.4239 16.3827ZM15 14V14.5C15.2398 14.5 15.3946 14.5003 15.5131 14.5084C15.6271 14.5161 15.6705 14.5294 15.6913 14.5381L15.8827 14.0761L16.074 13.6142C15.9111 13.5467 15.7461 13.5219 15.5812 13.5107C15.4208 13.4997 15.2261 13.5 15 13.5V14ZM16.5 15.5H17C17 15.2739 17.0003 15.0792 16.9893 14.9188C16.9781 14.7539 16.9533 14.5889 16.8858 14.426L16.4239 14.6173L15.9619 14.8087C15.9706 14.8295 15.9839 14.8729 15.9916 14.9869C15.9997 15.1054 16 15.2602 16 15.5H16.5ZM15.8827 14.0761L15.6913 14.5381C15.8139 14.5888 15.9112 14.6861 15.9619 14.8087L16.4239 14.6173L16.8858 14.426C16.7336 14.0584 16.4416 13.7664 16.074 13.6142L15.8827 14.0761ZM13 14V13.5C12.7739 13.5 12.5792 13.4997 12.4188 13.5107C12.2539 13.5219 12.0889 13.5467 11.926 13.6142L12.1173 14.0761L12.3087 14.5381C12.3295 14.5294 12.3729 14.5161 12.4869 14.5084C12.6054 14.5003 12.7602 14.5 13 14.5V14ZM11.5 15.5H12C12 15.2602 12.0003 15.1054 12.0084 14.9869C12.0161 14.8729 12.0294 14.8295 12.0381 14.8087L11.5761 14.6173L11.1142 14.426C11.0467 14.5889 11.0219 14.7539 11.0107 14.9188C10.9997 15.0792 11 15.2739 11 15.5H11.5ZM12.1173 14.0761L11.926 13.6142C11.5584 13.7664 11.2664 14.0584 11.1142 14.426L11.5761 14.6173L12.0381 14.8087C12.0888 14.6861 12.1861 14.5888 12.3087 14.5381L12.1173 14.0761Z" fill="#B5BBD3"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/public_section_icon.svg b/frontend/resources/flowy_icons/20x/public_section_icon.svg
new file mode 100644
index 0000000000..35fd28d9c3
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/public_section_icon.svg
@@ -0,0 +1,3 @@
+<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M14.1795 8.40914C15.2339 8.40914 16.0886 7.69686 16.0886 6.81823C16.0886 5.93959 15.2339 5.22732 14.1795 5.22732M6.54315 8.40914C5.48879 8.40914 4.63406 7.69686 4.63406 6.81823C4.63406 5.93959 5.48879 5.22732 6.54315 5.22732M15.4522 14.7728C16.5685 14.528 17.3613 13.908 17.3613 13.1819C17.3613 12.4557 16.5685 11.8358 15.4522 11.591M5.27042 14.7728C4.15408 14.528 3.36133 13.908 3.36133 13.1819C3.36133 12.4557 4.15408 11.8358 5.27042 11.591M7.81587 6.50004C7.81587 7.17514 8.08405 7.82259 8.56142 8.29995C9.03879 8.77732 9.68623 9.0455 10.3613 9.0455C11.0364 9.0455 11.6839 8.77732 12.1612 8.29995C12.6386 7.82259 12.9068 7.17514 12.9068 6.50004C12.9068 5.82495 12.6386 5.1775 12.1612 4.70014C11.6839 4.22277 11.0364 3.95459 10.3613 3.95459C9.68623 3.95459 9.03879 4.22277 8.56142 4.70014C8.08405 5.1775 7.81587 5.82495 7.81587 6.50004ZM6.54315 13.5C6.54315 14.1751 6.94542 14.8226 7.66147 15.3C8.37751 15.7773 9.34868 16.0455 10.3613 16.0455C11.374 16.0455 12.3451 15.7773 13.0612 15.3C13.7772 14.8226 14.1795 14.1751 14.1795 13.5C14.1795 12.8249 13.7772 12.1775 13.0612 11.7001C12.3451 11.2228 11.374 10.9546 10.3613 10.9546C9.34868 10.9546 8.37751 11.2228 7.66147 11.7001C6.94542 12.1775 6.54315 12.8249 6.54315 13.5Z" stroke="#6F748C" stroke-linecap="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/shared_section_icon.svg b/frontend/resources/flowy_icons/20x/shared_section_icon.svg
new file mode 100644
index 0000000000..8e3e1ab160
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/shared_section_icon.svg
@@ -0,0 +1,3 @@
+<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M12.3051 5.72222L8.41623 8.44444M12.3051 14.2778L8.41623 11.5556M8.41623 10C8.41623 11.0739 7.54567 11.9444 6.47179 11.9444C5.3979 11.9444 4.52734 11.0739 4.52734 10C4.52734 8.92612 5.3979 8.05556 6.47179 8.05556C7.54567 8.05556 8.41623 8.92612 8.41623 10ZM16.194 15.0556C16.194 16.1294 15.3234 17 14.2496 17C13.1757 17 12.3051 16.1294 12.3051 15.0556C12.3051 13.9817 13.1757 13.1111 14.2496 13.1111C15.3234 13.1111 16.194 13.9817 16.194 15.0556ZM16.194 4.94444C16.194 6.01833 15.3234 6.88889 14.2496 6.88889C13.1757 6.88889 12.3051 6.01833 12.3051 4.94444C12.3051 3.87056 13.1757 3 14.2496 3C15.3234 3 16.194 3.87056 16.194 4.94444Z" stroke="#6F748C" stroke-linecap="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/20x/turn_into_member.svg b/frontend/resources/flowy_icons/20x/turn_into_member.svg
new file mode 100644
index 0000000000..867b544200
--- /dev/null
+++ b/frontend/resources/flowy_icons/20x/turn_into_member.svg
@@ -0,0 +1,3 @@
+<svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M11.569 11.5619C11.0008 11.4794 10.3989 11.4351 9.77586 11.4351C6.3098 11.4351 3.5 12.8062 3.5 14.4976C3.5 16.1889 3.5 17.5601 9.77586 17.5601C11.5991 17.5601 12.8926 17.4443 13.8103 17.2387M12.9138 13.6226H16.5M14.7069 15.3726V11.8726M6.77902 6.36006C6.77902 7.10266 7.08128 7.81486 7.61932 8.33996C8.15735 8.86506 8.88709 9.16006 9.64798 9.16006C10.4089 9.16006 11.1386 8.86506 11.6766 8.33996C12.2147 7.81486 12.5169 7.10266 12.5169 6.36006C12.5169 5.61745 12.2147 4.90526 11.6766 4.38016C11.1386 3.85506 10.4089 3.56006 9.64798 3.56006C8.88709 3.56006 8.15735 3.85506 7.61932 4.38016C7.08128 4.90526 6.77902 5.61745 6.77902 6.36006Z" stroke="#21232A" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/rust-lib/flowy-folder/src/entities/view.rs b/frontend/rust-lib/flowy-folder/src/entities/view.rs
index a2c56d5138..cc3d231f0d 100644
--- a/frontend/rust-lib/flowy-folder/src/entities/view.rs
+++ b/frontend/rust-lib/flowy-folder/src/entities/view.rs
@@ -907,6 +907,20 @@ pub struct RepeatedSharedViewResponsePB {
pub shared_views: Vec<SharedViewPB>,
}
+#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone, Default)]
+pub enum SharedViewSectionPB {
+ #[default]
+ PrivateSection = 0,
+ PublicSection = 1,
+ SharedSection = 2,
+}
+
+#[derive(Default, ProtoBuf, Clone, Debug)]
+pub struct GetSharedViewSectionResponsePB {
+ #[pb(index = 1)]
+ pub section: SharedViewSectionPB,
+}
+
// impl<'de> Deserialize<'de> for ViewDataType {
// fn deserialize<D>(deserializer: D) -> Result<Self, <D as Deserializer<'de>>::Error>
// where
diff --git a/frontend/rust-lib/flowy-folder/src/event_handler.rs b/frontend/rust-lib/flowy-folder/src/event_handler.rs
index ef9e495d8a..5ac29f191d 100644
--- a/frontend/rust-lib/flowy-folder/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_handler.rs
@@ -589,3 +589,14 @@ pub(crate) async fn get_shared_views_handler(
let resp = folder.get_shared_pages().await?;
data_result_ok(resp)
}
+
+#[tracing::instrument(level = "debug", skip(data, folder))]
+pub(crate) async fn get_shared_view_section_handler(
+ data: AFPluginData<ViewIdPB>,
+ folder: AFPluginState<Weak<FolderManager>>,
+) -> DataResult<GetSharedViewSectionResponsePB, FlowyError> {
+ let folder = upgrade_folder(folder)?;
+ let view_id = data.into_inner().value;
+ let section = folder.get_shared_view_section(&view_id).await?;
+ data_result_ok(GetSharedViewSectionResponsePB { section })
+}
diff --git a/frontend/rust-lib/flowy-folder/src/event_map.rs b/frontend/rust-lib/flowy-folder/src/event_map.rs
index 75fe784d7d..ecfae2628f 100644
--- a/frontend/rust-lib/flowy-folder/src/event_map.rs
+++ b/frontend/rust-lib/flowy-folder/src/event_map.rs
@@ -58,6 +58,7 @@ pub fn init(folder: Weak<FolderManager>) -> AFPlugin {
.event(FolderEvent::RemoveUserFromSharedPage, remove_user_from_shared_page_handler)
.event(FolderEvent::GetSharedUsers, get_shared_users_handler)
.event(FolderEvent::GetSharedViews, get_shared_views_handler)
+ .event(FolderEvent::GetSharedViewSection, get_shared_view_section_handler)
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
@@ -242,4 +243,7 @@ pub enum FolderEvent {
#[event(output = "RepeatedSharedViewResponsePB")]
GetSharedViews = 59,
+
+ #[event(input = "ViewIdPB", output = "GetSharedViewSectionResponsePB")]
+ GetSharedViewSection = 60,
}
diff --git a/frontend/rust-lib/flowy-folder/src/manager.rs b/frontend/rust-lib/flowy-folder/src/manager.rs
index 0c05f4093f..ab38461925 100644
--- a/frontend/rust-lib/flowy-folder/src/manager.rs
+++ b/frontend/rust-lib/flowy-folder/src/manager.rs
@@ -2,9 +2,9 @@ use crate::entities::icon::UpdateViewIconParams;
use crate::entities::{
AFAccessLevelPB, CreateViewParams, DeletedViewPB, DuplicateViewParams, FolderSnapshotPB,
MoveNestedViewParams, RepeatedSharedViewResponsePB, RepeatedTrashPB, RepeatedViewIdPB,
- RepeatedViewPB, SharedViewPB, UpdateViewParams, ViewLayoutPB, ViewPB, ViewSectionPB,
- WorkspaceLatestPB, WorkspacePB, view_pb_with_all_child_views, view_pb_with_child_views,
- view_pb_without_child_views, view_pb_without_child_views_from_arc,
+ RepeatedViewPB, SharedViewPB, SharedViewSectionPB, UpdateViewParams, ViewLayoutPB, ViewPB,
+ ViewSectionPB, WorkspaceLatestPB, WorkspacePB, view_pb_with_all_child_views,
+ view_pb_with_child_views, view_pb_without_child_views, view_pb_without_child_views_from_arc,
};
use crate::manager_observer::{
ChildViewChangeReason, notify_child_views_changed, notify_did_update_workspace,
@@ -29,8 +29,8 @@ use collab_entity::{CollabType, EncodedCollab};
use collab_folder::folder_diff::FolderViewChange;
use collab_folder::hierarchy_builder::{ParentChildViews, ViewExtraBuilder};
use collab_folder::{
- Folder, FolderData, FolderNotify, Section, SectionItem, TrashInfo, View, ViewLayout, ViewUpdate,
- Workspace,
+ Folder, FolderData, FolderNotify, Section, SectionItem, SpacePermission, TrashInfo, View,
+ ViewLayout, ViewUpdate, Workspace,
};
use collab_integrate::CollabKVDB;
use collab_integrate::collab_builder::{
@@ -2296,6 +2296,52 @@ impl FolderManager {
Ok(flattened_views)
}
+ pub async fn get_shared_view_section(&self, view_id: &str) -> FlowyResult<SharedViewSectionPB> {
+ const MAX_LOOP_COUNT: usize = 20;
+ let mut loop_count = 0;
+ let mut current_view_id = view_id.to_string();
+
+ let lock = self
+ .mutex_folder
+ .load_full()
+ .ok_or_else(folder_not_init_error)?;
+ let folder = lock.read().await;
+
+ let flattened_shared_views = self.get_flatten_shared_pages().await?;
+
+ // if the view is in the flattened_shared_views, return the section
+ if flattened_shared_views.iter().any(|view| view.id == view_id) {
+ return Ok(SharedViewSectionPB::SharedSection);
+ }
+
+ loop {
+ if loop_count >= MAX_LOOP_COUNT {
+ return Ok(SharedViewSectionPB::PublicSection);
+ }
+ loop_count += 1;
+
+ let view = folder
+ .get_view(&current_view_id)
+ .ok_or_else(|| FlowyError::record_not_found().with_context("View not found"))?;
+
+ if let Some(space_info) = view.space_info() {
+ return match space_info.space_permission {
+ SpacePermission::PublicToAll => Ok(SharedViewSectionPB::PublicSection),
+ _ => Ok(SharedViewSectionPB::PrivateSection),
+ };
+ }
+
+ let parent_view_id = view.parent_view_id.clone();
+
+ // If parent_view_id is the same as current view id, return public to avoid infinite loop
+ if parent_view_id == current_view_id {
+ return Ok(SharedViewSectionPB::PublicSection);
+ }
+
+ current_view_id = parent_view_id;
+ }
+ }
+
fn flatten_child_views(views: &[ViewPB], flattened_views: &mut Vec<ViewPB>) {
for view in views {
let child_views = view.child_views.clone();