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

Move video url validation to PostEditorService and invalidate containing form if validation fails. #1508

Merged

Conversation

brymut
Copy link
Contributor

@brymut brymut commented Apr 20, 2020

This pull request makes the following changes:

  • move video url validation to PostEditService.validateVideoUrl
  • use PostEditService.validateVideoUrl to validate url in directive and invalidate form scope when validation fails.
  • [test] add PostEditService.validateVideoUrl tests

Testing checklist:

  • Go to settings and create a survey with an 'embed video' field.
  • Fill in a new survey response based on the one created in the previous step, using a random, non-youtube/non-vimeo-url to the video URL field.
  • Click save.
  • Error notification appears and post is NOT saved.
  • Edit the video URL field to include a valid youtube/vimeo URL and click save.
  • Post saves successfully.

Quick demo
demo of working version
apologies if too blurry, I can try to resubmit another screenshot on request.

  • I certify that I ran my checklist

Fixes ushahidi/platform#3904 .

Ping @ushahidi/platfrom

@ushbot
Copy link
Collaborator

ushbot commented Apr 20, 2020

Hey @brymut,
thank you for your Pull Request.

It looks like you haven't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement here.

Once you've signed reply with [clabot:check] to prove it.

Appreciation of efforts,

clabot

@brymut
Copy link
Contributor Author

brymut commented Apr 20, 2020

[clabot:check]

@ushbot
Copy link
Collaborator

ushbot commented Apr 20, 2020

@rjmackay It looks like @brymut just signed our Contributor License Agreement. 👍

Always at your service,

clabot

@brymut brymut changed the title move video url validation to PostEditorService and invalidate containing form if validation fails. WIP: move video url validation to PostEditorService and invalidate containing form if validation fails. Apr 20, 2020
@brymut

This comment has been minimized.

@brymut brymut force-pushed the bugfix/3904-move-video-url-validation branch 2 times, most recently from 4c2c99b to 27cc105 Compare April 22, 2020 12:59
@brymut brymut changed the title WIP: move video url validation to PostEditorService and invalidate containing form if validation fails. Move video url validation to PostEditorService and invalidate containing form if validation fails. Apr 22, 2020
@brymut brymut marked this pull request as ready for review April 22, 2020 13:29
@brymut
Copy link
Contributor Author

brymut commented Apr 22, 2020

Hi @Angamanga , I've managed to get a possible solution working and ready for feedback whenever possible. Also, there was some commented out thumbnail code in the post-video directive that I wasn't sure to remove, should I just leave it for now?

@Angamanga
Copy link
Collaborator

@brymut This looks good and works fine, super-well done 🎉 . You can absolutely delete the commented out code, thank you for noticing.

Another thing that would be nice to have, if you have time, is to display an error-label under the field, in case the url does not pass the validation. We have not had that for videos previously, but now we can actually add it. We do this for other fields, you can have a look here https://github.com/ushahidi/platform-client/blob/develop/app/main/posts/modify/post-value-edit.html#L22 for an example how it is done in other places. If you don't have time its totally fine and I'll add it as a new issue :).

Before I approve, @rowasc could you do a double-check as well? Since its one of the gnarliest parts of our code and I might have missed something. 🙏

@brymut brymut force-pushed the bugfix/3904-move-video-url-validation branch from 27cc105 to 2e2956d Compare April 23, 2020 07:16
@brymut
Copy link
Contributor Author

brymut commented Apr 23, 2020

Thanks for having a look @Angamanga

@brymut This looks good and works fine, super-well done 🎉 . You can absolutely delete the commented out code, thank you for noticing.

I've amended my last commit to delete the commented out code.

Another thing that would be nice to have, if you have time, is to display an error-label under the field, in case the url does not pass the validation. We have not had that for videos previously, but now we can actually add it. We do this for other fields, you can have a look here https://github.com/ushahidi/platform-client/blob/develop/app/main/posts/modify/post-value-edit.html#L22 for an example how it is done in other places. If you don't have time its totally fine and I'll add it as a new issue :).

At the moment, I don't quite have enough time for the remainder of the week, however, if you can track this a new issue could you please tag/ping me and I'll have a try again over the next week.

@brymut
Copy link
Contributor Author

brymut commented Apr 28, 2020

Hi again @Angamanga , just about to continue with adding the error-label you mentioned soon. Should I go on working off this PR or will it be tracked in a separate issue?

@Angamanga
Copy link
Collaborator

@brymut Sorry for late reply! Yes, please go ahead and add it to this pr since we haven't had time for a second review yet. Thank you so much for working on this 🎉

@tuxpiper
Copy link
Member

@Angamanga could you please take another quick look and consider for merging again?

@brymut
Copy link
Contributor Author

brymut commented Aug 17, 2020

Hi @tuxpiper, sorry I’ve taken so long on updating this PR as I agreed to. May I have one more week?

@tuxpiper
Copy link
Member

no problem @brymut , will check back next week. Thank you!

@brymut
Copy link
Contributor Author

brymut commented Aug 24, 2020

Got some progress done with this over the weekend will push by end of day

@brymut
Copy link
Contributor Author

brymut commented Aug 24, 2020

Okay, so I got a little stuck today and changes started to get messy, so I restarted a new solution that I think should be alright without requiring big edits to the directives involved.

ezgif com-video-to-gif (3)

…ing form if validation fails.

Changes:
- move video url validation to PostEditService.validateVideoUrl
- use PostEditService.validateVideoUrl to validate url in directive and setValidity of containing form when validation conditions fail.
- [test] mock validateVideoUrl & bindAllFunctionsToSelf functions (and fix typo)
- [test] add PostEditService.validateVideoUrl tests
@brymut brymut force-pushed the bugfix/3904-move-video-url-validation branch from 2e2956d to 70a89cb Compare August 24, 2020 16:52
@tuxpiper
Copy link
Member

hi @brymut! is this ready for review?

@brymut
Copy link
Contributor Author

brymut commented Aug 31, 2020

hi @tuxpiper , sorry I should have been more explicit in my previous comment. Yes, please review.

@tuxpiper
Copy link
Member

np @brymut 👌 thanks!

@Angamanga could you please take a look?

@rowasc
Copy link
Contributor

rowasc commented Sep 8, 2020

@Angamanga just bumping this in case it got lost 😅 Thanks!

@rowasc
Copy link
Contributor

rowasc commented Sep 15, 2020

@Angamanga hey just bumping this one (I know you're busy, just making sure it doesn't get lost ) . Thanks !

Copy link
Collaborator

@Angamanga Angamanga left a comment

Choose a reason for hiding this comment

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

This works fine now! Thank you @brymut for your contribution! 🎉

}
} else {
urlError(url);
$scope.$parent.form.$setValidity('videoUrlValidation', false, PostVideoController)
Notify.error('notify.video.incorrect_url', { url: url });
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be good to also use the validity to show an error-message to the user. We do this for other fields, you can have a look here https://github.com/ushahidi/platform-client/blob/develop/app/main/posts/modify/post-value-edit.html#L22 for an example how it is done for other fields.

@Angamanga
Copy link
Collaborator

@rowasc Reviewed and approved 👍

@rowasc
Copy link
Contributor

rowasc commented Sep 15, 2020

@Obadha2 this can be merged and tested in steve as soon as you're ready

@AmTryingMyBest AmTryingMyBest merged commit f3693bc into ushahidi:develop Sep 16, 2020
@AmTryingMyBest
Copy link
Contributor

QA'd, passes. 👍

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