Skip to content
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

Conversation

yufeiStella
Copy link
Contributor

@yufeiStella yufeiStella commented Jul 22, 2023

Description

Screen Shot 2023-07-21 at 16 31 39

Related PRS (if any):

This frontend PR is related to the #454 backend PR.

Main changes explained:

  • Create mouseover text of total time component and add it into leaderboard component
  • Create mouseover text action, reducer, etc.

How to test:

  1. check into current branch
  2. do npm install and npm run start:local to run this PR locally
  3. log in as an owner user and verify that the mouseover text appears when you move your mouse over both 'Total Time' and the numbers on the Leaderboard. Some numbers are blue (indicating intangible hours logged), and some numbers are black. Mouseover text will appear on both types of numbers.
  4. Only the owner can see the edit button next to 'Total Time'. Click on it and enter the new text to update the mouseover text. Please note that it may take some time to respond, as shown in my screen recording.
  5. Wait a few seconds for a green pop-up box to appear, showing the message "Mouseover Text updated!" Then you will see the newly updated mouseover text when you move your mouse over both 'Total Time' and the numbers. If you don't immediately see the changes, just wait a few more seconds, as it may take some time for the updates to respond.
  6. Hard refresh the page to see the change is globally. The same thing is if you don't immediately see the changes, just wait a few more seconds, as it may take some time for the updates to respond.
  7. login as any other role to verify the mouseoverText updates globally and they do not see the edit button.

Screenshots or videos of changes:

Log in as an owner:
Screen Shot 2023-07-21 at 19 43 12

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.

Copy link
Contributor

@xaanders xaanders left a 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

1
2

As an admin or manager I could only read the explanation:
3

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

change

@igorrochadasilva
Copy link

Hi @yufeiStella !
I hope you are well =D

I tested the PR, the admin I can see the mouseoverText, and can't see the edit button.

1030_01_admin-mouseover

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
1030_02_owner-mouseover

@AaronPersaud AaronPersaud self-requested a review July 22, 2023 21:54
Copy link
Contributor

@n0vay n0vay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job!
Checked the file as an owner to edit the hover over text, was able to see it with admin and other roles account too.
One small suggestion, you should include the steps to change backend in the testing instructions, I was a bit confused when it was not working.
image

Copy link
Contributor

@AuroraLovesWhales AuroraLovesWhales left a 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

Log in as any users other than Owner:
image

Copy link
Contributor

@AaronPersaud AaronPersaud left a 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 && (
Copy link
Contributor

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.

Copy link
Contributor Author

@yufeiStella yufeiStella Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Updated my code. The thing is that I still need to fetch updated mouseover text, but now I have changed to the following code:
Screen Shot 2023-08-02 at 00 05 00

MouseoverTextTotalTimeUpdater is just to fetch updated data, not a button with update function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks good.

Comment on lines 47 to 58
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);
}
Copy link
Contributor

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.

Suggested change
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);

Copy link
Contributor Author

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!

Copy link
Contributor Author

@yufeiStella yufeiStella Aug 2, 2023

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!

shiva2096
shiva2096 previously approved these changes Jul 23, 2023
Copy link
Contributor

@shiva2096 shiva2096 left a 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

@beblicarl beblicarl self-requested a review July 24, 2023 15:26
winghojackyli
winghojackyli previously approved these changes Jul 24, 2023
Copy link
Contributor

@winghojackyli winghojackyli left a 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".

Screenshot (1)

Screenshot (2)

Screenshot (3)

Then, I logged in as admin and I do not have the edit mousehover text button, but I can see the edited mousehover text.

Screenshot (4)

I logged in as volunteer and it worked as expected as well.

Screenshot (5)

@AnishPandita
Copy link

Hi @yufeiStella it seems to work correctly. Edited using Owner account and verified by admin account as well.
Screenshot 2023-07-24 at 5 25 36 PM
Screenshot 2023-07-24 at 5 31 50 PM
Screenshot 2023-07-24 at 5 33 07 PM

DavidC0126
DavidC0126 previously approved these changes Jul 25, 2023
Copy link
Contributor

@DavidC0126 DavidC0126 left a 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
PR1030_owner PR1030_editedWords
  • Admin role perspective => can see but cannot edit it
PR1030_adminRole

@beblicarl
Copy link
Contributor

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

issue #1030-error

eduardocodes
eduardocodes previously approved these changes Jul 25, 2023
Copy link
Contributor

@eduardocodes eduardocodes left a 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

sxiong5
sxiong5 previously approved these changes Jul 25, 2023
Copy link
Contributor

@sxiong5 sxiong5 left a 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

Comment on lines +6 to +18
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;
Copy link
Contributor

@sxiong5 sxiong5 Jul 25, 2023

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;

@Shreyj14
Copy link

Hi @yufeiStella

Reviewed this PR with backend 454, and it works as intended.
Screenshot 2023-07-26 at 6 10 53 PM

Screenshot 2023-07-26 at 6 11 55 PM Screenshot 2023-07-26 at 6 12 04 PM Screenshot 2023-07-26 at 6 13 00 PM

Shreyj14
Shreyj14 previously approved these changes Jul 26, 2023
@yufeiStella
Copy link
Contributor Author

yufeiStella commented Jul 27, 2023

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
issue #1030-error

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?

Screen Shot 2023-07-26 at 22 02 22

Updated:
Hi@beblicarl I believe you are also aware of the urgent problem in Slack, and the errors are not related to my PR. The thing is that my PR should be reviewed in the dashboard. I have also updated my PR. Could you please re-review my PR again and approve it if you agree with the changes? I noticed that the application is working much more smoothly today!

@iTvX
Copy link
Contributor

iTvX commented Jul 27, 2023

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

@yufeiStella
Copy link
Contributor Author

Hi @yufeiStella ! I have tested your PR. Functionality works as intended. I could change mouseover text as an owner

1 2

As an admin or manager I could only read the explanation: 3

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
change

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
@beblicarl
Copy link
Contributor

The functionality works as intended and the code is great!

screencast-bpconcjcammlapcogcnnelfmaeghhagj-2023.08.02-18_28_12.webm

beblicarl
beblicarl previously approved these changes Aug 2, 2023
AaronPersaud
AaronPersaud previously approved these changes Aug 3, 2023
Copy link
Contributor

@AaronPersaud AaronPersaud left a 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!

@yufeiStella yufeiStella dismissed stale reviews from AaronPersaud and beblicarl via ed6f115 August 3, 2023 19:29
Copy link
Contributor

@xaanders xaanders left a 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(() => {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.