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

#234 Disable upload button song and playlist if required fields not filled #271

Conversation

SaurabhGurde
Copy link
Contributor

@SaurabhGurde SaurabhGurde commented Oct 27, 2024

Description

This will disable song and playlist upload button if required field are not filled

Commit type

  • feat: indicates the addition of a new feature or functionality to the project.

Issue

#234

Solution

Added logic in disable button user will able to click button only when required field are filled.

Screenshots

Screenshot from 2024-10-27 17-20-36
Screenshot from 2024-10-27 17-20-44
image
Playlist getting added

@AntonioMrtz

@SaurabhGurde
Copy link
Contributor Author

SaurabhGurde commented Oct 27, 2024

Screenshot from 2024-10-27 17-39-49
image

@AntonioMrtz We dont need this validation bacause "formDataSong" and "formDataPlaylist" will always give true value as boolean value of any object is true in javascript.

@AntonioMrtz
Copy link
Owner

HI @SaurabhGurde thanks for following the guidelines. I would check the formData thing you're telling me. Can we have tests about the new functionality?

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde , formDataSong and formDataPlaylist checks are indeed not necessary, can you modify the code?

I notice this little bug in the interface, where close to song file picker there's a * symbol that doesn't do anything right?

image
image

I also noticed that fields are missaligned because of the * symbols. Fields rows should be aligned

image

@SaurabhGurde
Copy link
Contributor Author

Can i update tomorrow. its 11:30 pm here 😊

@AntonioMrtz
Copy link
Owner

Can i update tomorrow. its 11:30 pm here 😊

Yeah no problem @SaurabhGurde , take all the time you need

@SaurabhGurde
Copy link
Contributor Author

@AntonioMrtz pushed new code. fixed alignment using * but invisible property. its hard to calculate exact space taken by * and to add margin-left according to that.

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde , code looks good. I would add justify content: space between in the file picker/ genre row. That way you can get the row to take all the available space like this:

image

Also as I mentioned in the other PR, tests are failing. We should fix the failing tests and add new ones for the implemented functionality

@SaurabhGurde
Copy link
Contributor Author

image
@AntonioMrtz plz check now

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde code looks good. The final part is to add a unit tests in AddSongPlayListAccordion.test.tsx that checks the following for playlist and song upload:

  • Upload button is disabled if required fields are not filled
  • Upload button is enabled if required fields are filled

Let me know if you need anything about these unit tests implementation

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde , I saw the last changes you made.

That test case was made by another contributor to prove that the button was enabled/disabled when uploading a song. Each test should try to assert only one functionality.

In our case, it will be better to create a separate unit tests only to prove that the button is disabled if the required fields are not filled. Apply this to both add song and add playlist forms. As a result we should have 4 new tests:

  • Song, required fields not filled -> button disabled
  • Playlist, required fields not filled -> button disabled
  • Song, required fields filled -> button enabled
  • Playlist, required fields filled -> button enabled

@SaurabhGurde
Copy link
Contributor Author

Hi @SaurabhGurde , I saw the last changes you made.

That test case was made by another contributor to prove that the button was enabled/disabled when uploading a song. Each test should try to assert only one functionality.

In our case, it will be better to create a separate unit tests only to prove that the button is disabled if the required fields are not filled. Apply this to both add song and add playlist forms. As a result we should have 4 new tests:

  • Song, required fields not filled -> button disabled
  • Playlist, required fields not filled -> button disabled
  • Song, required fields filled -> button enabled
  • Playlist, required fields filled -> button enabled

i have modified one test case for upload song. button will be disabled by default and will only enable if required field are filled. and should i add test case for add playlist as well. or may be you are trying to say that i should remove test of disabled button during upload from song upload test and create another test for it "OR" should i completely remove test for disabled button during upload song?

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde , I saw the last changes you made.
That test case was made by another contributor to prove that the button was enabled/disabled when uploading a song. Each test should try to assert only one functionality.
In our case, it will be better to create a separate unit tests only to prove that the button is disabled if the required fields are not filled. Apply this to both add song and add playlist forms. As a result we should have 4 new tests:

  • Song, required fields not filled -> button disabled
  • Playlist, required fields not filled -> button disabled
  • Song, required fields filled -> button enabled
  • Playlist, required fields filled -> button enabled

i have modified one test case for upload song. button will be disabled by default and will only enable if required field are filled. and should i add test case for add playlist as well. or may be you are trying to say that i should remove test of disabled button during upload from song upload test and create another test for it "OR" should i completely remove test for disabled button during upload song?

Hi, you should add the 4 new tests listed. We don't wanna modify the already existing disable button tests. So:

  • Revert the modified tests from other contributor
  • Add the 4 new tests listed

@SaurabhGurde
Copy link
Contributor Author

@AntonioMrtz i have just pushed new test case for enabling upload button when required field are filled. plz check whether code format is correct or not that you want.

@AntonioMrtz
Copy link
Owner

@SaurabhGurde It looks good, just a few things:

  • Change test name to be something like: Upload song form button disabled and enabled depending on filled fields
  • Add the same test for playlists

:)

@SaurabhGurde
Copy link
Contributor Author

@AntonioMrtz plz check added test for playlist button as well.

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde everything looks god. I will do a last check launching the app and merge if everthing works as expected :)

@AntonioMrtz
Copy link
Owner

Hi @SaurabhGurde only some minor things:

When button is disabled boostrap adds some extra classes, the disabled button looks like this:

image

This style is more consitent with the app theme:

image

I only removed this styles(border and color):

image

@SaurabhGurde
Copy link
Contributor Author

@AntonioMrtz
image
added globally. whenever we will add button anywhere in project and if its disabled then it will have consistant styling across project. it will override styling of bootstrap

@AntonioMrtz
Copy link
Owner

@AntonioMrtz image added globally. whenever we will add button anywhere in project and if its disabled then it will have consistant styling across project. it will override styling of bootstrap

I dont think it's needed as global style yet. I'm planning on doing a refactor on frontend styles to make them more re-usable across the code. Can we just put the disabled button styles only for this component? Thanks, I will merge the PR when those changes are made

@SaurabhGurde
Copy link
Contributor Author

@AntonioMrtz
before required field filled
image

After required field filled
image

@AntonioMrtz AntonioMrtz merged commit a42ff94 into AntonioMrtz:master Nov 8, 2024
8 checks passed
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.

Disable upload button song and playlist if required fields not filled
2 participants