From c74308999d9410a60f1ff2e368bb839e3f000766 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 1 Mar 2023 16:02:49 +0800 Subject: [PATCH 1/4] chore: delete/create row --- .../appflowy_tauri/src-tauri/src/request.rs | 1 - .../TestApiButton/DatabaseTestHelper.ts | 14 ++- .../components/TestApiButton/TestAPI.tsx | 4 + .../components/TestApiButton/TestGrid.tsx | 97 +++++++++++++------ .../effects/database/cell/cell_cache.ts | 26 +++-- .../effects/database/cell/cell_controller.ts | 38 ++++---- .../effects/database/cell/cell_observer.ts | 4 +- .../effects/database/database_bd_svc.ts | 3 +- .../effects/database/database_controller.ts | 12 ++- .../database/field/field_controller.ts | 36 ++++--- .../effects/database/field/field_observer.ts | 26 ++--- .../database/notifications/observer.ts | 3 +- .../stores/effects/database/row/row_bd_svc.ts | 32 ++++++ .../database/view/database_view_cache.ts | 43 ++++---- .../database/view/view_row_observer.ts | 43 ++++---- .../stores/effects/folder/app/app_observer.ts | 7 +- .../effects/folder/view/view_observer.ts | 4 +- .../folder/workspace/workspace_observer.ts | 33 ++++--- .../src/ts_event/event_template.tera | 6 +- .../src/entities/row_entities.rs | 2 +- 20 files changed, 262 insertions(+), 172 deletions(-) create mode 100644 frontend/appflowy_tauri/src/appflowy_app/stores/effects/database/row/row_bd_svc.ts diff --git a/frontend/appflowy_tauri/src-tauri/src/request.rs b/frontend/appflowy_tauri/src-tauri/src/request.rs index 0e00342782..4f88885a51 100644 --- a/frontend/appflowy_tauri/src-tauri/src/request.rs +++ b/frontend/appflowy_tauri/src-tauri/src/request.rs @@ -32,7 +32,6 @@ impl std::convert::From for AFTauriResponse { } // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command -#[tracing::instrument(level = "trace", skip(app_handler))] #[tauri::command] pub async fn invoke_request( request: AFTauriRequest, diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/DatabaseTestHelper.ts b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/DatabaseTestHelper.ts index a3163c479d..4a79bc16e0 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/DatabaseTestHelper.ts +++ b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/DatabaseTestHelper.ts @@ -35,7 +35,7 @@ export async function assertTextCell(rowInfo: RowInfo, databaseController: Datab onCellChanged: (value) => { const cellContent = value.unwrap(); if (cellContent !== expectedContent) { - throw Error(); + throw Error('Text cell content is not match'); } }, }); @@ -111,7 +111,7 @@ export async function assertFieldName(viewId: string, fieldId: string, fieldType const svc = new TypeOptionBackendService(viewId); const typeOptionPB = await svc.getTypeOption(fieldId, fieldType).then((result) => result.unwrap()); if (typeOptionPB.field.name !== expected) { - throw Error(); + throw Error('Expect field name:' + expected + 'but receive:' + typeOptionPB.field.name); } } @@ -119,6 +119,14 @@ export async function assertNumberOfFields(viewId: string, expected: number) { const svc = new DatabaseBackendService(viewId); const databasePB = await svc.openDatabase().then((result) => result.unwrap()); if (databasePB.fields.length !== expected) { - throw Error(); + throw Error('Expect number of fields:' + expected + 'but receive:' + databasePB.fields.length); + } +} + +export async function assertNumberOfRows(viewId: string, expected: number) { + const svc = new DatabaseBackendService(viewId); + const databasePB = await svc.openDatabase().then((result) => result.unwrap()); + if (databasePB.rows.length !== expected) { + throw Error('Expect number of rows:' + expected + 'but receive:' + databasePB.rows.length); } } diff --git a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestAPI.tsx b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestAPI.tsx index 9f653f9adc..a9ee26b174 100644 --- a/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestAPI.tsx +++ b/frontend/appflowy_tauri/src/appflowy_app/components/TestApiButton/TestAPI.tsx @@ -3,8 +3,10 @@ import TestApiButton from './TestApiButton'; import { TestCreateGrid, TestCreateNewField, + TestCreateRow, TestCreateSelectOption, TestDeleteField, + TestDeleteRow, TestEditCell, TestEditField, } from './TestGrid'; @@ -15,6 +17,8 @@ export const TestAPI = () => {