-
Notifications
You must be signed in to change notification settings - Fork 41
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
Yufei - make intangible time numbers having a mouseover explanation editable by the owner #1030
Yufei - make intangible time numbers having a mouseover explanation editable by the owner #1030
Conversation
This reverts commit 8a26c65.
…s dynamic; in leaderboard: add id as new identifier for testing
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.
Hi @yufeiStella !
I have tested your PR. Functionality works as intended.
I could change mouseover text as an owner
As an admin or manager I could only read the explanation:
However I want to suggest rendering of the button based on permissions(and probably sending the update request as well):
scrnli_7_22_2023_10-41-35.AM.webm
Hi @yufeiStella ! I tested the PR, the admin I can see the mouseoverText, and can't see the edit button. But when I tested logged in as Owner, I can't see the edit button, I'll try to see what happened, maybe something in my local environment |
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.
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.
Hi @yufeiStella. I have tested your PR and it is working as expected. Great job!
Log in as Owner, edit the mouseover text for total time, and refresh the page:
Screen.Recording.2023-07-22.at.6.42.18.PM.mov
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.
Hi, I've tested it and it works as expected!
1030.mp4
(I realized after the video didn't record cursor hovering and displaying the text)
I tested the following:
- non owners cannot see icon for editing
- both textareas show up for all users
- owner can edit and save text
- text is updated on refresh and when switching to another page and back
I have added some code suggestions that would make it cleaner and a bit more concise.
{isOwner && ( | ||
<MouseoverTextTotalTime onUpdate={handleMouseoverTextUpdate} /> | ||
)} | ||
{!isOwner && ( |
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.
Like @xaanders mentioned, it's not necessary to render the hidden button if the user isn't owner. You can probably remove 224-228.
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.
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.
Thank you, looks good.
if (text) { | ||
updateMouseoverText(mouseoverTextId, mouseoverText); | ||
setModalOpen(false); | ||
setText(newText); | ||
onUpdate(newText); | ||
} else { | ||
//console.log('createMouseoverText is ' + mouseoverText.newMouseoverText); | ||
createMouseoverText(mouseoverText); | ||
setModalOpen(false); | ||
setText(newText); | ||
onUpdate(newText); | ||
} |
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.
line 49-51 is the exact same as 55-57, so it's a bit redundant to use the same logic twice. Since those steps happen regardless of the scenario, you can instead put that outside of the if/else blocks.
if (text) { | |
updateMouseoverText(mouseoverTextId, mouseoverText); | |
setModalOpen(false); | |
setText(newText); | |
onUpdate(newText); | |
} else { | |
//console.log('createMouseoverText is ' + mouseoverText.newMouseoverText); | |
createMouseoverText(mouseoverText); | |
setModalOpen(false); | |
setText(newText); | |
onUpdate(newText); | |
} | |
if (text) { | |
updateMouseoverText(mouseoverTextId, mouseoverText); | |
} else { | |
//console.log('createMouseoverText is ' + mouseoverText.newMouseoverText); | |
createMouseoverText(mouseoverText); | |
} | |
setModalOpen(false); | |
setText(newText); | |
onUpdate(newText); |
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.
All set, thank you for suggestion!
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.
Hi @AaronPersaud I've just updated this PR. Could you please re-review my PR and approve it if you agree with the changes? Thank you!
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.
Hi @yufeiStella
Great work! Functionality is working as expected.
Screen.Recording.2023-07-22.at.11.15.50.PM.mov
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 tested your PR and it worked as expected.
I logged in as owner and I can change the mousehover text from "text" to "text by owner".
Then, I logged in as admin and I do not have the edit mousehover text button, but I can see the edited mousehover text.
I logged in as volunteer and it worked as expected as well.
Hi @yufeiStella it seems to work correctly. Edited using Owner account and verified by admin account as well. |
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.
Hi @yufeiStella, I have tested your PR and everything works as intended!
I am able to see and edit the mouseover text as as owner, and I can only see the edited text but not able to edit the test as any other role.
- Owner perspective - edit icon and ability to adit the text
- Admin role perspective => can see but cannot edit it
I tried several times but I was unsuccessful in getting this to work as intended. Also, there were errors in the backend console which could be related to this issue. You would notice from the video that even after editing the field with different texts the text that shows onMouseOver remains "some text:text" screencast-localhost_3000-2023.07.24-17_04_18.webm |
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.
Disconsidering the slow local host, this PR works as intended. Great job!
mouseover_test.mp4
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.
Hey, the PR worked as intended.
Screen.Recording.2023-07-25.at.16.45.20.mov
switch(action.type) { | ||
case types.GET_MOUSEOVER_TEXT: | ||
const data = action.payload; | ||
return data; | ||
|
||
case types.CREATE_MOUSEOVER_TEXT: | ||
return state; | ||
|
||
case types.UPDATE_MOUSEOVER_TEXT: | ||
return state; | ||
|
||
default: | ||
return state; |
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.
The switch
seems unnecessary here. Consider the following code, which makes the code more readable now unless you have the plan to add more operations to other types
.
if (action.type === types.GET_MOUSEOVER_TEXT) {
return action.payload;
}
return state;
Hi @yufeiStella Reviewed this PR with backend 454, and it works as intended. |
Hi @beblicarl, I'm not sure if the error is related to my functionality, but it does have a long response time or even have to reload it again when running the app. Besides, I noticed that you don't have any warnings after running 'npm start' and so you can receive the feedback in the backend console. However, every time I run 'npm start', I receive the warning (Use node --trace-deprecation ... to show where the warning was created" after running 'npm run build' and 'npm start' in the backend. The application can still run, but then I can't see any feedback in the backend console when running the application on localhost. Have you ever had the same warning (because I know someone else also have the same problem), and how did you resolve it? Or have you never encountered such a problem before? Updated: |
I have checked your PR. The owner can change the text, and it looks good. But when I switch accounts (not the owner's account), I cannot see the text. It seems like it's not global. output.mp4 |
8b25df5
Hi @xaanders, now I have rendered the button based on permissions(also the updating request because it is all about the edit button)! Could you please re-review it again and approve it if you agree with it? Thank you! Screen.Recording.2023-08-02.at.00.20.08.mov |
…ing_mouseover_explanation merge with development
The functionality works as intended and the code is great! screencast-bpconcjcammlapcogcnnelfmaeghhagj-2023.08.02-18_28_12.webm |
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.
Hi Yufei, I have tested it and it looks good!
Thank you for addressing my code suggestions, they look great.
Nice work!
ed6f115
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.
Hi @yufeiStella! I've tested your changes. It works perfect!
I have just one suggestion to the code:
getMouseoverText(); | ||
}, [totalTimeMouseoverText]); | ||
|
||
useEffect(() => { |
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 would suggest to make just one useEffect because they have the same dependency anyway
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.
Thank you! Fixed.
Description
Related PRS (if any):
This frontend PR is related to the #454 backend PR.
Main changes explained:
How to test:
npm install
andnpm run start:local
to run this PR locallyScreenshots or videos of changes:
Log in as an owner:
Screen.Recording.2023-08-03.at.21.10.09.mov
Log in as any other user except owner:
Screen.Recording.2023-08-03.at.21.15.51.mov
Note:
Sometimes, you may need to wait for the page to respond and display the mouseover text. I encountered a similar situation as shown in my screenshot recording. When you move your mouse to another place where there should be mouseover text, you may experience the same situation. Just be patient and wait.