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 rename dialog logic (#6906)
Lucasd9bc97e012a6
diff --git a/frontend/appflowy_flutter/lib/core/config/kv_keys.dart b/frontend/appflowy_flutter/lib/core/config/kv_keys.dartindex 74ff98c46f..1d76e329b7 100644--- a/frontend/appflowy_flutter/lib/core/config/kv_keys.dart+++ b/frontend/appflowy_flutter/lib/core/config/kv_keys.dart@@ -49,6 +49,7 @@ class KVKeys {/// {'SidebarFolderCategoryType.value': true}static const String expandedFolders = 'expandedFolders';+ /// @deprecated in version 0.7.6/// The key for saving if showing the rename dialog when creating a new file////// The value is a boolean string.diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/folder/_section_folder.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/folder/_section_folder.dartindex 35a88ba76d..0b383cc5a1 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/folder/_section_folder.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/folder/_section_folder.dart@@ -1,14 +1,11 @@-import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/application/menu/sidebar_sections_bloc.dart';import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';import 'package:appflowy/workspace/presentation/home/home_sizes.dart';import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/_folder_header.dart';-import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';-import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -78,23 +75,17 @@ class _SectionFolderState extends State<SectionFolder> {onPressed: () =>context.read<FolderBloc>().add(const FolderEvent.expandOrUnExpand()),onAdded: () {- createViewAndShowRenameDialogIfNeeded(- context,- LocaleKeys.newPageText.tr(),- (_, __) {- context.read<SidebarSectionsBloc>().add(- SidebarSectionsEvent.createRootViewInSection(- name: '',- index: 0,- viewSection: widget.spaceType.toViewSectionPB,- ),- );+ context.read<SidebarSectionsBloc>().add(+ SidebarSectionsEvent.createRootViewInSection(+ name: '',+ index: 0,+ viewSection: widget.spaceType.toViewSectionPB,+ ),+ );- context- .read<FolderBloc>()- .add(const FolderEvent.expandOrUnExpand(isExpanded: true));- },- );+ context+ .read<FolderBloc>()+ .add(const FolderEvent.expandOrUnExpand(isExpanded: true));},);}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dartdeleted file mode 100644index e8fec96e9b..0000000000--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart+++ /dev/null@@ -1,36 +0,0 @@-import 'package:appflowy/core/config/kv.dart';-import 'package:appflowy/core/config/kv_keys.dart';-import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/startup/startup.dart';-import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';-import 'package:easy_localization/easy_localization.dart';-import 'package:flutter/material.dart';--/// Creates a new view and shows the rename dialog if needed.-///-/// If the user has enabled the setting to show the rename dialog when creating a new view,-/// this function will show the rename dialog.-///-/// Otherwise, it will just create the view with default name.-Future<void> createViewAndShowRenameDialogIfNeeded(- BuildContext context,- String dialogTitle,- void Function(String viewName, BuildContext context) createView,-) async {- final value = await getIt<KeyValueStorage>().getWithFormat(- KVKeys.showRenameDialogWhenCreatingNewFile,- (value) => bool.parse(value),- );- final showRenameDialog = value ?? false;- final defaultName = LocaleKeys.menuAppHeader_defaultNewPageName.tr();- if (context.mounted && showRenameDialog) {- await NavigatorTextFieldDialog(- title: dialogTitle,- value: defaultName,- autoSelectAllText: true,- onConfirm: createView,- ).show(context);- } else if (context.mounted) {- createView(defaultName, context);- }-}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_new_page_button.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_new_page_button.dartindex d661d3ec91..d35c4cd148 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_new_page_button.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/shared/sidebar_new_page_button.dart@@ -5,7 +5,6 @@ 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/home_sizes.dart';import 'package:appflowy/workspace/presentation/home/hotkeys.dart';-import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart';import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';@@ -57,35 +56,28 @@ class _SidebarNewPageButtonState extends State<SidebarNewPageButton> {}Future<void> _createNewPage() async {- return createViewAndShowRenameDialogIfNeeded(- context,- LocaleKeys.newPageText.tr(),- (_, __) {- // if the workspace is collaborative, create the view in the private section by default.- final section =- context.read<UserWorkspaceBloc>().state.isCollabWorkspaceOn- ? ViewSectionPB.Private- : ViewSectionPB.Public;- final spaceState = context.read<SpaceBloc>().state;- if (spaceState.spaces.isNotEmpty) {- context.read<SpaceBloc>().add(- const SpaceEvent.createPage(- name: '',- index: 0,- layout: ViewLayoutPB.Document,- openAfterCreate: true,- ),- );- } else {- context.read<SidebarSectionsBloc>().add(- SidebarSectionsEvent.createRootViewInSection(- name: '',- viewSection: section,- index: 0,- ),- );- }- },- );+ // if the workspace is collaborative, create the view in the private section by default.+ final section = context.read<UserWorkspaceBloc>().state.isCollabWorkspaceOn+ ? ViewSectionPB.Private+ : ViewSectionPB.Public;+ final spaceState = context.read<SpaceBloc>().state;+ if (spaceState.spaces.isNotEmpty) {+ context.read<SpaceBloc>().add(+ const SpaceEvent.createPage(+ name: '',+ index: 0,+ layout: ViewLayoutPB.Document,+ openAfterCreate: true,+ ),+ );+ } else {+ context.read<SidebarSectionsBloc>().add(+ SidebarSectionsEvent.createRootViewInSection(+ name: '',+ viewSection: section,+ index: 0,+ ),+ );+ }}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dartindex d3a2fc3c4f..6d6611b403 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_item.dart@@ -14,7 +14,6 @@ import 'package:appflowy/workspace/application/view/prelude.dart';import 'package:appflowy/workspace/application/view/view_ext.dart';import 'package:appflowy/workspace/presentation/home/home_sizes.dart';import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';-import 'package:appflowy/workspace/presentation/home/menu/sidebar/shared/rename_view_dialog.dart';import 'package:appflowy/workspace/presentation/home/menu/view/draggable_view_item.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_action_type.dart';import 'package:appflowy/workspace/presentation/home/menu/view/view_add_button.dart';@@ -692,26 +691,18 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {) {final viewBloc = context.read<ViewBloc>();- if (createNewView) {- createViewAndShowRenameDialogIfNeeded(- context,- _convertLayoutToHintText(pluginBuilder.layoutType!),- (viewName, _) {- // the name of new document should be empty- if (pluginBuilder.layoutType == ViewLayoutPB.Document) {- viewName = '';- }- viewBloc.add(- ViewEvent.createView(- viewName,- pluginBuilder.layoutType!,- openAfterCreated: openAfterCreated,- section: widget.spaceType.toViewSectionPB,- ),- );- },- );- }+ // the name of new document should be empty+ final viewName = pluginBuilder.layoutType != ViewLayoutPB.Document+ ? LocaleKeys.menuAppHeader_defaultNewPageName.tr()+ : '';+ viewBloc.add(+ ViewEvent.createView(+ viewName,+ pluginBuilder.layoutType!,+ openAfterCreated: openAfterCreated,+ section: widget.spaceType.toViewSectionPB,+ ),+ );viewBloc.add(const ViewEvent.setIsExpanded(true));}@@ -815,22 +806,6 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {),);}-- String _convertLayoutToHintText(ViewLayoutPB layout) {- switch (layout) {- case ViewLayoutPB.Document:- return LocaleKeys.newDocumentText.tr();- case ViewLayoutPB.Grid:- return LocaleKeys.newGridText.tr();- case ViewLayoutPB.Board:- return LocaleKeys.newBoardText.tr();- case ViewLayoutPB.Calendar:- return LocaleKeys.newCalendarText.tr();- case ViewLayoutPB.Chat:- return LocaleKeys.chat_newChat.tr();- }- return LocaleKeys.newPageText.tr();- }}class _DotIconWidget extends StatelessWidget {