1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00

improvements to post editor and board viewer

This commit is contained in:
Enrico Fasoli 2015-12-17 19:51:54 +01:00
parent d335992af0
commit 0bf9dcca1f
2 changed files with 18 additions and 9 deletions

View File

@ -46,13 +46,14 @@ module.exports = function (boardsAPI) {
} }
}) })
}, },
init (boards) { componentWillReceiveProps (props) {
if (!this.state.init) { boardsAPI.use(b => this.init(b, props))
if (this.props.params.userid) { },
boards.getBoardSettings(this.props.params.userid, this.props.params.boardname) init (boards, newProps) {
} var props = newProps || this.props
this.setState({ init: true, api: true, boards: boards }) if (!props.params.userid) return
} boards.getBoardSettings(props.params.userid, props.params.boardname)
this.setState({ loading: true, init: true, api: true, userid: boards.getMyID(), boards: boards })
}, },
toolbox () { toolbox () {
return <div className="iconbar text-center"> return <div className="iconbar text-center">
@ -63,7 +64,11 @@ module.exports = function (boardsAPI) {
render () { render () {
if (this.state.api) { if (this.state.api) {
if (this.state.loading) { if (this.state.loading) {
return <Loading title="Downloading Board data" /> return <Loading title="Downloading Board data">
{ this.props.params.userid === 'me' || this.props.params.userid === this.state.userid
? <Link to={'/edit/board/' + this.props.params.boardname} className="button button-primary">Edit Board</Link>
: <span></span> }
</Loading>
} else { } else {
return (<div className="board"> return (<div className="board">
<h2>{this.state.name}</h2> <h2>{this.state.name}</h2>

View File

@ -24,7 +24,7 @@ module.exports = function (boardsAPI) {
}, },
init (boards) { init (boards) {
if (this.state.init) return if (this.state.init) return
this.setState({ api: boards, init: true }) this.setState({ api: boards, userid: boards.getMyID(), init: true })
if (this.props.params.posthash) this.downloadPost(boards) if (this.props.params.posthash) this.downloadPost(boards)
}, },
downloadPost (boards) { downloadPost (boards) {
@ -88,6 +88,9 @@ module.exports = function (boardsAPI) {
<button className="button button-primary center-block" onClick={this.skip}>Skip</button> <button className="button button-primary center-block" onClick={this.skip}>Skip</button>
</Saving> </Saving>
} else { } else {
if (this.state.userid && this.props.params.boardname) {
var boardurl = '/@' + this.state.userid + '/' + this.props.params.boardname
}
return ( return (
<div className="editor"> <div className="editor">
<h2><Icon name="pencil" className="light" /> <h2><Icon name="pencil" className="light" />
@ -109,6 +112,7 @@ module.exports = function (boardsAPI) {
</div> </div>
<div className="buttons"> <div className="buttons">
<button className="button button-primary" onClick={this.save}>Publish</button> <button className="button button-primary" onClick={this.save}>Publish</button>
{boardurl ? <Link className="button not-first" to={boardurl}>View Board</Link> : <span></span> }
{this.additionalButtons()} {this.additionalButtons()}
</div> </div>
</div> </div>