-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix for #206, show authors, issues & articles editors in Dialog boxes on admin site #217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first attempt, and I think the general code is pretty correct and good. A few things though:
-
Since you're calling it in componentDidUpdate this will be called every single time the component changes anything, that could cause all kinds of weird edge cases, especially as the hash doesn't change as you scroll to different places. One edge case I can imagine is that we later also made a hash for the top of that page to go "back to top" or something, if that was your url and you went down and typed something in the article controller as soon as you typed something your screen would instantly jump up to the top again.
-
While you could correct 1. to make it work every place, instead of duplicating code everywhere (the first method would be just modularizing this to a function and put it in lib/utilities.js but there's a better method) why don't you do as described in the comment you linked me to? this one. I really liked that, using the Router's onUpdate prop, you can find the router in
src/client-scripts/admin-client.js
-
Other than that stuff looks good, the ids and the links all look good. So if you just move the scroll code to the onUpdate Router prop as I said above it should be ready to merge. By then I'll also look at the scroll animation and maybe we can use the
react-scroll
library or something if it's too ugly? Also, I think you could add this to the IssueController too.
@@ -119,6 +119,17 @@ export default class EditorArticleController extends FalcorController { | |||
// The update wasn't due to a change in article | |||
this.debouncedHandleFormStateChanges(); | |||
} | |||
// scroll to article editor once page loads | |||
const { hash } = window.location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, you have good knowledge of ES6 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the comments. Didn't find the Router code at first glance, thanks for pointing me to it! Will update later tonight or tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, just write a comment on the PR when you're ready for another review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better, if we're trying to enforce the Zenhub workflow I just did what I should've done and moved the issue and PR back to in progress, and when you're ready for review just move them back into Review/QA
One thing that's happening with the Issues page is, since the Articles and Categories components take a second to load, the scroll doesn't fully take effect when you click on those buttons as soon as the page loads. It functions normally only after those components are rendered. Actually, same thing happens with the other pages but to a less extent, so I was able to fix it for them with |
I can also explore |
I think what would be really elegant would be to simply style the article/author editor components to show up as modals. In this way they would be actually overall content (with the other content darkened) and then when they are dismissed, they disappear. This could be achieved pretty simply with a |
Hmm yeah, that's a solid idea, shall we settle on that instead of the scroll function? It may also be more mobile friendly even though as I said it's not our main priority. And I guess it would never be the case that you somehow wanted to look at both the picker and the article at the same time so a modal could be a good fix |
Okay I'll explore |
Sounds good! Thanks for the flexibility even though we completely changed direction :). |
Just tried One linter error: Other than that, I think this |
> | ||
<SelectField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only changed the indentation below this line. not sure why Git created such a mess with the blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm afraid git isn't always so smart <.<. It seems like it's taking line 363 as a constant because it used to be an end of React element of Form and now it's an end of React element Dialog, but git thinks that's a line that you "kept"
Thanks for the swift development cycle @CynthiaTong I'm really happy with you work until now! Just to quickly address your linting question, it's probably giving the error on the selectfield where you did If you personally feel like it's important for readability and transparency of the SelectField API I could be okay with you adding a I'll take a more thorough look this evening and get back to you with a proper review! |
@emilgoldsmith thanks :).
These are pretty standard attributes of Dialog, so I think it should be fine to keep them the way they are. |
Oh @CynthiaTong in that case all the linter wants you to do is simply write |
Amazing quick fix. Let me know what you think about the rest of the code. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally good work again, I really like how the UI turns out (also just checked it out on mobile haha, really doesn't work as you said, but as we mentioned it's not a priority issue). You did break some functionality though and a few minor comments.
The problem is you removed the submit button from the form and just made it a close dialogue button. The easiest thing is to just return that. I think the choice you made of putting the save changes button as a fixed button in the bottom (or in this context an action button) looks pretty good, the other possibility is just putting it in the bottom where it was and not adding any "actions." I personally think both are pretty okay, but also think @CynthiaTong's choice looks quite good actually. @zanemountcastle any opinion on this as it's front-end stuff?
Hmm I have a few thoughts about this though... Also because I feel like maybe when we do this modal we don't even need the routing anymore? As in, maybe we just implement it outside of routes, and just make the dialog appear on click.
another small thing is I would probably make Dialog the parent of all the divs in this, aka the most outer html element.
I have to think a bit more about this, and maybe @zanemountcastle has some inputs as well, but actually in class so should go back to listening. @CynthiaTong also feel free to voice your opinion if you have thoughts about it, and don't worry changing anything until we're sure what exactly is the best approach.
@@ -348,93 +356,107 @@ export default class EditorArticleController extends FalcorController { | |||
} | |||
} | |||
|
|||
// Dialog action button | |||
const actions = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I'll elaborate this button doesn't provide the functionality it previously did
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying it doesn't save changes now? That's a big issue. I'll look at it more carefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, doesn't save changes anymore, this button used to submit the form by being inside the form and being of type="submit"
but now it no longer does that.
It's okay if you wait a bit with implementing changes though, at least until we just decide finally on what's the optimal way to implement this.
I just have quite a lot of stuff to get done tonight, but it's ruminating in the back of my head and I think I nearly have a good structure, but yeah, have a lot of stuff I need to finish tonight, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it's totally cool. Good luck with whatever you're doing. Things can wait :).
disabled={!this.state.changed || this.state.saving} | ||
/>, | ||
]; | ||
|
||
return ( | ||
<div style={styles.innerPaper}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm don't you think this styled div should be within the Dialog maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed. I'll fix this.
@emilgoldsmith as for the point you raised about routing, I don't have enough experience yet with react-router so I'm not 100% sure of the benefits of using routing vs. just using Dialog. If these two approaches are roughly equivalent (in terms of efficiency, code consistency, data flow, etc), just using Dialog could be simpler. Although one good thing about routing I can think of is, people can share the url to the specific article editor/issue/author profile if they want (correct me on this if I'm wrong, I'm assuming people can access the linked page directly after login, skipping the articles/issues/author selection step) |
Okay, it has ruminated! So I definitely think we should keep routing, not only because of the point @CynthiaTong raises:
which would be even more relevant when we implement Google login which would probably entail cookies as well so you don't need to login all the time. And maybe sharing links with each other isn't the most common practice for the site, but maybe revisiting a link yourself could be. And the most important thing I can think of is actually that without routing the back button wouldn't work, and that would truly suck, so we definitely need the routing. So given that is set in stone, I can now list all the changes we need to make.
Okay, that was my 200 cents ;). Have fun working! (and also feel free to ask questions / make comments if you disagree with something) |
Actually just thought of something. The whole ref thing is totally overkill as we save everything in state, so there's actually no need (if you choose to go the "action" way in terms of UI) to do all that complicated stuff. You could simply call |
@emilgoldsmith thanks a lot for the very informative comment and advice! I will be very busy these days for various reasons, so it'll take longer for me to implement all this. But advice noted and I'll try my best to complete it asap. Also I'll let you know what I think of the questions you mentioned as I go. |
Sounds good, thanks for the heads up on the "delay" :). As long as you keep up good communication we can tolerate basically anything. |
Any update on this @CynthiaTong? |
@zanemountcastle sick over the weekend. I'll work on it tmr! (Update: actually looking at it right now |
Basically followed @emilgoldsmith's suggestions and moved the Let me know what you guys think (I hope it finally works this time :D. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a refreshingly small diff now that you no longer need to change the indentation of anything :).
Just a quick change regarding keeping open
in state as it's no longer relevant, should be a 30 second fix.
I'll just do a manual test now, but as far as I can see you barely changed anything so it should only be front-end stuff that could have problems.
Also just remembered that we still have the Paper
wrapped around this component in the EditorArticleListController
component yeah? We probably want to remove that. It might not actually render when it doesn't have any children, but it's definitely better not having it there if it doesn't make sense anymore.
Regarding the publish button not changing, yeah I noticed that a little while back as well, I believe I made an issue that's in one of our 80 issues on our todo list ;). But thanks for pointing it out.
Again, thanks for the good work! Very happy to have brought you on board.
<h2>Article Editor: {article.title}</h2> | ||
<Dialog | ||
title="Article Editor" | ||
open={this.state.open} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just change this to just open
(the implicit way of writing open={true}
) since we never change this, we "close" this by routing away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I kinda overlooked this.. will change it now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and thanks for bringing me onboard :D
@@ -36,6 +39,7 @@ export default class EditorArticleController extends FalcorController { | |||
image: updateFieldValue.bind(this, 'image', undefined), | |||
}; | |||
this.safeSetState({ | |||
open: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this as described below.
Okay just did a real test, works really well, I like it a lot. And also just to reply to your last points of your comment, yeah I completely agree with keeping the escape button and clicking outside to escape, maybe if we were doing mobile stuff making a closing X in the corner could make sense but as we're not currently supporting mobile I don't think that's relevant, so good call in my opinion :). And as for being sick, don't worry, you weren't really that slow. So yeah, just quickly remove I'm not sure about the issues one, feel free to try it out and make a call whether you like it or not @CynthiaTong and present whatever you think works best to us. |
And yeah the issue I talked about was #184 |
Alright! I'll see how |
Sounds good, I'll look forward to seeing the full PR |
This looks really good @CynthiaTong! This is definitely much more user-friendly than having to scroll down to see the article editor. I also think that this same kind of thing will look great in the authors and issues sections. Keep up the good work! :) |
Authors page looks good. There is an issue with the Issues page (haha puns). Tabs don't play well with Dialog - each tab's child component has their own height, and the Dialog box doesn't auto-adjust to that height change when you click on the tabs, the result is that contents don't show up in a pleasant manner. I'm not very familiar with this kind of "reloading" issue I guess, so if you guys have anything to say about it pls do! I included the changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good @CynthiaTong, I love it :D.
I especially like the idea of these modals (thanks @zanemountcastle !) as I feel like it opens up the easy possibility of doing things like allowing the editing of an article from the part where you're adding issues to an article (which would be super convenient) etc.
I just quickly pushed a small commit that just removes the styles.innerPaper
style object as I realized that was no longer in use, it was much easier for me to just push than tell you to do it as it was such a small insignificant thing.
And yeah I see what you mean about the issue stuff, what do you think @zanemountcastle ? If it was up to me I think I'd just drop the modal for that one for now, and I also don't think it's an issue there as @CynthiaTong and I mentioned earlier since the top part is so short. Unless you have a nice fix, @zanemountcastle ?
(I'm only requesting changes because we need to figure out what to do with the Issue stuff, otherwise it looks great)
Okay, so my input on the issues modal thing. I think that we should just leave the issue editor as it was because:
The author and article modals look great though and I know the editors will definitely appreciate them. 👍 It looks like this is ready to be merged into the site! |
Awesome, so we all agree! So yeah @CynthiaTong if you just reset he issues stuff when you find the time we'll merge it in :) |
You forgot to remove the redundant Paper elements in the parent components, so also just did that, but now everything looks good! Let's merge it in :D. Congratulations on your first merged PR :) |
thanks @emilgoldsmith! I didn't really pay attention to the parents components.. my bad. Will look out for it next time. |
EDIT Oct 1, 17:
Moved away from the scrolling fix and uses
Material UI
'sDialog
to show the editor components.Automatically scroll down to the Article Editor/Author Profile area when selecting certain one article/author.
The scroll/jump effect isn't very pretty but it does the trick.
See this discussion on Github for more info on the fix: remix-run/react-router#394
EDIT BY EMIL: resolves #206 (just so the issue is automatically closed when we merge this PR)