This repository has been archived by the owner on Feb 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Add latest route #103
Open
ezmiller
wants to merge
26
commits into
master
Choose a base branch
from
add-latest-route
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add latest route #103
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2a28039
Avoid error thrown by marshamllow_jsonapi
ezmiller b90a9df
Revert "Avoid error thrown by marshamllow_jsonapi"
ezmiller d45a5cf
Avoid args order error
ezmiller 0fc50b7
Add attempt to fix pagination schema
ezmiller 8872ac9
Set key to entities for latest route
ezmiller 6583f7c
Fix paging schema move to meta
ezmiller ca35e52
Adds prototype of latest view
ezmiller 2e7808a
Rig latest view for infinite list
ezmiller 39fd0a1
Update InfiniteList component to use ReactDOM
ezmiller e038be5
Fix incorrect lifecycle method name
ezmiller 4ef37c7
Update property desecrated prop name
ezmiller 479f46b
Add key to repeated components
ezmiller c885907
Revert preloadBatchSize to default
ezmiller 67cea29
Use isEqual in shouldComponentUpdate
ezmiller c4379ef
Use usewindowAsScrollContainer feature of react-infinite
ezmiller 899619e
Prevent load more action when isFetching or no next pages
ezmiller 838286c
Add isFetching prop to LatestView
ezmiller 8f7fe91
Fix reference to meta has_next
ezmiller 37224e2
Clean up
ezmiller 6baaac3
Fix long line
ezmiller ac20bc9
Add explanation for confusing react-infinite disable procedure
ezmiller 509b2e4
Please eslint
ezmiller 353dbab
Fix python style problems
ezmiller 62878f4
Revert to setting containerHeight explicitly
ezmiller c3207ca
Change default size of LIs to 20px
ezmiller f585241
Upgrade the react-infinite module
ezmiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { CALL_API } from 'middleware/api' | ||
import { LATEST } from 'reducers/latest' | ||
|
||
export const LATEST_REQUEST = 'LATEST_REQUEST' | ||
export const LATEST_SUCCESS = 'LATEST_SUCCESS' | ||
export const LATEST_FAILURE = 'LATEST_FAILURE' | ||
|
||
const fetchLatest = (page = 1) => { | ||
return { | ||
[CALL_API]: { | ||
types: [LATEST_REQUEST, LATEST_SUCCESS, LATEST_FAILURE], | ||
endpoint: '/latest?page=' + page, | ||
key: LATEST | ||
} | ||
} | ||
} | ||
|
||
export function loadLatest (page = 1) { | ||
return (dispatch, getState) => { | ||
return dispatch(fetchLatest(page = page)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { addNamedExtension } from 'config/extensions' | ||
import paginate from 'reducers/paginate' | ||
import { LATEST_SUCCESS, LATEST_FAILURE, LATEST_REQUEST } from 'actions/latest' | ||
|
||
export const LATEST = 'latest' | ||
|
||
addNamedExtension('reducers', LATEST, paginate({ | ||
mapActionToKey: x => LATEST, | ||
types: [LATEST_REQUEST, LATEST_SUCCESS, LATEST_FAILURE] | ||
})) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable react/no-multi-comp */ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
import { getStoreEntity } from 'utils' | ||
import { LATEST } from 'reducers/latest' | ||
import { loadLatest } from 'actions/latest' | ||
import InfiniteList from 'components/InfiniteList' | ||
|
||
// This should be a stateless component but if it's to be | ||
// consumed by the InfiniteList later, we'll need to add | ||
// a ref and you can't do that on stateless components. | ||
class Link extends Component { | ||
render () { | ||
const props = this.props | ||
return ( | ||
<li key={props.key} style={{height: 20}}> | ||
<a target='_blank' href={props.url}>{props.title}</a> | ||
</li> | ||
) | ||
} | ||
} | ||
|
||
const LinksList = ({ | ||
meta, | ||
links, | ||
isFetching, | ||
loadMore | ||
}) => ( | ||
<InfiniteList | ||
meta={meta} | ||
loader={loadMore} | ||
minimalItemHeight={24} | ||
isFetching={isFetching} | ||
> | ||
{links.map(l => | ||
<Link key={l.id} {...l} /> | ||
)} | ||
</InfiniteList> | ||
) | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
meta: state[LATEST].meta, | ||
links: state[LATEST].data.map((item) => { | ||
return getStoreEntity(state, item) | ||
}), | ||
isFetching: state[LATEST].isFetching | ||
} | ||
} | ||
|
||
const mapDispatchToProps = (dispatch, props) => { | ||
return { | ||
loadMore: (page) => { | ||
console.log('loadMore', {page: page}) | ||
dispatch(loadLatest(page)) | ||
} | ||
} | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(LinksList) | ||
/* eslint-enable react/no-multi-comp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
class ObjectQuery(AccessQuery): | ||
|
||
def by_capability(self, aborting=True, abort_code=404, *caps): | ||
def by_capability(self, *caps, aborting=True, abort_code=404): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was causing an error because of the order of the args list. In the commit, I wrote:
|
||
caps = set(chain.from_iterable(map(lambda c: | ||
getattr(Object.TypesForCapability, | ||
getattr(c, 'value', c), []), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
links
supposed to hold?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to hold paging links, but since we are using infinite pagination it's not implemented yet. This will also be a bit challenging because it's going to be hard for the pagination object to know, from the front-end, the details of the type of pagination.