Skip to content

Commit fa6db81

Browse files
authored
Merge branch 'develop' into feature-2751/post-approved-kudos-to-slack
2 parents 35143ef + 98b2cb7 commit fa6db81

File tree

15 files changed

+466
-110
lines changed

15 files changed

+466
-110
lines changed

server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class PulseResponse {
5252

5353
@Column(name="teammemberid")
5454
@TypeDef(type=DataType.STRING)
55-
@NotNull
55+
@Nullable
5656
@Schema(description = "id of the teamMember this entry is associated with")
5757
private UUID teamMemberId;
5858

@@ -77,7 +77,7 @@ public class PulseResponse {
7777
protected PulseResponse() {
7878
}
7979

80-
public PulseResponse(UUID id, Integer internalScore, Integer externalScore, LocalDate submissionDate, UUID teamMemberId, String internalFeelings, String externalFeelings) {
80+
public PulseResponse(UUID id, Integer internalScore, Integer externalScore, LocalDate submissionDate, @Nullable UUID teamMemberId, String internalFeelings, String externalFeelings) {
8181
this.id = id;
8282
this.internalScore = internalScore;
8383
this.externalScore = externalScore;
@@ -88,7 +88,7 @@ public PulseResponse(UUID id, Integer internalScore, Integer externalScore, Loca
8888
}
8989

9090
public PulseResponse(Integer internalScore, Integer externalScore, LocalDate submissionDate, UUID teamMemberId, String internalFeelings, String externalFeelings) {
91-
this(null,internalScore, externalScore, submissionDate, teamMemberId, internalFeelings, externalFeelings);
91+
this(null, internalScore, externalScore, submissionDate, teamMemberId, internalFeelings, externalFeelings);
9292
}
9393

9494
public UUID getId() {

server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseCreateDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class PulseResponseCreateDTO {
2727
@Schema(description = "date for submissionDate")
2828
private LocalDate submissionDate;
2929

30-
@NotNull
30+
@Nullable
3131
@Schema(description = "id of the associated member")
3232
private UUID teamMemberId;
3333

server/src/main/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseServicesImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ public PulseResponse save(PulseResponse pulseResponse) {
5555
LocalDate pulseSubDate = pulseResponse.getSubmissionDate();
5656
if (pulseResponse.getId() != null) {
5757
throw new BadArgException(String.format("Found unexpected id for pulseresponse %s", pulseResponse.getId()));
58-
} else if (memberRepo.findById(memberId).isEmpty()) {
58+
} else if (memberId != null &&
59+
memberRepo.findById(memberId).isEmpty()) {
5960
throw new BadArgException(String.format("Member %s doesn't exists", memberId));
6061
} else if (pulseSubDate.isBefore(LocalDate.EPOCH) || pulseSubDate.isAfter(LocalDate.MAX)) {
6162
throw new BadArgException(String.format("Invalid date for pulseresponse submission date %s", memberId));
62-
} else if (!currentUserId.equals(memberId) && !isSubordinateTo(memberId, currentUserId)) {
63+
} else if (memberId != null &&
64+
!currentUserId.equals(memberId) &&
65+
!isSubordinateTo(memberId, currentUserId)) {
6366
throw new BadArgException(String.format("User %s does not have permission to create pulse response for user %s", currentUserId, memberId));
6467
}
6568
pulseResponseRet = pulseResponseRepo.save(pulseResponse);
@@ -94,7 +97,7 @@ public PulseResponse update(PulseResponse pulseResponse) {
9497
} else if (memberRepo.findById(memberId).isEmpty()) {
9598
throw new BadArgException(String.format("Member %s doesn't exist", memberId));
9699
} else if (memberId == null) {
97-
throw new BadArgException(String.format("Invalid pulseresponse %s", pulseResponse));
100+
throw new BadArgException("Cannot update anonymous pulse response");
98101
} else if (pulseSubDate.isBefore(LocalDate.EPOCH) || pulseSubDate.isAfter(LocalDate.MAX)) {
99102
throw new BadArgException(String.format("Invalid date for pulseresponse submission date %s", memberId));
100103
} else if (!currentUserId.equals(memberId) && !isSubordinateTo(memberId, currentUserId)) {
@@ -191,4 +194,4 @@ public void sendPulseLowScoreEmail(PulseResponse pulseResponse) {
191194
emailSender.sendEmail(null, null, subject, bodyBuilder.toString(), recipients.toArray(new String[0]));
192195
}
193196
}
194-
}
197+
}

server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseControllerTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ void testCreateAnInvalidPulseResponse() {
7676
JsonNode body = responseException.getResponse().getBody(JsonNode.class).orElse(null);
7777
JsonNode errors = Objects.requireNonNull(body).get("_embedded").get("errors");
7878
JsonNode href = Objects.requireNonNull(body).get("_links").get("self").get("href");
79-
List<String> errorList = Stream.of(errors.get(0).get("message").asText(), errors.get(1).get("message").asText(), errors.get(2).get("message").asText()).sorted().collect(Collectors.toList());
80-
assertEquals(3, errorList.size());
79+
List<String> errorList = Stream.of(
80+
errors.get(0).get("message").asText(),
81+
errors.get(1).get("message").asText()
82+
).sorted().collect(Collectors.toList());
83+
84+
assertEquals(2, errorList.size());
8185
assertEquals(request.getPath(), href.asText());
8286
assertEquals(HttpStatus.BAD_REQUEST, responseException.getStatus());
8387
}
@@ -523,4 +527,4 @@ private MemberProfile profile(String key) {
523527
private UUID id(String key) {
524528
return profile(key).getId();
525529
}
526-
}
530+
}

server/src/test/java/com/objectcomputing/checkins/services/pulseresponse/PulseResponseCreateDTOTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void testConstraintViolation() {
3535
PulseResponseCreateDTO dto = new PulseResponseCreateDTO();
3636

3737
Set<ConstraintViolation<PulseResponseCreateDTO>> violations = validator.validate(dto);
38-
assertEquals(3, violations.size());
38+
assertEquals(2, violations.size());
3939
for (ConstraintViolation<PulseResponseCreateDTO> violation : violations) {
4040
assertEquals("must not be null", violation.getMessage());
4141
}

web-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"fuse.js": "^6.4.6",
2929
"html-react-parser": "^5.1.12",
3030
"isomorphic-fetch": "^3.0.0",
31+
"js-cookie": "^3.0.5",
3132
"js-file-download": "^0.4.12",
3233
"lodash": "^4.17.21",
3334
"markdown-builder": "^0.9.0",

web-ui/src/components/member-directory/MemberModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const MemberModal = ({ member, open, onSave, onClose }) => {
144144
});
145145
} else if (required && inputsFeasible) {
146146
onSave(editedMember).then(() => {
147-
if (isNewMember.current) {
147+
if (isNewMember) {
148148
setMember({ emptyMember });
149149
setIsNewMember(true);
150150
}

web-ui/src/helpers/colors.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// pSBC - Shade Blend Convert - Version 4.1 - 01/7/2021
2+
// https://github.com/PimpTrizkit/PJs/blob/master/pSBC.js
3+
4+
export const pSBC=(p,c0,c1,l)=>{
5+
let r,g,b,P,f,t,h,m=Math.round,a=typeof(c1)=="string";
6+
if(typeof(p)!="number"||p<-1||p>1||typeof(c0)!="string"||(c0[0]!='r'&&c0[0]!='#')||(c1&&!a))return null;
7+
h=c0.length>9,h=a?c1.length>9?true:c1=="c"?!h:false:h,f=pSBC.pSBCr(c0),P=p<0,t=c1&&c1!="c"?pSBC.pSBCr(c1):P?{r:0,g:0,b:0,a:-1}:{r:255,g:255,b:255,a:-1},p=P?p*-1:p,P=1-p;
8+
if(!f||!t)return null;
9+
if(l)r=m(P*f.r+p*t.r),g=m(P*f.g+p*t.g),b=m(P*f.b+p*t.b);
10+
else r=m((P*f.r**2+p*t.r**2)**0.5),g=m((P*f.g**2+p*t.g**2)**0.5),b=m((P*f.b**2+p*t.b**2)**0.5);
11+
a=f.a,t=t.a,f=a>=0||t>=0,a=f?a<0?t:t<0?a:a*P+t*p:0;
12+
if(h)return"rgb"+(f?"a(":"(")+r+","+g+","+b+(f?","+m(a*1000)/1000:"")+")";
13+
else return"#"+(4294967296+r*16777216+g*65536+b*256+(f?m(a*255):0)).toString(16).slice(1,f?undefined:-2)
14+
}
15+
16+
pSBC.pSBCr=(d)=>{
17+
const i=parseInt;
18+
let n=d.length,x={};
19+
if(n>9){
20+
const [r, g, b, a] = (d = d.split(','));
21+
n = d.length;
22+
if(n<3||n>4)return null;
23+
x.r=i(r[3]=="a"?r.slice(5):r.slice(4)),x.g=i(g),x.b=i(b),x.a=a?parseFloat(a):-1
24+
}else{
25+
if(n==8||n==6||n<4)return null;
26+
if(n<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(n>4?d[4]+d[4]:"");
27+
d=i(d.slice(1),16);
28+
if(n==9||n==5)x.r=d>>24&255,x.g=d>>16&255,x.b=d>>8&255,x.a=Math.round((d&255)/0.255)/1000;
29+
else x.r=d>>16,x.g=d>>8&255,x.b=d&255,x.a=-1
30+
}return x
31+
};

web-ui/src/helpers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * from './datetime';
44
export * from './query-parameters';
55
export * from './sanitizehtml';
66
export * from './strings';
7+
export * from './colors';

web-ui/src/pages/PulsePage.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@
1212
text-align: center;
1313
}
1414
}
15+
16+
.submit-row {
17+
align-items: center;
18+
display: flex;
19+
margin-top: 2rem; /* This is the default top margin for Buttons */
20+
}

0 commit comments

Comments
 (0)