From d1ed45c312a6a345bc16214281401d363edebd9b Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 25 Aug 2024 15:14:54 +0800 Subject: [PATCH] fix: upload all imported csv rows (#6063) * chore: upload imported csv rows * chore: format number --- frontend/appflowy_tauri/src-tauri/Cargo.lock | 14 ++++---- frontend/appflowy_tauri/src-tauri/Cargo.toml | 14 ++++---- .../appflowy_web_app/src-tauri/Cargo.lock | 14 ++++---- .../appflowy_web_app/src-tauri/Cargo.toml | 14 ++++---- frontend/rust-lib/Cargo.lock | 14 ++++---- frontend/rust-lib/Cargo.toml | 14 ++++---- .../src/deps_resolve/folder_deps.rs | 28 +++++++++++---- .../rust-lib/flowy-database2/src/manager.rs | 14 ++++---- .../src/services/database/database_observe.rs | 1 - .../number_type_option/number_type_option.rs | 32 +++++++++++++---- .../field/type_options/type_option_cell.rs | 1 + .../src/services/share/csv/import.rs | 27 ++++++++++---- frontend/rust-lib/flowy-folder/src/manager.rs | 36 ++++++++----------- .../flowy-folder/src/view_operation.rs | 5 ++- 14 files changed, 138 insertions(+), 90 deletions(-) diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock index 3ba822aba5..caf29a3fd9 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.lock +++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-trait", @@ -1018,7 +1018,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -1038,7 +1038,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "bytes", @@ -1057,7 +1057,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-stream", @@ -1180,7 +1180,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index b740368456..eef7c08efb 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock index f2869a4ece..a5a0298029 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.lock +++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -972,7 +972,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-trait", @@ -1001,7 +1001,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -1021,7 +1021,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "bytes", @@ -1040,7 +1040,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -1083,7 +1083,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-stream", @@ -1163,7 +1163,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "collab", diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml index 20e1501f91..da65390bbc 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.toml +++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml @@ -116,13 +116,13 @@ custom-protocol = ["tauri/custom-protocol"] # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 4a32e83a16..6ff746c577 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -825,7 +825,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -850,7 +850,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-trait", @@ -879,7 +879,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -899,7 +899,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "bytes", @@ -918,7 +918,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "arc-swap", @@ -961,7 +961,7 @@ dependencies = [ [[package]] name = "collab-plugins" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "async-stream", @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e51cde161cbce9af08f707ab1b3a3564eee90bac#e51cde161cbce9af08f707ab1b3a3564eee90bac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d#f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" dependencies = [ "anyhow", "collab", diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index b3a6de6e00..ae36a79141 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -136,13 +136,13 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120 # To switch to the local path, run: # scripts/tool/update_collab_source.sh # ⚠️⚠️⚠️️ -collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } -collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e51cde161cbce9af08f707ab1b3a3564eee90bac" } +collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } +collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f148b6ba98a12270c2faffaeaf2ee41b2cd84e7d" } # Working directory: frontend # To update the commit ID, run: diff --git a/frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps.rs b/frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps.rs index 62e192446a..241a96048b 100644 --- a/frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps.rs +++ b/frontend/rust-lib/flowy-core/src/deps_resolve/folder_deps.rs @@ -17,7 +17,7 @@ use flowy_folder::manager::{FolderManager, FolderUser}; use flowy_folder::share::ImportType; use flowy_folder::view_operation::{ DatabaseEncodedCollab, DocumentEncodedCollab, EncodedCollabWrapper, FolderOperationHandler, - FolderOperationHandlers, View, ViewData, + FolderOperationHandlers, ImportedData, View, ViewData, }; use flowy_folder::ViewLayout; use flowy_folder_pub::folder_builder::NestedViewBuilder; @@ -254,13 +254,17 @@ impl FolderOperationHandler for DocumentFolderOperation { _name: &str, _import_type: ImportType, bytes: Vec, - ) -> Result { + ) -> Result, FlowyError> { let data = DocumentDataPB::try_from(Bytes::from(bytes))?; let encoded_collab = self .0 .create_document(uid, view_id, Some(data.into())) .await?; - Ok(encoded_collab) + Ok(vec![( + view_id.to_string(), + CollabType::Document, + encoded_collab, + )]) } // will implement soon @@ -462,7 +466,7 @@ impl FolderOperationHandler for DatabaseFolderOperation { _name: &str, import_type: ImportType, bytes: Vec, - ) -> Result { + ) -> Result, FlowyError> { let format = match import_type { ImportType::CSV => CSVFormat::Original, ImportType::HistoryDatabase => CSVFormat::META, @@ -477,7 +481,19 @@ impl FolderOperationHandler for DatabaseFolderOperation { .0 .import_csv(view_id.to_string(), content, format) .await?; - Ok(result.encoded_collab) + Ok( + result + .encoded_collabs + .into_iter() + .map(|encoded| { + ( + encoded.object_id, + encoded.collab_type, + encoded.encoded_collab, + ) + }) + .collect(), + ) } async fn import_from_file_path( @@ -570,7 +586,7 @@ impl FolderOperationHandler for ChatFolderOperation { _name: &str, _import_type: ImportType, _bytes: Vec, - ) -> Result { + ) -> Result, FlowyError> { Err(FlowyError::not_support()) } diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index 127bd8b0df..53e42b6d8f 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -22,7 +22,7 @@ use dashmap::DashMap; use tokio::select; use tokio::sync::{Mutex, RwLock}; use tokio_util::sync::CancellationToken; -use tracing::{error, instrument, trace}; +use tracing::{error, info, instrument, trace}; use collab_integrate::collab_builder::{AppFlowyCollabBuilder, CollabBuilderConfig}; use collab_integrate::{CollabKVAction, CollabKVDB}; @@ -437,15 +437,17 @@ impl DatabaseManager { let view_id = params.inline_view_id.clone(); let database_id = params.database_id.clone(); let database = self.create_database_with_params(params).await?; - let encoded_collab = database - .read() - .await - .encode_collab_v1(|collab| CollabType::Database.validate_require_data(collab))?; + let encoded_database = database.read().await.encode_database_collabs().await?; + let encoded_collabs = std::iter::once(encoded_database.encoded_database_collab) + .chain(encoded_database.encoded_row_collabs.into_iter()) + .collect::>(); + let result = ImportResult { database_id, view_id, - encoded_collab, + encoded_collabs, }; + info!("import csv result: {}", result); Ok(result) } diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs index f9fd039935..f61629d964 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_observe.rs @@ -145,7 +145,6 @@ pub(crate) async fn observe_block_event(database_id: &str, database_editor: &Arc .subscribe_block_event(); let database_editor = Arc::downgrade(database_editor); af_spawn(async move { - // let token = CancellationToken::new(); while let Ok(event) = block_event_rx.recv().await { if database_editor.upgrade().is_none() { break; diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs index c13b007fa6..94b9a3b3c5 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs @@ -5,7 +5,7 @@ use std::cmp::Ordering; use std::default::Default; use std::str::FromStr; -use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder}; +use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder}; use collab_database::rows::{new_cell_builder, Cell}; use fancy_regex::Regex; use lazy_static::lazy_static; @@ -54,6 +54,12 @@ impl TypeOptionCellData for NumberCellData { } } +impl AsRef for NumberCellData { + fn as_ref(&self) -> &str { + &self.0 + } +} + impl From<&Cell> for NumberCellData { fn from(cell: &Cell) -> Self { Self(cell.get_as(CELL_DATA).unwrap_or_default()) @@ -122,21 +128,21 @@ impl NumberTypeOption { Self::default() } - fn format_cell_data(&self, num_cell_data: &NumberCellData) -> FlowyResult { + fn format_cell_data>(&self, num_cell_data: T) -> FlowyResult { match self.format { NumberFormat::Num => { if SCIENTIFIC_NOTATION_REGEX - .is_match(&num_cell_data.0) + .is_match(&num_cell_data.as_ref()) .unwrap() { - match Decimal::from_scientific(&num_cell_data.0.to_lowercase()) { + match Decimal::from_scientific(&num_cell_data.as_ref().to_lowercase()) { Ok(value, ..) => Ok(NumberCellFormat::from_decimal(value)), Err(_) => Ok(NumberCellFormat::new()), } } else { // Test the input string is start with dot and only contains number. // If it is, add a 0 before the dot. For example, ".123" -> "0.123" - let num_str = match START_WITH_DOT_NUM_REGEX.captures(&num_cell_data.0) { + let num_str = match START_WITH_DOT_NUM_REGEX.captures(&num_cell_data.as_ref()) { Ok(Some(captures)) => match captures.get(0).map(|m| m.as_str().to_string()) { Some(s) => { format!("0{}", s) @@ -146,7 +152,7 @@ impl NumberTypeOption { // Extract the number from the string. // For example, "123abc" -> "123". check out the number_type_option_input_test test for // more examples. - _ => match EXTRACT_NUM_REGEX.captures(&num_cell_data.0) { + _ => match EXTRACT_NUM_REGEX.captures(&num_cell_data.as_ref()) { Ok(Some(captures)) => captures .get(0) .map(|m| m.as_str().to_string()) @@ -163,7 +169,7 @@ impl NumberTypeOption { }, _ => { // If the format is not number, use the format string to format the number. - NumberCellFormat::from_format_str(&num_cell_data.0, &self.format) + NumberCellFormat::from_format_str(&num_cell_data.as_ref(), &self.format) }, } } @@ -191,6 +197,18 @@ impl CellDataDecoder for NumberTypeOption { } } + fn decode_cell_with_transform( + &self, + cell: &Cell, + _from_field_type: FieldType, + _field: &Field, + ) -> Option<::CellData> { + let num_cell = Self::CellData::from(cell); + Some(Self::CellData::from( + self.format_cell_data(&num_cell).ok()?.to_string(), + )) + } + fn numeric_cell(&self, cell: &Cell) -> Option { let num_cell_data = self.parse_cell(cell).ok()?; num_cell_data.0.parse::().ok() diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs index 36e017716a..d5f4b4fab7 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs @@ -522,6 +522,7 @@ pub fn is_type_option_cell_transformable( | (FieldType::RichText, FieldType::SingleSelect) | (FieldType::RichText, FieldType::MultiSelect) | (FieldType::RichText, FieldType::URL) + | (FieldType::RichText, FieldType::Number) | (_, FieldType::RichText) ) } diff --git a/frontend/rust-lib/flowy-database2/src/services/share/csv/import.rs b/frontend/rust-lib/flowy-database2/src/services/share/csv/import.rs index dab2b981c9..93f6987b17 100644 --- a/frontend/rust-lib/flowy-database2/src/services/share/csv/import.rs +++ b/frontend/rust-lib/flowy-database2/src/services/share/csv/import.rs @@ -1,13 +1,11 @@ -use std::{fs::File, io::prelude::*}; - use collab_database::database::{gen_database_id, gen_field_id, gen_row_id, timestamp}; -use collab_database::entity::{CreateDatabaseParams, CreateViewParams}; +use collab_database::entity::{CreateDatabaseParams, CreateViewParams, EncodedCollabInfo}; use collab_database::fields::Field; use collab_database::rows::{new_cell_builder, Cell, CreateRowParams}; use collab_database::views::DatabaseLayout; - -use collab_entity::EncodedCollab; use flowy_error::{FlowyError, FlowyResult}; +use std::fmt::Display; +use std::{fs::File, io::prelude::*}; use crate::entities::FieldType; use crate::services::field::{default_type_option_data_from_type, CELL_DATA}; @@ -169,9 +167,26 @@ impl FieldsRows { pub struct ImportResult { pub database_id: String, pub view_id: String, - pub encoded_collab: EncodedCollab, + pub encoded_collabs: Vec, } +impl Display for ImportResult { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let total_size: usize = self + .encoded_collabs + .iter() + .map(|c| c.encoded_collab.doc_state.len()) + .sum(); + write!( + f, + "ImportResult {{ database_id: {}, view_id: {}, num collabs: {}, size: {} }}", + self.database_id, + self.view_id, + self.encoded_collabs.len(), + total_size + ) + } +} #[cfg(test)] mod tests { use collab_database::database::gen_database_view_id; diff --git a/frontend/rust-lib/flowy-folder/src/manager.rs b/frontend/rust-lib/flowy-folder/src/manager.rs index 7a6966d306..173ffbd4c3 100644 --- a/frontend/rust-lib/flowy-folder/src/manager.rs +++ b/frontend/rust-lib/flowy-folder/src/manager.rs @@ -1421,7 +1421,7 @@ impl FolderManager { &self, parent_view_id: String, import_data: ImportValue, - ) -> FlowyResult<(View, Option)> { + ) -> FlowyResult<(View, Vec<(String, CollabType, EncodedCollab)>)> { // Ensure either data or file_path is provided if import_data.data.is_none() && import_data.file_path.is_none() { return Err(FlowyError::new( @@ -1433,21 +1433,19 @@ impl FolderManager { let handler = self.get_handler(&import_data.view_layout)?; let view_id = gen_view_id().to_string(); let uid = self.user.user_id()?; - let mut encoded_collab: Option = None; + let mut encoded_collab = vec![]; // Import data from bytes if available if let Some(data) = import_data.data { - encoded_collab = Some( - handler - .import_from_bytes( - uid, - &view_id, - &import_data.name, - import_data.import_type, - data, - ) - .await?, - ); + encoded_collab = handler + .import_from_bytes( + uid, + &view_id, + &import_data.name, + import_data.import_type, + data, + ) + .await?; } // Import data from file path if available @@ -1494,20 +1492,15 @@ impl FolderManager { // Iterate over the values in the import data for data in import_data.values { - let collab_type = data.import_type.clone().into(); - // Import a single file and get the view and encoded collab data - let (view, encoded_collab) = self + let (view, encoded_collabs) = self .import_single_file(import_data.parent_view_id.clone(), data) .await?; - let object_id = view.id.clone(); - views.push(view_pb_without_child_views(view)); if sync_after_create { - if let Some(encoded_collab) = encoded_collab { - // don't block the whole import process if the view can't be encoded - match self.get_folder_collab_params(object_id, collab_type, encoded_collab) { + for (object_id, collab_type, encode_collab) in encoded_collabs { + match self.get_folder_collab_params(object_id, collab_type, encode_collab) { Ok(params) => objects.push(params), Err(e) => { error!("import error {}", e); @@ -1519,6 +1512,7 @@ impl FolderManager { // Sync the view to the cloud if sync_after_create { + info!("Syncing the imported {} collab to the cloud", objects.len()); self .cloud_service .batch_create_folder_collab_objects(&workspace_id, objects) diff --git a/frontend/rust-lib/flowy-folder/src/view_operation.rs b/frontend/rust-lib/flowy-folder/src/view_operation.rs index 5cafee0d25..18560095b7 100644 --- a/frontend/rust-lib/flowy-folder/src/view_operation.rs +++ b/frontend/rust-lib/flowy-folder/src/view_operation.rs @@ -1,6 +1,7 @@ use async_trait::async_trait; use bytes::Bytes; use collab::entity::EncodedCollab; +use collab_entity::CollabType; pub use collab_folder::View; use collab_folder::ViewLayout; use std::collections::HashMap; @@ -37,6 +38,8 @@ pub struct DatabaseEncodedCollab { pub database_relations: HashMap, } +pub type ImportedData = (String, CollabType, EncodedCollab); + /// The handler will be used to handler the folder operation for a specific /// view layout. Each [ViewLayout] will have a handler. So when creating a new /// view, the [ViewLayout] will be used to get the handler. @@ -118,7 +121,7 @@ pub trait FolderOperationHandler { name: &str, import_type: ImportType, bytes: Vec, - ) -> Result; + ) -> Result, FlowyError>; /// Create a view by importing data from a file async fn import_from_file_path(