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

View-Only Sketches and Major Main/Editor Refactoring #219

Merged
merged 60 commits into from
Apr 3, 2020
Merged

Conversation

mattxwang
Copy link
Member

Wow, it's a relief to finally write out this PR! In sum, this is the PR that implements all the necessary work for a View-Only page for each sketch (which works whether or not the user is logged in). It required a lot of code motion and refactoring, and likely has lots of side effects (so I'd prefer some semi-rigorous testing and multiple reviewers). Many thanks to @jamieliu386 and @emmyc for the solid (and gruelling) work they put into this feature!

(this supersedes #103)

Here's a semi-detailed list of what we did:

  • moves the logic that combines Editor, Output, and SplitPane out of Main to new component EditorAndOutput; similarly moves requisite props/state and CodeDownloader work. necessary to remove code duplication
  • creates ViewOnly and accompanying ViewOnlyContainer for view-only programs. this component manages fetching the program from the pid, handling errors, and passing down the relevant props to EditorAndOutput
  • creates app route of /p/:pid for users to visit view-only sketches - directs to ViewOnly
  • adds custom props this.props.viewOnly, this.props.vLanguage to Output, to process props differently depending on program state
  • makes Editor banner behaviour (e.g. Dropdown vs. text, save button) dependent on view-only mode
  • adjusts ProfilePanel behaviour to have Create User and Login buttons when the user isn't logged in; maintains themeing capabilities
  • adjusts tests for profile panel for new behaviour (TODO: test non-logged in profile panel)

(also, we should probably squash merge this, but I'm not sure how useful the commit history actually might be!)

mattxwang and others added 30 commits October 29, 2019 19:42
…button components to common, remove unnecessary button imports
removing merge conflicts
ahhhhh this is all so jank
fixes weird bottom bar, makes styling on header more consistent. maybe a less jarring white makes this look less bad
forces them to render the logged-in panel
moved all the getting programs/error handling to ViewOnly itself; fixes problem that render functions cannot have async responses

possible TODO: "sketch not found" page
The bug:
Open a sketch in view-only mode. Go to the sketches page and try to download your most recently viewed sketch. The sketch title and extension are as expected, but the code is the code from the view-only sketch.

This fixes the bug by saving the original code for the most recently viewed program, and restoring it before the component unmounts.
@mattxwang
Copy link
Member Author

Just for transparency, @jamieliu386 discovered a bug where we corrupt the Redux state while viewing a view-only program when logged-in. Currently working on an (elegant) fix right now!

View-Only: Fixes Redux State Corruption
Copy link
Contributor

@krashanoff krashanoff left a comment

Choose a reason for hiding this comment

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

Hey all, great work on this! View-only mode will be great and the refactor is looking fresh 👀
Sorry for the radio silence - I am just now wading through the last few major changes I haven't looked at yet, and gradually testing. To be specific, I am yet to look at the brand new files in depth (EditorAndOutput, ViewOnly), and still want to fool around with user input that might break things. Should have those done by tomorrow.

Again, great work all! Glad to see this all rolling this out.

Copy link
Contributor

@krashanoff krashanoff left a comment

Choose a reason for hiding this comment

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

Finished parsing through the last few files and played around with the view only editor more. The only thing I stumbled on was that the view only editor does not load the set theme from cookies an user's cookies:

  • Log out
  • Load a sketch in view only, then change to light theme
  • Refresh. Theme does not persist.

Don't know if this was intentional or not - I think that dark theme is a sensible default and there really isn't much sense in attaching a cookie to a user who is likely just viewing it as a once-off. Still, thought that I should bring it up since we do set cookies on theme change from within the view only editor.

Other than this, LGTM!

@mattxwang
Copy link
Member Author

Finished parsing through the last few files and played around with the view only editor more. The only thing I stumbled on was that the view only editor does not load the set theme from cookies an user's cookies

Ah, that seems like a bug. If you have the time to take a look at that, that'd be great, but if not, I can probably fix it tomorrow!

Copy link
Contributor

@krashanoff krashanoff left a comment

Choose a reason for hiding this comment

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

It's been a long time coming gang. The hour is upon us. I know that my review is no longer unbiased, having made changes however small, but if I may be so bold: LGTM.

@mattxwang
Copy link
Member Author

Jeez, I think this is going to live in some sort of infamy.

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

Successfully merging this pull request may close these issues.

8 participants