Skip to content

Commit

Permalink
feat: publish databse to Web (#5709)
Browse files Browse the repository at this point in the history
* chore: refactor the publish code

* feat: integrate publish into database page

* feat: add publish database structure

* feat: add database row collab

* feat: publish the database row collabs

* chore: update collab

* chore: improve question bubble

* feat: publish the database relations

* fix: rust ci

* feat: select grid view to publish

* feat: unable to deselect the primary database

* feat: optimize the read recent views speed (#5726)

* feat: optimize the read recent views speed

* fix: order of recent views should be from the latest to the oldest

* chore: update translations

* fix: replace the unable to be selected icon

* feat: remove left padding of inline database

* fix: code review

* chore: remove publish api err log

* chore: read the database collab and document collab from disk instead of memory

* chore: code cleanup

* chore: revert beta.appflowy.com

* chore: code cleanup

* test: add database encode test

* test: add publish database test

* chore: refresh sidebar layout

* chore: update comments
  • Loading branch information
LucasXu0 authored Jul 22, 2024
1 parent e8e4162 commit 432db0f
Show file tree
Hide file tree
Showing 61 changed files with 1,592 additions and 815 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:io';

import 'package:appflowy/plugins/document/presentation/share/share_button.dart';
import 'package:appflowy/plugins/shared/share/share_button.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:path/path.dart' as p;
Expand Down Expand Up @@ -51,9 +51,8 @@ void main() {
},
);

final shareButton = find.byType(DocumentShareButton);
final shareButtonState =
tester.widget(shareButton) as DocumentShareButton;
final shareButton = find.byType(ShareButton);
final shareButtonState = tester.widget(shareButton) as ShareButton;

final path = await mockSaveFilePath(
p.join(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/mobile/presentation/presentation.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/emoji_picker_button.dart';
import 'package:appflowy/plugins/document/presentation/share/share_button.dart';
import 'package:appflowy/plugins/shared/share/share_button.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/presentation/screens/screens.dart';
Expand All @@ -35,6 +30,10 @@ import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/widget/buttons/primary_button.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import 'emoji.dart';
Expand Down Expand Up @@ -259,7 +258,7 @@ extension CommonOperations on WidgetTester {
/// Tap the share button above the document page.
Future<void> tapShareButton() async {
final shareButton = find.byWidgetPredicate(
(widget) => widget is DocumentShareButton,
(widget) => widget is ShareButton,
);
await tapButton(shareButton);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/appflowy_flutter/lib/plugins/ai_chat/chat.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:flutter/material.dart';

import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/plugins/ai_chat/chat_page.dart';
import 'package:appflowy/plugins/util.dart';
Expand All @@ -9,6 +7,7 @@ import 'package:appflowy/workspace/presentation/home/home_stack.dart';
import 'package:appflowy/workspace/presentation/widgets/tab_bar_item.dart';
import 'package:appflowy/workspace/presentation/widgets/view_title_bar.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class AIChatPluginBuilder extends PluginBuilder {
Expand Down Expand Up @@ -96,6 +95,7 @@ class AIChatPagePluginWidgetBuilder extends PluginWidgetBuilder
Widget buildWidget({
required PluginContext context,
required bool shrinkWrap,
Map<String, dynamic>? data,
}) {
notifier.isDeleted.addListener(() {
final deletedView = notifier.isDeleted.value;
Expand Down
1 change: 1 addition & 0 deletions frontend/appflowy_flutter/lib/plugins/blank/blank.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class BlankPagePluginWidgetBuilder extends PluginWidgetBuilder
Widget buildWidget({
required PluginContext context,
required bool shrinkWrap,
Map<String, dynamic>? data,
}) =>
const BlankPage();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:flutter/material.dart';

import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculations_row.dart';
Expand All @@ -9,13 +6,15 @@ import 'package:appflowy/plugins/database/tab_bar/desktop/setting_menu.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_builder.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/workspace/application/view/view_bloc.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:collection/collection.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scrollview.dart';
import 'package:flowy_infra_ui/widget/error_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:linked_scroll_controller/linked_scroll_controller.dart';

Expand All @@ -24,7 +23,6 @@ import '../../application/row/row_controller.dart';
import '../../tab_bar/tab_bar_view.dart';
import '../../widgets/row/row_detail.dart';
import '../application/grid_bloc.dart';

import 'grid_scroll.dart';
import 'layout/layout.dart';
import 'layout/sizes.dart';
Expand Down Expand Up @@ -504,7 +502,10 @@ class _PositionedCalculationsRowState
left: 0,
right: 0,
child: Container(
margin: EdgeInsets.only(left: GridSize.horizontalHeaderPadding + 40),
margin: EdgeInsets.only(
left:
context.read<DatabasePluginWidgetBuilderSize>().horizontalPadding,
),
padding: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: Theme.of(context).canvasColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:appflowy/plugins/database/application/field/field_controller.dar
import 'package:appflowy/plugins/database/domain/field_service.dart';
import 'package:appflowy/plugins/database/grid/application/grid_bloc.dart';
import 'package:appflowy/plugins/database/grid/application/grid_header_bloc.dart';
import 'package:appflowy/plugins/database/tab_bar/tab_bar_view.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
import 'package:easy_localization/easy_localization.dart';
Expand Down Expand Up @@ -139,7 +140,9 @@ class _GridHeaderState extends State<_GridHeader> {
}

Widget _cellLeading() {
return SizedBox(width: GridSize.horizontalHeaderPadding + 40);
return SizedBox(
width: context.read<DatabasePluginWidgetBuilderSize>().horizontalPadding,
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import 'package:flutter/material.dart';

import 'package:appflowy/generated/flowy_svgs.g.dart';
import "package:appflowy/generated/locale_keys.g.dart";
import 'package:appflowy/plugins/database/application/cell/cell_controller.dart';
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
import 'package:appflowy/plugins/database/application/row/row_controller.dart';
import 'package:appflowy/plugins/database/application/row/row_service.dart';
import 'package:appflowy/plugins/database/grid/application/row/row_bloc.dart';
import 'package:appflowy/plugins/database/tab_bar/tab_bar_view.dart';
import 'package:appflowy/plugins/database/widgets/cell/editable_cell_builder.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';

import '../../../../widgets/row/accessory/cell_accessory.dart';
import '../../../../widgets/row/cells/cell_container.dart';
import '../../layout/sizes.dart';

import 'action.dart';

class GridRow extends StatefulWidget {
Expand Down Expand Up @@ -112,7 +111,9 @@ class _RowLeadingState extends State<_RowLeading> {
child: Consumer<RegionStateNotifier>(
builder: (context, state, _) {
return SizedBox(
width: GridSize.horizontalHeaderPadding + 40,
width: context
.read<DatabasePluginWidgetBuilderSize>()
.horizontalPadding,
child: state.onEnter ? _activeWidget() : null,
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart';
import 'package:appflowy/plugins/database/tab_bar/tab_bar_view.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
Expand All @@ -17,14 +17,17 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'tab_bar_add_button.dart';

class TabBarHeader extends StatelessWidget {
const TabBarHeader({super.key});
const TabBarHeader({
super.key,
});

@override
Widget build(BuildContext context) {
return Container(
height: 30,
padding: EdgeInsets.symmetric(
horizontal: GridSize.horizontalHeaderPadding + 40,
horizontal:
context.read<DatabasePluginWidgetBuilderSize>().horizontalPadding,
),
child: Stack(
children: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:appflowy/plugins/database/application/database_controller.dart';
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
import 'package:appflowy/plugins/database/widgets/share_button.dart';
import 'package:appflowy/plugins/database/grid/presentation/layout/sizes.dart';
import 'package:appflowy/plugins/shared/share/share_button.dart';
import 'package:appflowy/plugins/util.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
Expand All @@ -16,6 +17,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';

import 'desktop/tab_bar_header.dart';
import 'mobile/mobile_tab_bar_header.dart';
Expand Down Expand Up @@ -219,6 +221,16 @@ class DatabaseTabBarViewPlugin extends Plugin {
}
}

const kDatabasePluginWidgetBuilderHorizontalPadding = 'horizontal_padding';

class DatabasePluginWidgetBuilderSize {
const DatabasePluginWidgetBuilderSize({
required this.horizontalPadding,
});

final double horizontalPadding;
}

class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
DatabasePluginWidgetBuilder({
required this.bloc,
Expand All @@ -244,6 +256,7 @@ class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
Widget buildWidget({
required PluginContext context,
required bool shrinkWrap,
Map<String, dynamic>? data,
}) {
notifier.isDeleted.addListener(() {
final deletedView = notifier.isDeleted.value;
Expand All @@ -252,11 +265,20 @@ class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
}
});

return DatabaseTabBarView(
key: ValueKey(notifier.view.id),
view: notifier.view,
shrinkWrap: shrinkWrap,
initialRowId: initialRowId,
final horizontalPadding =
data?[kDatabasePluginWidgetBuilderHorizontalPadding] as double? ??
GridSize.horizontalHeaderPadding + 40;

return Provider(
create: (context) => DatabasePluginWidgetBuilderSize(
horizontalPadding: horizontalPadding,
),
child: DatabaseTabBarView(
key: ValueKey(notifier.view.id),
view: notifier.view,
shrinkWrap: shrinkWrap,
initialRowId: initialRowId,
),
);
}

Expand All @@ -270,7 +292,7 @@ class DatabasePluginWidgetBuilder extends PluginWidgetBuilder {
value: bloc,
child: Row(
children: [
DatabaseShareButton(key: ValueKey(view.id), view: view),
ShareButton(key: ValueKey(view.id), view: view),
const HSpace(10),
ViewFavoriteButton(view: view),
const HSpace(4),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';

import 'package:appflowy/plugins/database/tab_bar/tab_bar_view.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:appflowy/workspace/application/view/view_listener.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:flutter/material.dart';

class DatabaseViewWidget extends StatefulWidget {
const DatabaseViewWidget({
Expand Down Expand Up @@ -55,6 +55,9 @@ class _DatabaseViewWidgetState extends State<DatabaseViewWidget> {
builder: (_, __, ___) => viewPlugin.widgetBuilder.buildWidget(
shrinkWrap: widget.shrinkWrap,
context: PluginContext(),
data: {
kDatabasePluginWidgetBuilderHorizontalPadding: 40.0,
},
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class DatabaseDocumentPluginWidgetBuilder extends PluginWidgetBuilder
Widget buildWidget({
required PluginContext context,
required bool shrinkWrap,
Map<String, dynamic>? data,
}) {
return BlocBuilder<DocumentAppearanceCubit, DocumentAppearance>(
builder: (_, state) => DatabaseDocumentPage(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export '../../shared/share/share_bloc.dart';
export 'document_bloc.dart';
export 'document_service.dart';
export 'document_share_bloc.dart';
5 changes: 3 additions & 2 deletions frontend/appflowy_flutter/lib/plugins/document/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/plugins/document/document_page.dart';
import 'package:appflowy/plugins/document/presentation/document_collaborators.dart';
import 'package:appflowy/plugins/document/presentation/share/share_button.dart';
import 'package:appflowy/plugins/shared/share/share_button.dart';
import 'package:appflowy/plugins/util.dart';
import 'package:appflowy/shared/feature_flags.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
Expand Down Expand Up @@ -109,6 +109,7 @@ class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
Widget buildWidget({
required PluginContext context,
required bool shrinkWrap,
Map<String, dynamic>? data,
}) {
notifier.isDeleted.addListener(() {
final deletedView = notifier.isDeleted.value;
Expand Down Expand Up @@ -154,7 +155,7 @@ class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
const HSpace(16),
]
: [const HSpace(8)],
DocumentShareButton(
ShareButton(
key: ValueKey('share_button_${view.id}'),
view: view,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_popover/appflowy_popover.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';

class BuiltInPageWidget extends StatefulWidget {
Expand Down Expand Up @@ -127,7 +125,6 @@ class _BuiltInPageWidgetState extends State<BuiltInPageWidget> {
icon: const FlowySvg(
FlowySvgs.information_s,
),
iconColorOnHover: Theme.of(context).colorScheme.onSecondary,
),
// setting
const Space(7, 0),
Expand All @@ -141,7 +138,6 @@ class _BuiltInPageWidgetState extends State<BuiltInPageWidget> {
width: 24,
height: 24,
iconPadding: const EdgeInsets.all(3),
iconColorOnHover: Theme.of(context).colorScheme.onSecondary,
icon: const FlowySvg(
FlowySvgs.settings_s,
),
Expand Down
Loading

0 comments on commit 432db0f

Please sign in to comment.