-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(common): team models #1986
base: main
Are you sure you want to change the base?
Changes from 5 commits
e8f1fd7
99eb81c
c79d89d
d60d1aa
c6f4049
8ab9b25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,12 @@ pub struct ProjectCreateRequest { | |
#[typeshare::typeshare] | ||
pub struct ProjectResponse { | ||
pub id: String, | ||
/// Display name | ||
pub name: String, | ||
/// Project owner | ||
pub user_id: String, | ||
pub name: String, | ||
/// Team project belongs to | ||
pub team_id: Option<String>, | ||
pub created_at: DateTime<Utc>, | ||
pub compute_tier: Option<ComputeTier>, | ||
/// State of the current deployment if one exists (something has been deployed). | ||
|
@@ -73,7 +76,15 @@ pub struct ProjectListResponse { | |
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)] | ||
#[typeshare::typeshare] | ||
pub struct ProjectUpdateRequest { | ||
/// Change display name | ||
pub name: Option<String>, | ||
/// Transfer to other user | ||
pub user_id: Option<String>, | ||
/// Transfer to a team | ||
pub team_id: Option<String>, | ||
/// Transfer away from current team | ||
pub remove_from_team: Option<bool>, | ||
/// Change compute tier | ||
pub compute_tier: Option<ComputeTier>, | ||
Comment on lines
78
to
88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: These fields could create conflicting states if multiple transfer options are set simultaneously (user_id, team_id, and remove_from_team). Consider adding validation or documenting the precedence rules. |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use strum::{Display, EnumString}; | ||
|
||
/// Minimal team information | ||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq)] | ||
pub struct Response { | ||
/// Team ID | ||
pub id: String, | ||
|
||
/// Name used for display purposes | ||
pub display_name: String, | ||
|
||
/// Is this user an admin of the team | ||
pub is_admin: bool, | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[typeshare::typeshare] | ||
pub struct TeamListResponse { | ||
pub teams: Vec<TeamResponse>, | ||
} | ||
|
||
/// Member of a team | ||
#[derive(Debug, Serialize, Deserialize, PartialEq)] | ||
pub struct MemberResponse { | ||
/// User ID | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[typeshare::typeshare] | ||
pub struct TeamResponse { | ||
pub id: String, | ||
/// Display name | ||
pub name: String, | ||
/// Membership info of the calling user | ||
pub membership: TeamMembership, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[typeshare::typeshare] | ||
pub struct TeamMembersResponse { | ||
pub members: Vec<TeamMembership>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[typeshare::typeshare] | ||
pub struct TeamMembership { | ||
pub user_id: String, | ||
/// Role of the user in the team | ||
pub role: MemberRole, | ||
pub role: TeamRole, | ||
} | ||
|
||
/// Role of a user in a team | ||
#[derive(Debug, Serialize, Deserialize, PartialEq, Display, EnumString)] | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Display, EnumString)] | ||
#[serde(rename_all = "lowercase")] | ||
#[strum(serialize_all = "lowercase")] | ||
pub enum MemberRole { | ||
#[typeshare::typeshare] | ||
pub enum TeamRole { | ||
Owner, | ||
Admin, | ||
Member, | ||
} | ||
|
||
/// Provide user id to add user. | ||
/// Provide email address to invite user via email. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[typeshare::typeshare] | ||
pub struct AddTeamMemberRequest { | ||
pub user_id: Option<String>, | ||
pub email: Option<String>, | ||
/// Role of the user in the team | ||
pub role: Option<TeamRole>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider making |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: remove_from_team field could be redundant since setting team_id to None could achieve the same result. Consider consolidating the team management logic.