-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cookie_Hover_Box #1127
Cookie_Hover_Box #1127
Conversation
The PopUp.js file may be better suited for the components folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some areas for touch ups; this looks pretty good so far!
src/pages/Privacy/PopUp.js
Outdated
const setCookie = function (cookieEmail, cookieValue, expDays) { | ||
date.setTime(date.getTime() + expDays); | ||
|
||
const expires = 'expires=' + date.toUTCString(); | ||
|
||
document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/'; | ||
|
||
return document.cookie; | ||
}; | ||
|
||
const deleteCookie = function (cookieEmail) { | ||
date.setTime(date.getTime()); | ||
const expires = 'expires=' + date.toUTCString(); | ||
document.cookie = cookieEmail + expires + ';path=/'; | ||
}; | ||
const acceptCookieConsent = () => { | ||
deleteCookie('civictecindex_cookie_consent'); | ||
setCookie('civictecindex_cookie_consent', 1, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.
One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.
This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.
Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)
Hi Dennis
I was not told anything about functionality, I was just told to code as per reference with 311 data. I think the functionality will be told after
src/pages/Privacy/PopUp.js
Outdated
deleteCookie('civictecindex_cookie_consent'); | ||
setCookie('civictecindex_cookie_consent', 1, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing letter 'h' to 'civictechindex'
deleteCookie('civictecindex_cookie_consent'); | |
setCookie('civictecindex_cookie_consent', 1, 30); | |
deleteCookie('civictechindex_cookie_consent'); | |
setCookie('civictechindex_cookie_consent', 1, 30); |
src/pages/Privacy/PopUp.js
Outdated
date.setTime(date.getTime() + expDays); | ||
|
||
const expires = 'expires=' + date.toUTCString(); | ||
|
||
document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/'; | ||
|
||
return document.cookie; | ||
}; | ||
|
||
const deleteCookie = function (cookieEmail) { | ||
date.setTime(date.getTime()); | ||
const expires = 'expires=' + date.toUTCString(); | ||
document.cookie = cookieEmail + expires + ';path=/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend replacing string concatenation with template literals.
date.setTime(date.getTime() + expDays); | |
const expires = 'expires=' + date.toUTCString(); | |
document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/'; | |
return document.cookie; | |
}; | |
const deleteCookie = function (cookieEmail) { | |
date.setTime(date.getTime()); | |
const expires = 'expires=' + date.toUTCString(); | |
document.cookie = cookieEmail + expires + ';path=/'; | |
date.setTime(date.getTime() + expDays); | |
const expires = `expires=${date.toUTCString()}`; | |
document.cookie = `${cookieEmail}${cookieValue};${expires};path=/`; | |
return document.cookie; | |
}; | |
const deleteCookie = function (cookieEmail) { | |
date.setTime(date.getTime()); | |
const expires = `expires=${date.toUTCString()}`; | |
document.cookie = `${cookieEmail}${expires};path=/` |
So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up. One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time. This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site. Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :) |
Just a reminder to close the privacy popup during the footer.spec test. Also, if possible, please create tests in a privacy.spec.js test file so that we have coverage of this new functionality. If any help/guidance is needed, let me know. Thank you! |
src/pages/Privacy/PopUp.js
Outdated
const setCookie = function (cookieEmail, cookieValue, expDays) { | ||
date.setTime(date.getTime() + expDays); | ||
|
||
const expires = 'expires=' + date.toUTCString(); | ||
|
||
document.cookie = cookieEmail + cookieValue + ';' + expires + ';path=/'; | ||
|
||
return document.cookie; | ||
}; | ||
|
||
const deleteCookie = function (cookieEmail) { | ||
date.setTime(date.getTime()); | ||
const expires = 'expires=' + date.toUTCString(); | ||
document.cookie = cookieEmail + expires + ';path=/'; | ||
}; | ||
const acceptCookieConsent = () => { | ||
deleteCookie('civictecindex_cookie_consent'); | ||
setCookie('civictecindex_cookie_consent', 1, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I'm not sure what the intended behavior for the cookie should be: currently the way it looks like it's working is the date is registered upon the user visiting the site, not when the user clicks 'Accept' on the cookie pop-up.
One concern I wanted to bring up is in certain scenarios where the user takes a while to select 'Accept', or visits the page but leaves it open for a long period of time.
This could potentially paint an inaccurate picture of traffic. Then again, maybe we only want to know the time when they just visit the site.
Wanted to bring this up to attention after playing around with and testing the cookie in the browser. :)
Hi Dennis
I was not told anything about functionality, I was just told to code as per reference with 311 data. I think the functionality will be told after
I don;t understand what you are saying |
My bad; ignore my previous comment. I got confused if we had already talked about how the cookie works. |
src/pages/Privacy/PopUp.js
Outdated
date.setTime(date.getTime() + expDays); | ||
const expires = 'expires=' + date.toUTCString(); | ||
|
||
document.cookie = `${cookieEmail} + ${cookieValue} + ';' + ${expires} + ';path=/'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With template literals, the pluses don't need to be used. It will actually show up in the string that way.
document.cookie = `${cookieEmail} + ${cookieValue} + ';' + ${expires} + ';path=/'`; | |
document.cookie = `${cookieEmail}${cookieValue}';'${expires}';path=/'`; |
src/pages/Privacy/PopUp.js
Outdated
const deleteCookie = function (cookieEmail) { | ||
date.setTime(date.getTime()); | ||
const expires = 'expires=' + date.toUTCString(); | ||
document.cookie = `${cookieEmail} + ${expires} + ';path=/'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here with template literal
document.cookie = `${cookieEmail} + ${expires} + ';path=/'`; | |
document.cookie = `${cookieEmail}${expires}';path=/'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks Bhaggya!
Thanks for reviewing my code and letting me know |
@smsada @kevindphan there is still the visual side effect of the privacy popup shifting to the left a few pixels when hovering over the header menu items (possibly due the scroll bar disappearing/appearing). Can we still merge this PR? |
PMs have decided to hold off on merging this until after MVP |
2e372fc
to
bc57c3c
Compare
Code Climate has analyzed commit 4f54f78 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 81.0% (0.2% change). View more on Code Climate. |
Closes #1075