@@ -65,9 +70,10 @@ export default class LoginPage extends React.Component {
- {this.state.isSending ? (
- Logging in...
- ) : null}
+ {this.state.isSending
+ ? (
+ Logging in...
+ ) : null}
{this.state.error != null ?
-

+
diff --git a/browser/main/index.js b/browser/main/index.js
index a3092cb6..2228cd8a 100644
--- a/browser/main/index.js
+++ b/browser/main/index.js
@@ -13,8 +13,8 @@ require('../styles/main/index.styl')
function onlyUser (state, replaceState) {
var currentUser = JSON.parse(localStorage.getItem('currentUser'))
- if (currentUser == null) replaceState('login', '/login')
- if (state.location.pathname === '/') replaceState('user', '/users/' + currentUser.id)
+ if (currentUser == null) return replaceState('login', '/login')
+ if (state.location.pathname === '/') return replaceState('user', '/users/' + currentUser.id)
}
let routes = (
@@ -62,18 +62,6 @@ React.render((
.then(function (res) {
let user = res.body
store.dispatch(updateUser(user))
-
- let users = [user].concat(user.Teams)
- users.forEach(user => {
- fetchArticles(user.id)
- .then(res => {
- store.dispatch(refreshArticles(user.id, res.body))
- })
- .catch(err => {
- if (err.status == null) throw err
- console.error(err)
- })
- })
})
.catch(function (err) {
console.error(err.message)
diff --git a/browser/main/reducer.js b/browser/main/reducer.js
index 25de8a13..9fd4600b 100644
--- a/browser/main/reducer.js
+++ b/browser/main/reducer.js
@@ -2,17 +2,28 @@ import { combineReducers } from 'redux'
import { findIndex } from 'lodash'
import { SWITCH_USER, SWITCH_FOLDER, SWITCH_MODE, SWITCH_ARTICLE, USER_UPDATE, ARTICLE_REFRESH, ARTICLE_UPDATE, ARTICLE_DESTROY, IDLE_MODE, CREATE_MODE } from './actions'
-const initialCurrentUser = JSON.parse(localStorage.getItem('currentUser'))
const initialStatus = {
mode: IDLE_MODE
}
-// init articles
-let teams = Array.isArray(initialCurrentUser.Teams) ? initialCurrentUser.Teams : []
-let users = [initialCurrentUser, ...teams]
-const initialArticles = users.reduce((res, user) => {
- res['team-' + user.id] = JSON.parse(localStorage.getItem('team-' + user.id))
- return res
-}, {})
+
+function getInitialCurrentUser () {
+ return JSON.parse(localStorage.getItem('currentUser'))
+}
+
+function getInitialArticles () {
+ let initialCurrentUser = getInitialCurrentUser()
+ if (initialCurrentUser == null) return []
+
+ let teams = Array.isArray(initialCurrentUser.Teams) ? initialCurrentUser.Teams : []
+
+ let users = [initialCurrentUser, ...teams]
+ let initialArticles = users.reduce((res, user) => {
+ res['team-' + user.id] = JSON.parse(localStorage.getItem('team-' + user.id))
+ return res
+ }, {})
+
+ return initialArticles
+}
function currentUser (state, action) {
switch (action.type) {
@@ -21,7 +32,7 @@ function currentUser (state, action) {
localStorage.setItem('currentUser', JSON.stringify(user))
return user
default:
- if (state == null) return initialCurrentUser
+ if (state == null) return getInitialCurrentUser()
return state
}
}
@@ -39,10 +50,10 @@ function status (state, action) {
return state
case SWITCH_MODE:
state.mode = action.data
- if (state.mode === CREATE_MODE) state.articleId = null
+ if (state.mode === CREATE_MODE) state.articleKey = null
return state
case SWITCH_ARTICLE:
- state.articleId = action.data
+ state.articleKey = action.data
state.mode = IDLE_MODE
return state
default:
@@ -94,7 +105,7 @@ function articles (state, action) {
}
return state
default:
- if (state == null) return initialArticles
+ if (state == null) return getInitialArticles()
return state
}
}
diff --git a/browser/styles/main/HomeContainer/components/ArticleNavigator.styl b/browser/styles/main/HomeContainer/components/ArticleNavigator.styl
index a2f02d45..da74fba6 100644
--- a/browser/styles/main/HomeContainer/components/ArticleNavigator.styl
+++ b/browser/styles/main/HomeContainer/components/ArticleNavigator.styl
@@ -45,6 +45,9 @@ articleNavBgColor = #353535
width 170px
border-radius 5px
font-size 20px
+ transition 0.1s
+ &:hover
+ background-color lighten(brandColor, 7%)
.folders, .members
.header
border-bottom 1px solid borderColor
diff --git a/browser/styles/main/HomeContainer/index.styl b/browser/styles/main/HomeContainer/index.styl
index 6210d6ca..4009c6ed 100644
--- a/browser/styles/main/HomeContainer/index.styl
+++ b/browser/styles/main/HomeContainer/index.styl
@@ -6,3 +6,4 @@
@require './lib/modal'
@require './lib/CreateNewTeam'
+@require './lib/CreateNewFolder'
diff --git a/browser/styles/main/HomeContainer/lib/CreateNewFolder.styl b/browser/styles/main/HomeContainer/lib/CreateNewFolder.styl
new file mode 100644
index 00000000..0da43f58
--- /dev/null
+++ b/browser/styles/main/HomeContainer/lib/CreateNewFolder.styl
@@ -0,0 +1,75 @@
+tabNavColor = #999999
+iptFocusBorderColor = #369DCD
+
+.CreateNewFolder.modal
+ width 600px
+ height 450px
+ .closeBtn
+ position absolute
+ top 15px
+ right 15px
+ width 33px
+ height 33px
+ font-size 18px
+ line-height 33px
+ padding 0
+ text-align center
+ background-color transparent
+ border none
+ color stripBtnColor
+ &:hover
+ color stripHoverBtnColor
+ .title
+ font-size 32px
+ text-align center
+ font-weight bold
+ margin-top 25px
+ .ipt
+ display block
+ width 330px
+ font-size 14px
+ height 44px
+ line-height 44px
+ padding 0 15px
+ border-radius 5px
+ border solid 1px borderColor
+ outline none
+ margin 100px auto 25px
+ &:focus
+ border-color iptFocusBorderColor
+ .public
+ margin 0 auto
+ text-align center
+ button
+ border none
+ background-color transparent
+ font-size 18px
+ color inactiveTextColor
+ transition 0.1s
+ button:hover
+ font-size 22px
+ button.active
+ color brandColor
+ font-size 22px
+ .divider
+ margin 0 5px
+ .confirmBtn
+ display block
+ position absolute
+ left 180px
+ bottom 44px
+ width 240px
+ font-size 24px
+ height 44px
+ line-height 24px
+ font-weight bold
+ background-color brandColor
+ color white
+ border none
+ border-radius 5px
+ margin 0 auto
+ transition 0.1s
+ &:hover
+ transform scale(1.1)
+ &:disabled
+ opacity 0.7
diff --git a/browser/styles/main/HomeContainer/lib/CreateNewTeam.styl b/browser/styles/main/HomeContainer/lib/CreateNewTeam.styl
index 07b2b399..20dc353e 100644
--- a/browser/styles/main/HomeContainer/lib/CreateNewTeam.styl
+++ b/browser/styles/main/HomeContainer/lib/CreateNewTeam.styl
@@ -157,7 +157,7 @@ stripBtnColor = lighten(stripHoverBtnColor, 35%)
height 44px
padding 0 25px
clearfix()
- &nth-last-child(1)
+ &:nth-last-child(1)
border-bottom-color transparent
.userPhoto
width 30px
diff --git a/browser/styles/mixins/marked.styl b/browser/styles/mixins/marked.styl
index 1dcf1947..96f086c4 100644
--- a/browser/styles/mixins/marked.styl
+++ b/browser/styles/mixins/marked.styl
@@ -46,7 +46,7 @@ marked()
margin-bottom 35px
li
display list-item
- margin 15px 0
+ line-height 1.8em
&>li>ul
list-style-type circle
&>li>ul
@@ -57,7 +57,7 @@ marked()
margin-bottom 35px
li
display list-item
- margin 15px 0
+ line-height 1.8em
code
font-family monospace
padding 2px 4px
diff --git a/lib/api.js b/lib/api.js
index e2d1a9ca..1874b71c 100644
--- a/lib/api.js
+++ b/lib/api.js
@@ -88,6 +88,15 @@ export function deleteMember (teamId, input) {
.send(input)
}
+export function createFolder (input) {
+ return request
+ .post(apiUrl + 'folders/')
+ .set({
+ Authorization: 'Bearer ' + localStorage.getItem('token')
+ })
+ .send(input)
+}
+
export function sendEmail (input) {
return request
.post(apiUrl + 'mail')
@@ -109,5 +118,6 @@ export default {
searchUser,
setMember,
deleteMember,
+ createFolder,
sendEmail
}
diff --git a/lib/components/modal/CreateNewFolder.js b/lib/components/modal/CreateNewFolder.js
new file mode 100644
index 00000000..cfdb98e1
--- /dev/null
+++ b/lib/components/modal/CreateNewFolder.js
@@ -0,0 +1,88 @@
+import React, { PropTypes } from 'react'
+import linkState from 'boost/linkState'
+import api from 'boost/api'
+import { pick } from 'lodash'
+
+export default class CreateNewFolder extends React.Component {
+ constructor (props) {
+ super(props)
+
+ this.state = {
+ name: '',
+ public: false
+ }
+ }
+
+ handlePublicButtonClick (value) {
+ console.log(value)
+ return e => {
+ this.setState({public: value})
+ }
+ }
+
+ handleConfirmButton (e) {
+ let { user, close } = this.props
+ let input = pick(this.state, ['public', 'name'])
+ input.UserId = user.id
+
+ api.createFolder(input)
+ .then(res => {
+ console.log(res)
+ close()
+ })
+ .catch(err => {
+ console.log(err)
+ if (err.code === '') {
+ let alert = {
+ type: 'error',
+ message: 'Can\'t connect to API server.'
+ }
+ }
+ else if (err.status != null) {
+ let alert = {
+ type: 'error',
+ message: err.response.body.message
+ }
+ this.setState({alert: alert})
+ }
+ else {
+ throw err
+ }
+ })
+ }
+
+ render () {
+ let alert = this.state.alert
+ let alertEl = alert != null ? (
+
+ {alert.message}
+
+ ) : null
+
+ return (
+
+
+
+
Create new folder
+
+
+
+
+
+ /
+
+
+ {alertEl}
+
+
+
+ )
+ }
+}
+
+CreateNewFolder.propTypes = {
+ user: PropTypes.shape(),
+ close: PropTypes.func
+}
+
+CreateNewFolder.prototype.linkState = linkState
diff --git a/lib/components/modal/CreateNewTeam.js b/lib/components/modal/CreateNewTeam.js
index 5ffbb18d..bd1d4211 100644
--- a/lib/components/modal/CreateNewTeam.js
+++ b/lib/components/modal/CreateNewTeam.js
@@ -144,7 +144,7 @@ export default class CreateNewTeam extends React.Component {
role: 'member'
}
- return function (e) {
+ return e => {
deleteMember(selectState.team.id, input)
.then(res => {
let selectState = this.state.select
@@ -162,7 +162,7 @@ export default class CreateNewTeam extends React.Component {
if (err.status != null) throw err
else console.error(err)
})
- }.bind(this)
+ }
}
handleMemberRoleChange (name) {