diff --git a/browser/main/SideNav/FolderItem.js b/browser/main/SideNav/FolderItem.js
deleted file mode 100644
index 937c0397..00000000
--- a/browser/main/SideNav/FolderItem.js
+++ /dev/null
@@ -1,244 +0,0 @@
-import React, { PropTypes } from 'react'
-import CSSModules from 'browser/lib/CSSModules'
-import styles from './FolderItem.styl'
-import store from 'browser/main/store'
-import Repository from 'browser/lib/Repository'
-import consts from 'browser/lib/consts'
-
-const electron = require('electron')
-const { remote } = electron
-const { Menu, MenuItem } = remote
-
-class FolderItem extends React.Component {
- constructor (props) {
- super(props)
-
- this.state = {
- isEditing: false,
- isUpdating: false,
- name: props.folder.name
- }
- }
-
- handleColorButtonClick (color) {
- return (e) => {
- let { repository, folder } = this.props
- this.setState({
- isUpdating: true
- }, () => {
- Repository.find(repository.key)
- .then((repository) => {
- console.log(repository)
- return repository.updateFolder(folder.key, {color: color})
- })
- .then((folder) => {
- store.dispatch({
- type: 'EDIT_FOLDER',
- key: repository.key,
- folder: folder
- })
- this.setState({
- isEditing: false,
- isUpdating: false
- })
- })
- .catch((err) => {
- console.error(err)
- this.setState({
- isEditing: false,
- isUpdating: false
- })
- })
- })
- }
- }
-
- handleContextButtonClick (e) {
- e.stopPropagation()
- if (this.state.isUpdating) {
- return
- }
-
- var menu = new Menu()
- menu.append(new MenuItem({
- label: 'New Note'
- }))
- menu.append(new MenuItem({ type: 'separator' }))
- menu.append(new MenuItem({
- label: 'Rename',
- click: () => this.handleRenameButtonClick(e)
- }))
- var colorMenu = new Menu()
- consts.FOLDER_COLORS.forEach((color, index) => {
- colorMenu.append(new MenuItem({
- label: consts.FOLDER_COLOR_NAMES[index],
- click: (e) => this.handleColorButtonClick(color)(e)
- }))
- })
- menu.append(new MenuItem({
- label: 'Recolor',
- submenu: colorMenu
- }))
- menu.append(new MenuItem({ type: 'separator' }))
- menu.append(new MenuItem({
- label: 'Delete',
- click: () => this.handleDeleteButtonClick(e)
- }))
-
- menu.popup(remote.getCurrentWindow())
- }
-
- handleRenameButtonClick (e) {
- this.setState({
- isEditing: true,
- name: this.props.folder.name
- }, () => {
- this.refs.nameInput.focus()
- this.refs.nameInput.select()
- })
- }
-
- handleDeleteButtonClick (e) {
- let { repository, folder } = this.props
-
- this.setState({
- isUpdating: true
- }, () => {
- Repository.find(repository.key)
- .then((repository) => {
- console.log(repository)
- return repository.removeFolder(folder.key)
- })
- .then(() => {
- store.dispatch({
- type: 'REMOVE_FOLDER',
- repository: repository.key,
- folder: folder.key
- })
- })
- .catch((err) => {
- console.error(err)
- this.setState({
- isUpdating: false
- })
- })
- })
- }
-
- handleClick (e) {
- let { folder, repository } = this.props
- let { router } = this.context
-
- router.push('/repositories/' + repository.key + '/folders/' + folder.key)
- }
-
- renderIdle () {
- let { folder, repository, isFolded } = this.props
- let { router } = this.context
-
- let isActive = router.isActive('/repositories/' + repository.key + '/folders/' + folder.key)
-
- return (
-
this.handleClick(e)}
- onContextMenu={(e) => this.handleContextButtonClick(e)}
- >
-
-
- {folder.name}
-
-
-
-
-
- )
- }
-
- handleNameInputChange (e) {
- this.setState({
- name: e.target.value
- })
- }
-
- handleNameInputBlur (e) {
- let { folder, repository } = this.props
-
- this.setState({
- isUpdating: true
- }, () => {
- Repository.find(repository.key)
- .then((repository) => {
- console.log(repository)
- return repository.updateFolder(folder.key, {name: this.state.name})
- })
- .then((folder) => {
- store.dispatch({
- type: 'EDIT_FOLDER',
- key: repository.key,
- folder: folder
- })
- this.setState({
- isEditing: false,
- isUpdating: false
- })
- })
- .catch((err) => {
- console.error(err)
- this.setState({
- isEditing: false,
- isUpdating: false
- })
- })
- })
- }
-
- renderEdit () {
- let { isFolded } = this.props
- return (
-
- this.handleNameInputChange(e)}
- onBlur={(e) => this.handleNameInputBlur(e)}
- disabled={this.state.isUpdating}
- />
-
- )
- }
-
- render () {
- return this.state.isEditing ? this.renderEdit() : this.renderIdle()
- }
-}
-
-FolderItem.contextTypes = {
- router: PropTypes.object
-}
-
-FolderItem.propTypes = {
- folder: PropTypes.shape({
- name: PropTypes.string,
- color: PropTypes.string
- }),
- repository: PropTypes.shape({
- key: PropTypes.string
- }),
- isFolded: PropTypes.bool
-}
-
-export default CSSModules(FolderItem, styles)
diff --git a/browser/main/SideNav/FolderItem.styl b/browser/main/SideNav/FolderItem.styl
deleted file mode 100644
index d2d16d50..00000000
--- a/browser/main/SideNav/FolderItem.styl
+++ /dev/null
@@ -1,115 +0,0 @@
-.root
- height 33px
- width 100%
- position relative
- cursor pointer
- navButtonColor()
-
-.root--active
- @extend .root
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
- &:hover
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
- .control-button
- opacity 1
- color white
- &:hover
- background-color alpha(white, 30%)
- &:active, &:hover:active
- background-color alpha(white, 15%)
-
-.label
- position absolute
- left 0
- top 0
- bottom 0
- right 48px
- padding-left 20px
- line-height 33px
- overflow-x hidden
-
-.label-name
- margin-left 5px
-
-.control
- position absolute
- top 0
- bottom 0
- right 5px
- width 24px
-
-.control-button
- opacity 0
- navButtonColor()
- width 24px
- height 24px
- margin-top 4.5px
- border-radius 5px
- transition opacity 0.15s
-
-.root--edit
- @extend .root
-
-.nameInput
- absolute top bottom
- left 10px
- right 10px
- height 33px
- padding 0 10px
- border-radius 5px
- border $ui-border
- outline none
- background-color white
- z-index 1
- &:focus
- border-color $ui-input--focus-borderColor
- &:disabled
- background-color $ui-input--disabled-backgroundColor
-
-.root--folded
- @extend .root
- width 44px - 1
- &:hover .label-name
- width 100px
- .label
- padding-left 0
- text-align center
- right 0
- .label-icon
- width 44px - 1
- .label-name
- position fixed
- height 34px
- left 44px
- width 0
- box-sizing border-box
- margin-left 0
- overflow ellipsis
- background-color $ui-tooltip-backgroundColor
- z-index 10
- color white
- line-height 34px
- border-top-right-radius 5px
- border-bottom-right-radius 5px
- transition width 0.15s
- pointer-events none
- .control
- display none
-
-.root--folded--active
- @extend .root--folded
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
- &:hover
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
-
-.root--edit--folded
- @extend .root--edit
- .nameInput
- position fixed
- top inherit
- bottom inherit
- width 100px
diff --git a/browser/main/SideNav/RepositorySection.js b/browser/main/SideNav/RepositorySection.js
deleted file mode 100644
index a643d9e8..00000000
--- a/browser/main/SideNav/RepositorySection.js
+++ /dev/null
@@ -1,219 +0,0 @@
-import React, { PropTypes } from 'react'
-import CSSModules from 'browser/lib/CSSModules'
-import styles from './RepositorySection.styl'
-import Repository from 'browser/lib/Repository'
-import FolderItem from './FolderItem'
-
-const electron = require('electron')
-const { remote } = electron
-const { Menu, MenuItem } = remote
-
-class RepositorySection extends React.Component {
- constructor (props) {
- super(props)
-
- this.state = {
- isOpen: true,
- isCreatingFolder: false,
- isSaving: false,
- newFolder: {
- name: ''
- }
- }
- }
-
- getRepository () {
- let { repository } = this.props
- return Repository.find(repository.key)
- }
-
- handleUnlinkButtonClick () {
- let { dispatch, repository } = this.props
-
- this.getRepository()
- .then((repositoryInstance) => {
- return repositoryInstance.unmount()
- })
- .then(() => {
- dispatch({
- type: 'REMOVE_REPOSITORY',
- key: repository.key
- })
- })
- }
-
- handleToggleButtonClick (e) {
- e.stopPropagation()
- this.setState({
- isOpen: !this.state.isOpen
- })
- }
-
- handleHeaderClick (e) {
- let { repository } = this.props
- let { router } = this.context
- router.push('/repositories/' + repository.key)
- }
-
- handleContextButtonClick (e) {
- e.stopPropagation()
- let menu = new Menu()
- menu.append(new MenuItem({
- label: 'New Folder',
- click: () => this.handleNewFolderButtonClick()
- }))
- menu.append(new MenuItem({ type: 'separator' }))
- menu.append(new MenuItem({
- label: 'Unmount',
- click: () => this.handleUnlinkButtonClick()
- }))
-
- menu.popup(remote.getCurrentWindow())
- }
-
- handleNewFolderButtonClick (e) {
- this.setState({
- isCreatingFolder: true,
- newFolder: {
- name: 'New Folder'
- }
- }, () => {
- this.refs.nameInput.select()
- this.refs.nameInput.focus()
- })
- }
-
- handleNewFolderFormChange (e) {
- let newFolder = this.state.newFolder
- newFolder.name = this.refs.nameInput.value
-
- this.setState({
- newFolder
- })
- }
-
- handleNameInputBlur (e) {
- let { dispatch, repository } = this.props
-
- this.setState({
- isSaving: true
- }, () => {
- this.getRepository()
- .then((repositoryInstance) => {
- return repositoryInstance.addFolder({
- name: this.state.newFolder.name
- })
- })
- .then((folder) => {
- dispatch({
- type: 'ADD_FOLDER',
- key: repository.key,
- folder: folder
- })
-
- this.setState({
- isCreatingFolder: false,
- isSaving: false
- })
- })
- .catch((err) => {
- console.error(err)
-
- this.setState({
- isCreatingFolder: false,
- isSaving: false
- })
- })
- })
- }
-
- render () {
- let { repository, isFolded } = this.props
- let { router } = this.context
-
- let isActive = router.isActive('/repositories/' + repository.key, true)
-
- let folderElements = repository.folders.map((folder) => {
- return (
-
- )
- })
-
- let toggleButtonIconClassName = this.state.isOpen
- ? 'fa fa-minus'
- : 'fa fa-plus'
-
- return (
-
-
this.handleHeaderClick(e)}
- onContextMenu={(e) => this.handleContextButtonClick(e)}
- >
-
-
- {repository.name}
-
-
-
-
-
-
-
- {this.state.isOpen &&
- {folderElements}
-
- {this.state.isCreatingFolder
- ?
- this.handleNewFolderFormChange(e)}
- onBlur={(e) => this.handleNameInputBlur(e)}
- />
-
- :
- }
-
}
-
- )
- }
-}
-
-RepositorySection.contextTypes = {
- router: PropTypes.object
-}
-
-RepositorySection.propTypes = {
- repository: PropTypes.shape({
- name: PropTypes.string,
- folders: PropTypes.arrayOf(PropTypes.shape({
- name: PropTypes.string
- }))
- }),
- dispatch: PropTypes.func,
- isFolded: PropTypes.bool
-}
-
-export default CSSModules(RepositorySection, styles)
diff --git a/browser/main/SideNav/RepositorySection.styl b/browser/main/SideNav/RepositorySection.styl
deleted file mode 100644
index ac6b6135..00000000
--- a/browser/main/SideNav/RepositorySection.styl
+++ /dev/null
@@ -1,184 +0,0 @@
-.root
- user-select none
- color $nav-text-color
-
-.header
- position relative
- width 100%
- height 33px
- cursor pointer
- text-align left
- font-size 14px
- color $ui-inactive-text-color
- &:hover
- background-color $ui-button--hover-backgroundColor
- &:hover .header-control-button
- opacity 1
- &:active
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
- .header-control-button, .header-control-button--show
- color white
-
-.header--active, .header--active:hover, .header--active:active
- @extend .header
- background-color $ui-button--active-backgroundColor
- color $ui-button--active-color
- &:hover
- background-color $ui-button--active-backgroundColor
- .header-control-button,
- .header-control-button--show
- color white
- opacity 1
- &:hover
- background-color alpha(white, 30%)
- &:active
- background-color alpha(white, 15%)
-
-.header-name
- position absolute
- left 0
- top 0
- bottom 0
- right 72px
- padding-left 10px
- line-height 33px
-
-.header-name-label
- margin-left 5px
-
-.header-control
- position absolute
- top 0
- bottom 0
- right 5px
- width 48px
-
-.header-control-button
- border none
- background-color transparent
- width 24px
- height 24px
- padding 0
- margin-top 4.5px
- border-radius 5px
- opacity 0
- color $ui-inactive-text-color
- transition color background-color 0.15s
- &:hover
- background-color $ui-button--hover-backgroundColor
-
-.header-control-button--show
- @extend .header-control-button
- opacity 1
-
-.newFolderForm
- width 100%
- padding 0 15px
- height 33px
-
-.newFolderForm-nameInput
- width 100%
- height 33px
- padding 0 10px
- border-radius 5px
- border $ui-border
- outline none
- &:focus
- border-color $ui-input--focus-borderColor
- &:disabled
- background-color $ui-input--disabled-backgroundColor
-
-.newFolderButton
- navButtonColor()
- height 34px
- width 100%
- border none
- padding 0 0 0 20px
- text-align left
- line-height 34px
-
-.newFolderButton-label
- margin-left 0
-
-.root-folded
- @extend .root
- width 44px - 1
- .header, .header--active
- width 44px - 1
- text-align center
- overflow hidden
- &:hover
- .header-name-label
- width 134px
- padding-left 34px
- .header-control
- width 35px
- padding-right 5px
- .header-name
- width 44px - 1
- padding-left 0
- .header-name-label
- position fixed
- display inline-block
- height 34px
- left 44px - 1
- width 0
- box-sizing border-box
- margin-left 0
- overflow ellipsis
- background-color $ui-tooltip-backgroundColor
- z-index 10
- color white
- line-height 34px
- border-top-right-radius 5px
- border-bottom-right-radius 5px
- transition width 0.15s
- pointer-events none
- .header-control
- position fixed
- width 0
- height 33px
- top inherit
- bottom inherit
- z-index 11
- left 44px - 1
- box-sizing border-box
- overflow hidden
- .header-control-button
- display none
- .header-control-button--show
- float right
- background-color $ui-tooltip-button-backgroundColor
- &:hover
- background-color $ui-tooltip-button--hover-backgroundColor
- .newFolderButton
- width 44px - 1
- padding 0
- &:hover .newFolderButton-label
- width 100px
- .newFolderButton-icon
- text-align center
- width 44px - 1
- .newFolderButton-label
- position fixed
- display inline-block
- height 34px
- left 44px
- width 0
- box-sizing border-box
- margin-left 0
- overflow ellipsis
- background-color $ui-tooltip-backgroundColor
- z-index 10
- color white
- line-height 34px
- border-top-right-radius 5px
- border-bottom-right-radius 5px
- transition width 0.15s
- pointer-events none
- font-size 14px
- text-align center
- .newFolderForm-nameInput
- position fixed
- width 100px
diff --git a/browser/main/SideNav/SideNav.styl b/browser/main/SideNav/SideNav.styl
index 5d772855..6d7e8417 100644
--- a/browser/main/SideNav/SideNav.styl
+++ b/browser/main/SideNav/SideNav.styl
@@ -44,13 +44,13 @@
.menu-button-label
margin-left 5px
-.repositoryList
+.storageList
absolute left right
bottom 44px
top 178px
overflow-y auto
-.repositoryList-empty
+.storageList-empty
padding 0 10px
margin-top 15px
line-height 24px
@@ -68,10 +68,10 @@
line-height 32px
padding 0
-.root-folded
+.root--folded
@extend .root
width 44px
- .repositoryList-empty
+ .storageList-empty
white-space nowrap
transform rotate(90deg)
.top-menu
diff --git a/browser/main/SideNav/StorageItem.js b/browser/main/SideNav/StorageItem.js
new file mode 100644
index 00000000..8bed86cd
--- /dev/null
+++ b/browser/main/SideNav/StorageItem.js
@@ -0,0 +1,95 @@
+import React, { PropTypes } from 'react'
+import CSSModules from 'browser/lib/CSSModules'
+import styles from './StorageItem.styl'
+import { hashHistory } from 'react-router'
+
+class StorageItem extends React.Component {
+ constructor (props) {
+ super(props)
+
+ this.state = {
+ isOpen: false
+ }
+ }
+
+ handleToggleButtonClick (e) {
+ this.setState({
+ isOpen: !this.state.isOpen
+ })
+ }
+
+ handleHeaderInfoClick (e) {
+ let { storage } = this.props
+ hashHistory.push('/storages/' + storage.key)
+ }
+
+ handleFolderButtonClick (folderKey) {
+ return (e) => {
+ let { storage } = this.props
+ hashHistory.push('/storages/' + storage.key + '/folders/' + folderKey)
+ }
+ }
+
+ render () {
+ let { storage, location } = this.props
+ let folderList = storage.folders.map((folder) => {
+ let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '\/folders\/' + folder.key))
+ return
+ })
+
+ let isActive = location.pathname.match(new RegExp('\/storages\/' + storage.key + '$'))
+
+ return (
+
+
+
+
+
+ {this.state.isOpen &&
+
+ {folderList}
+
+ }
+
+ )
+ }
+}
+
+StorageItem.propTypes = {
+}
+
+export default CSSModules(StorageItem, styles)
diff --git a/browser/main/SideNav/StorageItem.styl b/browser/main/SideNav/StorageItem.styl
new file mode 100644
index 00000000..7901ca98
--- /dev/null
+++ b/browser/main/SideNav/StorageItem.styl
@@ -0,0 +1,89 @@
+.root
+ width 100%
+ user-select none
+.header
+ position relative
+ height 30px
+ width 100%
+ &:hover
+ background-color $ui-button--hover-backgroundColor
+ &:active
+ .header-toggleButton
+ color white
+.header--active
+ @extend .header
+ .header-info
+ color $ui-button--active-color
+ background-color $ui-button--active-backgroundColor
+ .header-toggleButton
+ color white
+ &:active
+ color white
+
+.header-toggleButton
+ position absolute
+ left 0
+ width 25px
+ height 30px
+ padding 0
+ border none
+ color $ui-inactive-text-color
+ background-color transparent
+ &:hover
+ color $ui-text-color
+ &:active
+ color $ui-active-color
+
+.header-info
+ display block
+ width 100%
+ height 30px
+ padding-left 25px
+ padding-right 10px
+ line-height 30px
+ cursor pointer
+ font-size 14px
+ border none
+ overflow ellipsis
+ text-align left
+ background-color transparent
+ color $ui-inactive-text-color
+ &:active
+ color $ui-button--active-color
+ background-color $ui-button--active-backgroundColor
+
+.header-info-path
+ font-size 10px
+ margin 0 5px
+
+.folderList-item
+ display block
+ width 100%
+ height 3 0px
+ background-color transparent
+ color $ui-inactive-text-color
+ padding 0
+ margin 2px 0
+ text-align left
+ border none
+ font-size 14px
+ &:hover
+ background-color $ui-button--hover-backgroundColor
+ &:active
+ color $ui-button--active-color
+ background-color $ui-button--active-backgroundColor
+.folderList-item--active
+ @extend .folderList-item
+ color $ui-button--active-color
+ background-color $ui-button--active-backgroundColor
+ &:hover
+ color $ui-button--active-color
+ background-color $ui-button--active-backgroundColor
+.folderList-item-name
+ display block
+ padding 0 10px
+ height 30px
+ line-height 30px
+ border-width 0 0 0 6px
+ border-style solid
+ border-color transparent
diff --git a/browser/main/SideNav/index.js b/browser/main/SideNav/index.js
index 05411f16..d12ab9c9 100644
--- a/browser/main/SideNav/index.js
+++ b/browser/main/SideNav/index.js
@@ -2,43 +2,22 @@ import React, { PropTypes } from 'react'
import CSSModules from 'browser/lib/CSSModules'
import styles from './SideNav.styl'
import { openModal } from 'browser/main/lib/modal'
-import Preferences from '../modals/Preferences'
-import RepositorySection from './RepositorySection'
-import NewRepositoryModal from '../modals/NewRepositoryModal'
+import PreferencesModal from '../modals/PreferencesModal'
import ConfigManager from 'browser/main/lib/ConfigManager'
+import StorageItem from './StorageItem'
const electron = require('electron')
const { remote } = electron
-const Menu = remote.Menu
-const MenuItem = remote.MenuItem
class SideNav extends React.Component {
// TODO: should not use electron stuff v0.7
handleMenuButtonClick (e) {
- var menu = new Menu()
- menu.append(new MenuItem({
- label: 'Preferences',
- click: (e) => this.handlePreferencesButtonClick(e)
- }))
- menu.append(new MenuItem({ type: 'separator' }))
- menu.append(new MenuItem({
- label: 'Mount Repository',
- click: (e) => this.handleNewRepositoryButtonClick(e)
- }))
- menu.popup(remote.getCurrentWindow())
- }
-
- handleNewRepositoryButtonClick (e) {
- openModal(NewRepositoryModal)
- }
-
- handlePreferencesButtonClick (e) {
- openModal(Preferences)
+ openModal(PreferencesModal)
}
handleHomeButtonClick (e) {
let { router } = this.context
- router.push('/repositories')
+ router.push('/home')
}
handleStarredButtonClick (e) {
@@ -57,25 +36,22 @@ class SideNav extends React.Component {
}
render () {
- let { repositories, dispatch, location, config } = this.props
+ let { storages, location, config } = this.props
let isFolded = config.isSideNavFolded
let isHomeActive = location.pathname.match(/^\/home$/)
let isStarredActive = location.pathname.match(/^\/starred$/)
-
- let repositorieElements = repositories
- .map((repo) => {
- return
- })
+ let storageList = storages.map((storage) => {
+ return
+ })
return (
@@ -102,9 +78,9 @@ class SideNav extends React.Component {
-
- {repositories.length > 0 ? repositorieElements : (
-
No repository mount.
+
+ {storageList.length > 0 ? storageList : (
+
No storage mount.
)}
@@ -127,7 +103,7 @@ SideNav.contextTypes = {
SideNav.propTypes = {
dispatch: PropTypes.func,
- repositories: PropTypes.array,
+ storages: PropTypes.array,
config: PropTypes.shape({
isSideNavFolded: PropTypes.bool
}),
diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js
index 76d71988..a74d7157 100644
--- a/browser/main/TopBar/index.js
+++ b/browser/main/TopBar/index.js
@@ -2,9 +2,9 @@ import React, { PropTypes } from 'react'
import CSSModules from 'browser/lib/CSSModules'
import styles from './TopBar.styl'
import activityRecord from 'browser/lib/activityRecord'
-import Repository from 'browser/lib/Repository'
import _ from 'lodash'
import Commander from 'browser/main/lib/Commander'
+import dataApi from 'browser/main/lib/dataApi'
const OSX = window.process.platform === 'darwin'
@@ -33,65 +33,31 @@ class TopBar extends React.Component {
}
handleNewPostButtonClick (e) {
- activityRecord.emit('ARTICLE_CREATE')
-
- let { params, repositories } = this.props
-
- let folderKey = params.folderKey
- let repositoryKey = params.repositoryKey
- if (folderKey == null) {
- let repository = _.find(repositories, {key: repositoryKey})
- if (repository == null) {
- repository = repositories[0]
- }
- if (repository != null) {
- repositoryKey = repository.key
- folderKey = repository.folders[0] != null && repository.folders[0].key
- }
- if (folderKey == null) throw new Error('no folder exists')
- }
-
- let newNote = {
- title: 'New Note',
- content: '',
- folder: folderKey,
- tags: [],
- mode: 'markdown'
- }
-
- Repository
- .find(repositoryKey)
- .then((repo) => {
- return repo.addNote(newNote)
+ let { storages, params, dispatch } = this.props
+ let storage = _.find(storages, {key: params.storageKey})
+ if (storage == null) storage = storages[0]
+ if (storage == null) throw new Error('No storage to create a note')
+ let folder = _.find(storage.folders, {key: params.folderKey})
+ if (folder == null) folder = storage.folders[0]
+ if (folder == null) throw new Error('No folder to craete a note')
+ // activityRecord.emit('ARTICLE_CREATE')
+ console.log(storage, folder)
+ dataApi
+ .createNote(storage.key, folder.key, {
+ title: '',
+ content: ''
})
.then((note) => {
- let { dispatch, location } = this.props
- let { router } = this.context
dispatch({
- type: 'ADD_NOTE',
- repository: repositoryKey,
+ type: 'CREATE_NOTE',
note: note
})
-
- router.push({
- pathname: location.pathname,
- query: {
- key: `${note._repository.key}-${note.key}`
- }
- })
- Commander.fire('note-detail:focus')
- })
- .catch((err) => {
- console.error(err)
})
}
handleTutorialButtonClick (e) {
}
- handleLinksButton (e) {
- }
-
render () {
let { config } = this.props
return (
@@ -124,7 +90,7 @@ class TopBar extends React.Component {
onClick={(e) => this.handleNewPostButtonClick(e)}>
- New Post {OSX ? '⌘' : '^'} + n
+ New Note {OSX ? '⌘' : '^'} + n
@@ -137,11 +103,7 @@ class TopBar extends React.Component {
>
?
How to use
-
+
)
diff --git a/browser/main/global.styl b/browser/main/global.styl
new file mode 100644
index 00000000..cfeb0495
--- /dev/null
+++ b/browser/main/global.styl
@@ -0,0 +1,73 @@
+global-reset()
+
+DEFAULT_FONTS = 'Lato', helvetica, arial, sans-serif
+
+html, body
+ width 100%
+ height 100%
+ overflow hidden
+
+body
+ font-family DEFAULT_FONTS
+ color textColor
+ font-size fontSize
+ font-weight 400
+
+button, input, select, textarea
+ font-family DEFAULT_FONTS
+
+div, span, a, button, input, textarea
+ box-sizing border-box
+
+a
+ color $brand-color
+ &:hover
+ color lighten($brand-color, 5%)
+ &:visited
+ color $brand-color
+
+hr
+ border-top none
+ border-bottom solid 1px $border-color
+ margin 15px 0
+
+button
+ font-weight 400
+ cursor pointer
+ font-size 12px
+ &:focus, &.focus
+ outline none
+
+.noSelect
+ noSelect()
+
+.text-center
+ text-align center
+
+.form-group
+ margin-bottom 15px
+ &>label
+ display block
+ margin-bottom 5px
+
+textarea.block-input
+ resize vertical
+ height 125px
+ border-radius 5px
+ padding 5px 10px
+
+#content
+ fullsize()
+
+modalZIndex= 1000
+modalBackColor = transparentify(white, 65%)
+
+.ModalBase
+ fixed top left bottom right
+ z-index modalZIndex
+ &.hide
+ display none
+ .modalBack
+ absolute top left bottom right
+ background-color modalBackColor
+ z-index modalZIndex + 1
diff --git a/browser/main/index.js b/browser/main/index.js
index fedef081..9e0abe3f 100644
--- a/browser/main/index.js
+++ b/browser/main/index.js
@@ -3,7 +3,7 @@ import Main from './Main'
import store from './store'
import React from 'react'
import ReactDOM from 'react-dom'
-require('!!style!css!stylus?sourceMap!../styles/main/index.styl')
+require('!!style!css!stylus?sourceMap!./global.styl')
import activityRecord from 'browser/lib/activityRecord'
import fetchConfig from '../lib/fetchConfig'
import { Router, Route, IndexRoute, IndexRedirect, hashHistory } from 'react-router'
@@ -84,11 +84,10 @@ ReactDOM.render((