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

189 share hangout links #190

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

jmpainter
Copy link
Contributor

App.js - cookies passed to EventInfo
EventInfo.js - cookies passed to EventSummary
EventSummary.js - converted to class based component. Form added for hangout link entry if user is logged in. Basic validation of form has been implemented. Connected to redux to dispatch postEventLink
postEventLinkAction.js - new asyc action created to update event with hangout link - not completely implemented due to changes required on back end
types.js - POST_EVENT_LINK type added

Is this approach on track?

Tests have not been updated yet, I'm waiting for approval for this direction

fixes #189

@vercel
Copy link

vercel bot commented Apr 17, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://websiteone-fe-git-fork-jmpainter-189-share-hangout-links.agileventures1.now.sh

@mattwr18
Copy link
Contributor

great @jmpainter thanks for getting started on this so quickly and making some real progress!

Do we need to turn EventSummary into a class component?

I understand that you did it to calls setState, but I guess I was thinking we could actually have the form be itself a functional component.

Are you concerned about calling handleChange from the child or grandchild?
I think so far in the project we have tried to keep components as functional as far as possible.

Just some ideas, and open for discussion and what others think, but I wanted to get back to you.
I really like that you listed the changes you made in each file. Also, I like that you have thought about specific use cases like the user being logged in, trying to share a blank link 😸

I did find this article, which I haven't completely gone through, but I did see disables the button unless there is something added to the form input.

@jmpainter
Copy link
Contributor Author

  • EventInfo - state related to Hangout link form added
  • EventSummary - returned to functional component
  • SingleFormField - component added, could be used in other places where a form like this is desired

Yes, this is a much better setup

@mattwr18
Copy link
Contributor

mattwr18 commented Apr 22, 2019

hey @jmpainter, this is currently failing the build with this output

#!/bin/bash -eo pipefail
yarn test
yarn run v1.9.4
$ export NODE_ENV=testing && standard && jest
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  /root/WebsiteOne-FE/src/components/EventSummary.js:1:27: 'Component' is defined but never used.
  /root/WebsiteOne-FE/src/components/EventSummary.js:2:46: 'Form' is defined but never used.
  /root/WebsiteOne-FE/src/components/EventSummary.js:2:52: 'Button' is defined but never used.
  /root/WebsiteOne-FE/src/components/EventSummary.js:11:31: Block must not be padded by blank lines.
  /root/WebsiteOne-FE/src/components/SingleFieldForm.js:13:12: Extra semicolon.
  /root/WebsiteOne-FE/src/components/SingleFieldForm.js:36:31: Newline required at end of file but not found.
  /root/WebsiteOne-FE/src/containers/EventInfo.js:16:20: Missing space before function parentheses.
  /root/WebsiteOne-FE/src/containers/EventInfo.js:26:28: Missing space before function parentheses.
  /root/WebsiteOne-FE/src/containers/EventInfo.js:45:9: Missing space before function parentheses.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

I think you know this, but you can run yarn fix before pushing up... Also, it's good to get in the habit of running the tests locally with yarn test, which run standard first and fail if there are any linting issues.

import CustomRingLoader from './CustomRingLoader'
import Videos from './Videos'
import { postEventLink } from '../actions/postEventLinkAction'
import SingleFieldForm from './SingleFieldForm'
Copy link
Contributor

Choose a reason for hiding this comment

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

hey @jmpainter thanks for following my suggestion to make this into a child functional component!
Am I right to assume that you are calling it SingleFieldForm with the idea that it can be reused elsewhere in the code base?
I saw that you are passing down the label and placeholder, so you could use this same component for say sharing the YouTube links :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, my idea was that SingleFieldForm could be used in other places. In this situation I thought this approach needed review and I knew that it broke tests, but I wanted it to be looked at before committing the time to write tests. Would there be a better way to handle this kind of situation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was actually saying that as a positive! I like that you are thinking ahead!! great job!!
As you said, we need to have tests to get it to pass the checks, but really nice start. I'll pull it down and see if I can get the back end ready

@jmpainter
Copy link
Contributor Author

SingleFieldForm.test.js - added with tests for SingleFieldForm
EventInfoTest.js - added test for postEventLink
EventSummary.test.js - added test for SingleFieldForm render

EventSummary.js - returned to un-Redux connected component (no longer needed since EventInfo is dispatching the postEventLink action)

Not sure about Coveralls

@mattwr18
Copy link
Contributor

mattwr18 commented May 4, 2019

hey @jmpainter, I am gonna see if I can get this working with the backend, as we discussed.

So there were some merge conflicts that I did a rebase locally, but when you rebase you need to force push, so you might notice I was added as a co-collaborator on your other commits, hope that is ok.

@jmpainter
Copy link
Contributor Author

Yes, sure - no problem.

@mattwr18
Copy link
Contributor

@jmpainter, just to keep you in the loop with the progress I've made.
It's now working to post events to a our live slack instance!!

If you test it out, please only create events associated with the project Project for testing slack notifications, otherwise it will spam one or more of our live channels.

I removed your validation for an empty field in favor of using semantic-ui-react required prop, which does a similar thing.

Also, made some other changes, let me know if you have any doubts as to why, or if you think I can revert any changes I made.

