Skip to content

Commit 8dde582

Browse files
committed
make browser ide sharable
1 parent 331efbb commit 8dde582

6 files changed

Lines changed: 1103 additions & 1 deletion

File tree

crates/conductor/src/server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,8 @@ impl Conductor {
12361236
is_compose: ActiveValue::Set(false),
12371237
compose_parent: ActiveValue::Set(None),
12381238
pinned: ActiveValue::Set(false),
1239+
shared: ActiveValue::Set(None),
1240+
public: ActiveValue::Set(None),
12391241
};
12401242
let ws = ws.insert(&txn).await?;
12411243
self.enterprise
@@ -1957,6 +1959,8 @@ impl Conductor {
19571959
is_compose: ActiveValue::Set(is_compose),
19581960
compose_parent: ActiveValue::Set(Some(ws.id)),
19591961
pinned: ActiveValue::Set(false),
1962+
shared: ActiveValue::Set(None),
1963+
public: ActiveValue::Set(None),
19601964
}
19611965
.insert(&self.db.conn)
19621966
.await?;

crates/db/entities/src/workspace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct Model {
3838
pub compose_parent: Option<Uuid>,
3939
pub updated_at: Option<DateTimeWithTimeZone>,
4040
pub pinned: bool,
41+
pub shared: Option<bool>,
42+
pub public: Option<bool>,
4143
}
4244

4345
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

crates/db/migration/src/m20231106_100804_create_workspace_table.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ impl MigrationTrait for Migration {
5757
.col(ColumnDef::new(Workspace::IsCompose).boolean().not_null())
5858
.col(ColumnDef::new(Workspace::ComposeParent).uuid())
5959
.col(ColumnDef::new(Workspace::Pinned).boolean().not_null())
60+
.col(ColumnDef::new(Workspace::Shared).boolean())
61+
.col(ColumnDef::new(Workspace::Public).boolean())
6062
.foreign_key(
6163
ForeignKey::create()
6264
.from_tbl(Workspace::Table)
@@ -173,4 +175,6 @@ pub enum Workspace {
173175
IsCompose,
174176
ComposeParent,
175177
Pinned,
178+
Shared,
179+
Public,
176180
}

crates/proxy-http/src/proxy.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,19 @@ pub async fn forward_workspace(
6767
.get_workspace_by_name(prefix)
6868
.await
6969
.map_err(|_| WorkspaceForwardError::WorkspaceNotFound)?;
70+
71+
if ws.public == Some(true) {
72+
return Ok((ws, None));
73+
}
74+
7075
if let Some(user) = user {
71-
if user.id == ws.user_id {
76+
if user.id == ws.user_id
77+
|| (ws.shared == Some(true)
78+
&& db
79+
.get_organization_member(user.id, ws.organization_id)
80+
.await
81+
.is_ok())
82+
{
7283
return Ok((ws, None));
7384
}
7485
}

0 commit comments

Comments
 (0)