mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-26 03:23:01 +00:00
chore: open workspace with workspace auth type
This commit is contained in:
@ -123,7 +123,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
|
||||
context.read<UserWorkspaceBloc>().add(
|
||||
UserWorkspaceEvent.createWorkspace(
|
||||
name,
|
||||
AuthTypePB.Server,
|
||||
AuthTypePB.Local,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -127,7 +127,7 @@ class UserBackendService implements IUserBackendService {
|
||||
) {
|
||||
final payload = OpenUserWorkspacePB()
|
||||
..workspaceId = workspaceId
|
||||
..authType = authType;
|
||||
..workspaceAuthType = authType;
|
||||
return UserEventOpenWorkspace(payload).send();
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
|
||||
workspaceBloc.add(
|
||||
UserWorkspaceEvent.createWorkspace(
|
||||
name,
|
||||
AuthTypePB.Server,
|
||||
AuthTypePB.Local,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -150,7 +150,7 @@ SPEC CHECKSUMS:
|
||||
bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00
|
||||
connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747
|
||||
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
|
||||
device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720
|
||||
device_info_plus: 1b14eed9bf95428983aed283a8d51cce3d8c4215
|
||||
file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d
|
||||
flowy_infra_ui: 03301a39ad118771adbf051a664265c61c507f38
|
||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||
|
@ -283,7 +283,7 @@ impl EventIntegrationTest {
|
||||
pub async fn open_workspace(&self, workspace_id: &str, auth_type: AuthTypePB) {
|
||||
let payload = OpenUserWorkspacePB {
|
||||
workspace_id: workspace_id.to_string(),
|
||||
auth_type,
|
||||
workspace_auth_type: auth_type,
|
||||
};
|
||||
EventBuilder::new(self.clone())
|
||||
.event(UserEvent::OpenWorkspace)
|
||||
|
@ -656,6 +656,7 @@ fn to_user_workspace(af_workspace: AFWorkspace) -> UserWorkspace {
|
||||
icon: af_workspace.icon,
|
||||
member_count: af_workspace.member_count.unwrap_or(0),
|
||||
role: af_workspace.role.map(|r| r.into()),
|
||||
workspace_type: AuthType::AppFlowyCloud,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,12 @@ pub struct UserWorkspace {
|
||||
pub member_count: i64,
|
||||
#[serde(default)]
|
||||
pub role: Option<Role>,
|
||||
#[serde(default = "default_workspace_type")]
|
||||
pub workspace_type: AuthType,
|
||||
}
|
||||
|
||||
fn default_workspace_type() -> AuthType {
|
||||
AuthType::AppFlowyCloud
|
||||
}
|
||||
|
||||
impl UserWorkspace {
|
||||
@ -131,6 +137,7 @@ impl UserWorkspace {
|
||||
icon: "".to_string(),
|
||||
member_count: 1,
|
||||
role: Some(Role::Owner),
|
||||
workspace_type: AuthType::Local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::entities::{UserAuthResponse, UserWorkspace};
|
||||
use crate::entities::{AuthType, UserAuthResponse, UserWorkspace};
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use base64::Engine;
|
||||
use chrono::Utc;
|
||||
@ -77,6 +77,7 @@ impl<'de> Visitor<'de> for SessionVisitor {
|
||||
icon: "".to_owned(),
|
||||
member_count: 1,
|
||||
role: None,
|
||||
workspace_type: AuthType::Local,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ impl From<UserWorkspaceTable> for UserWorkspace {
|
||||
icon: value.icon,
|
||||
member_count: value.member_count,
|
||||
role: value.role.map(|v| v.into()),
|
||||
workspace_type: AuthType::from(value.workspace_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,10 @@ pub struct RepeatedUserWorkspacePB {
|
||||
pub items: Vec<UserWorkspacePB>,
|
||||
}
|
||||
|
||||
impl From<(AuthType, Vec<UserWorkspace>)> for RepeatedUserWorkspacePB {
|
||||
fn from(value: (AuthType, Vec<UserWorkspace>)) -> Self {
|
||||
let (auth_type, workspaces) = value;
|
||||
impl From<Vec<UserWorkspace>> for RepeatedUserWorkspacePB {
|
||||
fn from(workspaces: Vec<UserWorkspace>) -> Self {
|
||||
Self {
|
||||
items: workspaces
|
||||
.into_iter()
|
||||
.map(|w| UserWorkspacePB::from((auth_type, w)))
|
||||
.collect(),
|
||||
items: workspaces.into_iter().map(UserWorkspacePB::from).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,16 +189,16 @@ pub struct UserWorkspacePB {
|
||||
pub workspace_auth_type: AuthTypePB,
|
||||
}
|
||||
|
||||
impl From<(AuthType, UserWorkspace)> for UserWorkspacePB {
|
||||
fn from(value: (AuthType, UserWorkspace)) -> Self {
|
||||
impl From<UserWorkspace> for UserWorkspacePB {
|
||||
fn from(workspace: UserWorkspace) -> Self {
|
||||
Self {
|
||||
workspace_id: value.1.id,
|
||||
name: value.1.name,
|
||||
created_at_timestamp: value.1.created_at.timestamp(),
|
||||
icon: value.1.icon,
|
||||
member_count: value.1.member_count,
|
||||
role: value.1.role.map(AFRolePB::from),
|
||||
workspace_auth_type: AuthTypePB::from(value.0),
|
||||
workspace_id: workspace.id,
|
||||
name: workspace.name,
|
||||
created_at_timestamp: workspace.created_at.timestamp(),
|
||||
icon: workspace.icon,
|
||||
member_count: workspace.member_count,
|
||||
role: workspace.role.map(AFRolePB::from),
|
||||
workspace_auth_type: AuthTypePB::from(workspace.workspace_type),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ pub struct OpenUserWorkspacePB {
|
||||
pub workspace_id: String,
|
||||
|
||||
#[pb(index = 2)]
|
||||
pub auth_type: AuthTypePB,
|
||||
pub workspace_auth_type: AuthTypePB,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Clone, Validate)]
|
||||
|
@ -439,10 +439,7 @@ pub async fn get_all_workspace_handler(
|
||||
.get_all_user_workspaces(profile.uid, profile.auth_type)
|
||||
.await?;
|
||||
|
||||
data_result_ok(RepeatedUserWorkspacePB::from((
|
||||
profile.auth_type,
|
||||
user_workspaces,
|
||||
)))
|
||||
data_result_ok(RepeatedUserWorkspacePB::from(user_workspaces))
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "info", skip(data, manager), err)]
|
||||
@ -454,7 +451,7 @@ pub async fn open_workspace_handler(
|
||||
let params = data.try_into_inner()?;
|
||||
let workspace_id = Uuid::from_str(¶ms.workspace_id)?;
|
||||
manager
|
||||
.open_workspace(&workspace_id, AuthType::from(params.auth_type))
|
||||
.open_workspace(&workspace_id, AuthType::from(params.workspace_auth_type))
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
@ -627,7 +624,7 @@ pub async fn create_workspace_handler(
|
||||
let auth_type = AuthType::from(data.auth_type);
|
||||
let manager = upgrade_manager(manager)?;
|
||||
let new_workspace = manager.create_workspace(&data.name, auth_type).await?;
|
||||
data_result_ok(UserWorkspacePB::from((auth_type, new_workspace)))
|
||||
data_result_ok(UserWorkspacePB::from(new_workspace))
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip_all, err)]
|
||||
|
@ -451,7 +451,7 @@ impl UserManager {
|
||||
);
|
||||
// only send notification if there were real changes
|
||||
if let Ok(updated_list) = select_all_user_workspace(uid, &mut conn) {
|
||||
let repeated_pb = RepeatedUserWorkspacePB::from((auth_copy, updated_list));
|
||||
let repeated_pb = RepeatedUserWorkspacePB::from(updated_list);
|
||||
send_notification(&uid.to_string(), UserNotification::DidUpdateUserWorkspaces)
|
||||
.payload(repeated_pb)
|
||||
.send();
|
||||
|
Reference in New Issue
Block a user