mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: tauri folder display (#2176)
* fix: tauri folder display * refactor: rename layout type
This commit is contained in:
parent
e1c8135f5d
commit
ddd3fbb178
2
.gitignore
vendored
2
.gitignore
vendored
@ -35,3 +35,5 @@ pubspec.lock
|
||||
.githooks/gitlint
|
||||
.githooks/gitlint.exe
|
||||
.fvm/
|
||||
|
||||
**/AppFlowy-Collab/
|
||||
|
@ -79,7 +79,7 @@ class DatabaseController {
|
||||
final DatabaseViewBackendService _databaseViewBackendSvc;
|
||||
final FieldController fieldController;
|
||||
late DatabaseViewCache _viewCache;
|
||||
final LayoutTypePB layoutType;
|
||||
final DatabaseLayoutPB layoutType;
|
||||
|
||||
// Callbacks
|
||||
DatabaseCallbacks? _databaseCallbacks;
|
||||
@ -110,7 +110,7 @@ class DatabaseController {
|
||||
_listenOnFieldsChanged();
|
||||
_listenOnGroupChanged();
|
||||
_listenOnLayoutChanged();
|
||||
if (layoutType == LayoutTypePB.Calendar) {
|
||||
if (layoutType == DatabaseLayoutPB.Calendar) {
|
||||
_listenOnCalendarLayoutChanged();
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class DatabaseViewBackendService {
|
||||
}
|
||||
|
||||
Future<Either<LayoutSettingPB, FlowyError>> getLayoutSetting(
|
||||
LayoutTypePB layoutType) {
|
||||
DatabaseLayoutPB layoutType) {
|
||||
final payload = DatabaseLayoutIdPB.create()
|
||||
..viewId = viewId
|
||||
..layout = layoutType;
|
||||
|
@ -30,7 +30,7 @@ class BoardBloc extends Bloc<BoardEvent, BoardState> {
|
||||
BoardBloc({required ViewPB view})
|
||||
: _databaseController = DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Board,
|
||||
layoutType: DatabaseLayoutPB.Board,
|
||||
),
|
||||
super(BoardState.initial(view.id)) {
|
||||
boardController = AppFlowyBoardController(
|
||||
|
@ -29,7 +29,7 @@ class BoardPluginBuilder implements PluginBuilder {
|
||||
PluginType get pluginType => PluginType.board;
|
||||
|
||||
@override
|
||||
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Board;
|
||||
ViewLayoutPB? get layoutType => ViewLayoutPB.Board;
|
||||
}
|
||||
|
||||
class BoardPluginConfig implements PluginConfig {
|
||||
|
@ -28,7 +28,7 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
|
||||
CalendarBloc({required ViewPB view})
|
||||
: _databaseController = DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Calendar,
|
||||
layoutType: DatabaseLayoutPB.Calendar,
|
||||
),
|
||||
super(CalendarState.initial()) {
|
||||
on<CalendarEvent>(
|
||||
|
@ -29,7 +29,7 @@ class CalendarPluginBuilder extends PluginBuilder {
|
||||
PluginType get pluginType => PluginType.calendar;
|
||||
|
||||
@override
|
||||
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Calendar;
|
||||
ViewLayoutPB? get layoutType => ViewLayoutPB.Calendar;
|
||||
}
|
||||
|
||||
class CalendarPluginConfig implements PluginConfig {
|
||||
|
@ -29,7 +29,7 @@ class GridPluginBuilder implements PluginBuilder {
|
||||
PluginType get pluginType => PluginType.grid;
|
||||
|
||||
@override
|
||||
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Grid;
|
||||
ViewLayoutPB? get layoutType => ViewLayoutPB.Grid;
|
||||
}
|
||||
|
||||
class GridPluginConfig implements PluginConfig {
|
||||
|
@ -38,7 +38,7 @@ class GridPage extends StatefulWidget {
|
||||
Key? key,
|
||||
}) : databaseController = DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
),
|
||||
super(key: key);
|
||||
|
||||
|
@ -34,7 +34,7 @@ class DocumentPluginBuilder extends PluginBuilder {
|
||||
PluginType get pluginType => PluginType.editor;
|
||||
|
||||
@override
|
||||
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Document;
|
||||
ViewLayoutPB? get layoutType => ViewLayoutPB.Document;
|
||||
}
|
||||
|
||||
class DocumentPlugin extends Plugin<int> {
|
||||
|
@ -30,9 +30,9 @@ extension InsertPage on EditorState {
|
||||
|
||||
String _convertPageType(ViewPB viewPB) {
|
||||
switch (viewPB.layout) {
|
||||
case ViewLayoutTypePB.Grid:
|
||||
case ViewLayoutPB.Grid:
|
||||
return kGridType;
|
||||
case ViewLayoutTypePB.Board:
|
||||
case ViewLayoutPB.Board:
|
||||
return kBoardType;
|
||||
default:
|
||||
throw Exception('Unknown layout type');
|
||||
|
@ -17,7 +17,7 @@ void showLinkToPageMenu(
|
||||
EditorState editorState,
|
||||
SelectionMenuService menuService,
|
||||
BuildContext context,
|
||||
ViewLayoutTypePB pageType,
|
||||
ViewLayoutPB pageType,
|
||||
) {
|
||||
final alignment = menuService.alignment;
|
||||
final offset = menuService.offset;
|
||||
@ -27,10 +27,10 @@ void showLinkToPageMenu(
|
||||
|
||||
String hintText = '';
|
||||
switch (pageType) {
|
||||
case ViewLayoutTypePB.Grid:
|
||||
case ViewLayoutPB.Grid:
|
||||
hintText = LocaleKeys.document_slashMenu_grid_selectAGridToLinkTo.tr();
|
||||
break;
|
||||
case ViewLayoutTypePB.Board:
|
||||
case ViewLayoutPB.Board:
|
||||
hintText = LocaleKeys.document_slashMenu_board_selectABoardToLinkTo.tr();
|
||||
break;
|
||||
default:
|
||||
@ -82,7 +82,7 @@ class LinkToPageMenu extends StatefulWidget {
|
||||
});
|
||||
|
||||
final EditorState editorState;
|
||||
final ViewLayoutTypePB layoutType;
|
||||
final ViewLayoutPB layoutType;
|
||||
final String hintText;
|
||||
final void Function(ViewPB view, ViewPB childView) onSelected;
|
||||
|
||||
@ -174,9 +174,9 @@ class _LinkToPageMenuState extends State<LinkToPageMenu> {
|
||||
|
||||
String _iconName(ViewPB viewPB) {
|
||||
switch (viewPB.layout) {
|
||||
case ViewLayoutTypePB.Grid:
|
||||
case ViewLayoutPB.Grid:
|
||||
return 'editor/grid';
|
||||
case ViewLayoutTypePB.Board:
|
||||
case ViewLayoutPB.Board:
|
||||
return 'editor/board';
|
||||
default:
|
||||
throw Exception('Unknown layout type');
|
||||
|
@ -24,7 +24,7 @@ SelectionMenuItem boardMenuItem = SelectionMenuItem(
|
||||
editorState,
|
||||
menuService,
|
||||
context,
|
||||
ViewLayoutTypePB.Board,
|
||||
ViewLayoutPB.Board,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -23,17 +23,17 @@ SelectionMenuItem boardViewMenuItem(DocumentBloc documentBloc) =>
|
||||
// TODO(a-wallen): Translate keywords.
|
||||
keywords: ['board', 'kanban'],
|
||||
handler: (editorState, menuService, context) async {
|
||||
if (!documentBloc.view.hasAppId()) {
|
||||
if (!documentBloc.view.hasParentViewId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final appId = documentBloc.view.appId;
|
||||
final appId = documentBloc.view.parentViewId;
|
||||
final service = AppBackendService();
|
||||
|
||||
final result = (await service.createView(
|
||||
appId: appId,
|
||||
name: LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
||||
layoutType: ViewLayoutTypePB.Board,
|
||||
layoutType: ViewLayoutPB.Board,
|
||||
))
|
||||
.getLeftOrNull();
|
||||
|
||||
|
@ -23,7 +23,7 @@ SelectionMenuItem gridMenuItem = SelectionMenuItem(
|
||||
editorState,
|
||||
menuService,
|
||||
context,
|
||||
ViewLayoutTypePB.Grid,
|
||||
ViewLayoutPB.Grid,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -22,17 +22,17 @@ SelectionMenuItem gridViewMenuItem(DocumentBloc documentBloc) =>
|
||||
},
|
||||
keywords: ['grid'],
|
||||
handler: (editorState, menuService, context) async {
|
||||
if (!documentBloc.view.hasAppId()) {
|
||||
if (!documentBloc.view.hasParentViewId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final appId = documentBloc.view.appId;
|
||||
final appId = documentBloc.view.parentViewId;
|
||||
final service = AppBackendService();
|
||||
|
||||
final result = (await service.createView(
|
||||
appId: appId,
|
||||
name: LocaleKeys.menuAppHeader_defaultNewPageName.tr(),
|
||||
layoutType: ViewLayoutTypePB.Grid,
|
||||
layoutType: ViewLayoutPB.Grid,
|
||||
))
|
||||
.getLeftOrNull();
|
||||
|
||||
|
@ -52,7 +52,7 @@ abstract class PluginBuilder {
|
||||
|
||||
PluginType get pluginType;
|
||||
|
||||
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Document;
|
||||
ViewLayoutPB? get layoutType => ViewLayoutPB.Document;
|
||||
}
|
||||
|
||||
abstract class PluginConfig {
|
||||
|
@ -12,7 +12,7 @@ class AppBackendService {
|
||||
required String appId,
|
||||
required String name,
|
||||
String? desc,
|
||||
required ViewLayoutTypePB layoutType,
|
||||
required ViewLayoutPB layoutType,
|
||||
|
||||
/// The initial data should be the JSON of the document.
|
||||
/// Currently, only support create document with initial data.
|
||||
@ -90,7 +90,7 @@ class AppBackendService {
|
||||
}
|
||||
|
||||
Future<List<Tuple2<ViewPB, List<ViewPB>>>> fetchViews(
|
||||
ViewLayoutTypePB layoutType) async {
|
||||
ViewLayoutPB layoutType) async {
|
||||
final result = <Tuple2<ViewPB, List<ViewPB>>>[];
|
||||
return FolderEventReadCurrentWorkspace().send().then((value) async {
|
||||
final workspaces = value.getLeftOrNull<WorkspaceSettingPB>();
|
||||
|
@ -42,13 +42,13 @@ extension ViewExtension on ViewPB {
|
||||
|
||||
PluginType get pluginType {
|
||||
switch (layout) {
|
||||
case ViewLayoutTypePB.Board:
|
||||
case ViewLayoutPB.Board:
|
||||
return PluginType.board;
|
||||
case ViewLayoutTypePB.Calendar:
|
||||
case ViewLayoutPB.Calendar:
|
||||
return PluginType.calendar;
|
||||
case ViewLayoutTypePB.Document:
|
||||
case ViewLayoutPB.Document:
|
||||
return PluginType.editor;
|
||||
case ViewLayoutTypePB.Grid:
|
||||
case ViewLayoutPB.Grid:
|
||||
return PluginType.grid;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart'
|
||||
CreateViewPayloadPB,
|
||||
MoveFolderItemPayloadPB,
|
||||
MoveFolderItemType,
|
||||
ViewLayoutTypePB,
|
||||
ViewLayoutPB,
|
||||
ViewPB;
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder2/workspace.pb.dart';
|
||||
|
||||
@ -26,7 +26,7 @@ class WorkspaceService {
|
||||
..belongToId = workspaceId
|
||||
..name = name
|
||||
..desc = desc ?? ""
|
||||
..layout = ViewLayoutTypePB.Document;
|
||||
..layout = ViewLayoutPB.Document;
|
||||
|
||||
return FolderEventCreateView(payload).send();
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ class HomeScreenStackAdaptor extends HomeStackDelegate {
|
||||
@override
|
||||
void didDeleteStackWidget(ViewPB view, int? index) {
|
||||
final homeService = HomeService();
|
||||
homeService.readApp(appId: view.appId).then((result) {
|
||||
homeService.readApp(appId: view.parentViewId).then((result) {
|
||||
result.fold(
|
||||
(parentView) {
|
||||
final List<ViewPB> views = parentView.belongings;
|
||||
|
@ -43,7 +43,7 @@ class AppFlowyBoardTest {
|
||||
view,
|
||||
DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Board,
|
||||
layoutType: DatabaseLayoutPB.Board,
|
||||
),
|
||||
);
|
||||
final result = await context._boardDataController.open();
|
||||
|
@ -53,7 +53,7 @@ void main() {
|
||||
final service = FilterBackendService(viewId: context.gridView.id);
|
||||
final gridController = DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
);
|
||||
final gridBloc = GridBloc(
|
||||
view: context.gridView,
|
||||
@ -77,7 +77,7 @@ void main() {
|
||||
final service = FilterBackendService(viewId: context.gridView.id);
|
||||
final gridController = DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
);
|
||||
final gridBloc = GridBloc(
|
||||
view: context.gridView,
|
||||
@ -121,7 +121,7 @@ void main() {
|
||||
final service = FilterBackendService(viewId: context.gridView.id);
|
||||
final gridController = DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
);
|
||||
final gridBloc = GridBloc(
|
||||
view: context.gridView,
|
||||
@ -143,7 +143,7 @@ void main() {
|
||||
final service = FilterBackendService(viewId: context.gridView.id);
|
||||
final gridController = DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
);
|
||||
final gridBloc = GridBloc(
|
||||
view: context.gridView,
|
||||
|
@ -21,7 +21,7 @@ Future<GridTestContext> createTestFilterGrid(AppFlowyGridTest gridTest) async {
|
||||
view,
|
||||
DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
));
|
||||
final result = await context.gridController.open();
|
||||
|
||||
|
@ -23,7 +23,7 @@ void main() {
|
||||
view: context.gridView,
|
||||
databaseController: DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
))
|
||||
..add(const GridEvent.initial()),
|
||||
act: (bloc) => bloc.add(const GridEvent.createRow()),
|
||||
@ -39,7 +39,7 @@ void main() {
|
||||
view: context.gridView,
|
||||
databaseController: DatabaseController(
|
||||
view: context.gridView,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
))
|
||||
..add(const GridEvent.initial()),
|
||||
act: (bloc) async {
|
||||
|
@ -178,7 +178,7 @@ class AppFlowyGridTest {
|
||||
view,
|
||||
DatabaseController(
|
||||
view: view,
|
||||
layoutType: LayoutTypePB.Grid,
|
||||
layoutType: DatabaseLayoutPB.Grid,
|
||||
));
|
||||
final result = await context.gridController.open();
|
||||
result.fold((l) => null, (r) => throw Exception(r));
|
||||
|
@ -23,7 +23,7 @@ void main() {
|
||||
|
||||
assert(bloc.state.views.length == 1);
|
||||
assert(bloc.state.views.last.name == "Test document");
|
||||
assert(bloc.state.views.last.layout == ViewLayoutTypePB.Document);
|
||||
assert(bloc.state.views.last.layout == ViewLayoutPB.Document);
|
||||
});
|
||||
|
||||
test('create a grid', () async {
|
||||
@ -36,7 +36,7 @@ void main() {
|
||||
|
||||
assert(bloc.state.views.length == 1);
|
||||
assert(bloc.state.views.last.name == "Test grid");
|
||||
assert(bloc.state.views.last.layout == ViewLayoutTypePB.Grid);
|
||||
assert(bloc.state.views.last.layout == ViewLayoutPB.Grid);
|
||||
});
|
||||
|
||||
test('create a kanban', () async {
|
||||
@ -49,7 +49,7 @@ void main() {
|
||||
|
||||
assert(bloc.state.views.length == 1);
|
||||
assert(bloc.state.views.last.name == "Test board");
|
||||
assert(bloc.state.views.last.layout == ViewLayoutTypePB.Board);
|
||||
assert(bloc.state.views.last.layout == ViewLayoutPB.Board);
|
||||
});
|
||||
|
||||
test('create a calendar', () async {
|
||||
@ -62,6 +62,6 @@ void main() {
|
||||
|
||||
assert(bloc.state.views.length == 1);
|
||||
assert(bloc.state.views.last.name == "Test calendar");
|
||||
assert(bloc.state.views.last.layout == ViewLayoutTypePB.Calendar);
|
||||
assert(bloc.state.views.last.layout == ViewLayoutPB.Calendar);
|
||||
});
|
||||
}
|
||||
|
8
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
8
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
@ -564,7 +564,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#9b3f895bb6f8e92830acd90cfb68b69aece83095"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -582,7 +582,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#9b3f895bb6f8e92830acd90cfb68b69aece83095"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -594,7 +594,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#9b3f895bb6f8e92830acd90cfb68b69aece83095"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -612,7 +612,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-persistence"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#9b3f895bb6f8e92830acd90cfb68b69aece83095"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -33,8 +33,13 @@ default = ["custom-protocol"]
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
[patch.crates-io]
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
#collab = { path = "../../AppFlowy-Collab/collab" }
|
||||
#collab-folder = { path = "../../AppFlowy-Collab/collab-folder" }
|
||||
#collab-persistence = { path = "../../AppFlowy-Collab/collab-persistence" }
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,11 +5,11 @@ import { useAppDispatch } from '$app/stores/store';
|
||||
import loadField from './loadField';
|
||||
import { FieldInfo } from '$app/stores/effects/database/field/field_controller';
|
||||
import { RowInfo } from '$app/stores/effects/database/row/row_cache';
|
||||
import { ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
import { DatabaseGroupController } from '$app/stores/effects/database/group/group_controller';
|
||||
import { OnDragEndResponder } from 'react-beautiful-dnd';
|
||||
|
||||
export const useDatabase = (viewId: string, type?: ViewLayoutTypePB) => {
|
||||
export const useDatabase = (viewId: string, type?: ViewLayoutPB) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const [controller, setController] = useState<DatabaseController>();
|
||||
const [rows, setRows] = useState<readonly RowInfo[]>([]);
|
||||
@ -58,7 +58,7 @@ export const useDatabase = (viewId: string, type?: ViewLayoutTypePB) => {
|
||||
});
|
||||
await controller.open();
|
||||
|
||||
if (type === ViewLayoutTypePB.Board) {
|
||||
if (type === ViewLayoutPB.Board) {
|
||||
const fieldId = await controller.getGroupByFieldId();
|
||||
setGroupByFieldId(fieldId.unwrap());
|
||||
setGroups(controller.groups.value);
|
||||
|
@ -3,17 +3,14 @@ import { SearchInput } from '../_shared/SearchInput';
|
||||
import { BoardBlock } from './BoardBlock';
|
||||
import { NewBoardBlock } from './NewBoardBlock';
|
||||
import { useDatabase } from '../_shared/database-hooks/useDatabase';
|
||||
import { ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
import { DragDropContext } from 'react-beautiful-dnd';
|
||||
import { useState } from 'react';
|
||||
import { RowInfo } from '$app/stores/effects/database/row/row_cache';
|
||||
import { EditRow } from '$app/components/_shared/EditRow/EditRow';
|
||||
|
||||
export const Board = ({ viewId }: { viewId: string }) => {
|
||||
const { controller, rows, groups, groupByFieldId, onNewRowClick, onDragEnd } = useDatabase(
|
||||
viewId,
|
||||
ViewLayoutTypePB.Board
|
||||
);
|
||||
const { controller, rows, groups, groupByFieldId, onNewRowClick, onDragEnd } = useDatabase(viewId, ViewLayoutPB.Board);
|
||||
const [showBoardRow, setShowBoardRow] = useState(false);
|
||||
const [boardRowInfo, setBoardRowInfo] = useState<RowInfo>();
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { foldersActions, IFolder } from '../../../stores/reducers/folders/slice'
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAppDispatch, useAppSelector } from '../../../stores/store';
|
||||
import { IPage, pagesActions } from '../../../stores/reducers/pages/slice';
|
||||
import { AppPB, ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
import { AppBackendService } from '../../../stores/effects/folder/app/app_bd_svc';
|
||||
import { WorkspaceBackendService } from '../../../stores/effects/folder/workspace/workspace_bd_svc';
|
||||
import { useError } from '../../error/Error.hooks';
|
||||
@ -42,7 +42,7 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
const views = change.val;
|
||||
const updatedPages: IPage[] = views.items.map((view) => ({
|
||||
id: view.id,
|
||||
folderId: view.app_id,
|
||||
folderId: view.parent_view_id,
|
||||
pageType: view.layout,
|
||||
title: view.name,
|
||||
}));
|
||||
@ -129,13 +129,13 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
try {
|
||||
const newView = await appBackendService.createView({
|
||||
name: 'New Document 1',
|
||||
layoutType: ViewLayoutTypePB.Document,
|
||||
layoutType: ViewLayoutPB.Document,
|
||||
});
|
||||
|
||||
appDispatch(
|
||||
pagesActions.addPage({
|
||||
folderId: folder.id,
|
||||
pageType: ViewLayoutTypePB.Document,
|
||||
pageType: ViewLayoutPB.Document,
|
||||
title: newView.name,
|
||||
id: newView.id,
|
||||
})
|
||||
@ -154,7 +154,7 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
try {
|
||||
const newView = await appBackendService.createView({
|
||||
name: 'New Board 1',
|
||||
layoutType: ViewLayoutTypePB.Board,
|
||||
layoutType: ViewLayoutPB.Board,
|
||||
});
|
||||
|
||||
setShowPages(true);
|
||||
@ -162,7 +162,7 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
appDispatch(
|
||||
pagesActions.addPage({
|
||||
folderId: folder.id,
|
||||
pageType: ViewLayoutTypePB.Board,
|
||||
pageType: ViewLayoutPB.Board,
|
||||
title: newView.name,
|
||||
id: newView.id,
|
||||
})
|
||||
@ -179,7 +179,7 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
try {
|
||||
const newView = await appBackendService.createView({
|
||||
name: 'New Grid 1',
|
||||
layoutType: ViewLayoutTypePB.Grid,
|
||||
layoutType: ViewLayoutPB.Grid,
|
||||
});
|
||||
|
||||
setShowPages(true);
|
||||
@ -187,7 +187,7 @@ export const useFolderEvents = (folder: IFolder, pages: IPage[]) => {
|
||||
appDispatch(
|
||||
pagesActions.addPage({
|
||||
folderId: folder.id,
|
||||
pageType: ViewLayoutTypePB.Grid,
|
||||
pageType: ViewLayoutPB.Grid,
|
||||
title: newView.name,
|
||||
id: newView.id,
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useAppSelector } from '../../../stores/store';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { IPage } from '../../../stores/reducers/pages/slice';
|
||||
import { ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
import { useState } from 'react';
|
||||
|
||||
export const useNavigationPanelHooks = function () {
|
||||
@ -23,12 +23,12 @@ export const useNavigationPanelHooks = function () {
|
||||
const onPageClick = (page: IPage) => {
|
||||
let pageTypeRoute = (() => {
|
||||
switch (page.pageType) {
|
||||
case ViewLayoutTypePB.Document:
|
||||
case ViewLayoutPB.Document:
|
||||
return 'document';
|
||||
break;
|
||||
case ViewLayoutTypePB.Grid:
|
||||
case ViewLayoutPB.Grid:
|
||||
return 'grid';
|
||||
case ViewLayoutTypePB.Board:
|
||||
case ViewLayoutPB.Board:
|
||||
return 'board';
|
||||
default:
|
||||
return 'document';
|
||||
|
@ -7,7 +7,7 @@ import { IPage } from '../../../stores/reducers/pages/slice';
|
||||
import { Button } from '../../_shared/Button';
|
||||
import { usePageEvents } from './PageItem.hooks';
|
||||
import { RenamePopup } from './RenamePopup';
|
||||
import { ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { PAGE_ITEM_HEIGHT } from '../../_shared/constants';
|
||||
|
||||
@ -47,9 +47,9 @@ export const PageItem = ({ page, onPageClick }: { page: IPage; onPageClick: () =
|
||||
>
|
||||
<button className={'flex min-w-0 flex-1 items-center'}>
|
||||
<i className={'ml-1 mr-1 h-[16px] w-[16px]'}>
|
||||
{page.pageType === ViewLayoutTypePB.Document && <DocumentSvg></DocumentSvg>}
|
||||
{page.pageType === ViewLayoutTypePB.Board && <BoardSvg></BoardSvg>}
|
||||
{page.pageType === ViewLayoutTypePB.Grid && <GridSvg></GridSvg>}
|
||||
{page.pageType === ViewLayoutPB.Document && <DocumentSvg></DocumentSvg>}
|
||||
{page.pageType === ViewLayoutPB.Board && <BoardSvg></BoardSvg>}
|
||||
{page.pageType === ViewLayoutPB.Grid && <GridSvg></GridSvg>}
|
||||
</i>
|
||||
<span className={'ml-2 min-w-0 flex-1 overflow-hidden overflow-ellipsis whitespace-nowrap text-left'}>
|
||||
{page.title}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
FieldType,
|
||||
SingleSelectTypeOptionPB,
|
||||
ViewLayoutTypePB,
|
||||
ViewLayoutPB,
|
||||
ViewPB,
|
||||
WorkspaceSettingPB,
|
||||
} from '../../../services/backend';
|
||||
@ -29,7 +29,7 @@ import { SelectOptionBackendService } from '../../stores/effects/database/cell/s
|
||||
|
||||
// Create a database view for specific layout type
|
||||
// Do not use it production code. Just for testing
|
||||
export async function createTestDatabaseView(layout: ViewLayoutTypePB): Promise<ViewPB> {
|
||||
export async function createTestDatabaseView(layout: ViewLayoutPB): Promise<ViewPB> {
|
||||
const workspaceSetting: WorkspaceSettingPB = await FolderEventReadCurrentWorkspace().then((result) => result.unwrap());
|
||||
const app = workspaceSetting.workspace.views[0];
|
||||
const appService = new AppBackendService(app.id);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ViewLayoutTypePB, WorkspaceSettingPB } from '@/services/backend';
|
||||
import { ViewLayoutPB, WorkspaceSettingPB } from '@/services/backend';
|
||||
import { FolderEventReadCurrentWorkspace } from '@/services/backend/events/flowy-folder2';
|
||||
import { AppBackendService } from '$app/stores/effects/folder/app/app_bd_svc';
|
||||
|
||||
@ -6,5 +6,5 @@ export async function createTestDocument() {
|
||||
const workspaceSetting: WorkspaceSettingPB = await FolderEventReadCurrentWorkspace().then((result) => result.unwrap());
|
||||
const app = workspaceSetting.workspace.views[0];
|
||||
const appService = new AppBackendService(app.id);
|
||||
return await appService.createView({ name: 'New Document', layoutType: ViewLayoutTypePB.Document });
|
||||
return await appService.createView({ name: 'New Document', layoutType: ViewLayoutPB.Document });
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
FieldType,
|
||||
NumberFormat,
|
||||
NumberTypeOptionPB,
|
||||
SelectOptionCellDataPB,
|
||||
ViewLayoutTypePB,
|
||||
} from '@/services/backend';
|
||||
import { FieldType, NumberFormat, NumberTypeOptionPB, SelectOptionCellDataPB, ViewLayoutPB } from '@/services/backend';
|
||||
import { Log } from '$app/utils/log';
|
||||
import {
|
||||
assert,
|
||||
@ -60,7 +54,7 @@ export const RunAllGridTests = () => {
|
||||
};
|
||||
|
||||
async function createBuildInGrid() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
databaseController.subscribe({
|
||||
onViewChanged: (databasePB) => {
|
||||
@ -82,7 +76,7 @@ async function createBuildInGrid() {
|
||||
}
|
||||
|
||||
async function testEditGridCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -95,7 +89,7 @@ async function testEditGridCell() {
|
||||
}
|
||||
|
||||
async function testEditTextCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -117,7 +111,7 @@ async function testEditTextCell() {
|
||||
}
|
||||
|
||||
async function testEditURLCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -144,7 +138,7 @@ async function testEditURLCell() {
|
||||
}
|
||||
|
||||
async function testEditDateCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -169,7 +163,7 @@ async function testEditDateCell() {
|
||||
}
|
||||
|
||||
async function testCheckboxCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -195,7 +189,7 @@ async function testCheckboxCell() {
|
||||
}
|
||||
|
||||
async function testCreateRow() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
await assertNumberOfRows(view.id, 3);
|
||||
@ -207,7 +201,7 @@ async function testCreateRow() {
|
||||
}
|
||||
|
||||
async function testDeleteRow() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -226,7 +220,7 @@ async function testDeleteRow() {
|
||||
}
|
||||
|
||||
async function testCreateOptionInCell() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
for (const [index, row] of databaseController.databaseViewCache.rowInfos.entries()) {
|
||||
@ -253,7 +247,7 @@ async function testCreateOptionInCell() {
|
||||
}
|
||||
|
||||
async function testMoveField() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -271,7 +265,7 @@ async function testMoveField() {
|
||||
}
|
||||
|
||||
async function testGetSingleSelectFieldData() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -296,7 +290,7 @@ async function testGetSingleSelectFieldData() {
|
||||
}
|
||||
|
||||
async function testSwitchFromSingleSelectToNumber() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -322,7 +316,7 @@ async function testSwitchFromSingleSelectToNumber() {
|
||||
}
|
||||
|
||||
async function testSwitchFromMultiSelectToRichText() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -372,7 +366,7 @@ async function testSwitchFromMultiSelectToRichText() {
|
||||
}
|
||||
|
||||
async function testEditField() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
const fieldInfos = databaseController.fieldController.fieldInfos;
|
||||
@ -390,7 +384,7 @@ async function testEditField() {
|
||||
}
|
||||
|
||||
async function testCreateNewField() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
await assertNumberOfFields(view.id, 3);
|
||||
@ -403,7 +397,7 @@ async function testCreateNewField() {
|
||||
}
|
||||
|
||||
async function testDeleteField() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Grid);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Grid);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
createTestDatabaseView,
|
||||
openTestDatabase,
|
||||
} from './DatabaseTestHelper';
|
||||
import { FieldType, ViewLayoutTypePB } from '../../../services/backend';
|
||||
import { FieldType, ViewLayoutPB } from '../../../services/backend';
|
||||
import React from 'react';
|
||||
|
||||
export const TestAllKanbanTests = () => {
|
||||
@ -29,7 +29,7 @@ export const TestAllKanbanTests = () => {
|
||||
};
|
||||
|
||||
async function createBuildInBoard() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Board);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Board);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
databaseController.subscribe({
|
||||
onGroupByField: (groups) => {
|
||||
@ -49,7 +49,7 @@ async function createBuildInBoard() {
|
||||
}
|
||||
|
||||
async function createKanbanBoardRow() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Board);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Board);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -62,7 +62,7 @@ async function createKanbanBoardRow() {
|
||||
}
|
||||
|
||||
async function moveKanbanBoardRow() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Board);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Board);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -113,7 +113,7 @@ async function moveKanbanBoardRow() {
|
||||
}
|
||||
|
||||
async function createKanbanBoardColumn() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Board);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Board);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
@ -128,7 +128,7 @@ async function createKanbanBoardColumn() {
|
||||
}
|
||||
|
||||
async function createColumnInBoard() {
|
||||
const view = await createTestDatabaseView(ViewLayoutTypePB.Board);
|
||||
const view = await createTestDatabaseView(ViewLayoutPB.Board);
|
||||
const databaseController = await openTestDatabase(view.id);
|
||||
await databaseController.open().then((result) => result.unwrap());
|
||||
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
FolderEventMoveItem,
|
||||
FolderEventReadView,
|
||||
FolderEventUpdateView,
|
||||
ViewLayoutTypePB,
|
||||
ViewLayoutPB,
|
||||
} from '@/services/backend/events/flowy-folder2';
|
||||
import {
|
||||
CreateViewPayloadPB,
|
||||
@ -29,7 +29,7 @@ export class AppBackendService {
|
||||
createView = async (params: {
|
||||
name: string;
|
||||
desc?: string;
|
||||
layoutType: ViewLayoutTypePB;
|
||||
layoutType: ViewLayoutPB;
|
||||
/// The initial data should be the JSON of the document
|
||||
/// For example: {"document":{"type":"editor","children":[]}}
|
||||
initialData?: string;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Ok, Result } from 'ts-results';
|
||||
import { AppPB, FlowyError, FolderNotification, RepeatedViewPB } from '@/services/backend';
|
||||
import { FlowyError, FolderNotification, RepeatedViewPB } from '@/services/backend';
|
||||
import { ChangeNotifier } from '$app/utils/change_notifier';
|
||||
import { FolderNotificationObserver } from '../notifications/observer';
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
CreateViewPayloadPB,
|
||||
FlowyError,
|
||||
MoveFolderItemPayloadPB,
|
||||
ViewLayoutTypePB,
|
||||
ViewLayoutPB,
|
||||
WorkspaceIdPB,
|
||||
} from '@/services/backend';
|
||||
import assert from 'assert';
|
||||
@ -22,7 +22,7 @@ export class WorkspaceBackendService {
|
||||
belong_to_id: this.workspaceId,
|
||||
name: params.name,
|
||||
desc: params.desc || '',
|
||||
layout: ViewLayoutTypePB.Document,
|
||||
layout: ViewLayoutPB.Document,
|
||||
});
|
||||
|
||||
const result = await FolderEventCreateView(payload);
|
||||
|
@ -1,13 +1,5 @@
|
||||
import { Ok, Result } from 'ts-results';
|
||||
import {
|
||||
AppPB,
|
||||
FolderNotification,
|
||||
RepeatedAppPB,
|
||||
WorkspacePB,
|
||||
FlowyError,
|
||||
RepeatedViewPB,
|
||||
ViewPB,
|
||||
} from '@/services/backend';
|
||||
import { FolderNotification, WorkspacePB, FlowyError, RepeatedViewPB, ViewPB } from '@/services/backend';
|
||||
import { ChangeNotifier } from '$app/utils/change_notifier';
|
||||
import { FolderNotificationObserver } from '../notifications/observer';
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import { ViewLayoutTypePB } from '@/services/backend';
|
||||
import { ViewLayoutPB } from '@/services/backend';
|
||||
|
||||
export interface IPage {
|
||||
id: string;
|
||||
title: string;
|
||||
pageType: ViewLayoutTypePB;
|
||||
pageType: ViewLayoutPB;
|
||||
folderId: string;
|
||||
}
|
||||
|
||||
|
3
frontend/rust-lib/.gitignore
vendored
3
frontend/rust-lib/.gitignore
vendored
@ -12,4 +12,5 @@
|
||||
bin/
|
||||
**/src/protobuf
|
||||
**/resources/proto
|
||||
.idea/
|
||||
.idea/
|
||||
AppFlowy-Collab/
|
8
frontend/rust-lib/Cargo.lock
generated
8
frontend/rust-lib/Cargo.lock
generated
@ -491,7 +491,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#306f27e56481eb2a998da4cb9f13763699dade76"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -509,7 +509,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#306f27e56481eb2a998da4cb9f13763699dade76"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -521,7 +521,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#306f27e56481eb2a998da4cb9f13763699dade76"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -539,7 +539,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-persistence"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f25ce7f#f25ce7f71ef3f0a2a35260ebdf74d75534bfad45"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab#306f27e56481eb2a998da4cb9f13763699dade76"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"chrono",
|
||||
|
@ -8,7 +8,7 @@ members = [
|
||||
"flowy-user",
|
||||
"flowy-test",
|
||||
"flowy-sqlite",
|
||||
# "flowy-folder",
|
||||
# "flowy-folder",r
|
||||
"flowy-folder2",
|
||||
"flowy-notification",
|
||||
"flowy-document",
|
||||
@ -37,8 +37,10 @@ opt-level = 3
|
||||
## the amount of IO and the size of ./target, which make caching less effective.
|
||||
incremental = false
|
||||
|
||||
|
||||
[patch.crates-io]
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f25ce7f" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab" }
|
||||
#collab = { path = "../AppFlowy-Collab/collab" }
|
||||
#collab-folder = { path = "../AppFlowy-Collab/collab-folder" }
|
||||
#collab-persistence = { path = "../AppFlowy-Collab/collab-persistence" }
|
||||
|
@ -46,7 +46,7 @@ use_bunyan = ["lib-log/use_bunyan"]
|
||||
dart = [
|
||||
"flowy-user/dart",
|
||||
"flowy-net/dart",
|
||||
"flowy-folder/dart",
|
||||
# "flowy-folder/dart",
|
||||
"flowy-folder2/dart",
|
||||
"flowy-database/dart",
|
||||
"flowy-document/dart",
|
||||
@ -54,7 +54,7 @@ dart = [
|
||||
ts = [
|
||||
"flowy-user/ts",
|
||||
"flowy-net/ts",
|
||||
"flowy-folder/ts",
|
||||
# "flowy-folder/ts",
|
||||
"flowy-folder2/ts",
|
||||
"flowy-database/ts",
|
||||
"flowy-document/ts",
|
||||
|
@ -1,13 +1,14 @@
|
||||
use bytes::Bytes;
|
||||
use collab_persistence::CollabKV;
|
||||
use database_model::BuildDatabaseContext;
|
||||
use flowy_database::entities::LayoutTypePB;
|
||||
use flowy_database::entities::DatabaseLayoutPB;
|
||||
use flowy_database::manager::{create_new_database, link_existing_database, DatabaseManager};
|
||||
use flowy_database::util::{make_default_board, make_default_calendar, make_default_grid};
|
||||
use flowy_document::editor::make_transaction_from_document_content;
|
||||
use flowy_document::DocumentManager;
|
||||
use flowy_error::FlowyError;
|
||||
|
||||
use flowy_folder2::entities::ViewLayoutPB;
|
||||
use flowy_folder2::manager::{Folder2Manager, FolderUser};
|
||||
use flowy_folder2::view_ext::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
use flowy_folder2::ViewLayout;
|
||||
@ -183,9 +184,9 @@ impl ViewDataProcessor for DatabaseViewDataProcessor {
|
||||
match DatabaseExtParams::from_map(ext).map(|params| params.database_id) {
|
||||
None => {
|
||||
let (build_context, layout) = match layout {
|
||||
ViewLayout::Grid => (make_default_grid(), LayoutTypePB::Grid),
|
||||
ViewLayout::Board => (make_default_board(), LayoutTypePB::Board),
|
||||
ViewLayout::Calendar => (make_default_calendar(), LayoutTypePB::Calendar),
|
||||
ViewLayout::Grid => (make_default_grid(), DatabaseLayoutPB::Grid),
|
||||
ViewLayout::Board => (make_default_board(), DatabaseLayoutPB::Board),
|
||||
ViewLayout::Calendar => (make_default_calendar(), DatabaseLayoutPB::Calendar),
|
||||
ViewLayout::Document => {
|
||||
return FutureResult::new(async move {
|
||||
Err(FlowyError::internal().context(format!("Can't handle {:?} layout type", layout)))
|
||||
@ -197,7 +198,7 @@ impl ViewDataProcessor for DatabaseViewDataProcessor {
|
||||
})
|
||||
},
|
||||
Some(database_id) => {
|
||||
let layout = layout_type_from_view_layout(layout);
|
||||
let layout = layout_type_from_view_layout(layout.into());
|
||||
FutureResult::new(async move {
|
||||
link_existing_database(&view_id, name, &database_id, layout, database_manager).await
|
||||
})
|
||||
@ -220,7 +221,7 @@ impl ViewDataProcessor for DatabaseViewDataProcessor {
|
||||
) -> FutureResult<(), FlowyError> {
|
||||
let view_id = view_id.to_string();
|
||||
let database_manager = self.0.clone();
|
||||
let layout = layout_type_from_view_layout(layout);
|
||||
let layout = layout_type_from_view_layout(layout.into());
|
||||
let name = name.to_string();
|
||||
match DatabaseExtParams::from_map(ext).map(|params| params.database_id) {
|
||||
None => FutureResult::new(async move {
|
||||
@ -248,11 +249,11 @@ impl DatabaseExtParams {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layout_type_from_view_layout(layout: ViewLayout) -> LayoutTypePB {
|
||||
pub fn layout_type_from_view_layout(layout: ViewLayoutPB) -> DatabaseLayoutPB {
|
||||
match layout {
|
||||
ViewLayout::Grid => LayoutTypePB::Grid,
|
||||
ViewLayout::Board => LayoutTypePB::Board,
|
||||
ViewLayout::Calendar => LayoutTypePB::Calendar,
|
||||
ViewLayout::Document => LayoutTypePB::Grid,
|
||||
ViewLayoutPB::Grid => DatabaseLayoutPB::Grid,
|
||||
ViewLayoutPB::Board => DatabaseLayoutPB::Board,
|
||||
ViewLayoutPB::Calendar => DatabaseLayoutPB::Calendar,
|
||||
ViewLayoutPB::Document => DatabaseLayoutPB::Grid,
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ pub mod module;
|
||||
use crate::deps_resolve::*;
|
||||
|
||||
use flowy_client_ws::{listen_on_websocket, FlowyWebSocketConnect, NetworkType};
|
||||
use flowy_database::entities::LayoutTypePB;
|
||||
use flowy_database::entities::DatabaseLayoutPB;
|
||||
use flowy_database::manager::DatabaseManager;
|
||||
use flowy_document::entities::DocumentVersionPB;
|
||||
use flowy_document::{DocumentConfig, DocumentManager};
|
||||
@ -320,7 +320,7 @@ impl UserStatusListener {
|
||||
layout_type_from_view_layout(view.layout),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<(String, String, LayoutTypePB)>>()
|
||||
.collect::<Vec<(String, String, DatabaseLayoutPB)>>()
|
||||
});
|
||||
self
|
||||
.database_manager
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::entities::parser::NotEmptyStr;
|
||||
use crate::entities::{FieldIdPB, LayoutTypePB, RowPB};
|
||||
use crate::entities::{DatabaseLayoutPB, FieldIdPB, RowPB};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
|
||||
@ -201,5 +201,5 @@ pub struct DatabaseLayoutIdPB {
|
||||
pub view_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub layout: LayoutTypePB,
|
||||
pub layout: DatabaseLayoutPB,
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use strum_macros::EnumIter;
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct DatabaseViewSettingPB {
|
||||
#[pb(index = 1)]
|
||||
pub current_layout: LayoutTypePB,
|
||||
pub current_layout: DatabaseLayoutPB,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub layout_setting: LayoutSettingPB,
|
||||
@ -32,34 +32,34 @@ pub struct DatabaseViewSettingPB {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, ProtoBuf_Enum, EnumIter)]
|
||||
#[repr(u8)]
|
||||
pub enum LayoutTypePB {
|
||||
pub enum DatabaseLayoutPB {
|
||||
Grid = 0,
|
||||
Board = 1,
|
||||
Calendar = 2,
|
||||
}
|
||||
|
||||
impl std::default::Default for LayoutTypePB {
|
||||
impl std::default::Default for DatabaseLayoutPB {
|
||||
fn default() -> Self {
|
||||
LayoutTypePB::Grid
|
||||
DatabaseLayoutPB::Grid
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<LayoutRevision> for LayoutTypePB {
|
||||
impl std::convert::From<LayoutRevision> for DatabaseLayoutPB {
|
||||
fn from(rev: LayoutRevision) -> Self {
|
||||
match rev {
|
||||
LayoutRevision::Grid => LayoutTypePB::Grid,
|
||||
LayoutRevision::Board => LayoutTypePB::Board,
|
||||
LayoutRevision::Calendar => LayoutTypePB::Calendar,
|
||||
LayoutRevision::Grid => DatabaseLayoutPB::Grid,
|
||||
LayoutRevision::Board => DatabaseLayoutPB::Board,
|
||||
LayoutRevision::Calendar => DatabaseLayoutPB::Calendar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<LayoutTypePB> for LayoutRevision {
|
||||
fn from(layout: LayoutTypePB) -> Self {
|
||||
impl std::convert::From<DatabaseLayoutPB> for LayoutRevision {
|
||||
fn from(layout: DatabaseLayoutPB) -> Self {
|
||||
match layout {
|
||||
LayoutTypePB::Grid => LayoutRevision::Grid,
|
||||
LayoutTypePB::Board => LayoutRevision::Board,
|
||||
LayoutTypePB::Calendar => LayoutRevision::Calendar,
|
||||
DatabaseLayoutPB::Grid => LayoutRevision::Grid,
|
||||
DatabaseLayoutPB::Board => LayoutRevision::Board,
|
||||
DatabaseLayoutPB::Calendar => LayoutRevision::Calendar,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ pub struct DatabaseSettingChangesetPB {
|
||||
pub view_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub layout_type: LayoutTypePB,
|
||||
pub layout_type: DatabaseLayoutPB,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub alter_filter: Option<AlterFilterPayloadPB>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::LayoutTypePB;
|
||||
use crate::entities::DatabaseLayoutPB;
|
||||
use crate::services::database::{
|
||||
make_database_block_rev_manager, DatabaseEditor, DatabaseRefIndexerQuery,
|
||||
DatabaseRevisionCloudService, DatabaseRevisionMergeable, DatabaseRevisionSerde,
|
||||
@ -83,7 +83,7 @@ impl DatabaseManager {
|
||||
&self,
|
||||
user_id: i64,
|
||||
_token: &str,
|
||||
get_views_fn: Fut<Vec<(String, String, LayoutTypePB)>>,
|
||||
get_views_fn: Fut<Vec<(String, String, DatabaseLayoutPB)>>,
|
||||
) -> FlowyResult<()> {
|
||||
self.migration.run(user_id, get_views_fn).await?;
|
||||
Ok(())
|
||||
@ -327,7 +327,7 @@ pub async fn link_existing_database(
|
||||
view_id: &str,
|
||||
name: String,
|
||||
database_id: &str,
|
||||
layout: LayoutTypePB,
|
||||
layout: DatabaseLayoutPB,
|
||||
database_manager: Arc<DatabaseManager>,
|
||||
) -> FlowyResult<()> {
|
||||
tracing::trace!(
|
||||
@ -358,7 +358,7 @@ pub async fn link_existing_database(
|
||||
pub async fn create_new_database(
|
||||
view_id: &str,
|
||||
name: String,
|
||||
layout: LayoutTypePB,
|
||||
layout: DatabaseLayoutPB,
|
||||
database_manager: Arc<DatabaseManager>,
|
||||
build_context: BuildDatabaseContext,
|
||||
) -> FlowyResult<()> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
mod database_migration;
|
||||
mod database_view_migration;
|
||||
use crate::entities::LayoutTypePB;
|
||||
use crate::entities::DatabaseLayoutPB;
|
||||
use crate::manager::DatabaseUser;
|
||||
use crate::services::persistence::database_ref::DatabaseRefs;
|
||||
use crate::services::persistence::migration::database_migration::{
|
||||
@ -31,7 +31,7 @@ impl DatabaseMigration {
|
||||
pub async fn run(
|
||||
&self,
|
||||
user_id: i64,
|
||||
get_views_fn: Fut<Vec<(String, String, LayoutTypePB)>>,
|
||||
get_views_fn: Fut<Vec<(String, String, DatabaseLayoutPB)>>,
|
||||
) -> FlowyResult<()> {
|
||||
let pool = self.user.db_pool()?;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::entities::{
|
||||
AlterFilterParams, DatabaseSettingChangesetParams, DeleteFilterParams, LayoutTypePB,
|
||||
AlterFilterParams, DatabaseLayoutPB, DatabaseSettingChangesetParams, DeleteFilterParams,
|
||||
};
|
||||
|
||||
pub struct GridSettingChangesetBuilder {
|
||||
@ -7,7 +7,7 @@ pub struct GridSettingChangesetBuilder {
|
||||
}
|
||||
|
||||
impl GridSettingChangesetBuilder {
|
||||
pub fn new(grid_id: &str, layout_type: &LayoutTypePB) -> Self {
|
||||
pub fn new(grid_id: &str, layout_type: &DatabaseLayoutPB) -> Self {
|
||||
let params = DatabaseSettingChangesetParams {
|
||||
view_id: grid_id.to_string(),
|
||||
layout_type: layout_type.clone().into(),
|
||||
|
@ -26,32 +26,32 @@ pub struct DatabaseEditorTest {
|
||||
|
||||
impl DatabaseEditorTest {
|
||||
pub async fn new_grid() -> Self {
|
||||
Self::new(LayoutTypePB::Grid).await
|
||||
Self::new(DatabaseLayoutPB::Grid).await
|
||||
}
|
||||
|
||||
pub async fn new_board() -> Self {
|
||||
Self::new(LayoutTypePB::Board).await
|
||||
Self::new(DatabaseLayoutPB::Board).await
|
||||
}
|
||||
|
||||
pub async fn new_calendar() -> Self {
|
||||
Self::new(LayoutTypePB::Calendar).await
|
||||
Self::new(DatabaseLayoutPB::Calendar).await
|
||||
}
|
||||
|
||||
pub async fn new(layout: LayoutTypePB) -> Self {
|
||||
pub async fn new(layout: DatabaseLayoutPB) -> Self {
|
||||
let sdk = FlowySDKTest::default();
|
||||
let _ = sdk.init_user().await;
|
||||
let test = match layout {
|
||||
LayoutTypePB::Grid => {
|
||||
DatabaseLayoutPB::Grid => {
|
||||
let build_context = make_test_grid();
|
||||
let view_data: Bytes = build_context.into();
|
||||
ViewTest::new_grid_view(&sdk, view_data.to_vec()).await
|
||||
},
|
||||
LayoutTypePB::Board => {
|
||||
DatabaseLayoutPB::Board => {
|
||||
let build_context = make_test_board();
|
||||
let view_data: Bytes = build_context.into();
|
||||
ViewTest::new_board_view(&sdk, view_data.to_vec()).await
|
||||
},
|
||||
LayoutTypePB::Calendar => {
|
||||
DatabaseLayoutPB::Calendar => {
|
||||
let build_context = make_test_calendar();
|
||||
let view_data: Bytes = build_context.into();
|
||||
ViewTest::new_calendar_view(&sdk, view_data.to_vec()).await
|
||||
|
@ -7,7 +7,7 @@ use std::time::Duration;
|
||||
use bytes::Bytes;
|
||||
use futures::TryFutureExt;
|
||||
use tokio::sync::broadcast::Receiver;
|
||||
use flowy_database::entities::{AlterFilterParams, AlterFilterPayloadPB, DeleteFilterParams, LayoutTypePB, DatabaseSettingChangesetParams, DatabaseViewSettingPB, RowPB, TextFilterConditionPB, FieldType, NumberFilterConditionPB, CheckboxFilterConditionPB, DateFilterConditionPB, DateFilterContentPB, SelectOptionConditionPB, TextFilterPB, NumberFilterPB, CheckboxFilterPB, DateFilterPB, SelectOptionFilterPB, CellChangesetPB, FilterPB, ChecklistFilterConditionPB, ChecklistFilterPB};
|
||||
use flowy_database::entities::{AlterFilterParams, AlterFilterPayloadPB, DeleteFilterParams, DatabaseLayoutPB, DatabaseSettingChangesetParams, DatabaseViewSettingPB, RowPB, TextFilterConditionPB, FieldType, NumberFilterConditionPB, CheckboxFilterConditionPB, DateFilterConditionPB, DateFilterContentPB, SelectOptionConditionPB, TextFilterPB, NumberFilterPB, CheckboxFilterPB, DateFilterPB, SelectOptionFilterPB, CellChangesetPB, FilterPB, ChecklistFilterConditionPB, ChecklistFilterPB};
|
||||
use flowy_database::services::field::{SelectOptionCellChangeset, SelectOptionIds};
|
||||
use flowy_database::services::setting::GridSettingChangesetBuilder;
|
||||
use database_model::{FieldRevision, FieldTypeRevision};
|
||||
|
@ -1,183 +0,0 @@
|
||||
use crate::entities::parser::app::{AppColorStyle, AppIdentify, AppName};
|
||||
use crate::entities::parser::workspace::WorkspaceIdentify;
|
||||
use crate::entities::RepeatedViewPB;
|
||||
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_error::ErrorCode;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
pub struct AppPB {
|
||||
#[pb(index = 1)]
|
||||
pub id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub workspace_id: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub name: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub belongings: RepeatedViewPB,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Debug, Default, ProtoBuf, Clone)]
|
||||
pub struct RepeatedAppPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<AppPB>,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct CreateAppPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub workspace_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub name: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub desc: String,
|
||||
|
||||
#[pb(index = 4)]
|
||||
pub color_style: ColorStylePB,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Debug, Clone)]
|
||||
pub struct ColorStylePB {
|
||||
#[pb(index = 1)]
|
||||
pub theme_color: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CreateAppParams {
|
||||
pub workspace_id: String,
|
||||
pub name: String,
|
||||
pub desc: String,
|
||||
pub color_style: ColorStylePB,
|
||||
}
|
||||
|
||||
impl TryInto<CreateAppParams> for CreateAppPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<CreateAppParams, Self::Error> {
|
||||
let name = AppName::parse(self.name)?;
|
||||
let id = WorkspaceIdentify::parse(self.workspace_id)?;
|
||||
let color_style = AppColorStyle::parse(self.color_style.theme_color.clone())?;
|
||||
|
||||
Ok(CreateAppParams {
|
||||
workspace_id: id.0,
|
||||
name: name.0,
|
||||
desc: self.desc,
|
||||
color_style: color_style.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<AppColorStyle> for ColorStylePB {
|
||||
fn from(data: AppColorStyle) -> Self {
|
||||
ColorStylePB {
|
||||
theme_color: data.theme_color,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Clone, Debug)]
|
||||
pub struct AppIdPB {
|
||||
#[pb(index = 1)]
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
impl AppIdPB {
|
||||
pub fn new(app_id: &str) -> Self {
|
||||
Self {
|
||||
value: app_id.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UpdateAppPayloadPB {
|
||||
#[pb(index = 1)]
|
||||
pub app_id: String,
|
||||
|
||||
#[pb(index = 2, one_of)]
|
||||
pub name: Option<String>,
|
||||
|
||||
#[pb(index = 3, one_of)]
|
||||
pub desc: Option<String>,
|
||||
|
||||
#[pb(index = 4, one_of)]
|
||||
pub color_style: Option<ColorStylePB>,
|
||||
|
||||
#[pb(index = 5, one_of)]
|
||||
pub is_trash: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UpdateAppParams {
|
||||
pub app_id: String,
|
||||
|
||||
pub name: Option<String>,
|
||||
|
||||
pub desc: Option<String>,
|
||||
|
||||
pub color_style: Option<ColorStylePB>,
|
||||
|
||||
pub is_trash: Option<bool>,
|
||||
}
|
||||
|
||||
impl UpdateAppParams {
|
||||
pub fn new(app_id: &str) -> Self {
|
||||
Self {
|
||||
app_id: app_id.to_string(),
|
||||
name: None,
|
||||
desc: None,
|
||||
color_style: None,
|
||||
is_trash: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(mut self, name: &str) -> Self {
|
||||
self.name = Some(name.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn desc(mut self, desc: &str) -> Self {
|
||||
self.desc = Some(desc.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn trash(mut self) -> Self {
|
||||
self.is_trash = Some(true);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl TryInto<UpdateAppParams> for UpdateAppPayloadPB {
|
||||
type Error = ErrorCode;
|
||||
|
||||
fn try_into(self) -> Result<UpdateAppParams, Self::Error> {
|
||||
let app_id = AppIdentify::parse(self.app_id)?.0;
|
||||
|
||||
let name = match self.name {
|
||||
None => None,
|
||||
Some(name) => Some(AppName::parse(name)?.0),
|
||||
};
|
||||
|
||||
let color_style = match self.color_style {
|
||||
None => None,
|
||||
Some(color_style) => Some(AppColorStyle::parse(color_style.theme_color)?.into()),
|
||||
};
|
||||
|
||||
Ok(UpdateAppParams {
|
||||
app_id,
|
||||
name,
|
||||
desc: self.desc,
|
||||
color_style,
|
||||
is_trash: self.is_trash,
|
||||
})
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
pub mod app;
|
||||
mod parser;
|
||||
pub mod trash;
|
||||
pub mod view;
|
||||
pub mod workspace;
|
||||
|
||||
pub use app::*;
|
||||
pub use trash::*;
|
||||
pub use view::*;
|
||||
pub use workspace::*;
|
||||
|
@ -1,13 +0,0 @@
|
||||
use flowy_error::ErrorCode;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppColorStyle {
|
||||
pub theme_color: String,
|
||||
}
|
||||
|
||||
impl AppColorStyle {
|
||||
pub fn parse(theme_color: String) -> Result<AppColorStyle, ErrorCode> {
|
||||
// TODO: verify the color style format
|
||||
Ok(AppColorStyle { theme_color })
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
#[derive(Debug)]
|
||||
pub struct AppDesc(pub String);
|
||||
|
||||
impl AppDesc {
|
||||
#[allow(dead_code)]
|
||||
pub fn parse(s: String) -> Result<AppDesc, String> {
|
||||
if s.graphemes(true).count() > 1024 {
|
||||
return Err("Workspace description too long".to_string());
|
||||
}
|
||||
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for AppDesc {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use flowy_error::ErrorCode;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppIdentify(pub String);
|
||||
|
||||
impl AppIdentify {
|
||||
pub fn parse(s: String) -> Result<AppIdentify, ErrorCode> {
|
||||
if s.trim().is_empty() {
|
||||
return Err(ErrorCode::AppIdInvalid);
|
||||
}
|
||||
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for AppIdentify {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
use flowy_error::ErrorCode;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AppName(pub String);
|
||||
|
||||
impl AppName {
|
||||
pub fn parse(s: String) -> Result<AppName, ErrorCode> {
|
||||
if s.trim().is_empty() {
|
||||
return Err(ErrorCode::AppNameInvalid);
|
||||
}
|
||||
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for AppName {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
mod app_color_style;
|
||||
mod app_desc;
|
||||
mod app_id;
|
||||
mod app_name;
|
||||
|
||||
pub use app_color_style::*;
|
||||
pub use app_desc::*;
|
||||
pub use app_id::*;
|
||||
pub use app_name::*;
|
@ -1,4 +1,4 @@
|
||||
pub mod app;
|
||||
// pub mod app;
|
||||
pub mod trash;
|
||||
pub mod view;
|
||||
pub mod workspace;
|
||||
|
@ -1,7 +1,4 @@
|
||||
use crate::entities::parser::{
|
||||
app::AppIdentify,
|
||||
view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail},
|
||||
};
|
||||
use crate::entities::parser::view::{ViewDesc, ViewIdentify, ViewName, ViewThumbnail};
|
||||
use crate::view_ext::gen_view_id;
|
||||
use collab_folder::core::{View, ViewLayout};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
@ -16,7 +13,7 @@ pub struct ViewPB {
|
||||
pub id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub app_id: String,
|
||||
pub parent_view_id: String,
|
||||
|
||||
#[pb(index = 3)]
|
||||
pub name: String,
|
||||
@ -28,14 +25,14 @@ pub struct ViewPB {
|
||||
pub belongings: Vec<ViewPB>,
|
||||
|
||||
#[pb(index = 6)]
|
||||
pub layout: ViewLayoutTypePB,
|
||||
pub layout: ViewLayoutPB,
|
||||
}
|
||||
|
||||
impl std::convert::From<View> for ViewPB {
|
||||
fn from(view: View) -> Self {
|
||||
ViewPB {
|
||||
id: view.id,
|
||||
app_id: view.bid,
|
||||
parent_view_id: view.bid,
|
||||
name: view.name,
|
||||
create_time: view.created_at,
|
||||
belongings: Default::default(),
|
||||
@ -45,26 +42,35 @@ impl std::convert::From<View> for ViewPB {
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug, ProtoBuf_Enum, Clone)]
|
||||
pub enum ViewLayoutTypePB {
|
||||
pub enum ViewLayoutPB {
|
||||
Document = 0,
|
||||
Grid = 3,
|
||||
Board = 4,
|
||||
Calendar = 5,
|
||||
}
|
||||
|
||||
impl std::default::Default for ViewLayoutTypePB {
|
||||
impl std::default::Default for ViewLayoutPB {
|
||||
fn default() -> Self {
|
||||
ViewLayoutTypePB::Grid
|
||||
ViewLayoutPB::Grid
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewLayout> for ViewLayoutTypePB {
|
||||
impl ViewLayoutPB {
|
||||
pub fn is_database(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ViewLayoutPB::Grid | ViewLayoutPB::Board | ViewLayoutPB::Calendar
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<ViewLayout> for ViewLayoutPB {
|
||||
fn from(rev: ViewLayout) -> Self {
|
||||
match rev {
|
||||
ViewLayout::Grid => ViewLayoutTypePB::Grid,
|
||||
ViewLayout::Board => ViewLayoutTypePB::Board,
|
||||
ViewLayout::Document => ViewLayoutTypePB::Document,
|
||||
ViewLayout::Calendar => ViewLayoutTypePB::Calendar,
|
||||
ViewLayout::Grid => ViewLayoutPB::Grid,
|
||||
ViewLayout::Board => ViewLayoutPB::Board,
|
||||
ViewLayout::Document => ViewLayoutPB::Document,
|
||||
ViewLayout::Calendar => ViewLayoutPB::Calendar,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,12 +81,8 @@ pub struct RepeatedViewPB {
|
||||
pub items: Vec<ViewPB>,
|
||||
}
|
||||
|
||||
impl std::convert::From<Vec<View>> for RepeatedViewPB {
|
||||
fn from(views: Vec<View>) -> Self {
|
||||
let items = views
|
||||
.into_iter()
|
||||
.map(|value| value.into())
|
||||
.collect::<Vec<ViewPB>>();
|
||||
impl std::convert::From<Vec<ViewPB>> for RepeatedViewPB {
|
||||
fn from(items: Vec<ViewPB>) -> Self {
|
||||
RepeatedViewPB { items }
|
||||
}
|
||||
}
|
||||
@ -120,7 +122,7 @@ pub struct CreateViewPayloadPB {
|
||||
pub thumbnail: Option<String>,
|
||||
|
||||
#[pb(index = 5)]
|
||||
pub layout: ViewLayoutTypePB,
|
||||
pub layout: ViewLayoutPB,
|
||||
|
||||
#[pb(index = 6)]
|
||||
pub initial_data: Vec<u8>,
|
||||
@ -134,7 +136,7 @@ pub struct CreateViewParams {
|
||||
pub belong_to_id: String,
|
||||
pub name: String,
|
||||
pub desc: String,
|
||||
pub layout: ViewLayoutTypePB,
|
||||
pub layout: ViewLayoutPB,
|
||||
pub view_id: String,
|
||||
pub initial_data: Vec<u8>,
|
||||
pub ext: HashMap<String, String>,
|
||||
@ -145,7 +147,7 @@ impl TryInto<CreateViewParams> for CreateViewPayloadPB {
|
||||
|
||||
fn try_into(self) -> Result<CreateViewParams, Self::Error> {
|
||||
let name = ViewName::parse(self.name)?.0;
|
||||
let belong_to_id = AppIdentify::parse(self.belong_to_id)?.0;
|
||||
let belong_to_id = ViewIdentify::parse(self.belong_to_id)?.0;
|
||||
let view_id = gen_view_id();
|
||||
|
||||
Ok(CreateViewParams {
|
||||
|
@ -22,6 +22,18 @@ pub struct WorkspacePB {
|
||||
pub create_time: i64,
|
||||
}
|
||||
|
||||
impl std::convert::From<(Workspace, Vec<ViewPB>)> for WorkspacePB {
|
||||
fn from(params: (Workspace, Vec<ViewPB>)) -> Self {
|
||||
let (workspace, views) = params;
|
||||
WorkspacePB {
|
||||
id: workspace.id,
|
||||
name: workspace.name,
|
||||
views,
|
||||
create_time: workspace.created_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<Workspace> for WorkspacePB {
|
||||
fn from(workspace: Workspace) -> Self {
|
||||
WorkspacePB {
|
||||
|
@ -39,7 +39,8 @@ pub(crate) async fn open_workspace_handler(
|
||||
None => Err(FlowyError::workspace_id().context("workspace id should not be empty")),
|
||||
Some(workspace_id) => {
|
||||
let workspace = folder.open_workspace(&workspace_id).await?;
|
||||
let workspace_pb: WorkspacePB = workspace.into();
|
||||
let views = folder.get_workspace_views(&workspace_id).await?;
|
||||
let workspace_pb: WorkspacePB = (workspace, views).into();
|
||||
data_result_ok(workspace_pb)
|
||||
},
|
||||
}
|
||||
@ -67,7 +68,9 @@ pub(crate) async fn read_workspaces_handler(
|
||||
pub async fn read_cur_workspace_setting_handler(
|
||||
folder: AFPluginState<Arc<Folder2Manager>>,
|
||||
) -> DataResult<WorkspaceSettingPB, FlowyError> {
|
||||
let workspace: WorkspacePB = folder.get_current_workspace().await?.into();
|
||||
let workspace = folder.get_current_workspace().await?;
|
||||
let views = folder.get_workspace_views(&workspace.id).await?;
|
||||
let workspace: WorkspacePB = (workspace, views).into();
|
||||
let latest_view: Option<ViewPB> = folder.get_current_view().await;
|
||||
data_result_ok(WorkspaceSettingPB {
|
||||
workspace,
|
||||
|
@ -63,41 +63,28 @@ impl Folder2Manager {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_current_workspace_views(&self) -> FlowyResult<Vec<View>> {
|
||||
let views = self.with_folder(vec![], |folder| {
|
||||
let trash_ids = folder
|
||||
.trash
|
||||
.get_all_trash()
|
||||
.into_iter()
|
||||
.map(|trash| trash.id)
|
||||
.collect::<Vec<String>>();
|
||||
pub async fn get_current_workspace_views(&self) -> FlowyResult<Vec<ViewPB>> {
|
||||
let workspace_id = self
|
||||
.folder
|
||||
.lock()
|
||||
.as_ref()
|
||||
.map(|folder| folder.get_current_workspace_id());
|
||||
|
||||
let mut views = folder.get_views_belong_to_current_workspace();
|
||||
views.retain(|view| !trash_ids.contains(&view.id));
|
||||
views
|
||||
if let Some(Some(workspace_id)) = workspace_id {
|
||||
self.get_workspace_views(&workspace_id).await
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_workspace_views(&self, workspace_id: &str) -> FlowyResult<Vec<ViewPB>> {
|
||||
let views = self.with_folder(vec![], |folder| {
|
||||
get_workspace_view_pbs(workspace_id, folder)
|
||||
});
|
||||
|
||||
Ok(views)
|
||||
}
|
||||
|
||||
pub async fn get_workspace_views<F>(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
filter: F,
|
||||
) -> FlowyResult<Vec<View>>
|
||||
where
|
||||
F: Fn(&ViewLayout) -> bool,
|
||||
{
|
||||
Ok(self.with_folder(vec![], |folder| {
|
||||
folder
|
||||
.views
|
||||
.get_views_belong_to(workspace_id)
|
||||
.into_iter()
|
||||
.filter(|view| filter(&view.layout))
|
||||
.collect::<Vec<_>>()
|
||||
}))
|
||||
}
|
||||
|
||||
/// Called immediately after the application launched with the user sign in/sign up.
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub async fn initialize(&self, user_id: i64) -> FlowyResult<()> {
|
||||
@ -532,6 +519,34 @@ fn listen_on_trash_change(mut rx: TrashChangeReceiver, folder: Folder) {
|
||||
});
|
||||
}
|
||||
|
||||
fn get_workspace_view_pbs(workspace_id: &str, folder: &InnerFolder) -> Vec<ViewPB> {
|
||||
let trash_ids = folder
|
||||
.trash
|
||||
.get_all_trash()
|
||||
.into_iter()
|
||||
.map(|trash| trash.id)
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
let mut views = folder.get_workspace_views(workspace_id);
|
||||
views.retain(|view| !trash_ids.contains(&view.id));
|
||||
|
||||
views
|
||||
.into_iter()
|
||||
.map(|view| {
|
||||
let mut parent_view: ViewPB = view.into();
|
||||
|
||||
// Get child views
|
||||
parent_view.belongings = folder
|
||||
.views
|
||||
.get_views_belong_to(&parent_view.id)
|
||||
.into_iter()
|
||||
.map(|view| view.into())
|
||||
.collect();
|
||||
parent_view
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(folder, parent_view_ids))]
|
||||
fn notify_parent_view_did_change<T: AsRef<str>>(
|
||||
folder: Folder,
|
||||
@ -553,9 +568,7 @@ fn notify_parent_view_did_change<T: AsRef<str>>(
|
||||
// if the view's bid is equal to workspace id. Then it will fetch the current
|
||||
// workspace views. Because the the workspace is not a view stored in the views map.
|
||||
if parent_view_id == workspace_id {
|
||||
let mut child_views = folder.get_views_belong_to_current_workspace();
|
||||
child_views.retain(|view| !trash_ids.contains(&view.id));
|
||||
let repeated_view: RepeatedViewPB = child_views.into();
|
||||
let repeated_view: RepeatedViewPB = get_workspace_view_pbs(&workspace_id, folder).into();
|
||||
send_notification(&workspace_id, FolderNotification::DidUpdateWorkspaceViews)
|
||||
.payload(repeated_view)
|
||||
.send();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::{CreateViewParams, ViewLayoutTypePB};
|
||||
use crate::entities::{CreateViewParams, ViewLayoutPB};
|
||||
use crate::manager::Folder2Manager;
|
||||
use crate::view_ext::gen_view_id;
|
||||
use std::collections::HashMap;
|
||||
@ -12,7 +12,7 @@ impl Folder2Manager {
|
||||
ext: HashMap<String, String>,
|
||||
) -> String {
|
||||
self
|
||||
.create_test_view(app_id, name, ViewLayoutTypePB::Grid, ext)
|
||||
.create_test_view(app_id, name, ViewLayoutPB::Grid, ext)
|
||||
.await
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ impl Folder2Manager {
|
||||
ext: HashMap<String, String>,
|
||||
) -> String {
|
||||
self
|
||||
.create_test_view(app_id, name, ViewLayoutTypePB::Board, ext)
|
||||
.create_test_view(app_id, name, ViewLayoutPB::Board, ext)
|
||||
.await
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ impl Folder2Manager {
|
||||
&self,
|
||||
app_id: &str,
|
||||
name: &str,
|
||||
layout: ViewLayoutTypePB,
|
||||
layout: ViewLayoutPB,
|
||||
ext: HashMap<String, String>,
|
||||
) -> String {
|
||||
let view_id = gen_view_id();
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::{CreateViewParams, ViewLayoutTypePB};
|
||||
use crate::entities::{CreateViewParams, ViewLayoutPB};
|
||||
use bytes::Bytes;
|
||||
use collab_folder::core::{View, ViewLayout};
|
||||
use flowy_error::FlowyError;
|
||||
@ -43,13 +43,13 @@ pub trait ViewDataProcessor {
|
||||
|
||||
pub type ViewDataProcessorMap = Arc<HashMap<ViewLayout, Arc<dyn ViewDataProcessor + Send + Sync>>>;
|
||||
|
||||
impl From<ViewLayoutTypePB> for ViewLayout {
|
||||
fn from(pb: ViewLayoutTypePB) -> Self {
|
||||
impl From<ViewLayoutPB> for ViewLayout {
|
||||
fn from(pb: ViewLayoutPB) -> Self {
|
||||
match pb {
|
||||
ViewLayoutTypePB::Document => ViewLayout::Document,
|
||||
ViewLayoutTypePB::Grid => ViewLayout::Grid,
|
||||
ViewLayoutTypePB::Board => ViewLayout::Board,
|
||||
ViewLayoutTypePB::Calendar => ViewLayout::Calendar,
|
||||
ViewLayoutPB::Document => ViewLayout::Document,
|
||||
ViewLayoutPB::Grid => ViewLayout::Grid,
|
||||
ViewLayoutPB::Board => ViewLayout::Board,
|
||||
ViewLayoutPB::Calendar => ViewLayout::Calendar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
use crate::prelude::*;
|
||||
use flowy_folder2::entities::{
|
||||
CreateViewPayloadPB, CreateWorkspacePayloadPB, ViewLayoutTypePB, ViewPB, WorkspaceIdPB,
|
||||
WorkspacePB,
|
||||
CreateViewPayloadPB, CreateWorkspacePayloadPB, ViewLayoutPB, ViewPB, WorkspaceIdPB, WorkspacePB,
|
||||
};
|
||||
use flowy_folder2::event_map::FolderEvent::{CreateView, CreateWorkspace, OpenWorkspace};
|
||||
use flowy_user::{
|
||||
@ -21,7 +20,7 @@ pub struct ViewTest {
|
||||
|
||||
impl ViewTest {
|
||||
#[allow(dead_code)]
|
||||
pub async fn new(sdk: &FlowySDKTest, layout: ViewLayoutTypePB, data: Vec<u8>) -> Self {
|
||||
pub async fn new(sdk: &FlowySDKTest, layout: ViewLayoutPB, data: Vec<u8>) -> Self {
|
||||
let workspace = create_workspace(sdk, "Workspace", "").await;
|
||||
open_workspace(sdk, &workspace.id).await;
|
||||
let app = create_app(sdk, "App", "AppFlowy GitHub Project", &workspace.id).await;
|
||||
@ -35,19 +34,19 @@ impl ViewTest {
|
||||
}
|
||||
|
||||
pub async fn new_grid_view(sdk: &FlowySDKTest, data: Vec<u8>) -> Self {
|
||||
Self::new(sdk, ViewLayoutTypePB::Grid, data).await
|
||||
Self::new(sdk, ViewLayoutPB::Grid, data).await
|
||||
}
|
||||
|
||||
pub async fn new_board_view(sdk: &FlowySDKTest, data: Vec<u8>) -> Self {
|
||||
Self::new(sdk, ViewLayoutTypePB::Board, data).await
|
||||
Self::new(sdk, ViewLayoutPB::Board, data).await
|
||||
}
|
||||
|
||||
pub async fn new_calendar_view(sdk: &FlowySDKTest, data: Vec<u8>) -> Self {
|
||||
Self::new(sdk, ViewLayoutTypePB::Calendar, data).await
|
||||
Self::new(sdk, ViewLayoutPB::Calendar, data).await
|
||||
}
|
||||
|
||||
pub async fn new_document_view(sdk: &FlowySDKTest) -> Self {
|
||||
Self::new(sdk, ViewLayoutTypePB::Document, vec![]).await
|
||||
Self::new(sdk, ViewLayoutPB::Document, vec![]).await
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &s
|
||||
name: name.to_string(),
|
||||
desc: desc.to_string(),
|
||||
thumbnail: None,
|
||||
layout: ViewLayoutTypePB::Document,
|
||||
layout: ViewLayoutPB::Document,
|
||||
initial_data: vec![],
|
||||
ext: Default::default(),
|
||||
};
|
||||
@ -98,7 +97,7 @@ async fn create_app(sdk: &FlowySDKTest, name: &str, desc: &str, workspace_id: &s
|
||||
async fn create_view(
|
||||
sdk: &FlowySDKTest,
|
||||
app_id: &str,
|
||||
layout: ViewLayoutTypePB,
|
||||
layout: ViewLayoutPB,
|
||||
data: Vec<u8>,
|
||||
) -> ViewPB {
|
||||
let payload = CreateViewPayloadPB {
|
||||
|
Loading…
Reference in New Issue
Block a user