mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
sort by time & add FolderMark
This commit is contained in:
@@ -69,6 +69,9 @@ function remap (state) {
|
|||||||
|
|
||||||
let articles = state.articles['team-' + activeUser.id]
|
let articles = state.articles['team-' + activeUser.id]
|
||||||
if (articles == null) articles = []
|
if (articles == null) articles = []
|
||||||
|
articles.sort((a, b) => {
|
||||||
|
return new Date(b.updatedAt) - new Date(a.updatedAt)
|
||||||
|
})
|
||||||
|
|
||||||
let activeArticle = findWhere(articles, {key: status.articleKey})
|
let activeArticle = findWhere(articles, {key: status.articleKey})
|
||||||
if (activeArticle == null) activeArticle = articles[0]
|
if (activeArticle == null) activeArticle = articles[0]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import aceModes from 'boost/ace-modes'
|
|||||||
import Select from 'react-select'
|
import Select from 'react-select'
|
||||||
import linkState from 'boost/linkState'
|
import linkState from 'boost/linkState'
|
||||||
import api from 'boost/api'
|
import api from 'boost/api'
|
||||||
|
import FolderMark from 'boost/components/FolderMark'
|
||||||
|
|
||||||
var modeOptions = aceModes.map(function (mode) {
|
var modeOptions = aceModes.map(function (mode) {
|
||||||
return {
|
return {
|
||||||
@@ -19,7 +20,7 @@ var modeOptions = aceModes.map(function (mode) {
|
|||||||
|
|
||||||
function makeInstantArticle (article) {
|
function makeInstantArticle (article) {
|
||||||
let instantArticle = Object.assign({}, article)
|
let instantArticle = Object.assign({}, article)
|
||||||
instantArticle.Tags = typeof instantArticle.Tags === 'array' ? instantArticle.Tags.map(tag => tag.name) : []
|
instantArticle.Tags = (typeof instantArticle.Tags === 'array') ? instantArticle.Tags.map(tag => tag.name) : []
|
||||||
return instantArticle
|
return instantArticle
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +116,7 @@ export default class ArticleDetail extends React.Component {
|
|||||||
<div className='detailInfo'>
|
<div className='detailInfo'>
|
||||||
<div className='left'>
|
<div className='left'>
|
||||||
<div className='info'>
|
<div className='info'>
|
||||||
<i className='fa fa-fw fa-square'/> {folderName}
|
<FolderMark id={folder.id}/> {folderName}
|
||||||
by {activeArticle.User.profileName}
|
by {activeArticle.User.profileName}
|
||||||
Created {moment(activeArticle.createdAt).format('YYYY/MM/DD')}
|
Created {moment(activeArticle.createdAt).format('YYYY/MM/DD')}
|
||||||
Updated {moment(activeArticle.updatedAt).format('YYYY/MM/DD')}
|
Updated {moment(activeArticle.updatedAt).format('YYYY/MM/DD')}
|
||||||
@@ -139,7 +140,7 @@ export default class ArticleDetail extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
{activeArticle.mode === 'markdown'
|
{activeArticle.mode === 'markdown'
|
||||||
? <MarkdownPreview content={activeArticle.content}/>
|
? <MarkdownPreview content={activeArticle.content}/>
|
||||||
: <CodeEditor readOnly={true} onChange={this.handleContentChange} mode={activeArticle.mode} code={activeArticle.content}/>
|
: <CodeEditor readOnly onChange={this.handleContentChange} mode={activeArticle.mode} code={activeArticle.content}/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ProfileImage from 'boost/components/ProfileImage'
|
|||||||
import ModeIcon from 'boost/components/ModeIcon'
|
import ModeIcon from 'boost/components/ModeIcon'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { switchArticle, NEW } from '../actions'
|
import { switchArticle, NEW } from '../actions'
|
||||||
|
import FolderMark from 'boost/components/FolderMark'
|
||||||
|
|
||||||
export default class ArticleList extends React.Component {
|
export default class ArticleList extends React.Component {
|
||||||
handleArticleClick (key) {
|
handleArticleClick (key) {
|
||||||
@@ -26,7 +27,7 @@ export default class ArticleList extends React.Component {
|
|||||||
<div key={'article-' + article.key}>
|
<div key={'article-' + article.key}>
|
||||||
<div onClick={e => this.handleArticleClick(article.key)(e)} className={'articleItem' + (activeArticle.key === article.key ? ' active' : '')}>
|
<div onClick={e => this.handleArticleClick(article.key)(e)} className={'articleItem' + (activeArticle.key === article.key ? ' active' : '')}>
|
||||||
<div className='top'>
|
<div className='top'>
|
||||||
<i className='fa fa-fw fa-square'/>
|
<FolderMark id={article.FolderId}/>
|
||||||
by <ProfileImage className='profileImage' size='20' email={article.User.email}/> {article.User.profileName}
|
by <ProfileImage className='profileImage' size='20' email={article.User.email}/> {article.User.profileName}
|
||||||
<span className='updatedAt'>{article.status != null ? article.status : moment(article.updatedAt).fromNow()}</span>
|
<span className='updatedAt'>{article.status != null ? article.status : moment(article.updatedAt).fromNow()}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { findWhere } from 'lodash'
|
|||||||
import { switchMode, CREATE_MODE } from '../actions'
|
import { switchMode, CREATE_MODE } from '../actions'
|
||||||
import { openModal } from 'boost/modal'
|
import { openModal } from 'boost/modal'
|
||||||
import CreateNewFolder from 'boost/components/modal/CreateNewFolder'
|
import CreateNewFolder from 'boost/components/modal/CreateNewFolder'
|
||||||
|
import FolderMark from 'boost/components/FolderMark'
|
||||||
|
|
||||||
export default class ArticleNavigator extends React.Component {
|
export default class ArticleNavigator extends React.Component {
|
||||||
handleNewPostButtonClick (e) {
|
handleNewPostButtonClick (e) {
|
||||||
@@ -23,9 +24,10 @@ export default class ArticleNavigator extends React.Component {
|
|||||||
|
|
||||||
let activeFolder = findWhere(activeUser.Folders, {id: status.folderId})
|
let activeFolder = findWhere(activeUser.Folders, {id: status.folderId})
|
||||||
|
|
||||||
let folders = activeUser.Folders.map(folder => {
|
let folders = activeUser.Folders.map((folder, index) => {
|
||||||
return (
|
return (
|
||||||
<button key={'folder-' + folder.id} className={activeFolder != null && activeFolder.id === folder.id ? 'active' : ''}><i className='fa fa-fw fa-square'/> {folder.name}</button>
|
<button key={'folder-' + folder.id} className={activeFolder != null && activeFolder.id === folder.id ? 'active' : ''}>
|
||||||
|
<FolderMark id={folder.id}/> {folder.name}</button>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -55,7 +57,7 @@ export default class ArticleNavigator extends React.Component {
|
|||||||
<div className='folders'>
|
<div className='folders'>
|
||||||
<div className='header'>
|
<div className='header'>
|
||||||
<div className='title'>Folders</div>
|
<div className='title'>Folders</div>
|
||||||
<button onCLick={e => this.handleNewFolderButton(e)} className='addBtn'><i className='fa fa-fw fa-plus'/></button>
|
<button onClick={e => this.handleNewFolderButton(e)} className='addBtn'><i className='fa fa-fw fa-plus'/></button>
|
||||||
</div>
|
</div>
|
||||||
<div className='folderList'>
|
<div className='folderList'>
|
||||||
<button className={activeFolder == null ? 'active' : ''}>All folders</button>
|
<button className={activeFolder == null ? 'active' : ''}>All folders</button>
|
||||||
|
|||||||
46
lib/components/FolderMark.js
Normal file
46
lib/components/FolderMark.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import React, { PropTypes } from 'react'
|
||||||
|
|
||||||
|
const BLUE = '#3460C7'
|
||||||
|
const LIGHTBLUE = '#2BA5F7'
|
||||||
|
const ORANGE = '#FF8E00'
|
||||||
|
const YELLOW = '#EAEF31'
|
||||||
|
const GREEN = '#02FF26'
|
||||||
|
const DARKGREEN = '#008A59'
|
||||||
|
const RED = '#E10051'
|
||||||
|
const PURPLE = '#B013A4'
|
||||||
|
|
||||||
|
function getColorByIndex (index) {
|
||||||
|
switch (index % 8) {
|
||||||
|
case 0:
|
||||||
|
return LIGHTBLUE
|
||||||
|
case 1:
|
||||||
|
return ORANGE
|
||||||
|
case 2:
|
||||||
|
return RED
|
||||||
|
case 3:
|
||||||
|
return GREEN
|
||||||
|
case 4:
|
||||||
|
return DARKGREEN
|
||||||
|
case 5:
|
||||||
|
return YELLOW
|
||||||
|
case 6:
|
||||||
|
return BLUE
|
||||||
|
case 7:
|
||||||
|
return PURPLE
|
||||||
|
default:
|
||||||
|
return 'gray'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class FolderMark extends React.Component {
|
||||||
|
render () {
|
||||||
|
let color = getColorByIndex(this.props.id)
|
||||||
|
return (
|
||||||
|
<i className='fa fa-square fa-fw' style={{color: color}}/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderMark.propTypes = {
|
||||||
|
id: PropTypes.number
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user