Skip to content

Commit

Permalink
chore: create space view for imported notion zip file (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy authored Oct 7, 2024
1 parent 38ff187 commit 820db65
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
3 changes: 2 additions & 1 deletion services/appflowy-worker/src/import_worker/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down
23 changes: 14 additions & 9 deletions tests/workspace/import_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 820db65

Please sign in to comment.