Merge pull request #1356 from xavcz/fix-custom-package

🐙 Fix custom package
This commit is contained in:
Sacha Greif 2016-06-18 18:27:03 +09:00 committed by GitHub
commit 36bd733649
5 changed files with 20 additions and 20 deletions

View file

@ -1,4 +1,5 @@
import React, { PropTypes, Component } from 'react'; import React, { PropTypes, Component } from 'react';
import moment from 'moment';
class CustomPostsItem extends Telescope.components.PostsItem { class CustomPostsItem extends Telescope.components.PostsItem {

View file

@ -0,0 +1,7 @@
/*
Let's add an international label to the field added in custom_fields.js
*/
Telescope.strings.en = {
...Telescope.strings.en, // get all the string translated
"posts.color": "Color" // add a new one (collection.field: "Label")
};

View file

@ -5,4 +5,5 @@ Let's import all our files here.
import "./callbacks.js" import "./callbacks.js"
import "./components.js" import "./components.js"
import "./custom_fields.js" import "./custom_fields.js"
import "./routes.jsx" import "./intl.js"
import "./routes.jsx"

View file

@ -3,15 +3,6 @@ A new custom route for our custom page.
Browse to http://localhost:3000/my-custom-route to see it. Browse to http://localhost:3000/my-custom-route to see it.
*/ */
import React from 'react';
import {mount} from 'react-mounter';
import MyCustomPage from './components/MyCustomPage.jsx'; import MyCustomPage from './components/MyCustomPage.jsx';
FlowRouter.route('/my-custom-route', { Telescope.routes.add({name:"myCustomRoute", path:"/my-custom-route", component:MyCustomPage});
name: 'myCustomRoute',
action(params, queryParams) {
mount(Telescope.components.App, {content: <MyCustomPage />})
}
});

View file

@ -60,6 +60,14 @@ class Newsletter extends Component {
Cookie.save('showBanner', "no"); Cookie.save('showBanner', "no");
} }
renderButton() {
return <Telescope.components.NewsletterButton
successCallback={() => this.successCallbackSubscription}
subscribeText={this.context.intl.formatMessage({id: "newsletter.subscribe"})}
user={this.context.currentUser}
/>
}
renderForm() { renderForm() {
return ( return (
<Formsy.Form className="newsletter-form" onSubmit={this.subscribeEmail}> <Formsy.Form className="newsletter-form" onSubmit={this.subscribeEmail}>
@ -76,20 +84,12 @@ class Newsletter extends Component {
} }
render() { render() {
const currentUser = this.context.currentUser;
return this.state.showBanner return this.state.showBanner
? ( ? (
<div className="newsletter"> <div className="newsletter">
<h4 className="newsletter-tagline"><FormattedMessage id="newsletter.subscribe_prompt"/></h4> <h4 className="newsletter-tagline"><FormattedMessage id="newsletter.subscribe_prompt"/></h4>
{this.context.currentUser {this.context.currentUser ? this.renderButton() : this.renderForm()}
? <Telescope.components.NewsletterButton
successCallback={() => this.successCallbackSubscription}
subscribeText={this.context.intl.formatMessage({id: "newsletter.subscribe"})}
user={currentUser}
/>
: this.renderForm()
}
<a onClick={this.dismissBanner} className="newsletter-close"><Telescope.components.Icon name="close"/></a> <a onClick={this.dismissBanner} className="newsletter-close"><Telescope.components.Icon name="close"/></a>
</div> </div>
) : null; ) : null;