At the moment, the only thing(potentially) keeping this from getting merged in is testing the postEventLinkAction, I need to think about it cause at the moment, I am not dispatching anything to the store, since we don't need to use it for anything. I should dispatch any error message coming from the backend, maybe just testing that will be enough for our coverage(?)

Screenshot at 2019-05-11 16:43:29
Screenshot at 2019-05-11 16:43:41

@jmpainter
Copy link
Contributor Author

Thanks for getting this working with the back end. Looks good! I'll pull it down and take a look at it tomorrow to take a look at it and will see about writing the test for postEventLinkAction.

@jmpainter
Copy link
Contributor Author

It looks like right now we are not looking for any response coming from the /hangouts/:id endpoint in the postEventLinkAction. Would it be good to look for a success response and display a message to the user?

@mattwr18
Copy link
Contributor

Perhaps, at the moment in production we don't do that, but I wouldn't be opposed to it.

I know it was successful cause Slack notifies me. We should definitely show an error message if there is one.

@jmpainter
Copy link
Contributor Author

I see - maybe the success message isn't necessary because this is more of an internal use thing. An error message could be useful. Right now SingleFieldForm's 'error' prop is not connected to anything. Maybe we should be using redux-form for SingleFieldForm since it is used elsewhere in the project. Or the error prop could be passed down from EventInfo.js - or maybe none if this is worth it right now?

@mattwr18
Copy link
Contributor

I think error handling would be nice, we could maybe just show a toaster with the error message, what do you think?

@jmpainter
Copy link
Contributor Author

If redux-form is intended to be used on all forms in the project, I'd go with that on singleFieldForm for consistency. Otherwise I'd go with passing the error prop to SingleFieldForm from EventInfo because this would be the simplest, is consistent with the redux-form approach, and would put the error message by the field. If other forms in the app are putting error messages by the responsible fields, I think that would be what the user would expect.

@mattwr18
Copy link
Contributor

I think it depends on the type of error, no?
If the error is to do with frontend validations, then I would agree.
However, if the error comes from the backend, then we certainly have several examples of using toasters throughout the code base.

Have a look at the Login container, for example

@jmpainter
Copy link
Contributor Author

I see it now - had missed it before in a search. Then I'd go with the toast because that is the established pattern for the user and the boilerplate is in place. Redux-form generally doesn't work that way - the errors come from the backend into the store and come into the form to be displayed by the fields. So far only ProjectForm is using redux-form. I suppose that it could produce toasts instead. Probably it would be best to create all forms the same way - not sure what the long range plan is.

@mattwr18
Copy link
Contributor

I would agree it would be nice to have the forms use the same.
What I have seen mostly the form errors used for is validations and they are displayed onChange, but then if the backend responds with a Unauthorized, or 500 Internal Server Error that they would show up in a toaster.

But I'm not sure how the Redux-Form errors work, like if the backend responds saying some field is required, it shows up in the field's error? For me, it would be better to have frontend validations that don't allow a user to submit the form if there are certain validations that the backend enforces, you know?

@jmpainter
Copy link
Contributor Author

Redux-form is set up to use custom front end validators as well and feeds the errors from the front end and back end back to the form where they are displayed with the appropriate field. You can also have an overall form error displayed from the back end like for a 500 error.

Copy link
Member

@joaopapereira joaopapereira left a comment

Choose a reason for hiding this comment

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

Cool, looks good, please review my comments and we shold be ready to merge

notify_hangout: true,
project_id: props.projectId,
event_id: props.id
// token: props.cookies.get(process.env.SESSION || 'WebsiteOne_session')
Copy link
Member

Choose a reason for hiding this comment

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

do we need this line?

Copy link
Contributor

Choose a reason for hiding this comment

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

well, actually this brings up a good point.
At the moment, I have not tested that this works with a user signed in through GitHub OAuth.

For any actions where a user needs to be authenticated and they are signed in through OAuth, we are passing the JWT token in the params, instead of the headers, but I'm sure there is a better way to access the headers that are sent to the backend to decode them, just haven't figured that out yet.... I think it's a bug related to the OAuth, that can be dealt with in a separate ticket. So the above line can be removed.

/>
<Route path='/events/:slug' component={EventInfo} />
{/* <Route path='/events/:slug' component={EventInfo} /> */}
Copy link
Member

Choose a reason for hiding this comment

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

do we need this line?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's an oversight, I believe.

@mattwr18
Copy link
Contributor

@joaopapereira, @jmpainter and I discussed this PR in the meeting after you dropped off, and we were thinking it might be best to hold off on merging it until we can write a test for the postEventLinkAction

Now that we are using Redux-Form, we were talking about all new forms be created with it, so we'd need to refactor the SingleFieldForm to use it.

We had a doubt about error handling, should we be using Redux-Form's error handling, or should we be using toasters as we are in other places. I imagine that we could have refactoring tickets, which wouldn't have high priority, to use Redux-Form for all our forms, which means we could refactor out the toasters if we decide to use the native error handling form Redux-Form.

What do you think?

@joaopapereira
Copy link
Member

I am ok with holding off the merge

@mattwr18
Copy link
Contributor

Any progress on this @jmpainter??

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

Successfully merging this pull request may close these issues.

Ability to share hangout links for events
4 participants