Skip to content

Commit cd7b9f1

Browse files
committed
Undo date approved changes for private kudos and fixed the method that retrieves kudos for receiver. Updated UI to not show pending for private kudos.
1 parent c31f64a commit cd7b9f1

File tree

3 files changed

+57
-71
lines changed

3 files changed

+57
-71
lines changed

server/src/main/java/com/objectcomputing/checkins/services/kudos/KudosServicesImpl.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ public Kudos save(KudosCreateDTO kudosDTO) {
121121
kudosRecipientServices.save(kudosRecipient);
122122
}
123123

124-
if (!savedKudos.getPubliclyVisible()) {
125-
// Private kudos do not need to be approved by another party.
126-
savedKudos.setDateApproved(LocalDate.now());
127-
savedKudos = kudosRepository.update(savedKudos);
128-
}
129-
130124
sendNotification(savedKudos, NotificationType.creation);
131125
return savedKudos;
132126
}
@@ -176,16 +170,14 @@ public Kudos update(KudosUpdateDTO kudos) {
176170
boolean existingPublic = existingKudos.getPubliclyVisible();
177171
boolean proposedPublic = kudos.getPubliclyVisible();
178172
if (existingPublic && !proposedPublic) {
179-
// TODO: Somehow find and remove the Slack Kudos that the Check-Ins
173+
// TODO: Search for and remove the Slack Kudos that the Check-Ins
180174
// Integration posted.
181-
existingKudos.setDateApproved(LocalDate.now());
182-
} else if (!existingPublic && proposedPublic) {
183-
// Clear the date approved when going from private to public.
184175
existingKudos.setDateApproved(null);
185-
}
186-
if (proposedPublic &&
187-
!originalMessage.equals(existingKudos.getMessage())) {
188-
// If public and the text changed, require approval again.
176+
} else if ((!existingPublic && proposedPublic) ||
177+
(proposedPublic &&
178+
!originalMessage.equals(existingKudos.getMessage()))) {
179+
// Clear the date approved when going from private to public or
180+
// if public and the text changed, require approval again.
189181
existingKudos.setDateApproved(null);
190182
}
191183

@@ -336,7 +328,8 @@ private List<KudosResponseDTO> findAllToMember(UUID memberId) {
336328
Kudos relatedKudos = kudosRepository.findById(kudosId).orElseThrow(() ->
337329
new NotFoundException(KUDOS_DOES_NOT_EXIST_MSG.formatted(kudosId)));
338330

339-
if (relatedKudos.getDateApproved() != null) {
331+
if (!relatedKudos.getPubliclyVisible() ||
332+
relatedKudos.getDateApproved() != null) {
340333
kudosList.add(constructKudosResponseDTO(relatedKudos));
341334
}
342335
});

server/src/test/java/com/objectcomputing/checkins/services/kudos/KudosControllerTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ Kudos testCreateKudos(boolean supplyTeam, boolean publiclyVisible) {
138138
assertEquals(senderId, kudos.getSenderId());
139139
assertEquals(supplyTeam ? teamId : null, kudos.getTeamId());
140140
assertEquals(LocalDate.now(), kudos.getDateCreated());
141-
if (publiclyVisible) {
142-
assertNull(kudos.getDateApproved());
143-
}
141+
assertNull(kudos.getDateApproved());
144142

145143
List<KudosRecipient> kudosRecipients = findKudosRecipientByKudosId(kudos.getId());
146144
assertEquals(1, kudosRecipients.size());
@@ -611,14 +609,7 @@ void testUpdateKudos(boolean supplyTeam, boolean publiclyVisible) {
611609
final Kudos updated = response.body();
612610
assertEquals(message, updated.getMessage());
613611
assertEquals(visible, updated.getPubliclyVisible());
614-
615-
if (visible) {
616-
// Public kudos should not be approved.
617-
assertNull(updated.getDateApproved());
618-
} else {
619-
// Private kudos should be approved.
620-
assertNotNull(updated.getDateApproved());
621-
}
612+
assertNull(updated.getDateApproved());
622613

623614
final List<KudosRecipient> kudosRecipients =
624615
findKudosRecipientByKudosId(updated.getId());

web-ui/src/components/kudos_card/KudosCard.jsx

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -194,69 +194,71 @@ const KudosCard = ({ kudos, includeActions, includeEdit, onKudosAction }) => {
194194
const actions = [];
195195
if (includeActions) {
196196
actions.push(
197-
<Tooltip key="approve" arrow title="Approve">
198-
<Button
199-
variant="outlined"
200-
color="success"
201-
size="small"
202-
onClick={approveKudosCallback}
203-
>
204-
<CheckIcon />
205-
</Button>
206-
</Tooltip>
197+
<Tooltip key="approve" arrow title="Approve">
198+
<Button
199+
variant="outlined"
200+
color="success"
201+
size="small"
202+
onClick={approveKudosCallback}
203+
>
204+
<CheckIcon />
205+
</Button>
206+
</Tooltip>
207207
);
208208
} else if (dateApproved) {
209209
info.push(
210-
<Typography key="received" color="green" variant="body2">
211-
Received{" "}
212-
{dateApproved ? dateUtils.format(dateApproved, "MM/dd/yyyy") : ""}
213-
</Typography>
210+
<Typography key="received" color="green" variant="body2">
211+
Received{" "}
212+
{dateApproved ? dateUtils.format(dateApproved, "MM/dd/yyyy") : ""}
213+
</Typography>
214214
);
215215
} else {
216216
const dateCreated = new Date(kudos.dateCreated.join("/"));
217-
info.push(
217+
if (kudos.publiclyVisible) {
218+
info.push(
218219
<Typography key="pending" color="orange" variant="body2">
219220
Pending
220221
</Typography>
221-
);
222+
);
223+
}
222224
info.push(
223-
<Typography key="created" variant="body2" color="gray" fontSize="10px">
224-
Created {dateUtils.format(dateCreated, "MM/dd/yyyy")}
225-
</Typography>
225+
<Typography key="created" variant="body2" color="gray" fontSize="10px">
226+
Created {dateUtils.format(dateCreated, "MM/dd/yyyy")}
227+
</Typography>
226228
);
227229
}
228230
if (includeEdit) {
229231
actions.push(
230-
<Tooltip key="edit" arrow title="Edit">
231-
<Button
232-
variant="outlined"
233-
size="small"
234-
onClick={(event) => {
235-
event.stopPropagation();
236-
reloadKudosValues();
237-
setEditDialogOpen(true);
238-
}}
239-
>
240-
<EditIcon />
241-
</Button>
242-
</Tooltip>
232+
<Tooltip key="edit" arrow title="Edit">
233+
<Button
234+
variant="outlined"
235+
size="small"
236+
onClick={(event) => {
237+
event.stopPropagation();
238+
reloadKudosValues();
239+
setEditDialogOpen(true);
240+
}}
241+
>
242+
<EditIcon />
243+
</Button>
244+
</Tooltip>
243245
);
244246
}
245247
if (includeActions || includeEdit) {
246248
actions.push(
247-
<Tooltip key="delete" arrow title="Delete">
248-
<Button
249-
variant="outlined"
250-
color="error"
251-
size="small"
252-
onClick={(event) => {
253-
event.stopPropagation();
254-
setDeleteDialogOpen(true);
255-
}}
256-
>
257-
<CloseIcon />
258-
</Button>
259-
</Tooltip>
249+
<Tooltip key="delete" arrow title="Delete">
250+
<Button
251+
variant="outlined"
252+
color="error"
253+
size="small"
254+
onClick={(event) => {
255+
event.stopPropagation();
256+
setDeleteDialogOpen(true);
257+
}}
258+
>
259+
<CloseIcon />
260+
</Button>
261+
</Tooltip>
260262
);
261263
}
262264
return <>

0 commit comments

Comments
 (0)