mirror of
https://github.com/BoostIo/Boostnote
synced 2026-05-17 04:51:52 +00:00
cleanup redirecting
This commit is contained in:
@@ -20,7 +20,13 @@ var PlanetArticleDetail = React.createClass({
|
|||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var article = this.props.article
|
var article = this.props.article
|
||||||
|
if (article == null) {
|
||||||
|
return (
|
||||||
|
<div className='PlanetArticleDetail'>
|
||||||
|
Nothing selected
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
var tags = article.Tags.length > 0 ? article.Tags.map(function (tag) {
|
var tags = article.Tags.length > 0 ? article.Tags.map(function (tag) {
|
||||||
return (
|
return (
|
||||||
<a key={tag.id} href>#{tag.name}</a>
|
<a key={tag.id} href>#{tag.name}</a>
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ module.exports = React.createClass({
|
|||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
return {
|
return {
|
||||||
currentPlanet: null,
|
currentPlanet: null,
|
||||||
filteredArticles: [],
|
|
||||||
search: '',
|
search: '',
|
||||||
isFetched: false
|
isFetched: false
|
||||||
}
|
}
|
||||||
@@ -136,16 +135,16 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectNextArticle: function () {
|
selectNextArticle: function () {
|
||||||
if (this.state.currentPlanet == null || this.state.filteredArticles.length === 0) return
|
if (this.state.currentPlanet == null) return
|
||||||
|
|
||||||
var index = this.getFilteredIndexOfCurrentArticle()
|
var index = this.getFilteredIndexOfCurrentArticle()
|
||||||
|
|
||||||
if (index < this.state.filteredArticles.length - 1) {
|
if (index < this.refs.list.props.articles.length - 1) {
|
||||||
this.selectArticleByIndex(index + 1)
|
this.selectArticleByIndex(index + 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectPriorArticle: function () {
|
selectPriorArticle: function () {
|
||||||
if (this.state.currentPlanet == null || this.state.filteredArticles.length === 0) {
|
if (this.state.currentPlanet == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var index = this.getFilteredIndexOfCurrentArticle()
|
var index = this.getFilteredIndexOfCurrentArticle()
|
||||||
@@ -162,30 +161,10 @@ module.exports = React.createClass({
|
|||||||
if (res.status === 'planetFetched') {
|
if (res.status === 'planetFetched') {
|
||||||
var planet = res.data
|
var planet = res.data
|
||||||
this.setState({isFetched: true, currentPlanet: planet, filteredArticles: planet.Articles}, function () {
|
this.setState({isFetched: true, currentPlanet: planet, filteredArticles: planet.Articles}, function () {
|
||||||
if (this.state.filteredArticles.length > 0) {
|
if (this.refs.detail.props.article == null) {
|
||||||
if (this.props.params.localId == null) {
|
var params = this.props.params
|
||||||
var article = this.state.filteredArticles[0]
|
delete params.localId
|
||||||
if (article == null) return
|
this.transitionTo('planetHome', params)
|
||||||
this.transitionTo(article.type === 'snippet' ? 'snippets' : 'blueprints', {
|
|
||||||
userName: this.props.params.userName,
|
|
||||||
planetName: this.props.params.planetName,
|
|
||||||
localId: planet.Articles[0].localId
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.isActive('snippets')) {
|
|
||||||
this.transitionTo('snippets', {
|
|
||||||
userName: this.props.params.userName,
|
|
||||||
planetName: this.props.params.planetName,
|
|
||||||
localId: this.props.params.localId == null ? planet.Articles[0].localId : this.props.params.localId
|
|
||||||
})
|
|
||||||
} else if (this.isActive('blueprints')) {
|
|
||||||
this.transitionTo('blueprints', {
|
|
||||||
userName: this.props.params.userName,
|
|
||||||
planetName: this.props.params.planetName,
|
|
||||||
localId: this.props.params.localId == null ? planet.Articles[0].localId : this.props.params.localId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@@ -236,6 +215,7 @@ module.exports = React.createClass({
|
|||||||
this.setState({isLaunchModalOpen: false})
|
this.setState({isLaunchModalOpen: false})
|
||||||
},
|
},
|
||||||
openEditModal: function () {
|
openEditModal: function () {
|
||||||
|
if (this.refs.detail.props.article == null) {return}
|
||||||
this.setState({isEditModalOpen: true})
|
this.setState({isEditModalOpen: true})
|
||||||
},
|
},
|
||||||
closeEditModal: function () {
|
closeEditModal: function () {
|
||||||
@@ -245,6 +225,7 @@ module.exports = React.createClass({
|
|||||||
this.setState({isEditModalOpen: false})
|
this.setState({isEditModalOpen: false})
|
||||||
},
|
},
|
||||||
openDeleteModal: function () {
|
openDeleteModal: function () {
|
||||||
|
if (this.refs.detail.props.article == null) {return}
|
||||||
this.setState({isDeleteModalOpen: true})
|
this.setState({isDeleteModalOpen: true})
|
||||||
},
|
},
|
||||||
closeDeleteModal: function () {
|
closeDeleteModal: function () {
|
||||||
@@ -355,12 +336,6 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
var filteredArticles = this.state.isFetched ? searchArticle(this.state.search, this.state.currentPlanet.Articles) : []
|
var filteredArticles = this.state.isFetched ? searchArticle(this.state.search, this.state.currentPlanet.Articles) : []
|
||||||
|
|
||||||
var content = article != null ? (
|
|
||||||
<PlanetArticleDetail article={article} onOpenEditModal={this.openEditModal} onOpenDeleteModal={this.openDeleteModal}/>
|
|
||||||
) : (
|
|
||||||
<div className='PlanetArticleDetail'>Nothing selected</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
var editModal = article != null ? (article.type === 'snippet' ? (
|
var editModal = article != null ? (article.type === 'snippet' ? (
|
||||||
<SnippetEditModal snippet={article} submit={this.submitEditModal} close={this.closeEditModal}/>
|
<SnippetEditModal snippet={article} submit={this.submitEditModal} close={this.closeEditModal}/>
|
||||||
) : (
|
) : (
|
||||||
@@ -392,7 +367,8 @@ module.exports = React.createClass({
|
|||||||
<PlanetNavigator onOpenLaunchModal={this.openLaunchModal} currentPlanet={this.state.currentPlanet} currentUser={user}/>
|
<PlanetNavigator onOpenLaunchModal={this.openLaunchModal} currentPlanet={this.state.currentPlanet} currentUser={user}/>
|
||||||
|
|
||||||
<PlanetArticleList ref='list' articles={filteredArticles}/>
|
<PlanetArticleList ref='list' articles={filteredArticles}/>
|
||||||
{content}
|
|
||||||
|
<PlanetArticleDetail ref='detail' article={article} onOpenEditModal={this.openEditModal} onOpenDeleteModal={this.openDeleteModal}/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user