Skip to content

Commit 9bd772b

Browse files
authored
Merge pull request #1235 from revisit-studies/jay/UIfix
Fix UI bugs (screen recording download, reject/undo reject participant buttons)
2 parents 151335f + 1307d06 commit 9bd772b

2 files changed

Lines changed: 58 additions & 45 deletions

File tree

src/analysis/individualStudy/ParticipantRejectModal.tsx

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Modal, Text, TextInput, Flex, Button, Alert, Tooltip,
2+
Modal, Text, TextInput, Flex, Button, Alert, Tooltip, Group,
33
} from '@mantine/core';
44
import { IconAlertTriangle } from '@tabler/icons-react';
55
import {
@@ -52,6 +52,8 @@ export function ParticipantRejectModal({
5252
const currentAndSelectedParticipants = useMemo(() => [...selectedParticipants, currentParticipantData].filter((p) => p !== null) as ParticipantData[], [selectedParticipants, currentParticipantData]);
5353
const rejectedParticipantsCount = useMemo(() => currentAndSelectedParticipants.filter((p) => p.rejected).length, [currentAndSelectedParticipants]);
5454
const nonRejectedParticipantsCount = useMemo(() => currentAndSelectedParticipants.filter((p) => !p.rejected).length, [currentAndSelectedParticipants]);
55+
const rejectParticipantLabel = `Reject Participant${nonRejectedParticipantsCount === 1 ? '' : 's'}`;
56+
const undoRejectParticipantLabel = `Undo Reject Participant${rejectedParticipantsCount === 1 ? '' : 's'}`;
5557

5658
const rejectParticipant = useCallback(async (rejectParticipantId: string, reason: string) => {
5759
if (storageEngine && studyId) {
@@ -106,26 +108,30 @@ export function ParticipantRejectModal({
106108

107109
return (
108110
<>
109-
{rejectedParticipantsCount > 0 && (
110-
<Tooltip label="Only admins can undo rejection" disabled={user.isAdmin}>
111-
<Button disabled={!user.isAdmin} onClick={() => setModalUndoRejectOpened(true)} color="blue">
112-
Undo Reject
113-
{!footer ? ` Participants (${rejectedParticipantsCount})` : ''}
114-
</Button>
115-
</Tooltip>
116-
)}
117-
{nonRejectedParticipantsCount > 0 && (
118-
<Tooltip label="Only admins can reject participants" disabled={user.isAdmin}>
119-
<Button disabled={!user.isAdmin} onClick={() => setModalRejectOpened(true)} color="red">
120-
Reject
121-
{!footer ? ` Participants (${nonRejectedParticipantsCount})` : ''}
122-
</Button>
123-
</Tooltip>
111+
{(rejectedParticipantsCount > 0 || nonRejectedParticipantsCount > 0) && (
112+
<Group gap="xs">
113+
{rejectedParticipantsCount > 0 && (
114+
<Tooltip label="Only admins can undo rejection" disabled={user.isAdmin}>
115+
<Button disabled={!user.isAdmin} onClick={() => setModalUndoRejectOpened(true)} color="blue">
116+
{footer ? 'Undo Reject' : `${undoRejectParticipantLabel} (${rejectedParticipantsCount})`}
117+
</Button>
118+
</Tooltip>
119+
)}
120+
{nonRejectedParticipantsCount > 0 && (
121+
<Tooltip label="Only admins can reject participants" disabled={user.isAdmin}>
122+
<Button disabled={!user.isAdmin} onClick={() => setModalRejectOpened(true)} color="red">
123+
{footer ? 'Reject' : `${rejectParticipantLabel} (${nonRejectedParticipantsCount})`}
124+
</Button>
125+
</Tooltip>
126+
)}
127+
</Group>
124128
)}
125129
<Modal
126130
opened={modalRejectOpened}
127131
onClose={() => setModalRejectOpened(false)}
128-
title={nonRejectedParticipantsCount > 0 ? `Reject Participants (${nonRejectedParticipantsCount})` : 'Reject Participant'}
132+
title={footer
133+
? rejectParticipantLabel
134+
: `${rejectParticipantLabel} (${nonRejectedParticipantsCount})`}
129135
>
130136
<Alert
131137
icon={<IconAlertTriangle size={16} />}
@@ -134,25 +140,28 @@ export function ParticipantRejectModal({
134140
mb="md"
135141
>
136142
{currentAndSelectedParticipants.length > 0 && rejectedParticipantsCount > 0 && (
137-
<>
138-
{rejectedParticipantsCount}
139-
{' '}
140-
of your
141-
{' '}
142-
{currentAndSelectedParticipants.length}
143-
{' '}
144-
selected participant
145-
{currentAndSelectedParticipants.length === 1 ? '' : 's'}
146-
{' '}
147-
{rejectedParticipantsCount === 1 ? 'has' : 'have'}
148-
{' '}
149-
already been rejected. Clicking reject participants will now reject the other
150-
{' '}
151-
{nonRejectedParticipantsCount}
152-
.
153-
<br />
154-
<br />
155-
</>
143+
<>
144+
{rejectedParticipantsCount}
145+
{' '}
146+
of your
147+
{' '}
148+
{currentAndSelectedParticipants.length}
149+
{' '}
150+
selected participant
151+
{currentAndSelectedParticipants.length === 1 ? '' : 's'}
152+
{' '}
153+
{rejectedParticipantsCount === 1 ? 'has' : 'have'}
154+
{' '}
155+
already been rejected. Clicking reject participant
156+
{nonRejectedParticipantsCount === 1 ? '' : 's'}
157+
{' '}
158+
will now reject
159+
{' '}
160+
{nonRejectedParticipantsCount === 1 ? 'this participant' : 'these participants'}
161+
.
162+
<br />
163+
<br />
164+
</>
156165
)}
157166
When participants are rejected, their sequences will be reassigned to other participants.
158167
</Alert>
@@ -165,19 +174,17 @@ export function ParticipantRejectModal({
165174
Cancel
166175
</Button>
167176
<Button color="red" onClick={handleRejectParticipant}>
168-
{currentAndSelectedParticipants.length > 0 ? 'Reject Participants' : 'Reject Participant'}
177+
{rejectParticipantLabel}
169178
</Button>
170179
</Flex>
171180
</Modal>
172181

173182
<Modal
174183
opened={modalUndoRejectOpened}
175184
onClose={() => setModalUndoRejectOpened(false)}
176-
title={(
177-
<Text>
178-
{`Undo Reject Participants (${currentAndSelectedParticipants.length})`}
179-
</Text>
180-
)}
185+
title={footer
186+
? undoRejectParticipantLabel
187+
: `${undoRejectParticipantLabel} (${rejectedParticipantsCount})`}
181188
>
182189
<Alert
183190
icon={<IconAlertTriangle size={16} />}
@@ -188,7 +195,12 @@ export function ParticipantRejectModal({
188195
When you undo participant rejections, you may end up with unbalanced latin squares. This is because the rejected sequence may have been reassigned.
189196
</Alert>
190197
{currentAndSelectedParticipants.length > 0 ? (
191-
<Text>Are you sure you want to undo the rejection of these participants?</Text>
198+
<Text>
199+
Are you sure you want to undo the rejection of
200+
{' '}
201+
{rejectedParticipantsCount === 1 ? 'this participant' : 'these participants'}
202+
?
203+
</Text>
192204
) : (
193205
<>
194206
<Text>
@@ -206,7 +218,7 @@ export function ParticipantRejectModal({
206218
Cancel
207219
</Button>
208220
<Button color="blue" onClick={handleUndoRejectParticipant}>
209-
{currentAndSelectedParticipants.length > 0 ? 'Undo Reject Participants' : 'Undo Reject Participant'}
221+
{undoRejectParticipantLabel}
210222
</Button>
211223
</Flex>
212224
</Modal>

src/analysis/individualStudy/thinkAloud/ThinkAloudFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export function ThinkAloudFooter({
125125
async function fetchAssetsUrl() {
126126
if (!storageEngine || !participantId || !currentTrial) {
127127
setAudioUrl(null);
128+
setScreenRecordingUrl(null);
128129
return;
129130
}
130131

@@ -599,7 +600,7 @@ export function ThinkAloudFooter({
599600
)}
600601
{screenRecordingUrl && (
601602
<Tooltip label="Download screen recording">
602-
<ActionIcon variant="filled" size={30} onClick={handleDownloadScreenRecording}>
603+
<ActionIcon variant="light" size={30} onClick={handleDownloadScreenRecording}>
603604
<IconDeviceDesktopDown />
604605
</ActionIcon>
605606
</Tooltip>

0 commit comments

Comments
 (0)