123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /*
- * Copyright (C) 2015 - present Instructure, Inc.
- *
- * This file is part of Canvas.
- *
- * Canvas is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Affero General Public License as published by the Free
- * Software Foundation, version 3 of the License.
- *
- * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Affero General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- import React from 'react'
- import PropTypes from 'prop-types'
- import I18n from 'i18n!moderated_grading'
- var Header = React.createClass({
- displayName: 'Header',
- propTypes: {
- onPublishClick: PropTypes.func.isRequired,
- onReviewClick: PropTypes.func.isRequired,
- published: PropTypes.bool.isRequired,
- selectedStudentCount: PropTypes.number.isRequired,
- inflightAction: PropTypes.shape({
- review: PropTypes.bool.isRequired,
- publish: PropTypes.bool.isRequired
- }).isRequired,
- permissions: PropTypes.shape({
- editGrades: PropTypes.bool.isRequired
- }).isRequired
- },
- noStudentSelected () {
- return this.props.selectedStudentCount === 0;
- },
- handlePublishClick () {
- // TODO: Make a better looking confirm one day
- var confirmMessage = I18n.t('Are you sure you want to do this? It cannot be undone and will override existing grades in the gradebook.')
- if (window.confirm(confirmMessage)) {
- this.props.onPublishClick();
- }
- },
- renderPublishedMessage () {
- if (this.props.published) {
- return (
- <div className="ic-notification">
- <div className="ic-notification__icon" aria-hidden='true' role="presentation">
- <i className="icon-info"></i>
- </div>
- <div className="ic-notification__content">
- <div className="ic-notification__message">
- <div className="ic-notification__title">
- {I18n.t('Attention!')}
- </div>
- <span className="notification_message">
- {I18n.t('This page cannot be modified because grades have already been posted.')}
- </span>
- </div>
- </div>
- </div>
- );
- }
- },
- renderPostButton () {
- return this.props.permissions.editGrades && (
- <button
- ref={(p) => { this.publishBtn = p; }}
- type="button"
- className="ModeratedGrading__Header-PublishBtn Button Button--primary"
- onClick={this.handlePublishClick}
- disabled={this.props.published || this.props.inflightAction.publish}
- >
- {I18n.t('Post')}
- </button>
- );
- },
- render () {
- return (
- <div>
- {this.renderPublishedMessage()}
- <div className='ModeratedGrading__Header ic-Action-header'>
- <div className='ic-Action-header__Primary'>
- <div className='ic-Action-header__Heading ModeratedGrading__Header-Instructions'>
- {I18n.t('Select students for review')}
- </div>
- </div>
- <div className='ic-Action-header__Secondary ModeratedGrading__Header-Buttons '>
- <button
- ref='addReviewerBtn'
- type='button'
- className='ModeratedGrading__Header-AddReviewerBtn Button'
- onClick={this.props.onReviewClick}
- disabled={
- this.props.published ||
- this.noStudentSelected() ||
- this.props.inflightAction.review
- }
- >
- <span className='screenreader-only'>{I18n.t('Add a reviewer for the selected students')}</span>
- <span aria-hidden='true'>
- <i className='icon-plus' />
- {I18n.t(' Reviewer')}
- </span>
- </button>
- {this.renderPostButton()}
- </div>
- </div>
- </div>
- );
- }
- });
- export default Header
|