Added shortcuts
• Added: - shortcuts functionality - shortcuts route, controller, model - shortcut error message for "exists" - shortcut redux - EditShortcutsModal, constant - links to sidebar, sidebar_xs - options to add/remove group, account in GroupOptionsPopover, ProfileOptionsPopover - shortcuts page, feature/list
This commit is contained in:
62
app/javascript/gabsocial/features/shortcuts.js
Normal file
62
app/javascript/gabsocial/features/shortcuts.js
Normal file
@@ -0,0 +1,62 @@
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component'
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes'
|
||||
import { fetchShortcuts } from '../actions/shortcuts'
|
||||
import ColumnIndicator from '../components/column_indicator'
|
||||
import List from '../components/list'
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
isError: state.getIn(['shortcuts', 'isError']),
|
||||
isLoading: state.getIn(['shortcuts', 'isLoading']),
|
||||
shortcuts: state.getIn(['shortcuts', 'items']),
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onFetchShortcuts() {
|
||||
dispatch(fetchShortcuts())
|
||||
},
|
||||
})
|
||||
|
||||
export default
|
||||
@connect(mapStateToProps, mapDispatchToProps)
|
||||
class Shortcuts extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
isLoading: PropTypes.bool.isRequired,
|
||||
isError: PropTypes.bool.isRequired,
|
||||
onFetchShortcuts: PropTypes.func.isRequired,
|
||||
shortcuts: ImmutablePropTypes.list,
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.onFetchShortcuts()
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
isLoading,
|
||||
isError,
|
||||
shortcuts,
|
||||
} = this.props
|
||||
|
||||
if (isLoading) {
|
||||
return <ColumnIndicator type='loading' />
|
||||
} else if (isError) {
|
||||
return <ColumnIndicator type='error' message='Error fetching shortcuts' />
|
||||
}
|
||||
|
||||
const listItems = shortcuts.map((s) => ({
|
||||
to: s.get('to'),
|
||||
title: s.get('title'),
|
||||
image: s.get('image'),
|
||||
}))
|
||||
|
||||
return (
|
||||
<List
|
||||
scrollKey='shortcuts'
|
||||
emptyMessage='You have no shortcuts'
|
||||
items={listItems}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user