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
chore: remove change and reset path settings (#8010)
Richard Shiue730c291f4777
diff --git a/frontend/appflowy_flutter/lib/features/settings/data/models/user_data_location.dart b/frontend/appflowy_flutter/lib/features/settings/data/models/user_data_location.dartnew file mode 100644index 0000000000..5eeb0dc6cc--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/data/models/user_data_location.dart@@ -0,0 +1,14 @@+import 'package:equatable/equatable.dart';++class UserDataLocation extends Equatable {+ const UserDataLocation({+ required this.path,+ required this.isCustom,+ });++ final String path;+ final bool isCustom;++ @override+ List<Object?> get props => [path, isCustom];+}diff --git a/frontend/appflowy_flutter/lib/features/settings/data/repositories/rust_settings_repository_impl.dart b/frontend/appflowy_flutter/lib/features/settings/data/repositories/rust_settings_repository_impl.dartnew file mode 100644index 0000000000..afda3e12b5--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/data/repositories/rust_settings_repository_impl.dart@@ -0,0 +1,61 @@+import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/startup/tasks/rust_sdk.dart';+import 'package:appflowy/user/application/user_settings_service.dart';+import 'package:appflowy/workspace/application/settings/prelude.dart';+import 'package:appflowy_backend/protobuf/flowy-error/protobuf.dart';+import 'package:appflowy_result/appflowy_result.dart';++import '../models/user_data_location.dart';+import 'settings_repository.dart';++class RustSettingsRepositoryImpl implements SettingsRepository {+ const RustSettingsRepositoryImpl();++ final _userBackendService = const UserSettingsBackendService();++ @override+ Future<FlowyResult<UserDataLocation, FlowyError>>+ getUserDataLocation() async {+ final defaultDirectory = (await appFlowyApplicationDataDirectory()).path;+ final result = await _userBackendService.getUserSetting();++ return result.map(+ (settings) {+ final userDirectory = settings.userFolder;+ return UserDataLocation(+ path: userDirectory,+ isCustom: userDirectory.contains(defaultDirectory),+ );+ },+ );+ }++ @override+ Future<FlowyResult<UserDataLocation, FlowyError>>+ resetUserDataLocation() async {+ final directory = await appFlowyApplicationDataDirectory();+ await getIt<ApplicationDataStorage>().setPath(directory.path);++ return FlowyResult.success(+ UserDataLocation(+ path: directory.path,+ isCustom: false,+ ),+ );+ }++ @override+ Future<FlowyResult<UserDataLocation, FlowyError>> setCustomLocation(+ String path,+ ) async {+ final defaultDirectory = (await appFlowyApplicationDataDirectory()).path;+ await getIt<ApplicationDataStorage>().setCustomPath(path);++ return FlowyResult.success(+ UserDataLocation(+ path: path,+ isCustom: path.contains(defaultDirectory),+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/features/settings/data/repositories/settings_repository.dart b/frontend/appflowy_flutter/lib/features/settings/data/repositories/settings_repository.dartnew file mode 100644index 0000000000..39ba5153f1--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/data/repositories/settings_repository.dart@@ -0,0 +1,14 @@+import 'package:appflowy_backend/protobuf/flowy-error/protobuf.dart';+import 'package:appflowy_result/appflowy_result.dart';++import '../models/user_data_location.dart';++abstract class SettingsRepository {+ Future<FlowyResult<UserDataLocation, FlowyError>> getUserDataLocation();++ Future<FlowyResult<UserDataLocation, FlowyError>> resetUserDataLocation();++ Future<FlowyResult<UserDataLocation, FlowyError>> setCustomLocation(+ String path,+ );+}diff --git a/frontend/appflowy_flutter/lib/features/settings/logic/data_location_bloc.dart b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_bloc.dartnew file mode 100644index 0000000000..ed6cbc9d2b--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_bloc.dart@@ -0,0 +1,76 @@+import 'package:appflowy_result/appflowy_result.dart';+import 'package:flutter_bloc/flutter_bloc.dart';++import '../data/repositories/settings_repository.dart';+import 'data_location_event.dart';+import 'data_location_state.dart';++class DataLocationBloc extends Bloc<DataLocationEvent, DataLocationState> {+ DataLocationBloc({+ required SettingsRepository repository,+ }) : _repository = repository,+ super(DataLocationState.initial()) {+ on<DataLocationInitial>(_onStarted);+ on<DataLocationResetToDefault>(_onResetToDefault);+ on<DataLocationSetCustomPath>(_onSetCustomPath);+ on<DataLocationClearState>(_onClearState);+ }++ final SettingsRepository _repository;++ Future<void> _onStarted(+ DataLocationInitial event,+ Emitter<DataLocationState> emit,+ ) async {+ final userDataLocation =+ await _repository.getUserDataLocation().toNullable();++ emit(+ DataLocationState(+ userDataLocation: userDataLocation,+ didResetToDefault: false,+ ),+ );+ }++ Future<void> _onResetToDefault(+ DataLocationResetToDefault event,+ Emitter<DataLocationState> emit,+ ) async {+ final defaultLocation =+ await _repository.resetUserDataLocation().toNullable();++ emit(+ DataLocationState(+ userDataLocation: defaultLocation,+ didResetToDefault: true,+ ),+ );+ }++ Future<void> _onClearState(+ DataLocationClearState event,+ Emitter<DataLocationState> emit,+ ) async {+ emit(+ state.copyWith(+ didResetToDefault: false,+ ),+ );+ }++ Future<void> _onSetCustomPath(+ DataLocationSetCustomPath event,+ Emitter<DataLocationState> emit,+ ) async {+ final userDataLocation =+ await _repository.setCustomLocation(event.path).toNullable();++ emit(+ state.copyWith(+ userDataLocation: userDataLocation,+ didResetToDefault: false,+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/features/settings/logic/data_location_event.dart b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_event.dartnew file mode 100644index 0000000000..89d8a8ef40--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_event.dart@@ -0,0 +1,24 @@+sealed class DataLocationEvent {+ const DataLocationEvent();++ factory DataLocationEvent.initial() = DataLocationInitial;++ factory DataLocationEvent.resetToDefault() = DataLocationResetToDefault;++ factory DataLocationEvent.setCustomPath(String path) =+ DataLocationSetCustomPath;++ factory DataLocationEvent.clearState() = DataLocationClearState;+}++class DataLocationInitial extends DataLocationEvent {}++class DataLocationResetToDefault extends DataLocationEvent {}++class DataLocationSetCustomPath extends DataLocationEvent {+ const DataLocationSetCustomPath(this.path);++ final String path;+}++class DataLocationClearState extends DataLocationEvent {}diff --git a/frontend/appflowy_flutter/lib/features/settings/logic/data_location_state.dart b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_state.dartnew file mode 100644index 0000000000..f4cc88db20--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/logic/data_location_state.dart@@ -0,0 +1,29 @@+import 'package:equatable/equatable.dart';++import '../data/models/user_data_location.dart';++class DataLocationState extends Equatable {+ const DataLocationState({+ required this.userDataLocation,+ required this.didResetToDefault,+ });++ factory DataLocationState.initial() =>+ const DataLocationState(userDataLocation: null, didResetToDefault: false);++ final UserDataLocation? userDataLocation;+ final bool didResetToDefault;++ @override+ List<Object?> get props => [userDataLocation, didResetToDefault];++ DataLocationState copyWith({+ UserDataLocation? userDataLocation,+ bool? didResetToDefault,+ }) {+ return DataLocationState(+ userDataLocation: userDataLocation ?? this.userDataLocation,+ didResetToDefault: didResetToDefault ?? this.didResetToDefault,+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/features/settings/settings.dart b/frontend/appflowy_flutter/lib/features/settings/settings.dartnew file mode 100644index 0000000000..a3cca4204b--- /dev/null+++ b/frontend/appflowy_flutter/lib/features/settings/settings.dart@@ -0,0 +1,6 @@+export 'logic/data_location_bloc.dart';+export 'logic/data_location_event.dart';+export 'logic/data_location_state.dart';+export 'data/models/user_data_location.dart';+export 'data/repositories/settings_repository.dart';+export 'data/repositories/rust_settings_repository_impl.dart';diff --git a/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart b/frontend/appflowy_flutter/lib/user/application/user_settings_service.dartindex f9718a9134..47ba975466 100644--- a/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart+++ b/frontend/appflowy_flutter/lib/user/application/user_settings_service.dart@@ -6,6 +6,8 @@ import 'package:appflowy_backend/protobuf/flowy-user/user_setting.pb.dart';import 'package:appflowy_result/appflowy_result.dart';class UserSettingsBackendService {+ const UserSettingsBackendService();+Future<AppearanceSettingsPB> getAppearanceSetting() async {final result = await UserEventGetAppearanceSetting().send();diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_location_cubit.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_location_cubit.dartdeleted file mode 100644index 696bb9c348..0000000000--- a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_location_cubit.dart+++ /dev/null@@ -1,46 +0,0 @@-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/application/settings/application_data_storage.dart';-import 'package:appflowy_backend/dispatch/dispatch.dart';-import 'package:appflowy_backend/log.dart';-import 'package:flutter/foundation.dart';-import 'package:flutter_bloc/flutter_bloc.dart';-import 'package:freezed_annotation/freezed_annotation.dart';--import '../../../startup/tasks/prelude.dart';--part 'settings_location_cubit.freezed.dart';--@freezed-class SettingsLocationState with _$SettingsLocationState {- const factory SettingsLocationState.initial() = _Initial;- const factory SettingsLocationState.didReceivedPath(String path) =- _DidReceivedPath;-}--class SettingsLocationCubit extends Cubit<SettingsLocationState> {- SettingsLocationCubit() : super(const SettingsLocationState.initial()) {- _init();- }-- Future<void> resetDataStoragePathToApplicationDefault() async {- final directory = await appFlowyApplicationDataDirectory();- await getIt<ApplicationDataStorage>().setPath(directory.path);- emit(SettingsLocationState.didReceivedPath(directory.path));- }-- Future<void> setCustomPath(String path) async {- await getIt<ApplicationDataStorage>().setCustomPath(path);- emit(SettingsLocationState.didReceivedPath(path));- }-- Future<void> _init() async {- // The backend might change the real path that storge the data. So it needs- // to get the path from the backend instead of the KeyValueStorage- await UserEventGetUserSetting().send().then((result) {- result.fold(- (l) => emit(SettingsLocationState.didReceivedPath(l.userFolder)),- (r) => Log.error(r),- );- });- }-}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_manage_data_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_manage_data_view.dartindex db01670a65..2763ae87ab 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_manage_data_view.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_manage_data_view.dart@@ -1,46 +1,66 @@import 'dart:async';import 'package:appflowy/core/helpers/url_launcher.dart';+import 'package:appflowy/features/settings/settings.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/shared/appflowy_cache_manager.dart';import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/startup/tasks/rust_sdk.dart';import 'package:appflowy/util/share_log_files.dart';-import 'package:appflowy/util/theme_extension.dart';import 'package:appflowy/workspace/application/settings/setting_file_importer_bloc.dart';-import 'package:appflowy/workspace/application/settings/settings_location_cubit.dart';import 'package:appflowy/workspace/presentation/home/toast.dart';import 'package:appflowy/workspace/presentation/settings/pages/fix_data_widget.dart';-import 'package:appflowy/workspace/presentation/settings/shared/setting_action.dart';import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';import 'package:appflowy/workspace/presentation/settings/shared/settings_category.dart';import 'package:appflowy/workspace/presentation/settings/shared/single_setting_action.dart';import 'package:appflowy/workspace/presentation/settings/widgets/files/settings_export_file_widget.dart';+import 'package:appflowy/workspace/presentation/widgets/dialog_v2.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra/file_picker/file_picker_service.dart';import 'package:flowy_infra/theme_extension.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';-import 'package:flowy_infra_ui/style_widget/hover.dart';import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:fluttertoast/fluttertoast.dart';+import '../shared/setting_action.dart';+class SettingsManageDataView extends StatelessWidget {- const SettingsManageDataView({super.key, required this.userProfile});+ const SettingsManageDataView({+ super.key,+ required this.workspace,+ required this.userProfile,+ });+ final UserWorkspacePB workspace;final UserProfilePB userProfile;@overrideWidget build(BuildContext context) {- return BlocProvider<SettingsLocationCubit>(- create: (_) => SettingsLocationCubit(),- child: BlocBuilder<SettingsLocationCubit, SettingsLocationState>(+ return BlocProvider<DataLocationBloc>(+ create: (_) => DataLocationBloc(+ repository: const RustSettingsRepositoryImpl(),+ )..add(DataLocationEvent.initial()),+ child: BlocConsumer<DataLocationBloc, DataLocationState>(+ listenWhen: (previous, current) =>+ previous.didResetToDefault != current.didResetToDefault,+ listener: (context, state) {+ if (state.didResetToDefault) {+ Navigator.of(context).pop();+ runAppFlowy(isAnon: true);+ }+ },builder: (context, state) {+ // final _ = state.userDataLocation?.isCustom ?? false;+ final isCloudWorkspace =+ workspace.workspaceType == WorkspaceTypePB.ServerW;+ final path = state.userDataLocation?.path;+return SettingsBody(title: LocaleKeys.settings_manageDataPage_title.tr(),description: LocaleKeys.settings_manageDataPage_description.tr(),@@ -51,7 +71,7 @@ class SettingsManageDataView extends StatelessWidget {tooltip:LocaleKeys.settings_manageDataPage_dataStorage_tooltip.tr(),actions: [- if (state.mapOrNull(didReceivedPath: (_) => true) == true)+ if (isCloudWorkspace)SettingAction(tooltip: LocaleKeys.settings_manageDataPage_dataStorage_actions_resetTooltip@@ -61,42 +81,39 @@ class SettingsManageDataView extends StatelessWidget {size: Size.square(20),),label: LocaleKeys.settings_common_reset.tr(),- onPressed: () => showConfirmDialog(- context: context,- confirmLabel: LocaleKeys.button_confirm.tr(),- title: LocaleKeys- .settings_manageDataPage_dataStorage_resetDialog_title- .tr(),- description: LocaleKeys- .settings_manageDataPage_dataStorage_resetDialog_description- .tr(),- onConfirm: (_) async {- final directory =- await appFlowyApplicationDataDirectory();- final path = directory.path;- if (!context.mounted ||- state.mapOrNull(didReceivedPath: (e) => e.path) ==- path) {- return;- }-- await context- .read<SettingsLocationCubit>()- .resetDataStoragePathToApplicationDefault();- await runAppFlowy(isAnon: true);- },- ),+ onPressed: () {+ showSimpleAFDialog(+ context: context,+ title: LocaleKeys+ .settings_manageDataPage_dataStorage_resetDialog_title+ .tr(),+ content: LocaleKeys+ .settings_manageDataPage_dataStorage_resetDialog_description+ .tr(),+ primaryAction: (+ LocaleKeys.button_confirm.tr(),+ (_) {+ context+ .read<DataLocationBloc>()+ .add(DataLocationResetToDefault());+ }+ ),+ secondaryAction: (+ LocaleKeys.button_cancel.tr(),+ (_) {},+ ),+ );+ },),],- children: state- .map(- initial: (_) => [const CircularProgressIndicator()],- didReceivedPath: (event) => [- _CurrentPath(path: event.path),- _DataPathActions(currentPath: event.path),+ children: path == null+ ? [+ const CircularProgressIndicator(),+ ]+ : [+ _CurrentPath(path: path),+ if (isCloudWorkspace) _DataPathActions(path: path),],- )- .toList(),),SettingsCategory(title: LocaleKeys.settings_manageDataPage_importData_title.tr(),@@ -327,6 +344,7 @@ class _CurrentPath extends StatefulWidget {class _CurrentPathState extends State<_CurrentPath> {Timer? linkCopiedTimer;bool showCopyMessage = false;+ bool isHovering = false;@overridevoid dispose() {@@ -336,63 +354,84 @@ class _CurrentPathState extends State<_CurrentPath> {@overrideWidget build(BuildContext context) {- final isLM = Theme.of(context).isLightMode;+ final theme = AppFlowyTheme.of(context);return Column(children: [Row(children: [Expanded(- child: Listener(- behavior: HitTestBehavior.opaque,- onPointerDown: (_) => _copyLink(widget.path),- child: FlowyHover(- style: const HoverStyle.transparent(),- resetHoverOnRebuild: false,- builder: (_, isHovering) => FlowyText.regular(- widget.path,- maxLines: 2,- overflow: TextOverflow.ellipsis,- lineHeight: 1.5,- decoration: isHovering ? TextDecoration.underline : null,- color: isLM- ? const Color(0xFF005483)- : Theme.of(context).colorScheme.primary,+ child: FlowyTooltip(+ message: LocaleKeys+ .settings_manageDataPage_dataStorage_actions_openTooltip+ .tr(),+ child: GestureDetector(+ onTap: () => {+ afLaunchUri(Uri.file(widget.path)),+ },+ child: MouseRegion(+ cursor: SystemMouseCursors.click,+ onEnter: (_) => setState(() => isHovering = true),+ onExit: (_) => setState(() => isHovering = false),+ child: Text(+ widget.path,+ maxLines: 2,+ style: theme.textStyle.body+ .standard(color: theme.textColorScheme.action)+ .copyWith(+ decoration:+ isHovering ? TextDecoration.underline : null,+ ),+ overflow: TextOverflow.ellipsis,+ ),),),),),- const HSpace(8),- showCopyMessage- ? SizedBox(- height: 36,- child: FlowyTextButton(- LocaleKeys- .settings_manageDataPage_dataStorage_actions_copiedHint- .tr(),- padding: const EdgeInsets.symmetric(- horizontal: 24,- vertical: 12,- ),- fontWeight: FontWeight.w500,- radius: BorderRadius.circular(12),- fillColor: AFThemeExtension.of(context).tint7,- hoverColor: AFThemeExtension.of(context).tint7,+ HSpace(+ theme.spacing.m,+ ),+ IndexedStack(+ alignment: Alignment.centerRight,+ index: showCopyMessage ? 0 : 1,+ children: [+ Container(+ decoration: BoxDecoration(+ color: AFThemeExtension.of(context).tint7,+ borderRadius: BorderRadius.circular(8),+ ),+ padding: EdgeInsets.symmetric(+ horizontal: theme.spacing.l,+ vertical: theme.spacing.m,+ ),+ child: Text(+ LocaleKeys+ .settings_manageDataPage_dataStorage_actions_copiedHint+ .tr(),+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,),- )- : Padding(- padding: const EdgeInsets.only(left: 100),- child: SettingAction(- tooltip: LocaleKeys- .settings_manageDataPage_dataStorage_actions_copy- .tr(),- icon: const FlowySvg(+ overflow: TextOverflow.ellipsis,+ ),+ ),+ FlowyTooltip(+ message: LocaleKeys+ .settings_manageDataPage_dataStorage_actions_copy+ .tr(),+ child: AFGhostButton.normal(+ builder: (context, _, __) {+ return FlowySvg(FlowySvgs.copy_s,- size: Size.square(24),- ),- onPressed: () => _copyLink(widget.path),- ),+ size: Size.square(20),+ color: theme.textColorScheme.primary,+ );+ },+ padding: EdgeInsets.all(theme.spacing.m),+ onTap: () => _copyLink(widget.path),),+ ),+ ],+ ),],),],@@ -405,52 +444,34 @@ class _CurrentPathState extends State<_CurrentPath> {linkCopiedTimer?.cancel();linkCopiedTimer = Timer(const Duration(milliseconds: 300),- () => mounted ? setState(() => showCopyMessage = false) : null,+ () {+ if (mounted) {+ setState(() => showCopyMessage = false);+ }+ },);}}class _DataPathActions extends StatelessWidget {- const _DataPathActions({required this.currentPath});+ const _DataPathActions({required this.path});- final String currentPath;+ final String path;@overrideWidget build(BuildContext context) {- return Row(- children: [- SizedBox(- height: 42,- child: PrimaryRoundedButton(- text: LocaleKeys.settings_manageDataPage_dataStorage_actions_change- .tr(),- margin: const EdgeInsets.symmetric(horizontal: 24),- fontWeight: FontWeight.w600,- radius: 12.0,- onTap: () async {- final path = await getIt<FilePickerService>().getDirectoryPath();- if (!context.mounted || path == null || currentPath == path) {- return;- }-- await context.read<SettingsLocationCubit>().setCustomPath(path);- await runAppFlowy(isAnon: true);-- if (context.mounted) Navigator.of(context).pop();- },- ),- ),- const HSpace(16),- SettingAction(- tooltip: LocaleKeys- .settings_manageDataPage_dataStorage_actions_openTooltip- .tr(),- label:- LocaleKeys.settings_manageDataPage_dataStorage_actions_open.tr(),- icon: const FlowySvg(FlowySvgs.folder_m, size: Size.square(20)),- onPressed: () => afLaunchUri(Uri.file(currentPath)),- ),- ],+ return AFFilledTextButton.primary(+ text: LocaleKeys.settings_manageDataPage_dataStorage_actions_change.tr(),+ onTap: () async {+ final path = await getIt<FilePickerService>().getDirectoryPath();+ if (!context.mounted || path == null || path == path) {+ return;+ }++ context+ .read<DataLocationBloc>()+ .add(DataLocationEvent.setCustomPath(path));+ },);}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dartindex 0cf3d4bf5b..a120eac3b1 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart@@ -101,7 +101,7 @@ class SettingsDialog extends StatelessWidget {builder: (context, state) {return Expanded(child: getSettingsView(- state.currentWorkspace!.workspaceId,+ state.currentWorkspace!,context.read<SettingsDialogBloc>().state.page,state.userProfile,state.currentWorkspace?.role,@@ -119,7 +119,7 @@ class SettingsDialog extends StatelessWidget {}Widget getSettingsView(- String workspaceId,+ UserWorkspacePB workspace,SettingsPage page,UserProfilePB user,AFRolePB? currentWorkspaceMemberRole,@@ -137,7 +137,10 @@ class SettingsDialog extends StatelessWidget {currentWorkspaceMemberRole: currentWorkspaceMemberRole,);case SettingsPage.manageData:- return SettingsManageDataView(userProfile: user);+ return SettingsManageDataView(+ userProfile: user,+ workspace: workspace,+ );case SettingsPage.notifications:return const SettingsNotificationsView();case SettingsPage.cloud:@@ -147,36 +150,36 @@ class SettingsDialog extends StatelessWidget {case SettingsPage.ai:if (user.workspaceType == WorkspaceTypePB.ServerW) {return SettingsAIView(- key: ValueKey(workspaceId),+ key: ValueKey(workspace.workspaceId),userProfile: user,currentWorkspaceMemberRole: currentWorkspaceMemberRole,- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,);} else {return LocalSettingsAIView(- key: ValueKey(workspaceId),+ key: ValueKey(workspace.workspaceId),userProfile: user,- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,);}case SettingsPage.member:return WorkspaceMembersPage(userProfile: user,- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,);case SettingsPage.plan:return SettingsPlanView(- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,user: user,);case SettingsPage.billing:return SettingsBillingView(- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,user: user,);case SettingsPage.sites:return SettingsSitesPage(- workspaceId: workspaceId,+ workspaceId: workspace.workspaceId,user: user,);case SettingsPage.featureFlags:diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dartindex 329315b475..866274a57e 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/dialog_v2.dart@@ -70,14 +70,12 @@ Future<void> showSimpleAFDialog({AFModalFooter(trailing: [if (secondaryAction != null)- AFOutlinedButton.normal(+ AFOutlinedTextButton.normal(+ text: secondaryAction.$1,onTap: () {secondaryAction.$2?.call(context);Navigator.of(context).pop();},- builder: (context, isHovering, disabled) {- return Text(secondaryAction.$1);- },),isDestructive? AFFilledTextButton.destructive(diff --git a/frontend/appflowy_flutter/test/bloc_test/lib/features/settings/data_location_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/lib/features/settings/data_location_bloc_test.dartnew file mode 100644index 0000000000..f134546bc4--- /dev/null+++ b/frontend/appflowy_flutter/test/bloc_test/lib/features/settings/data_location_bloc_test.dart@@ -0,0 +1,90 @@+import 'package:appflowy/features/settings/settings.dart';+import 'package:appflowy_result/appflowy_result.dart';+import 'package:bloc_test/bloc_test.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:mocktail/mocktail.dart';++class MockSettingsRepository extends Mock implements SettingsRepository {}++void main() {+ late MockSettingsRepository repository;+ late DataLocationBloc bloc;++ const defaultPath = '/default/path';+ const customPath = '/custom/path';++ setUp(() {+ repository = MockSettingsRepository();+ when(() => repository.getUserDataLocation()).thenAnswer(+ (_) async => FlowyResult.success(+ UserDataLocation(path: defaultPath, isCustom: false),+ ),+ );+ bloc = DataLocationBloc(repository: repository)+ ..add(DataLocationEvent.initial());+ });++ tearDown(() async {+ await bloc.close();+ });++ blocTest<DataLocationBloc, DataLocationState>(+ 'emits updated state when resetting to default',+ build: () => bloc,+ setUp: () {+ when(() => repository.resetUserDataLocation()).thenAnswer(+ (_) async => FlowyResult.success(+ UserDataLocation(path: defaultPath, isCustom: false),+ ),+ );+ },+ act: (bloc) => bloc.add(DataLocationEvent.resetToDefault()),+ wait: const Duration(milliseconds: 100),+ expect: () => [+ DataLocationState(+ userDataLocation: UserDataLocation(path: defaultPath, isCustom: false),+ didResetToDefault: true,+ ),+ ],+ );++ blocTest<DataLocationBloc, DataLocationState>(+ 'emits updated state when setting custom path',+ build: () => bloc,+ setUp: () {+ when(() => repository.setCustomLocation(customPath)).thenAnswer(+ (_) async => FlowyResult.success(+ UserDataLocation(path: customPath, isCustom: true),+ ),+ );+ },+ act: (bloc) => bloc.add(DataLocationEvent.setCustomPath(customPath)),+ wait: const Duration(milliseconds: 100),+ expect: () => [+ DataLocationState(+ userDataLocation: UserDataLocation(path: customPath, isCustom: true),+ didResetToDefault: false,+ ),+ ],+ );++ blocTest<DataLocationBloc, DataLocationState>(+ 'emits state with cleared reset flag',+ build: () => bloc,+ seed: () => DataLocationState(+ userDataLocation: UserDataLocation(path: defaultPath, isCustom: false),+ didResetToDefault: true,+ ),+ act: (bloc) => bloc.add(DataLocationEvent.clearState()),+ wait: const Duration(milliseconds: 100),+ expect: () => [+ DataLocationState(+ userDataLocation: UserDataLocation(+ path: defaultPath,+ isCustom: false,+ ),+ didResetToDefault: false,+ ),+ ],+ );+}