Skip to content

Commit

Permalink
Include en-US description of custom roles in static API (#1181)
Browse files Browse the repository at this point in the history
* Include en-US description of custom roles in static API

* Add a custom role to static-api test
  • Loading branch information
dtolnay committed Jan 9, 2024
1 parent 3161442 commit 4fea82a
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 3 deletions.
7 changes: 7 additions & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Team {
pub alumni: Vec<TeamMember>,
pub github: Option<TeamGitHub>,
pub website_data: Option<TeamWebsite>,
pub roles: Vec<MemberRole>,
pub discord: Vec<TeamDiscord>,
}

Expand Down Expand Up @@ -60,6 +61,12 @@ pub struct TeamWebsite {
pub weight: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MemberRole {
pub id: String,
pub description: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TeamDiscord {
pub name: String,
Expand Down
8 changes: 8 additions & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ impl<'a> Generator<'a> {
zulip_stream: ws.zulip_stream().map(|s| s.into()),
weight: ws.weight(),
}),
roles: team
.roles()
.iter()
.map(|role| v1::MemberRole {
id: role.id.clone(),
description: role.description.clone(),
})
.collect(),
discord: team
.discord_roles()
.map(|roles| {
Expand Down
15 changes: 14 additions & 1 deletion tests/static-api/_expected/v1/teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
},
"foo": {
Expand Down Expand Up @@ -69,6 +70,7 @@
"zulip_stream": "t-foo",
"weight": 1000
},
"roles": [],
"discord": []
},
"leaderless": {
Expand All @@ -86,6 +88,7 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
},
"leads-permissions": {
Expand Down Expand Up @@ -115,6 +118,7 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
},
"wg-test": {
Expand All @@ -126,7 +130,10 @@
"name": "Second user",
"github": "user-2",
"github_id": 2,
"is_lead": true
"is_lead": true,
"roles": [
"convener"
]
}
],
"alumni": [
Expand All @@ -145,6 +152,12 @@
],
"github": null,
"website_data": null,
"roles": [
{
"id": "convener",
"description": "Convener"
}
],
"discord": []
}
}
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams/alumni.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
}
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams/foo.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
"zulip_stream": "t-foo",
"weight": 1000
},
"roles": [],
"discord": []
}
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams/leaderless.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
}
1 change: 1 addition & 0 deletions tests/static-api/_expected/v1/teams/leads-permissions.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"alumni": [],
"github": null,
"website_data": null,
"roles": [],
"discord": []
}
11 changes: 10 additions & 1 deletion tests/static-api/_expected/v1/teams/wg-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"name": "Second user",
"github": "user-2",
"github_id": 2,
"is_lead": true
"is_lead": true,
"roles": [
"convener"
]
}
],
"alumni": [
Expand All @@ -26,5 +29,11 @@
],
"github": null,
"website_data": null,
"roles": [
{
"id": "convener",
"description": "Convener"
}
],
"discord": []
}
8 changes: 7 additions & 1 deletion tests/static-api/teams/wg-test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ kind = "working-group"

[people]
leads = ["user-2"]
members = ["user-2"]
members = [
{ github = "user-2", roles = ["convener"] },
]
alumni = ["user-0", "user-5"]

[[roles]]
id = "convener"
description = "Convener"

0 comments on commit 4fea82a

Please sign in to comment.