Skip to content

Commit

Permalink
Merge pull request #23428 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [robo-dtt]
  • Loading branch information
deploy-code-org committed Jun 29, 2018
2 parents f657b16 + 4a74fcc commit 10b398b
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 54 deletions.
2 changes: 1 addition & 1 deletion apps/i18n/common/en_us.json
Expand Up @@ -541,7 +541,7 @@
"findLocalClassButton": "Find a class",
"finish": "Finish",
"forTeachersOnly": "For Teachers Only",
"fromDaysAgo": "(From {number} days ago)",
"fromWhen": "(From {when}):",
"gdprDialogHeader": "Do you agree to using a website based in the United States?",
"gdprDialogDetails": "Data from your use of this site may be sent to and stored or processed in the United States.",
"gdprDialogSeePrivacyPolicy": "For details see our privacy policy",
Expand Down
1 change: 1 addition & 0 deletions apps/package.json
Expand Up @@ -225,6 +225,7 @@
"filesaver.js": "0.2.0",
"jshint": "^2.9.5",
"jszip": "3.0.0",
"moment": "^2.14.1",
"object-fit-images": "^3.2.3",
"qrcode.react": "^0.8.0",
"query-string": "4.1.0",
Expand Down
3 changes: 2 additions & 1 deletion apps/src/code-studio/components/SmallFooter.jsx
Expand Up @@ -2,6 +2,7 @@

import $ from 'jquery';
import React, {PropTypes} from 'react';
import debounce from 'lodash/debounce';

