feat: add support for renaming and updating the icon for workspaces (#4806)

This commit is contained in:
Zack
2024-03-04 16:05:16 +08:00
committed by GitHub
parent f8962edfd7
commit 2af93a9bcb
14 changed files with 283 additions and 37 deletions

View File

@ -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> {

View File

@ -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"),
)
})
}

View File

@ -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 {