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

Rename Files From Recent Refactors of Teacher Panel and Instructions #29050

Merged
merged 7 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import FontAwesome from '@cdo/apps/templates/FontAwesome';
import {tryGetLocalStorage, trySetLocalStorage} from '@cdo/apps/utils';

export default class TeacherPanel extends React.Component {
export default class TeacherPanelContainer extends React.Component {
static propTypes = {
children: PropTypes.node
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import TeacherPanel from '../TeacherPanel';
import TeacherPanelContainer from '../TeacherPanelContainer';
import SectionSelector from './SectionSelector';
import ViewAsToggle from './ViewAsToggle';
import FontAwesome from '@cdo/apps/templates/FontAwesome';
Expand Down Expand Up @@ -51,7 +51,7 @@ const styles = {
}
};

class ScriptTeacherPanel extends React.Component {
class TeacherPanel extends React.Component {
static propTypes = {
onSelectUser: PropTypes.func,
getSelectedUserId: PropTypes.func,
Expand Down Expand Up @@ -105,7 +105,7 @@ class ScriptTeacherPanel extends React.Component {
const sectionId = selectedSection && selectedSection.id;

return (
<TeacherPanel>
<TeacherPanelContainer>
<h3>{i18n.teacherPanel()}</h3>
<div style={styles.scrollable}>
<ViewAsToggle />
Expand Down Expand Up @@ -188,12 +188,12 @@ class ScriptTeacherPanel extends React.Component {
/>
)}
</div>
</TeacherPanel>
</TeacherPanelContainer>
);
}
}

export const UnconnectedScriptTeacherPanel = ScriptTeacherPanel;
export const UnconnectedTeacherPanel = TeacherPanel;
export default connect(state => {
const {stagesBySectionId, lockableAuthorized} = state.stageLock;
const {
Expand Down Expand Up @@ -228,4 +228,4 @@ export default connect(state => {
unlockedStageNames: unlockedStageIds.map(id => stageNames[id]),
students: state.teacherSections.selectedStudents
};
})(ScriptTeacherPanel);
})(TeacherPanel);
4 changes: 2 additions & 2 deletions apps/src/code-studio/teacherPanelHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ReactDOM from 'react-dom';
import {reload} from '@cdo/apps/utils';
import {updateQueryParam} from '@cdo/apps/code-studio/utils';
import {setStudentsForCurrentSection} from '@cdo/apps/templates/teacherDashboard/teacherSectionsRedux';
import ScriptTeacherPanel from './components/progress/ScriptTeacherPanel';
import TeacherPanel from './components/progress/TeacherPanel';

/**
* Render our teacher panel that shows up on our course overview page.
Expand Down Expand Up @@ -44,7 +44,7 @@ export function renderTeacherPanel(

ReactDOM.render(
<Provider store={store}>
<ScriptTeacherPanel
<TeacherPanel
sectionData={sectionData}
onSelectUser={onSelectUser}
scriptName={scriptName}
Expand Down
4 changes: 2 additions & 2 deletions apps/src/templates/instructions/InstructionsWithWorkspace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import {connect} from 'react-redux';
import CodeWorkspaceContainer from '../CodeWorkspaceContainer';
import TopInstructionsCSP from './TopInstructionsCSP';
import TopInstructions from './TopInstructions';
import {setInstructionsMaxHeightAvailable} from '../../redux/instructions';

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ export class UnwrappedInstructionsWithWorkspace extends React.Component {
render() {
return (
<span>
<TopInstructionsCSP />
<TopInstructions />
<CodeWorkspaceContainer
ref={this.setCodeWorkspaceContainerRef}
topMargin={this.props.instructionsHeight}
Expand Down
4 changes: 2 additions & 2 deletions apps/src/templates/instructions/MarkdownInstructions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MarkdownInstructions extends React.Component {
componentWillUnmount() {
const detailsDOM = $(ReactDOM.findDOMNode(this)).find('details');
if (detailsDOM.details) {
detailsDOM.off('toggle.details.TopInstructionsCSP');
detailsDOM.off('toggle.details.TopInstructions');
}
}

Expand All @@ -72,7 +72,7 @@ class MarkdownInstructions extends React.Component {
if (detailsDOM.details) {
detailsDOM.details();
detailsDOM.on({
'toggle.details.TopInstructionsCSP': () => {
'toggle.details.TopInstructions': () => {
this.props.onResize();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const audioStyle = {
}
};

class TopInstructionsCSP extends Component {
class TopInstructions extends Component {
static propTypes = {
isEmbedView: PropTypes.bool.isRequired,
hasContainedLevels: PropTypes.bool,
Expand Down Expand Up @@ -682,7 +682,7 @@ class TopInstructionsCSP extends Component {
);
}
}
export const UnconnectedTopInstructionsCSP = TopInstructionsCSP;
export const UnconnectedTopInstructions = TopInstructions;
export default connect(
state => ({
isEmbedView: state.pageConstants.isEmbedView,
Expand Down Expand Up @@ -725,4 +725,4 @@ export default connect(
}),
null,
{withRef: true}
)(Radium(TopInstructionsCSP));
)(Radium(TopInstructions));
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import {shallow} from 'enzyme';
import {assert, expect} from '../../../../util/reconfiguredChai';
import {UnconnectedScriptTeacherPanel as ScriptTeacherPanel} from '@cdo/apps/code-studio/components/progress/ScriptTeacherPanel';
import {UnconnectedTeacherPanel as TeacherPanel} from '@cdo/apps/code-studio/components/progress/TeacherPanel';
import {ViewType} from '@cdo/apps/code-studio/viewAsRedux';
import TeacherPanel from '@cdo/apps/code-studio/components/TeacherPanel';
import TeacherPanelContainer from '@cdo/apps/code-studio/components/TeacherPanelContainer';
import SectionSelector from '@cdo/apps/code-studio/components/progress/SectionSelector';
import ViewAsToggle from '@cdo/apps/code-studio/components/progress/ViewAsToggle';
import i18n from '@cdo/locale';
Expand All @@ -23,61 +23,61 @@ const MINIMUM_PROPS = {

const students = [{id: 1, name: 'Student 1'}, {id: 2, name: 'Student 2'}];

describe('ScriptTeacherPanel', () => {
describe('TeacherPanel', () => {
describe('on script page', () => {
it('initial view as student', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Student} />
<TeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Student} />
);

expect(
wrapper.containsMatchingElement(
<TeacherPanel>
<TeacherPanelContainer>
<h3>{i18n.teacherPanel()}</h3>
<div>
<ViewAsToggle />
<div>{i18n.loading()}</div>
</div>
</TeacherPanel>
</TeacherPanelContainer>
)
).to.be.true;
});

it('initial view as teacher', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Teacher} />
<TeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Teacher} />
);
assert(
wrapper.containsMatchingElement(
<TeacherPanel>
<TeacherPanelContainer>
<h3>{i18n.teacherPanel()}</h3>
<div>
<ViewAsToggle />
<div>{i18n.loading()}</div>
</div>
</TeacherPanel>
</TeacherPanelContainer>
)
);
});
});

it('shows loading message when sections are not loaded', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={false} />
<TeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={false} />
);
assert(wrapper.containsMatchingElement(<div>{i18n.loading()}</div>));
});

it('hides loading message when sections are loaded', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={true} />
<TeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={true} />
);
assert(!wrapper.containsMatchingElement(<div>{i18n.loading()}</div>));
});

it('shows SectionSelector if hasSections and sectionsAreLoaded', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
hasSections={true}
sectionsAreLoaded={true}
Expand All @@ -88,21 +88,21 @@ describe('ScriptTeacherPanel', () => {

it('hides SectionSelector if hasSections is false', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} hasSections={false} />
<TeacherPanel {...MINIMUM_PROPS} hasSections={false} />
);
assert(!wrapper.containsMatchingElement(<SectionSelector />));
});

it('hides SectionSelector if sectionsAreLoaded is false', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={false} />
<TeacherPanel {...MINIMUM_PROPS} sectionsAreLoaded={false} />
);
assert(!wrapper.containsMatchingElement(<SectionSelector />));
});

it('shows section selection instructions if viewing as a teacher, and has sections and lockable stages', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
scriptHasLockableStages={true}
Expand All @@ -120,7 +120,7 @@ describe('ScriptTeacherPanel', () => {

it('adds a warning if there are also unlocked stages', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
scriptHasLockableStages={true}
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('ScriptTeacherPanel', () => {
describe('StudentTable', () => {
it('displays StudentTable for teacher with students', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
students={students}
Expand All @@ -164,7 +164,7 @@ describe('ScriptTeacherPanel', () => {

it('does not display StudentTable for teacher with no students', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
students={[]}
Expand All @@ -175,7 +175,7 @@ describe('ScriptTeacherPanel', () => {

it('does not display StudentTable for student', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Student}
students={students}
Expand All @@ -189,7 +189,7 @@ describe('ScriptTeacherPanel', () => {
describe('on script', () => {
it('does not display SelectedStudentInfo', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
students={students}
Expand All @@ -205,7 +205,7 @@ describe('ScriptTeacherPanel', () => {
describe('on level', () => {
it('displays SelectedStudentInfo when student selected', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
students={students}
Expand All @@ -229,7 +229,7 @@ describe('ScriptTeacherPanel', () => {
describe('on script', () => {
it('does not display example solutions', () => {
const wrapper = shallow(
<ScriptTeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Teacher} />
<TeacherPanel {...MINIMUM_PROPS} viewAs={ViewType.Teacher} />
);
expect(wrapper.find('Button')).to.have.length(0);
});
Expand All @@ -238,7 +238,7 @@ describe('ScriptTeacherPanel', () => {
describe('on level', () => {
it('displays example solution for level with one example solution', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
sectionData={{
Expand All @@ -257,7 +257,7 @@ describe('ScriptTeacherPanel', () => {

it('does not display example solution for level with no example solution', () => {
const wrapper = shallow(
<ScriptTeacherPanel
<TeacherPanel
{...MINIMUM_PROPS}
viewAs={ViewType.Teacher}
sectionData={{
Expand Down