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

show hidden unit warning banner on script overview page #24695

Merged
merged 4 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@
"helpTips": "Help & Tips",
"hidden": "Hidden",
"hiddenScriptTooltip": "Please select a section before trying to toggle whether or not the unit is visible to your students.",
"hiddenUnitWarningNotice": "The unit is hidden for this section",
"hiddenUnitWarningDetails": "Go to the course overview page to update which units are visible to your students by clicking \"View all units.\"",
"hide": "Hide",
"hideArchivedSections": "Hide archived sections",
"hideFullList": "Hide full list",
Expand Down
11 changes: 11 additions & 0 deletions apps/src/code-studio/components/progress/ScriptOverview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ProgressLegend from '@cdo/apps/templates/progress/ProgressLegend';
import { resourceShape } from '@cdo/apps/templates/courseOverview/resourceType';
import { hasLockableStages } from '@cdo/apps/code-studio/progressRedux';
import ScriptOverviewHeader from './ScriptOverviewHeader';
import { isScriptHiddenForSection } from '@cdo/apps/code-studio/hiddenStageRedux';

/**
* Stage progress component used in level header and script overview.
Expand Down Expand Up @@ -47,6 +48,8 @@ class ScriptOverview extends React.Component {
currentCourseId: PropTypes.number,
scriptHasLockableStages: PropTypes.bool.isRequired,
scriptAllowsHiddenStages: PropTypes.bool.isRequired,
hiddenStageState: PropTypes.object,
selectedSectionId: PropTypes.string,
};

render() {
Expand All @@ -69,6 +72,8 @@ class ScriptOverview extends React.Component {
showCourseUnitVersionWarning,
showScriptVersionWarning,
versions,
hiddenStageState,
selectedSectionId,
} = this.props;

let scriptProgress = NOT_STARTED;
Expand All @@ -78,13 +83,17 @@ class ScriptOverview extends React.Component {
scriptProgress = IN_PROGRESS;
}

const isHiddenUnit = !!selectedSectionId && !!scriptId &&
isScriptHiddenForSection(hiddenStageState, selectedSectionId, scriptId);

return (
<div>
{onOverviewPage && (
<div>
<ScriptOverviewHeader
showCourseUnitVersionWarning={showCourseUnitVersionWarning}
showScriptVersionWarning={showScriptVersionWarning}
showHiddenUnitWarning={isHiddenUnit}
versions={versions}
/>
{!professionalLearningCourse && viewAs === ViewType.Teacher &&
Expand Down Expand Up @@ -129,4 +138,6 @@ export default connect(state => ({
currentCourseId: state.progress.courseId,
scriptHasLockableStages: state.stageLock.lockableAuthorized && hasLockableStages(state.progress),
scriptAllowsHiddenStages: state.hiddenStage.hideableStagesAllowed,
hiddenStageState: state.hiddenStage,
selectedSectionId: state.teacherSections.selectedSectionId,
}))(UnconnectedScriptOverview);
13 changes: 13 additions & 0 deletions apps/src/code-studio/components/progress/ScriptOverviewHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ScriptOverviewHeader extends Component {
version_year: PropTypes.string.isRequired,
version_title: PropTypes.string.isRequired,
})).isRequired,
showHiddenUnitWarning: PropTypes.bool,
};

componentDidMount() {
Expand Down Expand Up @@ -113,6 +114,7 @@ class ScriptOverviewHeader extends Component {
showCourseUnitVersionWarning,
showScriptVersionWarning,
versions,
showHiddenUnitWarning,
} = this.props;

let verifiedResourcesAnnounce = [];
Expand Down Expand Up @@ -156,6 +158,17 @@ class ScriptOverviewHeader extends Component {
onDismiss={this.onDismissVersionWarning}
/>
}
{showHiddenUnitWarning &&
<Notification
type={NotificationType.warning}
notice={i18n.hiddenUnitWarningNotice()}
details={i18n.hiddenUnitWarningDetails()}
dismissible={false}
width={SCRIPT_OVERVIEW_WIDTH}
buttonText={i18n.learnMore()}
buttonLink="https://support.code.org/hc/en-us/articles/115001479372-Hiding-units-and-lessons-in-Code-org-s-CS-Principles-and-CS-Discoveries-courses"
/>
}
<div id="lesson">
<div id="heading" style={styles.heading}>
<div style={styles.titleWrapper}>
Expand Down
3 changes: 3 additions & 0 deletions apps/src/code-studio/hiddenStageRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ function postToggleHidden(scriptName, sectionId, stageId, hidden) {
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(data)
}).success(() => {
window.__TestInterface = window.__TestInterface || {};
window.__TestInterface.toggleHiddenUnitComplete = true;
});
}

Expand Down
3 changes: 3 additions & 0 deletions dashboard/test/ui/features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,9 @@ def refute_bad_gateway_or_site_unreachable

Then /^I hide unit "([^"]+)"$/ do |unit_name|
@browser.execute_script("$('.uitest-CourseScript:contains(#{unit_name}) .fa-eye-slash').click();")
wait_short_until do
@browser.execute_script("return window.__TestInterface.toggleHiddenUnitComplete;")
end
end

Then /^unit "([^"]+)" is marked as (not )?visible$/ do |unit_name, negation|
Expand Down
6 changes: 5 additions & 1 deletion dashboard/test/ui/features/teacher_homepage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ Feature: Using the teacher homepage sections feature

# Hide a unit from the section
When I hide unit "CSP Unit 2 - Digital Information"
And I wait for 5 seconds
And unit "CSP Unit 2 - Digital Information" is marked as not visible

# Verify hidden unit warning banner appears
When I am on "http://studio.code.org/s/csp2-2017"
And I wait until element "#script-title" is visible
Then I wait until element ".announcement-notification:contains(unit is hidden)" is visible

# Try to assign the unit
Given I am on "http://studio.code.org/home"
And I click selector ".ui-test-section-dropdown"
Expand Down