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

Research Module - create/edit #1116

Merged
merged 7 commits into from
Apr 5, 2021
Merged

Conversation

danitrod
Copy link
Collaborator

@danitrod danitrod commented Mar 19, 2021

PR Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR Checklist

  • - Latest master branch merged
  • - PR title descriptive (can be used in release notes)
  • - Passes Tests

Description

Adding create/edit research forms, and create research update form. A couple of notes:

  • when accessing the URL to directly edit an existing research or add an update to it (/research/<slug>/edit or /research/<slug>/create-update), the store takes a while to validate if a user is logged in or not. I found no way for now to assure the user store has tried loading the user, so I added a forced timeout of 3 seconds to load the user before the code makes any decisions (visible in lines 21-26 of CreateUpdate). Its probably best if we can take the "triedToLogin" information from the user store directly.
  • I implemented moderation for the researches but couldn't test accepting/rejecting a research as I do not have an admin account.

Git Issues

Closes #1111

Screenshots/Videos

research-forms

@cypress
Copy link

cypress bot commented Mar 19, 2021



Test summary

62 0 0 0


Run details

Project onearmy-community-platform
Status Passed
Commit f603f0d ℹ️
Started Mar 21, 2021 10:58 PM
Ended Mar 21, 2021 11:04 PM
Duration 05:32 💡
OS Linux Ubuntu Linux - 16.04
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@davehakkens davehakkens added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label Mar 19, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2021

Visit the preview URL for this PR (updated for commit 292b6c4):

https://onearmy-next--pr1116-research-form-y2c0ejg8.web.app

(expires Tue, 20 Apr 2021 23:02:55 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@davehakkens
Copy link
Contributor

wauw again a super nice pull request! 💪

Not a coder myself, so can't comment to much on code, i'll leave that to @chrismclarke.
Few remarks from testing it.

  1. Image upload doesn't work here.
  2. I get a message when saving: "you have unsaved changes, are you sure to leave the page" (but it looks like you get this as well)
  3. Notifications is not a must in the beginning. We would start using the module internally first for a while with a selected group of people. No need for verification or moderation.
  4. I started a research and added a few steps. When I changed the title of my research all the steps dissapeared
  5. In how-to's we have the original step + all the following steps in one page. (so you can edit all of the steps in one place and also move certain steps up or down) Looks like you splitted this up, each update having its own "page". Any specific reason for this? And how could you edit an update?

@danitrod
Copy link
Collaborator Author

danitrod commented Mar 19, 2021

Thank you for testing it and for the valuable feedback!

  1. not reallly sure why that happens, but trying in dev mode it works ok. I think its probably something related to preview mode, as I just tried to create a new how-to with images in the preview and the images don't load as well. Maybe @chrismclarke has some insight?
  2. yeah, that's kinda weird, ill try to understand what's happening and fix it
  3. cool, no worries then, ill just make any new research be published as 'accepted' for now
  4. definitely a bug, forgot about the updates on editing a research - will fix
  5. I was thinking the UI for creating a research should be split for the initial intro and each following update, as the updates will be normally created one by one - i might have misunderstood, is it supposed to work like this? About editing an update, its not implemented for now but i can surely work on it, the only question is if they should be edited separately or edited like a howto, all in a single page.

I'll take a look at those bugs and commit fixes soon.

@davehakkens
Copy link
Contributor

davehakkens commented Mar 19, 2021

  1. Tested on dev now, works indeed. Just not the preview link. not a big deal.
  2. Yeh I'm up for trying it the way you made it (separated). Seems more clear and perhaps you don't want to move steps around anyway since it's all chronological time-based anyway. Would be good to add that "edit update" though.

@davehakkens
Copy link
Contributor

SUPER neat. it passes all my tests 💪

@@ -32,7 +32,7 @@ export const EventCard = (props: IProps) => (
data-eventId={props.event._id}
>
{props.event.moderation !== 'accepted' && (
<ModerationStatusText event={props.event} top={'0px'} />
<ModerationStatusText moderable={props.event} kind="event" top={'0px'} />
Copy link
Member

Choose a reason for hiding this comment

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

Good to see this refactored into a common component, I don't really understand what the word moderable means, but I can see you inherited the code from others so definitely not blaming!

Would you have any suggestion for a word that makes more sense? maybe moderatedContent or similar? Similarly we could change the word kind to something a bit more specific (e.g. contentType) to make things clearer for future devs.

But these are minor issues so I might just add a small comment myself to tidy in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, I was struggling to find a good name for this but definitely moderatedContent and contentType would be more describing names. Should I open a PR for this?


React.useEffect(() => {
if (submissionHandler.shouldSubmit) {
const form = document.getElementById('researchForm')
Copy link
Member

@chrismclarke chrismclarke Apr 5, 2021

Choose a reason for hiding this comment

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

I think react probably prefers when people use refs (https://reactjs.org/docs/refs-and-the-dom.html) instead of accessing dom directly, but I'm not aware of any issues doing it the vanilla way (the id is defined well enough to avoid multiple elements with the same id).
A bit more here: https://stackoverflow.com/questions/37273876/reactjs-this-refs-vs-document-getelementbyid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I was adapting some of the logic from the HowTo form, which used this approach. Definitely a future improvement to not access the DOM directly.

setTimeout(() => {
loggedInUser = store.activeUser
resolve()
}, 3000),
Copy link
Member

@chrismclarke chrismclarke Apr 5, 2021

Choose a reason for hiding this comment

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

I think this is something you mentioned in your comments - agreed it's a pain to know whether there is no user or if they just haven't finished login initialisation after direct nav / page reload. This workaround is fine for now, I think there would probably be some better way long term to handle more generally but I'll create a separate issue for that (#1124)

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

There's a huge amount here, which is really appreciated but also a bit tricky to review in depth. Overall the code looks really solid (I've added a few minor comments), so happy to merge. I think we can do some manual testing to check if everything is behaving as expected, and just make minor issues to fix anything as we come across it.

As the majority of the code is nicely encapsulated within the research module we can test most from that page, but for reference @davehakkens - there's also a few updates included to re-organise/re-use some of the content from howtos and events (specifically moderation status) - so will be good to double check that is still working as expected too.

@chrismclarke chrismclarke merged commit ee423fe into ONEARMY:master Apr 5, 2021
@danitrod danitrod deleted the research-form branch April 5, 2021 12:40
@davehakkens
Copy link
Contributor

Got this message in Slack today. Are they related?

afbeelding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: HowTo 📰 Mod: Research 🔬 Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Research Module - create/edit
3 participants