Skip to content

Commit bad46b9

Browse files
authored
Merge pull request #2662 from objectcomputing/bugfix-2653/self-review-accessibility
Bugfix 2653/self review accessibility
2 parents 113f74b + 02d8037 commit bad46b9

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

server/src/main/resources/db/dev/R__Load_testing_data.sql

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,22 +1298,32 @@ INSERT INTO review_periods
12981298
VALUES
12991299
('12345678-e29c-4cf4-9ea4-6baa09405c58', 'Review Period 2', 'PLANNING', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-10 06:00:00', '2024-09-11 06:00:00', '2024-09-12 06:00:00', '2024-01-01 06:00:00', '2024-08-31 06:00:00');
13001300

1301+
INSERT INTO review_periods
1302+
(id, name, review_status, review_template_id, self_review_template_id, launch_date, self_review_close_date, close_date, period_start_date, period_end_date)
1303+
VALUES
1304+
('12345678-e29c-4cf4-9ea4-6baa09405c59', 'Review Period 3', 'CLOSED', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-10-01 06:00:00', '2024-10-02 06:00:00', '2024-10-03 06:00:00', '2024-01-01 06:00:00', '2024-09-30 06:00:00');
1305+
1306+
INSERT INTO review_periods
1307+
(id, name, review_status, review_template_id, self_review_template_id, launch_date, self_review_close_date, close_date, period_start_date, period_end_date)
1308+
VALUES
1309+
('12345678-e29c-4cf4-9ea4-6baa09405c5a', 'Review Period 4', 'CLOSED', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-10-01 06:00:00', '2024-10-02 06:00:00', '2024-10-03 06:00:00', '2024-01-01 06:00:00', '2024-09-30 06:00:00');
1310+
13011311
-- CAE - Self-Review feedback request, Creator: Big Boss
13021312
INSERT INTO feedback_requests
13031313
(id, creator_id, requestee_id, recipient_id, template_id, send_date, due_date, submit_date, status, review_period_id)
13041314
VALUES
1305-
('98390c09-7121-110a-bfee-9380a470a7ef', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'c7406157-a38f-4d48-aaed-04018d846727', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-09-04', '2024-09-30', '2024-09-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c57');
1315+
('98390c09-7121-110a-bfee-9380a470a7ef', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'c7406157-a38f-4d48-aaed-04018d846727', '926a37a4-4ded-4633-8900-715b0383aecc', '2024-10-04', '2024-10-30', '2024-10-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c59');
13061316

13071317
-- CAE - Review feedback request, Creator: Big Boss
13081318
INSERT INTO feedback_requests
13091319
(id, creator_id, requestee_id, recipient_id, template_id, send_date, due_date, submit_date, status, review_period_id)
13101320
VALUES
1311-
('98390c09-7121-110a-bfee-9380a470a7f0', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '2024-09-04', '2024-09-30', '2024-09-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c57');
1321+
('98390c09-7121-110a-bfee-9380a470a7f0', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', '6207b3fd-042d-49aa-9e28-dcc04f537c2d', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '2024-10-04', '2024-10-30', '2024-10-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c59');
13121322

13131323
INSERT INTO feedback_requests
13141324
(id, creator_id, requestee_id, recipient_id, template_id, send_date, due_date, submit_date, status, review_period_id)
13151325
VALUES
1316-
('98390c09-7121-110a-bfee-9380a470a7f3', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'dfe2f986-fac0-11eb-9a03-0242ac130003', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '2024-09-04', '2024-09-30', '2024-09-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c57');
1326+
('98390c09-7121-110a-bfee-9380a470a7f3', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'dfe2f986-fac0-11eb-9a03-0242ac130003', 'd1e94b60-47c4-4945-87d1-4dc88f088e57', '2024-10-04', '2024-10-30', '2024-10-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c59');
13171327

13181328
INSERT INTO feedback_requests
13191329
(id, creator_id, requestee_id, recipient_id, template_id, send_date, due_date, submit_date, status, review_period_id)
@@ -1344,7 +1354,7 @@ VALUES
13441354
INSERT INTO feedback_requests
13451355
(id, creator_id, requestee_id, recipient_id, template_id, send_date, due_date, submit_date, status, review_period_id)
13461356
VALUES
1347-
('98390c09-7121-110a-bfee-9380a470a7f2', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'dfe2f986-fac0-11eb-9a03-0242ac130003', '1c8bc142-c447-4889-986e-42ab177da683', '2024-09-04', '2024-09-30', '2024-09-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c57');
1357+
('98390c09-7121-110a-bfee-9380a470a7f2', '72655c4f-1fb8-4514-b31e-7f7e19fa9bd7', 'c7406157-a38f-4d48-aaed-04018d846727', 'dfe2f986-fac0-11eb-9a03-0242ac130003', '1c8bc142-c447-4889-986e-42ab177da683', '2024-10-04', '2024-10-30', '2024-10-05', 'submitted', '12345678-e29c-4cf4-9ea4-6baa09405c59');
13481358

13491359
---- Creator: Big Boss
13501360
INSERT INTO feedback_requests

web-ui/src/components/reviews/periods/ReviewPeriods.jsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ const ReviewStatus = {
9999
UNKNOWN: 'UNKNOWN'
100100
};
101101

102+
// mode will be either "self" or undefined.
103+
const selfReviewMode = "self";
104+
102105
const ReviewPeriods = ({ onPeriodSelected, mode }) => {
103106
const { state, dispatch } = useContext(AppContext);
104107

105108
const [canSave, setCanSave] = useState(false);
106109
const [loading, setLoading] = useState(false);
110+
const [periods, setPeriods] = useState([]);
107111
const [periodToAdd, setPeriodToAdd] = useState({
108112
name: '',
109113
reviewStatus: ReviewStatus.PLANNING,
@@ -119,9 +123,15 @@ const ReviewPeriods = ({ onPeriodSelected, mode }) => {
119123

120124
const currentUserId = selectCurrentUserId(state);
121125
const csrf = selectCsrfToken(state);
122-
const periods = selectReviewPeriods(state);
123126
const userProfile = selectUserProfile(state);
124127

128+
useEffect(() => {
129+
setPeriods(selectReviewPeriods(state)
130+
.filter((r) => mode !== selfReviewMode ||
131+
r.reviewStatus === ReviewStatus.OPEN ||
132+
r.reviewStatus === ReviewStatus.CLOSED));
133+
}, [state, mode]);
134+
125135
useQueryParameters([
126136
{
127137
name: 'add',
@@ -255,6 +265,7 @@ const ReviewPeriods = ({ onPeriodSelected, mode }) => {
255265

256266
useEffect(() => {
257267
const getSelfReviews = async () => {
268+
setLoading(true);
258269
let reviews = {};
259270
Promise.all(
260271
periods.map(async period => {
@@ -280,7 +291,17 @@ const ReviewPeriods = ({ onPeriodSelected, mode }) => {
280291
});
281292
}
282293
})
283-
).then(() => setSelfReviews(reviews));
294+
).then(() => {
295+
// Now that we have the reviews loaded, filter out closed
296+
// self-review periods in which the current user is not involved.
297+
if (mode == selfReviewMode) {
298+
setPeriods(periods.filter((r) =>
299+
r.reviewStatus !== ReviewStatus.CLOSED ||
300+
!!reviews[r.id]));
301+
}
302+
setSelfReviews(reviews);
303+
setLoading(false);
304+
});
284305
};
285306
if (
286307
csrf &&
@@ -291,18 +312,17 @@ const ReviewPeriods = ({ onPeriodSelected, mode }) => {
291312
) {
292313
getSelfReviews();
293314
}
294-
}, [csrf, periods, currentUserId, selfReviews]);
315+
}, [csrf, periods, currentUserId, selfReviews ]);
295316

296317
const onPeriodClick = useCallback(
297318
id => {
298319
const status = selectReviewPeriod(state, id)?.reviewStatus;
299320
switch (status) {
300321
case ReviewStatus.PLANNING:
301-
onPeriodSelected(id);
302-
break;
303322
case ReviewStatus.AWAITING_APPROVAL:
304-
// TODO: Check for the required permission.
305-
onPeriodSelected(id);
323+
if (mode !== selfReviewMode) {
324+
onPeriodSelected(id);
325+
}
306326
break;
307327
case ReviewStatus.OPEN:
308328
onPeriodSelected(id);

web-ui/src/components/settings/types/boolean.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { createLabelId } from '../../../helpers/strings.js';
1515
*/
1616
const SettingsBoolean = ({ name, description, value, handleChange }) => {
1717
const labelId = createLabelId(name);
18-
18+
const checked =
19+
typeof(value) === 'boolean' ? value : value.toLowerCase() == "true";
1920
return (
2021
<div className="settings-type">
2122
<label htmlFor={labelId}>
@@ -28,7 +29,7 @@ const SettingsBoolean = ({ name, description, value, handleChange }) => {
2829
id={labelId}
2930
className="settings-control"
3031
type="checkbox"
31-
checked={value}
32+
checked={checked}
3233
onChange={handleChange}
3334
/>
3435
</div>

web-ui/src/pages/SettingsPage.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ const SettingsPage = () => {
4646
if (allOptions) {
4747
// Sort the options by category, store them, and upate the state.
4848
setSettingsControls(
49-
allOptions.sort((l, r) => l.category.localeCompare(r.category)));
49+
allOptions.sort((l, r) => {
50+
if (l.category === r.category) {
51+
return l.name.localeCompare(r.name);
52+
} else {
53+
return l.category.localeCompare(r.category);
54+
}
55+
})
56+
);
5057
}
5158
};
5259
if (csrf) {
@@ -124,7 +131,7 @@ const SettingsPage = () => {
124131
for(let key of Object.keys(handlers)) {
125132
const setting = handlers[key].setting;
126133
// The settings controller does not allow blank values.
127-
if (setting && setting.value) {
134+
if (setting?.name && `${setting.value}` != "") {
128135
let res;
129136
if (setting.id) {
130137
res = await putOption({ name: setting.name,
@@ -133,7 +140,7 @@ const SettingsPage = () => {
133140
res = await postOption({ name: setting.name,
134141
value: setting.value }, csrf);
135142
if (res?.payload?.data) {
136-
setting.exists = true;
143+
setting.id = res.payload.data.id;
137144
}
138145
}
139146
if (res?.error) {
@@ -147,6 +154,8 @@ const SettingsPage = () => {
147154
if (res?.payload?.data) {
148155
saved++;
149156
}
157+
} else {
158+
console.warn(`WARNING: ${setting.name} not sent to the server`);
150159
}
151160
}
152161

web-ui/src/pages/__snapshots__/SettingsPage.test.jsx.snap

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ exports[`SettingsPage > renders correctly 1`] = `
3838
class="MuiSwitch-root MuiSwitch-sizeMedium settings-control css-julti5-MuiSwitch-root"
3939
>
4040
<span
41-
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary Mui-checked Mui-checked css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
41+
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase"
4242
>
4343
<input
44-
checked=""
4544
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
4645
id="another-setting"
4746
type="checkbox"
@@ -68,12 +67,12 @@ exports[`SettingsPage > renders correctly 1`] = `
6867
class="settings-type"
6968
>
7069
<label
71-
for="string-setting"
70+
for="other-setting"
7271
>
7372
<h5
7473
class="MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom css-h93ljk-MuiTypography-root"
7574
>
76-
String Setting
75+
Other Setting
7776
</h5>
7877
</label>
7978
<p>
@@ -84,23 +83,22 @@ exports[`SettingsPage > renders correctly 1`] = `
8483
>
8584
<input
8685
class="MuiInputBase-input MuiInput-input css-1x51dt5-MuiInputBase-input-MuiInput-input"
87-
id="string-setting"
88-
placeholder="Enter String Setting"
89-
type="text"
90-
value="The value"
86+
id="other-setting"
87+
type="number"
88+
value="42"
9189
/>
9290
</div>
9391
</div>
9492
<div
9593
class="settings-type"
9694
>
9795
<label
98-
for="other-setting"
96+
for="string-setting"
9997
>
10098
<h5
10199
class="MuiTypography-root MuiTypography-h5 MuiTypography-gutterBottom css-h93ljk-MuiTypography-root"
102100
>
103-
Other Setting
101+
String Setting
104102
</h5>
105103
</label>
106104
<p>
@@ -111,9 +109,10 @@ exports[`SettingsPage > renders correctly 1`] = `
111109
>
112110
<input
113111
class="MuiInputBase-input MuiInput-input css-1x51dt5-MuiInputBase-input-MuiInput-input"
114-
id="other-setting"
115-
type="number"
116-
value="42"
112+
id="string-setting"
113+
placeholder="Enter String Setting"
114+
type="text"
115+
value="The value"
117116
/>
118117
</div>
119118
</div>

0 commit comments

Comments
 (0)