mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
Updating queries to mono host and adding start script
This commit is contained in:
@@ -17,7 +17,6 @@ import Flag from '../../coral-plugin-flags/FlagButton'
|
||||
import {ReplyBox, ReplyButton} from '../../coral-plugin-replies'
|
||||
import Pym from 'pym.js'
|
||||
|
||||
console.log(authActions);
|
||||
const {addItem, updateItem, postItem, getItemsQuery, postAction, appendItemRelated} = itemActions
|
||||
const {addNotification, clearNotification} = notificationActions
|
||||
const {setLoggedInUser} = authActions
|
||||
@@ -39,11 +38,11 @@ const {setLoggedInUser} = authActions
|
||||
updateItem: (id, property, value) => {
|
||||
return dispatch(updateItem(id, property, value))
|
||||
},
|
||||
postItem: (host) => (data, type, id) => {
|
||||
return dispatch(postItem(data, type, id, host))
|
||||
postItem: (data, type, id) => {
|
||||
return dispatch(postItem(data, type, id))
|
||||
},
|
||||
getItemsQuery: (host) => (query, rootId, view) => {
|
||||
return dispatch(getItemsQuery(query, rootId, view, host))
|
||||
getItemsQuery: (rootId) => {
|
||||
return dispatch(getItemsQuery(rootId))
|
||||
},
|
||||
addNotification: (type, text) => {
|
||||
return dispatch(addNotification(type, text))
|
||||
@@ -54,8 +53,8 @@ const {setLoggedInUser} = authActions
|
||||
setLoggedInUser: (user_id) => {
|
||||
return dispatch(setLoggedInUser(user_id))
|
||||
},
|
||||
postAction: (host) => (item, action, user) => {
|
||||
return dispatch(postAction(item, action, user, host))
|
||||
postAction: (item, action, user) => {
|
||||
return dispatch(postAction(item, action, user))
|
||||
},
|
||||
appendItemRelated: (item, property, value) => {
|
||||
return dispatch(appendItemRelated(item, property, value))
|
||||
@@ -79,17 +78,15 @@ class CommentStream extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
if (this.props.config.coralHost) {
|
||||
const host = this.props.config.coralHost
|
||||
if (Object.keys(this.props.items).length === 0) {
|
||||
// Loading mock asset
|
||||
this.props.postItem(host)({
|
||||
this.props.postItem({
|
||||
comments: [],
|
||||
url: 'http://coralproject.net'
|
||||
}, 'asset', 'assetTest')
|
||||
|
||||
// Loading mock user
|
||||
this.props.postItem(host)({name: 'Ban Ki-Moon'}, 'user', 'user_8989')
|
||||
this.props.postItem({name: 'Ban Ki-Moon'}, 'user', 'user_8989')
|
||||
.then((id) => {
|
||||
this.props.setLoggedInUser(id)
|
||||
})
|
||||
@@ -100,16 +97,14 @@ class CommentStream extends Component {
|
||||
|
||||
return <RootContainer
|
||||
items={this.props.items}
|
||||
view={this.props.config.view}
|
||||
rootId='assetTest'
|
||||
type='asset'
|
||||
query={this.props.config.query}
|
||||
getItemsQuery={this.props.getItemsQuery(host)}>
|
||||
getItemsQuery={this.props.getItemsQuery}>
|
||||
<Container name="commentBox">
|
||||
<Count data="{item_id,comment(type:'comment'){item_id,child(type:'comment'){item_id}}}"/>
|
||||
<CommentBox
|
||||
addNotification={this.props.addNotification}
|
||||
postItem={this.props.postItem(host)}
|
||||
postItem={this.props.postItem}
|
||||
appendItemRelated={this.props.appendItemRelated}
|
||||
updateItem={this.props.updateItem}
|
||||
data="{item_id}"/>
|
||||
@@ -123,7 +118,7 @@ class CommentStream extends Component {
|
||||
<Flag
|
||||
addNotification={this.props.addNotification}
|
||||
data="{item_id,flag}"
|
||||
postAction={this.props.postAction(host)}
|
||||
postAction={this.props.postAction}
|
||||
currentUser={this.props.auth.user}/>
|
||||
<ReplyButton
|
||||
updateItem={this.props.updateItem}
|
||||
@@ -131,7 +126,7 @@ class CommentStream extends Component {
|
||||
</Container>
|
||||
<ReplyBox
|
||||
addNotification={this.props.addNotification}
|
||||
postItem={this.props.postItem(host)}
|
||||
postItem={this.props.postItem}
|
||||
appendItemRelated={this.props.appendItemRelated}
|
||||
updateItem={this.props.updateItem}
|
||||
data="{item_id,showReply}"/>
|
||||
@@ -144,7 +139,7 @@ class CommentStream extends Component {
|
||||
<Flag
|
||||
addNotificiation={this.props.addNotification}
|
||||
data="{item_id,flag}"
|
||||
postAction={this.props.postAction(host)}
|
||||
postAction={this.props.postAction}
|
||||
currentUser={this.props.auth.user}/>
|
||||
<ReplyButton
|
||||
updateItem={this.props.updateItem}
|
||||
@@ -159,9 +154,6 @@ class CommentStream extends Component {
|
||||
clearNotification={this.props.clearNotification}
|
||||
notification={this.props.notification}/>
|
||||
</RootContainer>
|
||||
} else {
|
||||
return <div>Loading</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
entry: [
|
||||
'babel-polyfill',
|
||||
'webpack-hot-middleware/client',
|
||||
'./src/app'
|
||||
path.join(__dirname, 'src', 'app')
|
||||
],
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist'),
|
||||
|
||||
@@ -2,6 +2,8 @@ const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const Copy = require('copy-webpack-plugin')
|
||||
|
||||
//Keeping this file for reference, it should move to a global webpack.
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
entry: [
|
||||
@@ -9,7 +11,7 @@ module.exports = {
|
||||
'./src/app'
|
||||
],
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist'),
|
||||
path: path.join(__dirname, '..', '..','dist'),
|
||||
filename: 'bundle.js',
|
||||
publicPath: '/dist/'
|
||||
},
|
||||
|
||||
@@ -11,13 +11,12 @@ class RootContainer extends Component {
|
||||
rootId: PropTypes.string.isRequired,
|
||||
items: PropTypes.object.isRequired,
|
||||
type: PropTypes.string.isRequired,
|
||||
query: PropTypes.string.isRequired,
|
||||
getItemsQuery: PropTypes.func.isRequired
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
const {query, getItemsQuery, rootId, view} = this.props
|
||||
getItemsQuery(query, rootId, view)
|
||||
const {getItemsQuery, rootId} = this.props
|
||||
getItemsQuery(rootId)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
@@ -18,9 +18,10 @@ export const fetchConfig = () => async (dispatch) => {
|
||||
dispatch({ type: FETCH_CONFIG_REQUEST })
|
||||
|
||||
try {
|
||||
const response = await fetch(`./talk.config.json`)
|
||||
const json = await response.json()
|
||||
dispatch({ type: FETCH_CONFIG_SUCCESS, config: fromJS(json) })
|
||||
//TODO: Replace with fetching config from backend
|
||||
// const response = await fetch(`./talk.config.json`)
|
||||
// const json = await response.json()
|
||||
dispatch({ type: FETCH_CONFIG_SUCCESS, config: fromJS({}) })
|
||||
} catch (error) {
|
||||
dispatch({ type: FETCH_CONFIG_FAILED })
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ export const appendItemRelated = (item_id, property, value) => {
|
||||
* @dispatches
|
||||
* A set of items to the item store
|
||||
*/
|
||||
export function getItemsQuery (query, rootId, view, host) {
|
||||
export function getItemsQuery (query, rootId) {
|
||||
return (dispatch) => {
|
||||
return fetch(host + '/v1/exec/' + query + '/view/' + view + '/' + rootId)
|
||||
return fetch('/v1/exec/view/' + rootId)
|
||||
.then(
|
||||
response => {
|
||||
return response.ok ? response.json() : Promise.reject(response.status + ' ' + response.statusText)
|
||||
@@ -120,9 +120,9 @@ export function getItemsQuery (query, rootId, view, host) {
|
||||
* A set of items to the item store
|
||||
*/
|
||||
|
||||
export function getItemsArray (ids, host) {
|
||||
export function getItemsArray (ids) {
|
||||
return (dispatch) => {
|
||||
return fetch(host + '/v1/item/' + ids)
|
||||
return fetch('/v1/item/' + ids)
|
||||
.then(
|
||||
response => {
|
||||
return response.ok ? response.json()
|
||||
@@ -152,7 +152,7 @@ export function getItemsArray (ids, host) {
|
||||
* The newly put item to the item store
|
||||
*/
|
||||
|
||||
export function postItem (data, type, id, host) {
|
||||
export function postItem (data, type, id) {
|
||||
return (dispatch) => {
|
||||
let item = {
|
||||
type,
|
||||
@@ -166,7 +166,7 @@ export function postItem (data, type, id, host) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(item)
|
||||
}
|
||||
return fetch(host + '/v1/item', options)
|
||||
return fetch('/v1/item', options)
|
||||
.then(
|
||||
response => {
|
||||
return response.ok ? response.json()
|
||||
@@ -198,13 +198,13 @@ export function postItem (data, type, id, host) {
|
||||
*
|
||||
*/
|
||||
|
||||
export function postAction (item, action, user, host) {
|
||||
export function postAction (item, action, user) {
|
||||
return (dispatch) => {
|
||||
let options = {
|
||||
method: 'POST'
|
||||
}
|
||||
dispatch(appendItemArray(item, action, user))
|
||||
return fetch(host + '/v1/action/' + action + '/user/' + user + '/on/item/' + item, options)
|
||||
return fetch('/v1/action/' + action + '/user/' + user + '/on/item/' + item, options)
|
||||
.then(
|
||||
response => {
|
||||
return response.ok ? response.text()
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"start": "./bin/www"
|
||||
"start": "./bin/www",
|
||||
"embed-start":"node client/coral-embed-stream/dev-server.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user