mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: enable relation to (#4866)
* chore: enable relation to * chore: fix database name and improve UI * chore: remove database view id from relation type option * chore: add remove row id test * chore: improve appearance of untitled rows * chore: empty in row detail * fix: cannot add events after closing --------- Co-authored-by: Richard Shiue <71320345+richardshiue@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
use collab::core::collab_state::SyncState;
|
||||
use collab_database::rows::RowId;
|
||||
use collab_database::user::DatabaseMeta;
|
||||
use collab_database::views::DatabaseLayout;
|
||||
|
||||
use flowy_derive::ProtoBuf;
|
||||
@ -203,23 +202,18 @@ impl TryInto<MoveGroupRowParams> for MoveGroupRowPayloadPB {
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, ProtoBuf)]
|
||||
pub struct DatabaseDescriptionPB {
|
||||
pub struct DatabaseMetaPB {
|
||||
#[pb(index = 1)]
|
||||
pub database_id: String,
|
||||
}
|
||||
|
||||
impl From<DatabaseMeta> for DatabaseDescriptionPB {
|
||||
fn from(data: DatabaseMeta) -> Self {
|
||||
Self {
|
||||
database_id: data.database_id,
|
||||
}
|
||||
}
|
||||
#[pb(index = 2)]
|
||||
pub inline_view_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, ProtoBuf)]
|
||||
pub struct RepeatedDatabaseDescriptionPB {
|
||||
#[pb(index = 1)]
|
||||
pub items: Vec<DatabaseDescriptionPB>,
|
||||
pub items: Vec<DatabaseMetaPB>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, ProtoBuf)]
|
||||
|
@ -3,6 +3,7 @@ use std::sync::{Arc, Weak};
|
||||
use collab_database::rows::RowId;
|
||||
use lib_infra::box_any::BoxAny;
|
||||
use tokio::sync::oneshot;
|
||||
use tracing::error;
|
||||
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use lib_dispatch::prelude::{af_spawn, data_result_ok, AFPluginData, AFPluginState, DataResult};
|
||||
@ -741,7 +742,22 @@ pub(crate) async fn get_databases_handler(
|
||||
manager: AFPluginState<Weak<DatabaseManager>>,
|
||||
) -> DataResult<RepeatedDatabaseDescriptionPB, FlowyError> {
|
||||
let manager = upgrade_manager(manager)?;
|
||||
let data = manager.get_all_databases_description().await;
|
||||
let metas = manager.get_all_databases_meta().await;
|
||||
|
||||
let mut items = Vec::with_capacity(metas.len());
|
||||
for meta in metas {
|
||||
match manager.get_database_inline_view_id(&meta.database_id).await {
|
||||
Ok(view_id) => items.push(DatabaseMetaPB {
|
||||
database_id: meta.database_id,
|
||||
inline_view_id: view_id,
|
||||
}),
|
||||
Err(err) => {
|
||||
error!(?err);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
let data = RepeatedDatabaseDescriptionPB { items };
|
||||
data_result_ok(data)
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@ use std::sync::{Arc, Weak};
|
||||
|
||||
use collab::core::collab::{CollabDocState, MutexCollab};
|
||||
use collab_database::blocks::BlockEvent;
|
||||
use collab_database::database::{DatabaseData, MutexDatabase};
|
||||
use collab_database::database::{get_inline_view_id, DatabaseData, MutexDatabase};
|
||||
use collab_database::error::DatabaseError;
|
||||
use collab_database::user::{
|
||||
CollabDocStateByOid, CollabFuture, DatabaseCollabService, WorkspaceDatabase,
|
||||
CollabDocStateByOid, CollabFuture, DatabaseCollabService, DatabaseMeta, WorkspaceDatabase,
|
||||
};
|
||||
use collab_database::views::{CreateDatabaseParams, CreateViewParams, DatabaseLayout};
|
||||
use collab_entity::CollabType;
|
||||
@ -24,10 +24,7 @@ use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use lib_dispatch::prelude::af_spawn;
|
||||
use lib_infra::priority_task::TaskDispatcher;
|
||||
|
||||
use crate::entities::{
|
||||
DatabaseDescriptionPB, DatabaseLayoutPB, DatabaseSnapshotPB, DidFetchRowPB,
|
||||
RepeatedDatabaseDescriptionPB,
|
||||
};
|
||||
use crate::entities::{DatabaseLayoutPB, DatabaseSnapshotPB, DidFetchRowPB};
|
||||
use crate::notification::{send_notification, DatabaseNotification};
|
||||
use crate::services::database::DatabaseEditor;
|
||||
use crate::services::database_view::DatabaseLayoutDepsResolver;
|
||||
@ -164,16 +161,27 @@ impl DatabaseManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_all_databases_description(&self) -> RepeatedDatabaseDescriptionPB {
|
||||
pub async fn get_database_inline_view_id(&self, database_id: &str) -> FlowyResult<String> {
|
||||
let wdb = self.get_workspace_database().await?;
|
||||
let database_collab = wdb.get_database_collab(database_id).await.ok_or_else(|| {
|
||||
FlowyError::record_not_found().with_context(format!("The database:{} not found", database_id))
|
||||
})?;
|
||||
|
||||
let inline_view_id = get_inline_view_id(&database_collab.lock()).ok_or_else(|| {
|
||||
FlowyError::record_not_found().with_context(format!(
|
||||
"Can't find the inline view for database:{}",
|
||||
database_id
|
||||
))
|
||||
})?;
|
||||
Ok(inline_view_id)
|
||||
}
|
||||
|
||||
pub async fn get_all_databases_meta(&self) -> Vec<DatabaseMeta> {
|
||||
let mut items = vec![];
|
||||
if let Ok(wdb) = self.get_workspace_database().await {
|
||||
items = wdb
|
||||
.get_all_database_meta()
|
||||
.into_iter()
|
||||
.map(DatabaseDescriptionPB::from)
|
||||
.collect();
|
||||
items = wdb.get_all_database_meta()
|
||||
}
|
||||
RepeatedDatabaseDescriptionPB { items }
|
||||
items
|
||||
}
|
||||
|
||||
pub async fn track_database(
|
||||
|
Reference in New Issue
Block a user