mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add support for renaming and updating the icon for workspaces (#4806)
This commit is contained in:
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use client_api::entity::workspace_dto::{
|
||||
CreateWorkspaceMember, CreateWorkspaceParam, WorkspaceMemberChangeset,
|
||||
CreateWorkspaceMember, CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset,
|
||||
};
|
||||
use client_api::entity::{AFRole, AFWorkspace, AuthProvider, CollabParams, CreateCollabParams};
|
||||
use client_api::{Client, ClientConfiguration};
|
||||
@ -16,6 +16,7 @@ use flowy_user_pub::cloud::{UserCloudService, UserCollabParams, UserUpdate, User
|
||||
use flowy_user_pub::entities::*;
|
||||
use lib_infra::box_any::BoxAny;
|
||||
use lib_infra::future::FutureResult;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::af_cloud::define::USER_SIGN_IN_URL;
|
||||
use crate::af_cloud::impls::user::dto::{
|
||||
@ -320,6 +321,32 @@ where
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn patch_workspace(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
new_workspace_name: Option<&str>,
|
||||
new_workspace_icon: Option<&str>,
|
||||
) -> FutureResult<(), FlowyError> {
|
||||
let try_get_client = self.server.try_get_client();
|
||||
let owned_workspace_id = workspace_id.to_owned();
|
||||
let owned_workspace_name = new_workspace_name.map(|s| s.to_owned());
|
||||
let owned_workspace_icon = new_workspace_icon.map(|s| s.to_owned());
|
||||
FutureResult::new(async move {
|
||||
let workspace_id: Uuid = owned_workspace_id
|
||||
.parse()
|
||||
.map_err(|_| ErrorCode::InvalidParams)?;
|
||||
let client = try_get_client?;
|
||||
client
|
||||
.patch_workspace(PatchWorkspaceParam {
|
||||
workspace_id,
|
||||
workspace_name: owned_workspace_name,
|
||||
workspace_icon: owned_workspace_icon,
|
||||
})
|
||||
.await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_admin_client(client: &Arc<AFCloudClient>) -> FlowyResult<Client> {
|
||||
|
@ -179,7 +179,7 @@ impl UserCloudService for LocalServerUserAuthServiceImpl {
|
||||
FutureResult::new(async {
|
||||
Err(
|
||||
FlowyError::local_version_not_support()
|
||||
.with_context("local server doesn't support mulitple workspaces"),
|
||||
.with_context("local server doesn't support multiple workspaces"),
|
||||
)
|
||||
})
|
||||
}
|
||||
@ -188,7 +188,21 @@ impl UserCloudService for LocalServerUserAuthServiceImpl {
|
||||
FutureResult::new(async {
|
||||
Err(
|
||||
FlowyError::local_version_not_support()
|
||||
.with_context("local server doesn't support mulitple workspaces"),
|
||||
.with_context("local server doesn't support multiple workspaces"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn patch_workspace(
|
||||
&self,
|
||||
_workspace_id: &str,
|
||||
_new_workspace_name: Option<&str>,
|
||||
_new_workspace_icon: Option<&str>,
|
||||
) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async {
|
||||
Err(
|
||||
FlowyError::local_version_not_support()
|
||||
.with_context("local server doesn't support multiple workspaces"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -372,6 +372,20 @@ where
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn patch_workspace(
|
||||
&self,
|
||||
_workspace_id: &str,
|
||||
_new_workspace_name: Option<&str>,
|
||||
_new_workspace_icon: Option<&str>,
|
||||
) -> FutureResult<(), FlowyError> {
|
||||
FutureResult::new(async {
|
||||
Err(
|
||||
FlowyError::local_version_not_support()
|
||||
.with_context("supabase server doesn't support mulitple workspaces"),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CreateCollabAction {
|
||||
|
Reference in New Issue
Block a user