Skip to content

Commit

Permalink
Merge branch 'develop' into feature-2805/convert-skills-data-structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ocielliottc authored Jan 21, 2025
2 parents 8d47265 + 6975f56 commit 9efc6e0
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 42 deletions.
2 changes: 1 addition & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id "jacoco"
}

version "0.8.11"
version "0.8.12"
group "com.objectcomputing.checkins"

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public String toSlackBlock(Kudos kudos) {
content.add(
RichTextSectionElement.Text.builder()
.text("\n" + kudos.getMessage() + "\n")
.style(boldItalic())
.build()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ public Set<PulseResponse> findByFields(UUID teamMemberId, LocalDate dateFrom, Lo
// The current user can view the pulse response if they are the team member who submitted the pulse response
// or if they are the supervisor of the team member who submitted the pulse response
private boolean canViewDueToReportingHierarchy(PulseResponse pulse, UUID currentUserId) {
return pulse.getTeamMemberId().equals(currentUserId) ||
isSubordinateTo(pulse.getTeamMemberId(), currentUserId);
UUID id = pulse.getTeamMemberId();
return id != null &&
(id.equals(currentUserId) || isSubordinateTo(id, currentUserId));
}

private boolean isSubordinateTo(UUID reportMember, UUID currentUserId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ default PulseResponse createADefaultPulseResponse(MemberProfile memberprofile) {
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
memberprofile.getId(), "internalfeelings", "externalfeelings"));
}

default PulseResponse createADefaultAnonymousPulseResponse() {
return getPulseResponseRepository().save(new PulseResponse(0, 0, LocalDate.now(),
null, "internalfeelings", "externalfeelings"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,22 @@ void testGetFindByfindBySubmissionDateBetween() {
assertEquals(Set.of(pulseResponse), response.body());
}

@Test
void testAnonymousGetFindByfindBySubmissionDateBetween() {
MemberProfile memberProfile = createADefaultMemberProfile();

PulseResponse pulseResponse = createADefaultAnonymousPulseResponse();

LocalDate testDateFrom = LocalDate.of(2019, 1, 1);
LocalDate testDateTo = Util.MAX.toLocalDate();

final HttpRequest<?> request = HttpRequest.GET(String.format("/?dateFrom=%tF&dateTo=%tF", testDateFrom, testDateTo)).basicAuth(memberProfile.getWorkEmail(), ADMIN_ROLE);
final HttpResponse<Set<PulseResponse>> response = client.toBlocking().exchange(request, Argument.setOf(PulseResponse.class));

assertEquals(HttpStatus.OK, response.getStatus());
assertEquals(Set.of(pulseResponse), response.body());
}

@Test
void testGetFindById() {

Expand Down
2 changes: 1 addition & 1 deletion web-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-ui",
"version": "0.8.11",
"version": "0.8.12",
"private": true,
"type": "module",
"dependencies": {
Expand Down
91 changes: 60 additions & 31 deletions web-ui/src/components/private-note/PrivateNote.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import {
selectIsPDL,
selectIsAdmin,
selectCheckin,
selectProfile
selectProfile,
selectCanViewPrivateNotesPermission,
selectCanCreatePrivateNotesPermission,
selectCanUpdatePrivateNotesPermission,
} from '../../context/selectors';
import { UPDATE_TOAST } from '../../context/actions';
import { debounce } from 'lodash/function';
import { Editor } from '@tinymce/tinymce-react';
import LockIcon from '@mui/icons-material/Lock';
Expand Down Expand Up @@ -49,19 +53,36 @@ const PrivateNote = () => {

useEffect(() => {
async function getPrivateNotes() {
setIsLoading(true);
try {
let res = await getPrivateNoteByCheckinId(checkinId, csrf);
if (res.error) throw new Error(res.error);
const currentNote =
res.payload && res.payload.data && res.payload.data.length > 0
? res.payload.data[0]
: null;
if (currentNote) {
setNote(currentNote);
} else if (currentUserId === pdlId) {
if (!noteRef.current.some(id => id === checkinId)) {
noteRef.current.push(checkinId);
if (selectCanViewPrivateNotesPermission(state)) {
setIsLoading(true);
try {
let res = await getPrivateNoteByCheckinId(checkinId, csrf);
if (res.error) throw new Error(res.error);
const currentNote =
res.payload && res.payload.data && res.payload.data.length > 0
? res.payload.data[0]
: null;
if (currentNote) {
setNote(currentNote);
} else if (currentUserId === pdlId) {
if (!noteRef.current.some(id => id === checkinId) &&
selectCanCreatePrivateNotesPermission(state)) {
noteRef.current.push(checkinId);
res = await createPrivateNote(
{
checkinid: checkinId,
createdbyid: currentUserId,
description: ''
},
csrf
);
noteRef.current = noteRef.current.filter(id => id !== checkinId);
if (res.error) throw new Error(res.error);
if (res && res.payload && res.payload.data) {
setNote(res.payload.data);
}
}
} else if (selectCanCreatePrivateNotesPermission(state)) {
res = await createPrivateNote(
{
checkinid: checkinId,
Expand All @@ -70,37 +91,45 @@ const PrivateNote = () => {
},
csrf
);
noteRef.current = noteRef.current.filter(id => id !== checkinId);
if (res.error) throw new Error(res.error);
if (res && res.payload && res.payload.data) {
setNote(res.payload.data);
}
}
} else {
res = await createPrivateNote(
{
checkinid: checkinId,
createdbyid: currentUserId,
description: ''
},
csrf
);
if (res.error) throw new Error(res.error);
if (res && res.payload && res.payload.data) {
setNote(res.payload.data);
}
} catch (e) {
console.error("getPrivateNotes: " + e);
}
} catch (e) {
console.error("getPrivateNotes: " + e);
setIsLoading(false);
}
setIsLoading(false);
}
if (csrf) {
getPrivateNotes();
}
}, [csrf, checkinId, currentUserId, pdlId]);

const handleNoteChange = (content, delta, source, editor) => {
if (note == null) {
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
severity: 'error',
toast: selectCanCreatePrivateNotesPermission(state)
? 'No private note was created'
: 'No permission to create private notes'
}
});
return;
}
if (!selectCanUpdatePrivateNotesPermission(state)) {
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
severity: 'error',
toast: 'No permission to update private notes'
}
});
return;
}
if (Object.keys(note).length === 0 || !csrf || currentCheckin?.completed) {
return;
}
Expand Down
6 changes: 5 additions & 1 deletion web-ui/src/context/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export const reducer = (state, action) => {
state.userProfile.memberProfile.bioText = action.payload;
break;
case ADD_CHECKIN:
state.checkins = [...state.checkins, action.payload];
if (state?.checkins?.length > 0) {
state.checkins = [...state.checkins, action.payload];
} else {
state.checkins = [action.payload];
}
break;
case UPDATE_CHECKINS:
if (state?.checkins?.length > 0) {
Expand Down
12 changes: 12 additions & 0 deletions web-ui/src/context/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ export const selectCanViewCheckinsPermission = hasPermission(
'CAN_VIEW_CHECKINS'
);

export const selectCanViewPrivateNotesPermission = hasPermission(
'CAN_VIEW_PRIVATE_NOTE'
);

export const selectCanCreatePrivateNotesPermission = hasPermission(
'CAN_CREATE_PRIVATE_NOTE'
);

export const selectCanUpdatePrivateNotesPermission = hasPermission(
'CAN_UPDATE_PRIVATE_NOTE'
);

export const selectIsPDL = createSelector(
selectUserProfile,
userProfile =>
Expand Down
2 changes: 2 additions & 0 deletions web-ui/src/pages/CheckinsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
selectProfile,
selectCheckinsForMember,
selectCanViewCheckinsPermission,
selectCanViewPrivateNotesPermission,
} from '../context/selectors';
import { getCheckins, createNewCheckin } from '../context/thunks';
import { UPDATE_CHECKIN, UPDATE_TOAST } from '../context/actions';
Expand Down Expand Up @@ -91,6 +92,7 @@ const CheckinsPage = () => {
const isPdl = selectIsPDL(state);

const canViewPrivateNote =
selectCanViewPrivateNotesPermission(state) &&
(isAdmin || selectedProfile?.pdlId === currentUserId) &&
currentUserId !== memberId;

Expand Down
16 changes: 11 additions & 5 deletions web-ui/src/pages/ErrorBoundaryPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ const ErrorFallback = ({ error }) => {
//before upload to server
let sanitizeBody = sanitizeQuillElements(body);
let res = await newGitHubIssue(sanitizeBody, title, csrf);
if (res && res.payload) {
if (res?.error) {
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
severity: 'error',
toast: res.error.message,
}
});
} else if (res?.payload?.data) {
setLink(res.payload.data[0].html_url);
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
severity: !res.error ? 'success' : 'error',
toast: !res.error
? `New issue ${title} created! Gratzie &#128512`
: res.error.message
severity: 'success',
toast: `New issue ${title} created! Gratzie &#128512`,
}
});
}
Expand Down

0 comments on commit 9efc6e0

Please sign in to comment.