From ecc7ba0e9d862d2c20403acf4f0d7f19c1ad28f1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 19 Nov 2018 23:01:49 -0800 Subject: [PATCH] Added: Collection to starred view Alphabetical sort to starred view --- app/components/Sidebar/Main.js | 2 +- app/routes.js | 1 + app/scenes/Starred.js | 33 ++++++++++++++++++++++++++++++--- app/stores/DocumentsStore.js | 7 ++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/components/Sidebar/Main.js b/app/components/Sidebar/Main.js index f56d29f7..acebccb0 100644 --- a/app/components/Sidebar/Main.js +++ b/app/components/Sidebar/Main.js @@ -62,7 +62,7 @@ class MainSidebar extends React.Component { }> Search - }> + } exact={false}> Starred + diff --git a/app/scenes/Starred.js b/app/scenes/Starred.js index 30a09188..7363b7d7 100644 --- a/app/scenes/Starred.js +++ b/app/scenes/Starred.js @@ -9,12 +9,15 @@ import Empty from 'components/Empty'; import PageTitle from 'components/PageTitle'; import Heading from 'components/Heading'; import DocumentList from 'components/DocumentList'; +import Tabs from 'components/Tabs'; +import Tab from 'components/Tab'; import NewDocumentMenu from 'menus/NewDocumentMenu'; import Actions, { Action } from 'components/Actions'; import DocumentsStore from 'stores/DocumentsStore'; type Props = { documents: DocumentsStore, + match: Object, }; @observer @@ -24,7 +27,13 @@ class Starred extends React.Component { } render() { - const { isLoaded, isFetching, starred } = this.props.documents; + const { + isLoaded, + isFetching, + starred, + starredAlphabetical, + } = this.props.documents; + const { sort } = this.props.match.params; const showLoading = !isLoaded && isFetching; const showEmpty = isLoaded && !starred.length; @@ -32,9 +41,27 @@ class Starred extends React.Component { Starred + {showEmpty ? ( + You’ve not starred any documents yet. + ) : ( + + + + Recently Updated + + + Alphabetical + + + + + )} {showLoading && } - {showEmpty && You’ve not starred any documents yet.} - } /> diff --git a/app/stores/DocumentsStore.js b/app/stores/DocumentsStore.js index 4fbb1f19..9b888211 100644 --- a/app/stores/DocumentsStore.js +++ b/app/stores/DocumentsStore.js @@ -1,7 +1,7 @@ // @flow import { observable, action, computed, ObservableMap, runInAction } from 'mobx'; import { client } from 'utils/ApiClient'; -import { map, find, orderBy, filter, uniq } from 'lodash'; +import { map, find, orderBy, filter, uniq, sortBy } from 'lodash'; import invariant from 'invariant'; import BaseStore from 'stores/BaseStore'; @@ -81,6 +81,11 @@ class DocumentsStore extends BaseStore { return filter(this.data.values(), 'starred'); } + @computed + get starredAlphabetical(): Document[] { + return sortBy(this.starred, doc => doc.title.toLowerCase()); + } + @computed get drafts(): Document[] { return filter(