Updated oauth2 app register modal

Этот коммит содержится в:
JoramWilander
2015-12-01 11:13:58 -05:00
родитель b717a8100c
Коммит 5707df39bf
5 изменённых файлов: 144 добавлений и 75 удалений

Просмотреть файл

@@ -2,21 +2,57 @@
// See License.txt for license information. // See License.txt for license information.
import * as Client from '../utils/client.jsx'; import * as Client from '../utils/client.jsx';
import ModalStore from '../stores/modal_store.jsx';
const Modal = ReactBootstrap.Modal;
import Constants from '../utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
export default class RegisterAppModal extends React.Component { export default class RegisterAppModal extends React.Component {
constructor() { constructor() {
super(); super();
this.register = this.register.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.onHide = this.onHide.bind(this); this.onHide = this.onHide.bind(this);
this.save = this.save.bind(this); this.save = this.save.bind(this);
this.updateShow = this.updateShow.bind(this);
this.state = {clientId: '', clientSecret: '', saved: false}; this.state = {
clientId: '',
clientSecret: '',
saved: false,
show: false
};
} }
componentDidMount() { componentDidMount() {
$(ReactDOM.findDOMNode(this)).on('hide.bs.modal', this.onHide); ModalStore.addModalListener(ActionTypes.TOGGLE_REGISTER_APP_MODAL, this.updateShow);
} }
register() { componentWillUnmount() {
ModalStore.removeModalListener(ActionTypes.TOGGLE_REGISTER_APP_MODAL, this.updateShow);
}
updateShow(show) {
if (!show) {
if (this.state.clientId !== '' && !this.state.saved) {
return;
}
this.setState({
clientId: '',
clientSecret: '',
saved: false,
homepageError: null,
callbackError: null,
serverError: null,
nameError: null
});
}
this.setState({show});
}
handleSubmit(e) {
e.preventDefault();
var state = this.state; var state = this.state;
state.serverError = null; state.serverError = null;
@@ -94,6 +130,7 @@ export default class RegisterAppModal extends React.Component {
} }
var body = ''; var body = '';
var footer = '';
if (this.state.clientId === '') { if (this.state.clientId === '') {
body = ( body = (
<div className='settings-modal'> <div className='settings-modal'>
@@ -148,24 +185,29 @@ export default class RegisterAppModal extends React.Component {
</div> </div>
</div> </div>
{serverError} {serverError}
<hr />
<a
className='btn btn-sm theme pull-right'
href='#'
data-dismiss='modal'
aria-label='Close'
>
{'Cancel'}
</a>
<a
className='btn btn-sm btn-primary pull-right'
onClick={this.register}
>
{'Register'}
</a>
</div> </div>
</div> </div>
); );
footer = (
<div>
<button
type='button'
className='btn btn-default'
onClick={() => this.updateShow(false)}
>
{'Cancel'}
</button>
<button
onClick={this.handleSubmit}
type='submit'
className='btn btn-primary'
tabIndex='3'
>
{'Register'}
</button>
</div>
);
} else { } else {
var btnClass = ' disabled'; var btnClass = ' disabled';
if (this.state.saved) { if (this.state.saved) {
@@ -173,17 +215,35 @@ export default class RegisterAppModal extends React.Component {
} }
body = ( body = (
<div className='form-group user-settings'> <div className='form-horizontal user-settings'>
<h3>{'Your Application Credentials'}</h3> <h4 className='padding-bottom x3'>{'Your Application Credentials'}</h4>
<br/>
<div className='row'>
<label className='col-sm-4 control-label'>{'Client ID'}</label>
<div className='col-sm-7'>
<input
className='form-control'
type='text'
value={this.state.clientId}
readOnly='true'
/>
</div>
</div>
<br/>
<div className='row padding-top x2'>
<label className='col-sm-4 control-label'>{'Client Secret'}</label>
<div className='col-sm-7'>
<input
className='form-control'
type='text'
value={this.state.clientSecret}
readOnly='true'
/>
</div>
</div>
<br/> <br/>
<br/> <br/>
<label className='col-sm-12 control-label'>{'Client ID: '}{this.state.clientId}</label> <strong>{'Save these somewhere SAFE and SECURE. Treat your Client ID as your app\'s username and your Client Secret as the app\'s password.'}</strong>
<label className='col-sm-12 control-label'>{'Client Secret: '}{this.state.clientSecret}</label>
<br/>
<br/>
<br/>
<br/>
<strong>{'Save these somewhere SAFE and SECURE. We can retrieve your Client Id if you lose it, but your Client Secret will be lost forever if you were to lose it.'}</strong>
<br/> <br/>
<br/> <br/>
<div className='checkbox'> <div className='checkbox'>
@@ -192,56 +252,50 @@ export default class RegisterAppModal extends React.Component {
ref='save' ref='save'
type='checkbox' type='checkbox'
checked={this.state.saved} checked={this.state.saved}
onClick={this.save} onChange={this.save}
> />
{'I have saved both my Client Id and Client Secret somewhere safe'} {'I have saved both my Client Id and Client Secret somewhere safe'}
</input>
</label> </label>
</div> </div>
<a
className={'btn btn-sm btn-primary pull-right' + btnClass}
href='#'
data-dismiss='modal'
aria-label='Close'
>
{'Close'}
</a>
</div> </div>
); );
footer = (
<a
className={'btn btn-sm btn-primary pull-right' + btnClass}
href='#'
onClick={(e) => {
e.preventDefault();
this.updateShow(false);
}}
>
{'Close'}
</a>
);
} }
return ( return (
<div <span>
className='modal fade' <Modal
ref='modal' show={this.state.show}
id='register_app' onHide={() => this.updateShow(false)}
role='dialog' >
aria-hidden='true' <Modal.Header closeButton={true}>
> <Modal.Title>{'Developer Applications'}</Modal.Title>
<div className='modal-dialog'> </Modal.Header>
<div className='modal-content'> <form
<div className='modal-header'> role='form'
<button className='form-horizontal'
type='button' >
className='close' <Modal.Body>
data-dismiss='modal' {body}
aria-label='Close' </Modal.Body>
> <Modal.Footer>
<span aria-hidden='true'>{'×'}</span> {footer}
</button> </Modal.Footer>
<h4 </form>
className='modal-title' </Modal>
ref='title' </span>
>
{'Developer Applications'}
</h4>
</div>
<div className='modal-body'>
{body}
</div>
</div>
</div>
</div>
); );
} }
} }

Просмотреть файл

@@ -3,16 +3,19 @@
import SettingItemMin from '../setting_item_min.jsx'; import SettingItemMin from '../setting_item_min.jsx';
import SettingItemMax from '../setting_item_max.jsx'; import SettingItemMax from '../setting_item_max.jsx';
import * as EventHelpers from '../../dispatcher/event_helpers.jsx';
export default class DeveloperTab extends React.Component { export default class DeveloperTab extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.register = this.register.bind(this);
this.state = {}; this.state = {};
} }
register() { register() {
$('#user_settings1').modal('hide'); this.props.closeModal();
$('#register_app').modal('show'); EventHelpers.showRegisterAppModal();
} }
render() { render() {
var appSection; var appSection;
@@ -21,7 +24,10 @@ export default class DeveloperTab extends React.Component {
var inputs = []; var inputs = [];
inputs.push( inputs.push(
<div className='form-group'> <div
key='registerbtn'
className='form-group'
>
<div className='col-sm-7'> <div className='col-sm-7'>
<a <a
className='btn btn-sm btn-primary' className='btn btn-sm btn-primary'

Просмотреть файл

@@ -104,3 +104,10 @@ export function showInviteMemberModal() {
value: true value: true
}); });
} }
export function showRegisterAppModal() {
AppDispatcher.handleViewAction({
type: ActionTypes.TOGGLE_REGISTER_APP_MODAL,
value: true
});
}

Просмотреть файл

@@ -35,6 +35,7 @@ class ModalStoreClass extends EventEmitter {
case ActionTypes.TOGGLE_INVITE_MEMBER_MODAL: case ActionTypes.TOGGLE_INVITE_MEMBER_MODAL:
case ActionTypes.TOGGLE_DELETE_POST_MODAL: case ActionTypes.TOGGLE_DELETE_POST_MODAL:
case ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL: case ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL:
case ActionTypes.TOGGLE_REGISTER_APP_MODAL:
this.emit(type, value, args); this.emit(type, value, args);
break; break;
} }

Просмотреть файл

@@ -49,7 +49,8 @@ export default {
TOGGLE_IMPORT_THEME_MODAL: null, TOGGLE_IMPORT_THEME_MODAL: null,
TOGGLE_INVITE_MEMBER_MODAL: null, TOGGLE_INVITE_MEMBER_MODAL: null,
TOGGLE_DELETE_POST_MODAL: null, TOGGLE_DELETE_POST_MODAL: null,
TOGGLE_GET_TEAM_INVITE_LINK_MODAL: null TOGGLE_GET_TEAM_INVITE_LINK_MODAL: null,
TOGGLE_REGISTER_APP_MODAL: null
}), }),
PayloadSources: keyMirror({ PayloadSources: keyMirror({