Skip to content

Commit

Permalink
chore: improve link between folder and database (#5024)
Browse files Browse the repository at this point in the history
* chore: improve link between folder and database

* chore: fix tests

* chore: update collab rev

---------

Co-authored-by: Lucas.Xu <[email protected]>
  • Loading branch information
richardshiue and LucasXu0 authored Apr 19, 2024
1 parent fab871e commit 7745e54
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 122 deletions.
14 changes: 7 additions & 7 deletions frontend/appflowy_tauri/src-tauri/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 frontend/appflowy_tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "390
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
14 changes: 7 additions & 7 deletions frontend/appflowy_web/wasm-libs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "390
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
14 changes: 7 additions & 7 deletions frontend/appflowy_web_app/src-tauri/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 frontend/appflowy_web_app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "390
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
14 changes: 7 additions & 7 deletions frontend/rust-lib/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 frontend/rust-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ client-api = { git = " https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "39
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "f1ef8ef3c179a7340d91ad6e5e176cc980accb9c" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5e32057ac8e6939368a8e75df91bcbce2ac143e7" }
21 changes: 16 additions & 5 deletions frontend/rust-lib/flowy-database2/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl DatabaseManager {

pub async fn duplicate_database(&self, view_id: &str) -> FlowyResult<Vec<u8>> {
let wdb = self.get_workspace_database().await?;
let data = wdb.get_database_duplicated_data(view_id).await?;
let data = wdb.get_database_data(view_id).await?;
let json_bytes = data.to_json_bytes()?;
Ok(json_bytes)
}
Expand All @@ -294,11 +294,22 @@ impl DatabaseManager {
view_id: &str,
data: Vec<u8>,
) -> FlowyResult<()> {
let mut database_data = DatabaseData::from_json_bytes(data)?;
database_data.view.id = view_id.to_string();
let database_data = DatabaseData::from_json_bytes(data)?;

let mut create_database_params = CreateDatabaseParams::from_database_data(database_data);
let old_view_id = create_database_params.inline_view_id.clone();
create_database_params.inline_view_id = view_id.to_string();

if let Some(create_view_params) = create_database_params
.views
.iter_mut()
.find(|view| view.view_id == old_view_id)
{
create_view_params.view_id = view_id.to_string();
}

let wdb = self.get_workspace_database().await?;
let _ = wdb.create_database_with_data(database_data)?;
let _ = wdb.create_database(create_database_params)?;
Ok(())
}

Expand Down Expand Up @@ -346,7 +357,7 @@ impl DatabaseManager {
.map_err(internal_error)??;
let result = ImportResult {
database_id: params.database_id.clone(),
view_id: params.view_id.clone(),
view_id: params.inline_view_id.clone(),
};
self.create_database_with_params(params).await?;
Ok(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ impl DatabaseViewEditor {
&self,
params: CreateRowPayloadPB,
) -> FlowyResult<CreateRowParams> {
let timestamp = timestamp();
let mut result = CreateRowParams {
collab_params: collab_database::rows::CreateRowParams {
id: gen_row_id(),
cells: Cells::new(),
height: 60,
visibility: true,
row_position: params.row_position.try_into()?,
timestamp: timestamp(),
created_at: timestamp,
modified_at: timestamp,
},
open_after_create: false,
};
Expand Down
Loading

0 comments on commit 7745e54

Please sign in to comment.