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

Assign course/script to newly created section #17056

Merged
merged 9 commits into from Aug 15, 2017
Merged

Conversation

Bjvanminnen
Copy link
Contributor

@Bjvanminnen Bjvanminnen commented Aug 14, 2017

This PR makes it so that when we click on New Section in the assign course dropdown, we load the page with the section edit experience started. This should be true whether our experiment is on or off.
image

It does so by going to the page with courseId/scriptId query params. We have a redux action that will parse these query params, and put them in the store. Not sure if it would be better to keep the query param parse logic outside of redux?

*/
export function getQueryString_() {
return window.location.search;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know if there's a better way to be able to stub this, but this seems to work (semi-copied from what we do in experiments.js)

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine to me.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

It seems like there's a more direct approach to this, but maybe I misunderstand the feature.

defaultScriptId = parseInt(query.scriptId, 10);
}
store.dispatch(setDefaultAssignment());
console.log('dispatched');
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover console.log

if (experiments.isEnabled(SECTION_FLOW_2017)) {
hrefNewSection = '/home?' + queryString.stringify({courseId, scriptId});
} else {
hrefNewSection = `${window.dashboard.CODE_ORG_URL}/teacher-dashboard?` +
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use the pegasus() helper here.

...state,
defaultCourseId: courseId,
defaultScriptId: scriptId
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused - don't we want to launch straight into the new section flow when we pass these queryparams? Why wouldn't we dispatch that and set the course and script ids on the sectionBeingEdited instead of introducing some new and independent state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that might make more sense. Let me give that a try.

*/
export function getQueryString_() {
return window.location.search;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine to me.

@Bjvanminnen
Copy link
Contributor Author

Your approach makes a lot more sense. I've updated to do that. As part of this, I moved all of the query param stuff out of redux (where it didn't really feel right). Though it's semi-duplicated between the two entry points, one of these will go away once we don't have the experiment.

@@ -40,6 +38,8 @@ class OwnedSections extends React.Component {
beginEditingNewSection: PropTypes.func.isRequired,
beginEditingSection: PropTypes.func.isRequired,
beginImportRosterFlow: PropTypes.func.isRequired,
defaultCourseId: PropTypes.number,
defaultScriptId: PropTypes.number,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: remove these props

@@ -1,6 +1,7 @@
import sinon from 'sinon';
import { assert, expect } from '../../../util/configuredChai';
import {stubRedux, restoreRedux, registerReducers, getStore} from '@cdo/apps/redux';
// Use wildcard import so that we can stub
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove comment

@Bjvanminnen Bjvanminnen reopened this Aug 15, 2017
@Bjvanminnen
Copy link
Contributor Author

@islemaster If you could take another look at this PR and sign off if things look good, that would be great :)

if (experiments.isEnabled(SECTION_FLOW_2017)) {
this.props.beginEditingNewSection(defaultCourseId, defaultScriptId);
this.props.beginEditingNewSection();
} else {
// This is the only usage of the newSection action, and can be removed once
// SECTION_FLOW_2017 is finished
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: This comment is not longer accurate :)

} else {
// This is the only usage of the newSection action, and can be removed once
// SECTION_FLOW_2017 is finished
return this.props.newSection(defaultCourseId);
return this.props.newSection();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking this PR (this is really my bad) but note to self: We should have a unit test for OwnedSections.jsx that clicks this button both with the experiment on and off.

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

Cool, I like that this mostly removed code.

@Bjvanminnen Bjvanminnen merged commit 263c8c3 into staging Aug 15, 2017
@Bjvanminnen Bjvanminnen deleted the assignNewCourse branch August 15, 2017 18:09
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.

None yet

2 participants