forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseWizard.js
More file actions
138 lines (125 loc) · 4.46 KB
/
Copy pathCourseWizard.js
File metadata and controls
138 lines (125 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Copyright (C) 2014 - 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 $ from 'jquery'
import React from 'react'
import PropTypes from 'prop-types'
import I18n from 'i18n!course_wizard'
import ReactModal from 'react-modal'
import InfoFrame from './InfoFrame'
import Checklist from './Checklist'
import userSettings from 'compiled/userSettings'
import 'compiled/jquery.rails_flash_notifications'
const modalOverrides = {
overlay : {
backgroundColor: 'transparent'
},
content : {
position: 'static',
top: '0',
left: '0',
right: 'auto',
bottom: 'auto',
borderRadius: '0',
border: 'none',
padding: '0'
}
};
var CourseWizard = React.createClass({
displayName: 'CourseWizard',
propTypes: {
showWizard: PropTypes.bool,
overlayClassName: PropTypes.string
},
getInitialState: function () {
return {
showWizard: this.props.showWizard,
selectedItem: ''
};
},
componentDidMount: function () {
this.refs.closeLink.getDOMNode().focus();
$(this.refs.wizardBox.getDOMNode()).removeClass('ic-wizard-box--is-closed');
$.screenReaderFlashMessageExclusive(I18n.t("Course Setup Wizard is showing."));
},
componentWillReceiveProps: function (nextProps) {
this.setState({
showWizard: nextProps.showWizard
}, () => {
$(this.refs.wizardBox.getDOMNode()).removeClass('ic-wizard-box--is-closed');
if (this.state.showWizard) {
this.refs.closeLink.getDOMNode().focus();
}
});
},
/**
* Handles what should happen when a checklist item is clicked.
*/
checklistClickHandler: function (itemToShowKey) {
this.setState({
selectedItem: itemToShowKey
});
},
closeModal: function (event) {
if (event) {
event.preventDefault()
};
var pathname = window.location.pathname;
userSettings.set('hide_wizard_' + pathname, true);
this.setState({
showWizard: false
})
},
render: function () {
return (
<ReactModal
isOpen={this.state.showWizard}
onRequestClose={this.closeModal}
style={modalOverrides}
overlayClassName={this.props.overlayClassName}
>
<main role='main'>
<div ref='wizardBox' className='ic-wizard-box'>
<div className='ic-wizard-box__header'>
<a href='/' className='ic-wizard-box__logo-link'>
<span className='screenreader-only'>{I18n.t('My dashboard')}</span>
</a>
<Checklist className='ic-wizard-box__nav'
selectedItem={this.state.selectedItem}
clickHandler={this.checklistClickHandler}
/>
</div>
<div className='ic-wizard-box__main'>
<div className='ic-wizard-box__close'>
<div className='ic-Expand-link ic-Expand-link--from-right'>
<a ref='closeLink' href='#' className='ic-Expand-link__trigger' onClick={this.closeModal}>
<div className='ic-Expand-link__layout'>
<i className='icon-x ic-Expand-link__icon'></i>
<span className='ic-Expand-link__text'>{I18n.t('Close and return to Canvas')}</span>
</div>
</a>
</div>
</div>
<InfoFrame className='ic-wizard-box__content' itemToShow={this.state.selectedItem} closeModal={this.closeModal} />
</div>
</div>
</main>
</ReactModal>
);
}
});
export default CourseWizard