Skip to content

Commit

Permalink
Merge pull request #43702 from code-dot-org/emergency-mode-banners
Browse files Browse the repository at this point in the history
Emergency mode banner for teacher dashboard
  • Loading branch information
hannahbergam committed Nov 22, 2021
2 parents a711617 + 890b381 commit 4e0a9f3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 10 deletions.
2 changes: 2 additions & 0 deletions apps/i18n/common/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@
"disabledProgress1": "Yikes! This week is Hour of Code and we are experiencing even more traffic than we anticipated.",
"disabledProgress2": "Unfortunately, we are not able to save the progress that you make on your course while we are dealing with this issue. Don't worry, your progress from before this week is still safe.",
"disabledProgress3": "You can still try Hour of Code tutorials even though your progress won't save.",
"disabledProgressTeacherDashboard1": "Warning: Progress not saving",
"disabledProgressTeacherDashboard2": "Unfortunately, we are not able to save the progress that your students make on their course while we are dealing with this issue. Don't worry, their progress from before this week is still safe. They can still try Hour of Code tutorials even though their progress won't save.",
"disableMaker": "Disable Maker Toolkit",
"discussionGoal": "Discussion Goal",
"discountCodeSchoolConfirm": "Before you can receive your code, please verify the school at which you teach:",
Expand Down
22 changes: 22 additions & 0 deletions apps/src/templates/teacherDashboard/TeacherDashboardHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import {sectionShape} from '@cdo/apps/templates/teacherDashboard/shapes';
import Button from '../Button';
import DropdownButton from '../DropdownButton';
import {disabledBubblesSupportArticle} from '@cdo/apps/code-studio/disabledBubbles';

class TeacherDashboardHeader extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -70,6 +71,24 @@ class TeacherDashboardHeader extends React.Component {
/>
));

progressNotSavingNotification() {
return (
<Notification
type={NotificationType.failure}
notice={i18n.disabledProgressTeacherDashboard1()}
details={
i18n.disabledProgress1() +
' ' +
i18n.disabledProgressTeacherDashboard2()
}
detailsLinkText={i18n.learnMore()}
detailsLink={disabledBubblesSupportArticle}
detailsLinkNewWindow={true}
dismissable={false}
/>
);
}

render() {
return (
<div>
Expand All @@ -83,6 +102,9 @@ class TeacherDashboardHeader extends React.Component {
restrictSection={this.props.selectedSection.restrictSection}
loginType={this.props.selectedSection.loginType}
/>
{this.props.selectedSection.postMilestoneDisabled && (
<this.progressNotSavingNotification />
)}
<div style={styles.header}>
<div>
<h1>{this.props.selectedSection.name}</h1>
Expand Down
3 changes: 2 additions & 1 deletion apps/src/templates/teacherDashboard/shapes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const sectionShape = PropTypes.shape({
scriptId: PropTypes.number,
grade: PropTypes.string,
providerManaged: PropTypes.bool.isRequired,
restrictSection: PropTypes.bool
restrictSection: PropTypes.bool,
postMilestoneDisabled: PropTypes.bool
});

// Used on the Teacher Dashboard for components that
Expand Down
3 changes: 2 additions & 1 deletion apps/src/templates/teacherDashboard/teacherSectionsRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ export const sectionFromServerSection = serverSection => ({
hidden: serverSection.hidden,
isAssigned: serverSection.isAssigned,
restrictSection: serverSection.restrict_section,
codeReviewEnabled: serverSection.code_review_enabled
codeReviewEnabled: serverSection.code_review_enabled,
postMilestoneDisabled: serverSection.post_milestone_disabled
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const sections = [
studentCount: 10,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
},
{
id: 12,
Expand All @@ -97,7 +98,8 @@ const sections = [
studentCount: 1,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
},
{
id: 307,
Expand All @@ -119,7 +121,8 @@ const sections = [
studentCount: 0,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
}
];

Expand Down Expand Up @@ -646,7 +649,8 @@ describe('teacherSectionsRedux', () => {
hidden: false,
isAssigned: undefined,
restrictSection: false,
codeReviewEnabled: true
codeReviewEnabled: true,
postMilestoneDisabled: false
});
});
});
Expand Down Expand Up @@ -787,7 +791,8 @@ describe('teacherSectionsRedux', () => {
createdAt: createdAt,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
};

function successResponse(customProps = {}) {
Expand Down Expand Up @@ -939,7 +944,8 @@ describe('teacherSectionsRedux', () => {
hidden: false,
isAssigned: undefined,
restrictSection: false,
codeReviewEnabled: true
codeReviewEnabled: true,
postMilestoneDisabled: false
}
});
});
Expand Down Expand Up @@ -995,7 +1001,8 @@ describe('teacherSectionsRedux', () => {
script_id: null,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
};

function successResponse(sectionId, customProps = {}) {
Expand Down Expand Up @@ -1228,7 +1235,8 @@ describe('teacherSectionsRedux', () => {
studentCount: 10,
hidden: false,
restrict_section: false,
code_review_enabled: true
code_review_enabled: true,
post_milestone_disabled: false
};

it('transfers some fields directly, mapping from snake_case to camelCase', () => {
Expand Down Expand Up @@ -1258,6 +1266,10 @@ describe('teacherSectionsRedux', () => {
section.code_review_enabled,
serverSection.codeReviewEnabled
);
assert.strictEqual(
section.post_milestone_disabled,
serverSection.postMilestoneDisabled
);
});

it('maps from a script object to a script_id', () => {
Expand Down
2 changes: 2 additions & 0 deletions dashboard/app/models/sections/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ def summarize(include_students: true)
restrict_section: restrict_section,
code_review_enabled: code_review_enabled?,
is_assigned_csa: assigned_csa?,
# this will be true when we are in emergency mode, for the scripts returned by ScriptConfig.hoc_scripts and ScriptConfig.csf_scripts
post_milestone_disabled: !!script && !Gatekeeper.allows('postMilestone', where: {script_name: script.name}, default: true),
code_review_expires_at: code_review_expires_at
}
end
Expand Down
4 changes: 4 additions & 0 deletions dashboard/test/models/sections/section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def verify(actual, expected)
restrict_section: false,
code_review_enabled: true,
is_assigned_csa: false,
post_milestone_disabled: false,
code_review_expires_at: nil
}
# Compare created_at separately because the object's created_at microseconds
Expand Down Expand Up @@ -437,6 +438,7 @@ def verify(actual, expected)
restrict_section: false,
code_review_enabled: true,
is_assigned_csa: false,
post_milestone_disabled: false,
code_review_expires_at: nil
}
# Compare created_at separately because the object's created_at microseconds
Expand Down Expand Up @@ -483,6 +485,7 @@ def verify(actual, expected)
restrict_section: false,
code_review_enabled: true,
is_assigned_csa: false,
post_milestone_disabled: false,
code_review_expires_at: nil
}
# Compare created_at separately because the object's created_at microseconds
Expand Down Expand Up @@ -523,6 +526,7 @@ def verify(actual, expected)
restrict_section: false,
code_review_enabled: true,
is_assigned_csa: false,
post_milestone_disabled: false,
code_review_expires_at: nil
}
# Compare created_at separately because the object's created_at microseconds
Expand Down

0 comments on commit 4e0a9f3

Please sign in to comment.