chore: create space view for imported notion zip file (#863)

This commit is contained in:
Nathan.fooo 2024-10-07 12:41:45 +08:00 committed by GitHub
parent 38ff1874e4
commit 820db6564e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 24 deletions

14
Cargo.lock generated
View File

@ -2230,7 +2230,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"arc-swap",
@ -2255,7 +2255,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"async-trait",
@ -2294,7 +2294,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"arc-swap",
@ -2315,7 +2315,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"bytes",
@ -2335,7 +2335,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"arc-swap",
@ -2357,7 +2357,7 @@ dependencies = [
[[package]]
name = "collab-importer"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"async-recursion",
@ -2454,7 +2454,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=d7dc26a906e3ce5d72a309e933f853f1e75da1cb#d7dc26a906e3ce5d72a309e933f853f1e75da1cb"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=f882a1720f7b35a874ea276e604434f0b5b04698#f882a1720f7b35a874ea276e604434f0b5b04698"
dependencies = [
"anyhow",
"collab",

View File

@ -293,13 +293,13 @@ debug = true
[patch.crates-io]
# It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate.
# So using patch to workaround this issue.
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "d7dc26a906e3ce5d72a309e933f853f1e75da1cb" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f882a1720f7b35a874ea276e604434f0b5b04698" }
[features]
history = []

View File

@ -316,6 +316,7 @@ async fn process_unzip_file(
s3_client: &Arc<dyn S3Client>,
) -> Result<(), ImportError> {
let notion_importer = NotionImporter::new(
import_task.uid,
unzip_dir_path,
import_task.workspace_id.clone(),
import_task.host.clone(),
@ -326,7 +327,7 @@ async fn process_unzip_file(
.import()
.await
.map_err(ImportError::ImportCollabError)?;
let nested_views = imported.build_nested_views(import_task.uid).await;
let nested_views = imported.build_nested_views().await;
trace!(
"[Import]: {} imported nested views:{}",
import_task.workspace_id,

View File

@ -9,16 +9,18 @@ use std::time::Duration;
async fn import_blog_post_test() {
let (client, imported_workspace_id) = import_zip("blog_post.zip").await;
let folder = client.get_folder(&imported_workspace_id).await;
let mut workspace_sub_views = folder.get_views_belong_to(&imported_workspace_id);
let mut space_views = folder.get_views_belong_to(&imported_workspace_id);
assert_eq!(
workspace_sub_views.len(),
space_views.len(),
1,
"Expected 1 view, found {:?}",
workspace_sub_views
space_views
);
let imported_view = workspace_sub_views.pop().unwrap();
assert_eq!(imported_view.name, "Blog Post");
let space_view = space_views.pop().unwrap();
assert_eq!(space_view.name, "blog_post");
let imported_view = folder.get_views_belong_to(&space_view.id).pop().unwrap();
let document = client
.get_document(&imported_workspace_id, &imported_view.id)
.await;
@ -53,15 +55,18 @@ async fn import_project_and_task_zip_test() {
let (client, imported_workspace_id) = import_zip("project&task.zip").await;
let folder = client.get_folder(&imported_workspace_id).await;
let workspace_database = client.get_workspace_database(&imported_workspace_id).await;
let mut workspace_sub_views = folder.get_views_belong_to(&imported_workspace_id);
let space_views = folder.get_views_belong_to(&imported_workspace_id);
assert_eq!(
workspace_sub_views.len(),
space_views.len(),
1,
"Expected 1 view, found {:?}",
workspace_sub_views
space_views
);
assert_eq!(space_views[0].name, "project&task");
assert!(space_views[0].space_info().is_some());
let imported_view = workspace_sub_views.pop().unwrap();
let mut sub_views = folder.get_views_belong_to(&space_views[0].id);
let imported_view = sub_views.pop().unwrap();
assert_eq!(imported_view.name, "Projects & Tasks");
assert_eq!(
imported_view.children.len(),