const MenuState = {
MINIMIZING: 'MINIMIZING',
Expand Down Expand Up @@ -68,7 +69,7 @@ export default class SmallFooter extends React.Component {

componentDidMount() {
this.captureBaseElementDimensions();
window.addEventListener('resize', this.captureBaseElementDimensions);
window.addEventListener('resize', debounce(this.captureBaseElementDimensions, 100));
}

captureBaseElementDimensions = () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/src/code-studio/responsive.js
@@ -1,4 +1,4 @@
import throttle from 'lodash/debounce';
import debounce from 'lodash/debounce';
import { getStore } from './redux';
import { getResponsiveBreakpoint, setResponsiveSize } from './responsiveRedux';

Expand All @@ -9,7 +9,7 @@ import { getResponsiveBreakpoint, setResponsiveSize } from './responsiveRedux';
export default function initResponsive() {
const store = getStore();

window.addEventListener('resize', throttle(() => {
window.addEventListener('resize', debounce(() => {
store.dispatch(setResponsiveSize(getResponsiveBreakpoint(window.innerWidth)));
}, 50));
}, 100));
}
3 changes: 2 additions & 1 deletion apps/src/templates/VisualizationOverlay.jsx
Expand Up @@ -2,6 +2,7 @@

import React, {PropTypes} from 'react';
import { connect } from 'react-redux';
import debounce from 'lodash/debounce';

/**
* Overlay for the play space that helps render additional UI (like the
Expand Down Expand Up @@ -37,7 +38,7 @@ export class VisualizationOverlay extends React.Component {
// Note: This is currently used within a ProtectedStatefulDiv, so we need
// to hook up our own handlers that trigger updates (based on state) instead
// of depending on props passed in - hence, these globals.
window.addEventListener('resize', this.recalculateTransform);
window.addEventListener('resize', debounce(this.recalculateTransform, 100));
document.addEventListener('mousemove', this.onMouseMove);
}

Expand Down
39 changes: 39 additions & 0 deletions apps/src/templates/instructions/FeedbacksList.jsx
@@ -0,0 +1,39 @@
import React, {PropTypes, Component} from 'react';
import i18n from '@cdo/locale';
import moment from 'moment';

const styles = {
content: {
padding: 10
},
header: {
fontWeight: 'bold',
paddingRight: 5
}
};

export default class FeedbacksList extends Component {
static propTypes = {
feedbacks: PropTypes.arrayOf(PropTypes.shape({
teacher_name: PropTypes.string.isRequired,
created_at: PropTypes.string.isRequired,
comment: PropTypes.string.isRequired
})).isRequired
};

render() {
return (
<div>
{this.props.feedbacks.map((feedback, i) => (
<div style={styles.content} key={i}>
<div>
<span style={styles.header}>{i18n.feedbackFrom({teacher: feedback.teacher_name})}</span>
{i18n.fromWhen({when: moment(feedback.created_at).fromNow()})}
</div>
<div>{feedback.comment}</div>
</div>
))}
</div>
);
}
}
37 changes: 0 additions & 37 deletions apps/src/templates/instructions/StudentFeedback.jsx

This file was deleted.

27 changes: 22 additions & 5 deletions apps/src/templates/instructions/TopInstructionsCSP.jsx
Expand Up @@ -7,7 +7,7 @@ import {connect} from 'react-redux';
import processMarkdown from 'marked';
import renderer from "../../util/StylelessRenderer";
import TeacherOnlyMarkdown from './TeacherOnlyMarkdown';
import StudentFeedback from "./StudentFeedback";
import FeedbacksList from "./FeedbacksList";
import TeacherFeedback from "./TeacherFeedback";
import InlineAudio from './InlineAudio';
import ContainedLevel from '../ContainedLevel';
Expand Down Expand Up @@ -127,12 +127,15 @@ class TopInstructions extends Component {
mapReference: PropTypes.string,
referenceLinks: PropTypes.array,
viewAs: PropTypes.oneOf(Object.keys(ViewType)),
readOnlyWorkspace: PropTypes.bool
readOnlyWorkspace: PropTypes.bool,
serverLevelId:PropTypes.number,
user: PropTypes.number
};

state = {
tabSelected: this.props.viewAs === ViewType.Teacher && this.props.readOnlyWorkspace &&
experiments.isEnabled(experiments.DEV_COMMENT_BOX_TAB) ? TabType.COMMENTS : TabType.INSTRUCTIONS,
feedbacks: []
};

/**
Expand All @@ -146,6 +149,16 @@ class TopInstructions extends Component {
// Initially set to 300. This might be adjusted when InstructionsWithWorkspace
// adjusts max height.
this.props.setInstructionsRenderedHeight(Math.min(maxNeededHeight, 300));

if (this.props.viewAs === ViewType.Student && experiments.isEnabled(experiments.DEV_COMMENT_BOX_TAB)) {
$.ajax({
url: '/api/v1/teacher_feedbacks/get_feedbacks?student_id='+this.props.user+'&level_id='+this.props.serverLevelId,
method: 'GET',
contentType: 'application/json;charset=UTF-8',
}).done(data => {
this.setState({feedbacks: data});
});
}
}

componentWillUnmount() {
Expand Down Expand Up @@ -266,7 +279,8 @@ class TopInstructions extends Component {
const displayFeedbackDevTeacher = experiments.isEnabled(experiments.DEV_COMMENT_BOX_TAB) &&
this.props.viewAs === ViewType.Teacher && this.props.readOnlyWorkspace;

const displayFeedbackDevStudent = experiments.isEnabled(experiments.DEV_COMMENT_BOX_TAB) && this.props.viewAs === ViewType.Student;
const displayFeedbackDevStudent = experiments.isEnabled(experiments.DEV_COMMENT_BOX_TAB) &&
this.props.viewAs === ViewType.Student && this.state.feedbacks.length > 0;

const displayFeedback = displayFeedbackDevTeacher || displayFeedbackStable || displayFeedbackDevStudent;
return (
Expand Down Expand Up @@ -354,7 +368,8 @@ class TopInstructions extends Component {
/>
}
{this.props.viewAs === ViewType.Student &&
<StudentFeedback
<FeedbacksList
feedbacks={this.state.feedbacks}
ref="commentTab"
/>
}
Expand Down Expand Up @@ -390,7 +405,9 @@ export default connect(state => ({
mapReference: state.instructions.mapReference,
referenceLinks: state.instructions.referenceLinks,
viewAs: state.viewAs,
readOnlyWorkspace: state.pageConstants.isReadOnlyWorkspace
readOnlyWorkspace: state.pageConstants.isReadOnlyWorkspace,
serverLevelId: state.pageConstants.serverLevelId,
user: state.pageConstants.userId
}), dispatch => ({
toggleInstructionsCollapsed() {
dispatch(toggleInstructionsCollapsed());
Expand Down
6 changes: 5 additions & 1 deletion apps/yarn.lock
Expand Up @@ -8304,10 +8304,14 @@ mock-firmata@0.2.0:
dependencies:
board-io "^3.0.5"

moment@2.14.1, moment@^2.10.3, moment@^2.13.0:
moment@^2.10.3, moment@^2.13.0:
version "2.14.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.14.1.tgz#b35b27c47e57ed2ddc70053d6b07becdb291741c"

moment@^2.14.1:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"

ms@0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
Expand Down
23 changes: 22 additions & 1 deletion dashboard/app/controllers/registrations_controller.rb
@@ -1,7 +1,8 @@
class RegistrationsController < Devise::RegistrationsController
respond_to :json
prepend_before_action :authenticate_scope!, only: [
:edit, :update, :destroy, :upgrade, :set_email, :set_user_type
:edit, :update, :destroy, :upgrade, :set_email, :set_user_type,
:migrate_to_multi_auth, :demigrate_from_multi_auth
]
skip_before_action :verify_authenticity_token, only: [:set_age]

Expand Down Expand Up @@ -181,6 +182,26 @@ def set_user_type
end
end

#
# GET /users/migrate_to_multi_auth
#
def migrate_to_multi_auth
was_migrated = current_user.migrated?
current_user.migrate_to_multi_auth
redirect_to after_update_path_for(current_user),
notice: "Multi-auth is #{was_migrated ? 'still' : 'now'} enabled on your account."
end

#
# GET /users/demigrate_from_multi_auth
#
def demigrate_from_multi_auth
was_migrated = current_user.migrated?
current_user.demigrate_from_multi_auth
redirect_to after_update_path_for(current_user),
notice: "Multi-auth is #{was_migrated ? 'now' : 'still'} disabled on your account."
end

private

def respond_to_account_update(successfully_updated, flash_message_kind = :updated)
Expand Down
2 changes: 2 additions & 0 deletions dashboard/config/routes.rb
Expand Up @@ -144,6 +144,8 @@ module OPS
get '/users/clever_takeover', to: 'sessions#clever_takeover'
get '/users/clever_modal_dismissed', to: 'sessions#clever_modal_dismissed'
get '/users/auth/:provider/connect', to: 'omniauth_callbacks#connect'
get '/users/migrate_to_multi_auth', to: 'registrations#migrate_to_multi_auth'
get '/users/demigrate_from_multi_auth', to: 'registrations#demigrate_from_multi_auth'
end
devise_for :users, controllers: {
omniauth_callbacks: 'omniauth_callbacks',
Expand Down
@@ -0,0 +1,67 @@
require 'test_helper'

class RegistrationsControllerIntegrationTest < ActionDispatch::IntegrationTest
test "migrate_to_multi_auth fails when signed out" do
get '/users/migrate_to_multi_auth'
assert_redirected_to '/users/sign_in'
assert_equal '/users/migrate_to_multi_auth', session[:user_return_to]
end

test "migrate_to_multi_auth migrates an unmigrated user" do
teacher = create :teacher
refute teacher.migrated?

sign_in teacher
get '/users/migrate_to_multi_auth'
assert_redirected_to '/home'
assert_equal 'Multi-auth is now enabled on your account.', flash[:notice]

teacher.reload
assert teacher.migrated?
end

test "migrate_to_multi_auth is a no-op for a migrated user" do
teacher = create :teacher, :with_migrated_email_authentication_option
assert teacher.migrated?

sign_in teacher
get '/users/migrate_to_multi_auth'
assert_redirected_to '/home'
assert_equal 'Multi-auth is still enabled on your account.', flash[:notice]

teacher.reload
assert teacher.migrated?
end

test "demigrate_from_multi_auth fails when signed out" do
get '/users/demigrate_from_multi_auth'
assert_redirected_to '/users/sign_in'
assert_equal '/users/demigrate_from_multi_auth', session[:user_return_to]
end

test "demigrate_from_multi_auth demigrates a migrated user" do
teacher = create :teacher, :with_migrated_email_authentication_option
assert teacher.migrated?

sign_in teacher
get '/users/demigrate_from_multi_auth'
assert_redirected_to '/home'
assert_equal 'Multi-auth is now disabled on your account.', flash[:notice]

teacher.reload
refute teacher.migrated?
end

test "demigrate_from_multi_auth is a no-op for an unmigrated user" do
teacher = create :teacher
refute teacher.migrated?

sign_in teacher
get '/users/demigrate_from_multi_auth'
assert_redirected_to '/home'
assert_equal 'Multi-auth is still disabled on your account.', flash[:notice]

teacher.reload
refute teacher.migrated?
end
end
7 changes: 4 additions & 3 deletions dashboard/test/ui/features/feedback_tab.feature
Expand Up @@ -32,13 +32,14 @@ Scenario: With stable flag, 'Feedback' tab is not visible for students and displ
#As teacher, all flags off, tab not visible
And element ".uitest-feedback" is not visible

Scenario: With dev flag, as student, 'Feedback' tab is visible and displays temporary text
Scenario: With dev flag, as student, 'Feedback' tab is not visible if no feedback
#As student, see temporary text
And I am on "http://studio.code.org/s/allthethings/stage/18/puzzle/7?enableExperiments=devCommentBoxTab"
And I click selector ".uitest-feedback" once I see it
And I wait until ".editor-column" contains text "Feedback from Temp"
And element ".uitest-feedback" is not visible
And I am on "http://studio.code.org/s/allthethings/stage/18/puzzle/7?disableExperiments=devCommentBoxTab"

#TODO - epeach - With dev flag, tests for student when feedback available

Scenario: With dev flag, as teacher,tab is invisible when not reviewing student work and visible when viewing student work
#As teacher, not reviewing work, don't see feedback tab
Then I sign in as "Teacher_Lillian"
Expand Down
Expand Up @@ -24,7 +24,7 @@ Scenario: Teachercon Registration form submission
And I press the first "input[name='liveFarAway']" element
And I press keys "1501 4th Avenue" for element "#addressStreet"
And I press keys "Seattle" for element "#addressCity"
And I press keys "WA" for element "#addressState"
And I select the "Washington" option in dropdown "addressState"
And I press keys "98101" for element "#addressZip"
And I press the first "input[name='howTraveling']" element
And I press the first "input[name='needHotel']" element
Expand Down

0 comments on commit 10b398b

Please sign in to comment.