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

Darien Classrooms & Assignments Mk2 - Part 1 #107

Merged
merged 10 commits into from
Dec 8, 2017
Merged

Conversation

shaunanoordin
Copy link
Member

PR Overview

This PR plans to improve the WildCam Darien Lab's Classrooms and Assignments.

Goals:

  • Only logged-in users can access Educators page (i.e. Classroom & Assignment management.) ( fixes Darien: secure classroom management #91 )
  • Non-logged-in users have access to a limited subset of pages and are prompted to login.
  • Educators can create & edit Darien-specific Classrooms.
  • Educators can create & edit Darien-specific Assignments.
  • [major][ambitious] Educators can select Subjects from the Map Explorer to create Assignments. (EDIT: maybe start with empty Assignments first?)

Expected BIG STUFF that needs handling:

NOT in the scope:

  • Students pages. (i.e. "view my Assignments, view my Classrooms")

Dev Notes

Please note that I'm reorganising the way that the Darien components are organised, subdivided, and named.

Notably, I'm reconceptualising the "DarienRoutesContainer" container into the "DarienProgram" container, which contains more logic and (hopefully) is a better way of thinking of how we organise our Programs.

Status

WIP

@shaunanoordin
Copy link
Member Author

PR Update

I think I'll split the planned updates for this PR into multiple parts. In this PR:

  • Only logged-in users can access Educators page (i.e. Classroom & Assignment management.) ( fixes Darien: secure classroom management #91 )
  • Non-logged-in users have access to a limited subset of pages and are prompted to login.
    • New Darien 401 and 404 pages introduced.
    • The Map (Explorer) page is still open to all.
      • NOTE: I'm separating 'Students' from 'Explorers', which will be a change from WildCam Gorongosa. 'Students' pages will come way later.
  • Darien components re-organised; we now have a 'root' DarienProgram component for, well, handling the Program itself.
    • The Darien Home page has also been updated; mostly, this is a minor restyle and content/text tweak.

Next PR:

  • Educators can create & edit Darien-specific Classrooms.
  • Educators can create & edit Darien-specific Assignments.

As previously noted in "Expected Big Stuff": I'll likely need to clone & spinoff the Classroom and Assignment components used in I2A into "WildCamClassroomLayout" components.

Status

Ready for review. 👌 This will be followed up with a PR Part 2.

@shaunanoordin shaunanoordin changed the title Darien Classrooms & Assignments Mk2 Darien Classrooms & Assignments Mk2 - Part 1 Dec 7, 2017
Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

I really only have non-blocking comments, some of which could be addressed in your part 2 PR. I'll hold off on merging so you can choose how you want to address them.

Organization is much better 👍 . The old routes container was a pretty WTF reaction to React Router v4's API and non-sensical.

404 and 401 pages work well. Perhaps we can think about sharing those between the I2A side of the app too?

import PropTypes from 'prop-types';
import GenericStatusPage from '../../components/common/GenericStatusPage';

const Darien401 = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been switching to writing functional components using declaration rather than expression: function MyComponent() {}. React will correctly use the function name as the component display name this way. For some reason, React won't use it if it's an expression. It really helps with debugging using the React Dev Tools to see the correct names.

import PropTypes from 'prop-types';
import GenericStatusPage from '../../components/common/GenericStatusPage';

const Darien404 = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about declaration vs expression for ease of debugging purposes.

import PropTypes from 'prop-types';
import ClassroomsLayout from '../classrooms/ClassroomsLayout';

const DarienEducators = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about declaration.

constructor(props) {
super(props);
}
const DarienHome = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about using declaration.

@@ -3,20 +3,20 @@ import PropTypes from 'prop-types';
import MapExplorer from '../../containers/maps/MapExplorer';
import mapConfig from '../../lib/wildcam-darien.mapConfig.js';

const DarienExplorer = (props) => {
const DarienMap = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about using declaration.

import Darien404 from '../../components/darien/Darien404';
import GenericStatusPage from '../../components/common/GenericStatusPage';

class DarienProgram extends React.Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can still use the higher order connect function with functional components, so I don't think this has to be a class, unless you have plans to add some lifecycle methods to handle something.

<ProgramHome className="darien-home">
<Hero
className="program-home__hero"
background={<Image src="https://placeimg.com/1000/1000/nature/any" fit="cover" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

The Darien team might want to pick an actual background image here rather than use this placeholder. Maybe something from the project?

I put the string for the background source into the program metadata for I2A just so it's consistent with referencing everything about the program from the database. Just so you know, the controllers for update hasn't been done for programs on the API, so you have to ask for someone update it via the Rails console.

<Box align="center" direction="column">
<Paragraph>Investigate ecological questions by exploring trail camera data using an interactive map. Filter and download data to perform analyses and test hypotheses.</Paragraph>

<Box pad="medium" size="medium">
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor styling comment, but perhaps the Box should be defined as a bigger size to allow for the paragraphs to be displaying inline? Even with a fairly high resolution screen, I still have to scroll to see both options for the lab to get started.


<Box pad="medium" size="medium">
<Paragraph> Alternatively, you can simply explore the data.</Paragraph>
<Button path="/wildcam-darien-lab/map/" label="Explorer" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add className="button--secondary" here so this button correctly gets hover/focus styles? I still have had a moment to figure out why Grommet is being inconsistent with the styles.

<Box pad="medium" size="medium">
<Paragraph>If you are an educator, you can set up private classrooms and invite your students to join. Curate data sets or let your students explore on their own. Guided activities and supporting educational resources are also available. {(signedIn) ? null : '(Sign In required)'}</Paragraph>
{(signedIn)
? <Button path="/wildcam-darien-lab/educators/" label="Educator" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add className="button--secondary" here too?

@shaunanoordin
Copy link
Member Author

shaunanoordin commented Dec 8, 2017

Thanks @srallen, that's some great feedback!

I'll perform the following updates for this PR:

  • Darien401 and Darien404 will now become common/Status401, common/Status404
  • const myComponent = () => {} will be transformed into function myCompontent() {}
  • className='button--secondary' will be added to the Educator and Explorer buttons

I won't touch the styling (background image, Box sizes) for WildCam Darien this round though, as I'll need to talk to HHMI about these things anyway, so I expect them to be changed soon-ish.

@shaunanoordin
Copy link
Member Author

Actually, dangit, now that I look at it, what WildCam Darien home page styling can be improved quite a bit. Mrrrgh!

@shaunanoordin
Copy link
Member Author

PR Update

This PR has been updated to reflect the excellent feedback from @srallen

  • We now have common/Status401 and common/Status404 pages.
  • Darien Component definitions now use declarations(), (not) => { expressions }.
  • Darien Home page buttons use proper button stylings.
  • Darien Home page... RESTYLED! For now! I'll need to get HHMI to review the text & etc but it's an improvement.
    screen shot 2017-12-08 at 15 30 13

Status

Ready for re-review! 👍

Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

I have a couple of minor comments on naming, but this otherwise looks good to merge!

import PropTypes from 'prop-types';
import GenericStatusPage from './GenericStatusPage';

function Darien401(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe name the function Status401?

import PropTypes from 'prop-types';
import GenericStatusPage from './GenericStatusPage';

function Darien404(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Name this Status404?

@srallen srallen merged commit f2a4f61 into master Dec 8, 2017
@shaunanoordin
Copy link
Member Author

Nyarp! 😱 Sorry, I forgot to rename Darien401/404's actual function names - I'll take care of that in part 2. Thanks for spotting that!

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

Successfully merging this pull request may close these issues.

Darien: secure classroom management
2 participants