'use strict'; import React from 'react'; import ApplicationStore from '../../stores/application_store'; import ApplicationActions from '../../actions/application_actions'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; import Form from '../ascribe_forms/form'; import Property from '../ascribe_forms/property'; import ActionPanel from '../ascribe_panel/action_panel'; import CollapsibleParagraph from '../ascribe_collapsible/collapsible_paragraph'; import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; import { getLangText } from '../../utils/lang_utils'; let APISettings = React.createClass({ propTypes: { defaultExpanded: React.PropTypes.bool }, getInitialState() { return ApplicationStore.getState(); }, componentDidMount() { ApplicationStore.listen(this.onChange); ApplicationActions.fetchApplication(); }, componentWillUnmount() { ApplicationStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); }, handleCreateSuccess() { ApplicationActions.fetchApplication(); let notification = new GlobalNotificationModel(getLangText('Application successfully created'), 'success', 5000); GlobalNotificationActions.appendGlobalNotification(notification); }, handleTokenRefresh(event) { let applicationName = event.target.getAttribute('data-id'); ApplicationActions.refreshApplicationToken(applicationName); let notification = new GlobalNotificationModel(getLangText('Token refreshed'), 'success', 2000); GlobalNotificationActions.appendGlobalNotification(notification); }, getApplications(){ let content = ; if (this.state.applications.length > -1) { content = this.state.applications.map(function(app, i) { return ( {app.name} {'Bearer ' + app.bearer_token.token} } buttons={ {getLangText('REFRESH')} }/> ); }, this); } return content; }, render() { return ( Usage: curl <url> -H 'Authorization: Bearer <token>' {this.getApplications()} ); } }); export default APISettings;
Usage: curl <url> -H 'Authorization: Bearer <token>'