Skip to content

Commit b23d10c

Browse files
authored
Merge pull request #117 from CodeGov-org/nathan/update-review-pages
feat: update review pages
2 parents 865f750 + 970a8d2 commit b23d10c

58 files changed

Lines changed: 1044 additions & 499 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/styles/global/buttons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ $btn-disabled-color: rgba(colors.$primary, 0.45);
8585
flex-direction: row;
8686
justify-content: end;
8787
align-items: center;
88+
margin-top: sizing.size(4);
8889

8990
> :not(:last-child) {
9091
margin-right: sizing.size(2);

lib/styles/global/typography.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,24 @@ code {
140140
background-color: colors.$slate-900;
141141
}
142142
}
143+
144+
.truncate {
145+
display: block;
146+
overflow-x: hidden;
147+
white-space: nowrap;
148+
text-overflow: ellipsis;
149+
margin-right: sizing.size(4);
150+
}
151+
152+
.page-heading {
153+
display: flex;
154+
flex-direction: row;
155+
justify-content: space-between;
156+
align-items: center;
157+
margin-bottom: sizing.size(4);
158+
159+
> * {
160+
margin-bottom: 0;
161+
margin-top: 0;
162+
}
163+
}

src/backend/api/backend.did

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,24 @@ type UserConfig = variant {
4141
anonymous;
4242
};
4343

