mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: support publish view and unpublish views
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use bytes::Bytes;
|
||||
use collab::entity::EncodedCollab;
|
||||
use collab_integrate::collab_builder::AppFlowyCollabBuilder;
|
||||
use collab_integrate::CollabKVDB;
|
||||
use flowy_chat::manager::ChatManager;
|
||||
@ -200,6 +201,21 @@ impl FolderOperationHandler for DocumentFolderOperation {
|
||||
})
|
||||
}
|
||||
|
||||
fn encoded_collab_v1(
|
||||
&self,
|
||||
view_id: &str,
|
||||
layout: ViewLayout,
|
||||
) -> FutureResult<EncodedCollab, FlowyError> {
|
||||
debug_assert_eq!(layout, ViewLayout::Document);
|
||||
let view_id = view_id.to_string();
|
||||
let manager = self.0.clone();
|
||||
FutureResult::new(async move {
|
||||
let encoded_collab = manager.encode_collab(&view_id).await?;
|
||||
|
||||
Ok(encoded_collab)
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a view with built-in data.
|
||||
fn create_built_in_view(
|
||||
&self,
|
||||
@ -287,6 +303,15 @@ impl FolderOperationHandler for DatabaseFolderOperation {
|
||||
})
|
||||
}
|
||||
|
||||
fn encoded_collab_v1(
|
||||
&self,
|
||||
_view_id: &str,
|
||||
_layout: ViewLayout,
|
||||
) -> FutureResult<EncodedCollab, FlowyError> {
|
||||
// Database view doesn't support collab
|
||||
FutureResult::new(async move { Err(FlowyError::not_support()) })
|
||||
}
|
||||
|
||||
fn duplicate_view(&self, view_id: &str) -> FutureResult<Bytes, FlowyError> {
|
||||
let database_manager = self.0.clone();
|
||||
let view_id = view_id.to_owned();
|
||||
@ -547,4 +572,13 @@ impl FolderOperationHandler for ChatFolderOperation {
|
||||
) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async move { Err(FlowyError::not_support()) })
|
||||
}
|
||||
|
||||
fn encoded_collab_v1(
|
||||
&self,
|
||||
_view_id: &str,
|
||||
_layout: ViewLayout,
|
||||
) -> FutureResult<EncodedCollab, FlowyError> {
|
||||
// Chat view doesn't support collab
|
||||
FutureResult::new(async move { Err(FlowyError::not_support()) })
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_folder_pub::cloud::{
|
||||
FolderCloudService, FolderCollabParams, FolderData, FolderSnapshot, Workspace, WorkspaceRecord,
|
||||
};
|
||||
use flowy_folder_pub::entities::{PublishInfoResponse, PublishViewPayload};
|
||||
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
|
||||
use flowy_server_pub::supabase_config::SupabaseConfiguration;
|
||||
use flowy_storage_pub::cloud::{ObjectIdentity, ObjectValue, StorageCloudService};
|
||||
@ -294,6 +295,65 @@ impl FolderCloudService for ServerProvider {
|
||||
.map(|provider| provider.folder_service().service_name())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn publish_view(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
payload: Vec<PublishViewPayload>,
|
||||
) -> FutureResult<(), Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let server = self.get_server();
|
||||
FutureResult::new(async move {
|
||||
server?
|
||||
.folder_service()
|
||||
.publish_view(&workspace_id, payload)
|
||||
.await
|
||||
})
|
||||
}
|
||||
|
||||
fn unpublish_views(&self, workspace_id: &str, view_ids: Vec<String>) -> FutureResult<(), Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let server = self.get_server();
|
||||
FutureResult::new(async move {
|
||||
server?
|
||||
.folder_service()
|
||||
.unpublish_views(&workspace_id, view_ids)
|
||||
.await
|
||||
})
|
||||
}
|
||||
|
||||
fn get_publish_info(&self, view_id: &str) -> FutureResult<PublishInfoResponse, Error> {
|
||||
let view_id = view_id.to_string();
|
||||
let server = self.get_server();
|
||||
FutureResult::new(async move { server?.folder_service().get_publish_info(&view_id).await })
|
||||
}
|
||||
|
||||
fn set_publish_namespace(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
new_namespace: &str,
|
||||
) -> FutureResult<(), Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let new_namespace = new_namespace.to_string();
|
||||
let server = self.get_server();
|
||||
FutureResult::new(async move {
|
||||
server?
|
||||
.folder_service()
|
||||
.set_publish_namespace(&workspace_id, &new_namespace)
|
||||
.await
|
||||
})
|
||||
}
|
||||
|
||||
fn get_publish_namespace(&self, workspace_id: &str) -> FutureResult<String, Error> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let server = self.get_server();
|
||||
FutureResult::new(async move {
|
||||
server?
|
||||
.folder_service()
|
||||
.get_publish_namespace(&workspace_id)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl DatabaseCloudService for ServerProvider {
|
||||
|
Reference in New Issue
Block a user