44-
type GetMyUserProfileResponse = variant {
44+
type UserProfile = record {
45+
id : text;
46+
username : text;
47+
config : UserConfig;
48+
};
49+
50+
type ListReviewerProfilesResponse = variant {
4551
ok : record {
46-
id : text;
47-
username : text;
48-
config : UserConfig;
52+
profiles : vec UserProfile;
4953
};
5054
err : Err;
5155
};
5256

57+
type GetMyUserProfileResponse = variant {
58+
ok : UserProfile;
59+
err : Err;
60+
};
61+
5362
type UserProfileHistoryEntry = record {
5463
username : text;
5564
config : UserConfig;
@@ -396,6 +405,7 @@ type HttpResponse = record {
396405
// End HTTP
397406

398407
service : {
408+
list_reviewer_profiles : () -> (ListReviewerProfilesResponse) query;
399409
get_my_user_profile : () -> (GetMyUserProfileResponse) query;
400410
get_my_user_profile_history : () -> (GetMyUserProfileHistoryResponse) query;
401411
create_my_user_profile : () -> (CreateMyUserProfileResponse);

src/backend/api/src/user_profile.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ pub struct SocialLink {
5252
}
5353

5454
#[derive(Debug, Clone, CandidType, PartialEq, Eq)]
55-
pub struct GetMyUserProfileResponse {
55+
pub struct UserProfile {
5656
pub id: String,
5757
pub username: String,
5858
pub config: UserConfig,
5959
}
6060

61+
#[derive(Debug, Clone, CandidType, PartialEq, Eq)]
62+
pub struct ListReviewerProfilesResponse {
63+
pub profiles: Vec<UserProfile>,
64+
}
65+
66+
pub type GetMyUserProfileResponse = UserProfile;
67+
6168
#[derive(Debug, Clone, CandidType, PartialEq, Eq)]
6269
pub struct CreateMyUserProfileResponse {
6370
pub id: String,

src/backend/impl/src/controllers/log_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mod tests {
6969

7070
#[rstest]
7171
#[case::anonymous_principal(Principal::anonymous())]
72-
#[case::non_admin_principal(fixtures::principal())]
72+
#[case::non_admin_principal(fixtures::principal_a())]
7373
fn list_logs_unauthorized(#[case] calling_principal: Principal) {
7474
let request = LogsFilterRequest {
7575
before_timestamp_ms: None,
@@ -105,7 +105,7 @@ mod tests {
105105

106106
#[rstest]
107107
fn list_logs() {
108-
let calling_principal = fixtures::principal();
108+
let calling_principal = fixtures::principal_a();
109109
let request = LogsFilterRequest {
110110
before_timestamp_ms: None,
111111
after_timestamp_ms: None,

src/backend/impl/src/controllers/proposal_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ mod tests {
135135

136136
#[rstest]
137137
#[case::anonymous_principal(Principal::anonymous())]
138-
#[case::non_admin_principal(fixtures::principal())]
138+
#[case::non_admin_principal(fixtures::principal_a())]
139139
async fn sync_proposals_unauthorized(#[case] calling_principal: Principal) {
140140
let error = ApiError::permission_denied(&format!(
141141
"Principal {} must be an admin to call this endpoint",
@@ -171,7 +171,7 @@ mod tests {
171171

172172
#[rstest]
173173
async fn sync_proposals() {
174-
let calling_principal = fixtures::principal();
174+
let calling_principal = fixtures::principal_a();
175175
let synced_proposals_count = 2;
176176
let completed_proposals_count = 1;
177177

src/backend/impl/src/controllers/proposal_review_commit_controller.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ mod tests {
135135

136136
#[rstest]
137137
async fn create_proposal_review_commit() {
138-
let calling_principal = fixtures::principal();
138+
let calling_principal = fixtures::principal_a();
139139
let request = CreateProposalReviewCommitRequest {
140140
proposal_review_id: "proposal_review_id".to_string(),
141141
commit_sha: "commit_sha".to_string(),
@@ -177,7 +177,7 @@ mod tests {
177177

178178
#[rstest]
179179
async fn create_proposal_review_commit_unauthorized() {
180-
let calling_principal = fixtures::principal();
180+
let calling_principal = fixtures::principal_a();
181181
let request = CreateProposalReviewCommitRequest {
182182
proposal_review_id: "proposal_review_id".to_string(),
183183
commit_sha: "commit_sha".to_string(),
@@ -215,7 +215,7 @@ mod tests {
215215

216216
#[rstest]
217217
fn update_proposal_review_commit() {
218-
let calling_principal = fixtures::principal();
218+
let calling_principal = fixtures::principal_a();
219219
let request = UpdateProposalReviewCommitRequest {
220220
id: "id".to_string(),
221221
state: backend_api::ReviewCommitState::Reviewed {
@@ -249,7 +249,7 @@ mod tests {
249249

250250
#[rstest]
251251
fn update_proposal_review_commit_unauthorized() {
252-
let calling_principal = fixtures::principal();
252+
let calling_principal = fixtures::principal_a();
253253
let request = UpdateProposalReviewCommitRequest {
254254
id: "id".to_string(),
255255
state: backend_api::ReviewCommitState::Reviewed {
@@ -285,7 +285,7 @@ mod tests {
285285

286286
#[rstest]
287287
fn delete_proposal_review_commit() {
288-
let calling_principal = fixtures::principal();
288+
let calling_principal = fixtures::principal_a();
289289
let request = DeleteProposalReviewCommitRequest {
290290
id: "id".to_string(),
291291
};
@@ -314,7 +314,7 @@ mod tests {
314314

315315
#[rstest]
316316
fn delete_proposal_review_commit_unauthorized() {
317-
let calling_principal = fixtures::principal();
317+
let calling_principal = fixtures::principal_a();
318318
let request = DeleteProposalReviewCommitRequest {
319319
id: "id".to_string(),
320320
};

src/backend/impl/src/controllers/proposal_review_controller.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ mod tests {
250250

251251
#[rstest]
252252
async fn create_proposal_review() {
253-
let calling_principal = fixtures::principal();
253+
let calling_principal = fixtures::principal_a();
254254
let request = CreateProposalReviewRequest {
255255
proposal_id: "proposal_id".to_string(),
256256
summary: Some("summary".to_string()),
@@ -293,7 +293,7 @@ mod tests {
293293

294294
#[rstest]
295295
async fn create_proposal_review_unauthorized() {
296-
let calling_principal = fixtures::principal();
296+
let calling_principal = fixtures::principal_a();
297297
let request = CreateProposalReviewRequest {
298298
proposal_id: "proposal_id".to_string(),
299299
summary: Some("summary".to_string()),
@@ -333,7 +333,7 @@ mod tests {
333333

334334
#[rstest]
335335
fn update_proposal_review() {
336-
let calling_principal = fixtures::principal();
336+
let calling_principal = fixtures::principal_a();
337337
let request = UpdateProposalReviewRequest {
338338
proposal_id: fixtures::proposal_id().to_string(),
339339
status: None,
@@ -369,7 +369,7 @@ mod tests {
369369

370370
#[rstest]
371371
fn update_proposal_review_unauthorized() {
372-
let calling_principal = fixtures::principal();
372+
let calling_principal = fixtures::principal_a();
373373
let request = UpdateProposalReviewRequest {
374374
proposal_id: fixtures::proposal_id().to_string(),
375375
status: None,
@@ -409,7 +409,7 @@ mod tests {
409409

410410
#[rstest]
411411
async fn create_proposal_review_image() {
412-
let calling_principal = fixtures::principal();
412+
let calling_principal = fixtures::principal_a();
413413
let request = CreateProposalReviewImageRequest {
414414
proposal_id: fixtures::proposal_id().to_string(),
415415
content_type: "image/png".to_string(),
@@ -448,7 +448,7 @@ mod tests {
448448

449449
#[rstest]
450450
async fn create_proposal_review_image_unauthorized() {
451-
let calling_principal = fixtures::principal();
451+
let calling_principal = fixtures::principal_a();
452452
let request = CreateProposalReviewImageRequest {
453453
proposal_id: fixtures::proposal_id().to_string(),
454454
content_type: "image/png".to_string(),
@@ -486,7 +486,7 @@ mod tests {
486486

487487
#[rstest]
488488
async fn delete_proposal_review_image() {
489-
let calling_principal = fixtures::principal();
489+
let calling_principal = fixtures::principal_a();
490490
let request = DeleteProposalReviewImageRequest {
491491
proposal_id: fixtures::proposal_id().to_string(),
492492
image_path: "/images/reviews/dummy-image-id".to_string(),
@@ -518,7 +518,7 @@ mod tests {
518518

519519
#[rstest]
520520
async fn delete_proposal_review_image_unauthorized() {
521-
let calling_principal = fixtures::principal();
521+
let calling_principal = fixtures::principal_a();
522522
let request = DeleteProposalReviewImageRequest {
523523
proposal_id: fixtures::proposal_id().to_string(),
524524
image_path: "/images/reviews/dummy-image-id".to_string(),

src/backend/impl/src/controllers/user_profile_controller.rs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ use crate::{
66
};
77
use backend_api::{
88
ApiError, ApiResult, CreateMyUserProfileResponse, GetMyUserProfileHistoryResponse,
9-
GetMyUserProfileResponse, UpdateMyUserProfileRequest, UpdateUserProfileRequest,
9+
GetMyUserProfileResponse, ListReviewerProfilesResponse, UpdateMyUserProfileRequest,
10+
UpdateUserProfileRequest,
1011
};
1112
use candid::Principal;
1213
use ic_cdk::*;
1314

15+
#[query]
16+
fn list_reviewer_profiles() -> ApiResult<ListReviewerProfilesResponse> {
17+
UserProfileController::default()
18+
.list_reviewer_profiles()
19+
.into()
20+
}
21+
1422
#[query]
1523
fn get_my_user_profile() -> ApiResult<GetMyUserProfileResponse> {
1624
let calling_principal = caller();
@@ -84,6 +92,12 @@ impl<A: AccessControlService, U: UserProfileService> UserProfileController<A, U>
8492
}
8593
}
8694

95+
fn list_reviewer_profiles(&self) -> Result<ListReviewerProfilesResponse, ApiError> {
96+
let profiles = self.user_profile_service.list_reviewer_profiles()?;
97+
98+
Ok(profiles)
99+
}
100+
87101
fn get_my_user_profile(
88102
&self,
89103
calling_principal: Principal,
@@ -163,16 +177,39 @@ mod tests {
163177
use super::*;
164178
use crate::{
165179
fixtures,
166-
mappings::{map_get_my_user_profile_history_response, map_get_my_user_profile_response},
180+
mappings::{
181+
map_get_my_user_profile_history_response, map_get_my_user_profile_response,
182+
map_list_reviewer_profiles_response,
183+
},
167184
services::{MockAccessControlService, MockUserProfileService},
168185
};
169186
use backend_api::UserConfig;
170187
use mockall::predicate::*;
171188
use rstest::*;
172189

190+
#[rstest]
191+
fn list_reviewer_profiles() {
192+
let profiles = map_list_reviewer_profiles_response(vec![(
193+
fixtures::user_id(),
194+
fixtures::reviewer_user_profile(),
195+
)]);
196+
197+
let mut service_mock = MockUserProfileService::new();
198+
service_mock
199+
.expect_list_reviewer_profiles()
200+
.once()
201+
.return_const(Ok(profiles.clone()));
202+
203+
let controller = UserProfileController::new(MockAccessControlService::new(), service_mock);
204+
205+
let result = controller.list_reviewer_profiles().unwrap();
206+
207+
assert_eq!(result, profiles);
208+
}
209+
173210
#[rstest]
174211
fn get_my_user_profile() {
175-
let calling_principal = fixtures::principal();
212+
let calling_principal = fixtures::principal_a();
176213
let profile =
177214
map_get_my_user_profile_response(fixtures::user_id(), fixtures::admin_user_profile());
178215

@@ -224,7 +261,7 @@ mod tests {
224261

225262
#[rstest]
226263
fn get_my_user_profile_no_profile() {
227-
let calling_principal = fixtures::principal();
264+
let calling_principal = fixtures::principal_a();
228265
let error = ApiError::not_found("User profile not found");
229266

230267
let mut access_control_service_mock = MockAccessControlService::new();
@@ -253,7 +290,7 @@ mod tests {
253290

254291
#[rstest]
255292
fn get_my_user_profile_history() {
256-
let calling_principal = fixtures::principal();
293+
let calling_principal = fixtures::principal_a();
257294
let profile_history =
258295
map_get_my_user_profile_history_response(fixtures::user_profile_history());
259296

@@ -329,7 +366,7 @@ mod tests {
329366

330367
#[rstest]
331368
async fn create_my_user_profile() {
332-
let calling_principal = fixtures::principal();
369+
let calling_principal = fixtures::principal_a();
333370
let profile = CreateMyUserProfileResponse {
334371
id: "id".to_string(),
335372
username: "username".to_string(),
@@ -387,7 +424,7 @@ mod tests {
387424

388425
#[rstest]
389426
fn update_user_profile() {
390-
let calling_principal = fixtures::principal();
427+
let calling_principal = fixtures::principal_a();
391428
let user_id = fixtures::user_id();
392429
let request = UpdateUserProfileRequest {
393430
user_id: user_id.to_string(),
@@ -423,7 +460,7 @@ mod tests {
423460

424461
#[rstest]
425462
fn update_my_user_profile() {
426-
let calling_principal = fixtures::principal();
463+
let calling_principal = fixtures::principal_a();
427464
let request = UpdateMyUserProfileRequest {
428465
username: Some("username".to_string()),
429466
config: None,
@@ -511,7 +548,7 @@ mod tests {
511548

512549
#[rstest]
513550
fn update_user_profile_non_admin_principal() {
514-
let calling_principal = fixtures::principal();
551+
let calling_principal = fixtures::principal_a();
515552
let user_id = fixtures::user_id();
516553
let request = UpdateUserProfileRequest {
517554
user_id: user_id.to_string(),

0 commit comments

Comments
 (0)