commit
072ab191cc
@ -0,0 +1,313 @@ |
||||
import api from 'flavours/glitch/util/api'; |
||||
|
||||
export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST'; |
||||
export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS'; |
||||
export const LIST_FETCH_FAIL = 'LIST_FETCH_FAIL'; |
||||
|
||||
export const LISTS_FETCH_REQUEST = 'LISTS_FETCH_REQUEST'; |
||||
export const LISTS_FETCH_SUCCESS = 'LISTS_FETCH_SUCCESS'; |
||||
export const LISTS_FETCH_FAIL = 'LISTS_FETCH_FAIL'; |
||||
|
||||
export const LIST_EDITOR_TITLE_CHANGE = 'LIST_EDITOR_TITLE_CHANGE'; |
||||
export const LIST_EDITOR_RESET = 'LIST_EDITOR_RESET'; |
||||
export const LIST_EDITOR_SETUP = 'LIST_EDITOR_SETUP'; |
||||
|
||||
export const LIST_CREATE_REQUEST = 'LIST_CREATE_REQUEST'; |
||||
export const LIST_CREATE_SUCCESS = 'LIST_CREATE_SUCCESS'; |
||||
export const LIST_CREATE_FAIL = 'LIST_CREATE_FAIL'; |
||||
|
||||
export const LIST_UPDATE_REQUEST = 'LIST_UPDATE_REQUEST'; |
||||
export const LIST_UPDATE_SUCCESS = 'LIST_UPDATE_SUCCESS'; |
||||
export const LIST_UPDATE_FAIL = 'LIST_UPDATE_FAIL'; |
||||
|
||||
export const LIST_DELETE_REQUEST = 'LIST_DELETE_REQUEST'; |
||||
export const LIST_DELETE_SUCCESS = 'LIST_DELETE_SUCCESS'; |
||||
export const LIST_DELETE_FAIL = 'LIST_DELETE_FAIL'; |
||||
|
||||
export const LIST_ACCOUNTS_FETCH_REQUEST = 'LIST_ACCOUNTS_FETCH_REQUEST'; |
||||
export const LIST_ACCOUNTS_FETCH_SUCCESS = 'LIST_ACCOUNTS_FETCH_SUCCESS'; |
||||
export const LIST_ACCOUNTS_FETCH_FAIL = 'LIST_ACCOUNTS_FETCH_FAIL'; |
||||
|
||||
export const LIST_EDITOR_SUGGESTIONS_CHANGE = 'LIST_EDITOR_SUGGESTIONS_CHANGE'; |
||||
export const LIST_EDITOR_SUGGESTIONS_READY = 'LIST_EDITOR_SUGGESTIONS_READY'; |
||||
export const LIST_EDITOR_SUGGESTIONS_CLEAR = 'LIST_EDITOR_SUGGESTIONS_CLEAR'; |
||||
|
||||
export const LIST_EDITOR_ADD_REQUEST = 'LIST_EDITOR_ADD_REQUEST'; |
||||
export const LIST_EDITOR_ADD_SUCCESS = 'LIST_EDITOR_ADD_SUCCESS'; |
||||
export const LIST_EDITOR_ADD_FAIL = 'LIST_EDITOR_ADD_FAIL'; |
||||
|
||||
export const LIST_EDITOR_REMOVE_REQUEST = 'LIST_EDITOR_REMOVE_REQUEST'; |
||||
export const LIST_EDITOR_REMOVE_SUCCESS = 'LIST_EDITOR_REMOVE_SUCCESS'; |
||||
export const LIST_EDITOR_REMOVE_FAIL = 'LIST_EDITOR_REMOVE_FAIL'; |
||||
|
||||
export const fetchList = id => (dispatch, getState) => { |
||||
if (getState().getIn(['lists', id])) { |
||||
return; |
||||
} |
||||
|
||||
dispatch(fetchListRequest(id)); |
||||
|
||||
api(getState).get(`/api/v1/lists/${id}`) |
||||
.then(({ data }) => dispatch(fetchListSuccess(data))) |
||||
.catch(err => dispatch(fetchListFail(id, err))); |
||||
}; |
||||
|
||||
export const fetchListRequest = id => ({ |
||||
type: LIST_FETCH_REQUEST, |
||||
id, |
||||
}); |
||||
|
||||
export const fetchListSuccess = list => ({ |
||||
type: LIST_FETCH_SUCCESS, |
||||
list, |
||||
}); |
||||
|
||||
export const fetchListFail = (id, error) => ({ |
||||
type: LIST_FETCH_FAIL, |
||||
id, |
||||
error, |
||||
}); |
||||
|
||||
export const fetchLists = () => (dispatch, getState) => { |
||||
dispatch(fetchListsRequest()); |
||||
|
||||
api(getState).get('/api/v1/lists') |
||||
.then(({ data }) => dispatch(fetchListsSuccess(data))) |
||||
.catch(err => dispatch(fetchListsFail(err))); |
||||
}; |
||||
|
||||
export const fetchListsRequest = () => ({ |
||||
type: LISTS_FETCH_REQUEST, |
||||
}); |
||||
|
||||
export const fetchListsSuccess = lists => ({ |
||||
type: LISTS_FETCH_SUCCESS, |
||||
lists, |
||||
}); |
||||
|
||||
export const fetchListsFail = error => ({ |
||||
type: LISTS_FETCH_FAIL, |
||||
error, |
||||
}); |
||||
|
||||
export const submitListEditor = shouldReset => (dispatch, getState) => { |
||||
const listId = getState().getIn(['listEditor', 'listId']); |
||||
const title = getState().getIn(['listEditor', 'title']); |
||||
|
||||
if (listId === null) { |
||||
dispatch(createList(title, shouldReset)); |
||||
} else { |
||||
dispatch(updateList(listId, title, shouldReset)); |
||||
} |
||||
}; |
||||
|
||||
export const setupListEditor = listId => (dispatch, getState) => { |
||||
dispatch({ |
||||
type: LIST_EDITOR_SETUP, |
||||
list: getState().getIn(['lists', listId]), |
||||
}); |
||||
|
||||
dispatch(fetchListAccounts(listId)); |
||||
}; |
||||
|
||||
export const changeListEditorTitle = value => ({ |
||||
type: LIST_EDITOR_TITLE_CHANGE, |
||||
value, |
||||
}); |
||||
|
||||
export const createList = (title, shouldReset) => (dispatch, getState) => { |
||||
dispatch(createListRequest()); |
||||
|
||||
api(getState).post('/api/v1/lists', { title }).then(({ data }) => { |
||||
dispatch(createListSuccess(data)); |
||||
|
||||
if (shouldReset) { |
||||
dispatch(resetListEditor()); |
||||
} |
||||
}).catch(err => dispatch(createListFail(err))); |
||||
}; |
||||
|
||||
export const createListRequest = () => ({ |
||||
type: LIST_CREATE_REQUEST, |
||||
}); |
||||
|
||||
export const createListSuccess = list => ({ |
||||
type: LIST_CREATE_SUCCESS, |
||||
list, |
||||
}); |
||||
|
||||
export const createListFail = error => ({ |
||||
type: LIST_CREATE_FAIL, |
||||
error, |
||||
}); |
||||
|
||||
export const updateList = (id, title, shouldReset) => (dispatch, getState) => { |
||||
dispatch(updateListRequest(id)); |
||||
|
||||
api(getState).put(`/api/v1/lists/${id}`, { title }).then(({ data }) => { |
||||
dispatch(updateListSuccess(data)); |
||||
|
||||
if (shouldReset) { |
||||
dispatch(resetListEditor()); |
||||
} |
||||
}).catch(err => dispatch(updateListFail(id, err))); |
||||
}; |
||||
|
||||
export const updateListRequest = id => ({ |
||||
type: LIST_UPDATE_REQUEST, |
||||
id, |
||||
}); |
||||
|
||||
export const updateListSuccess = list => ({ |
||||
type: LIST_UPDATE_SUCCESS, |
||||
list, |
||||
}); |
||||
|
||||
export const updateListFail = (id, error) => ({ |
||||
type: LIST_UPDATE_FAIL, |
||||
id, |
||||
error, |
||||
}); |
||||
|
||||
export const resetListEditor = () => ({ |
||||
type: LIST_EDITOR_RESET, |
||||
}); |
||||
|
||||
export const deleteList = id => (dispatch, getState) => { |
||||
dispatch(deleteListRequest(id)); |
||||
|
||||
api(getState).delete(`/api/v1/lists/${id}`) |
||||
.then(() => dispatch(deleteListSuccess(id))) |
||||
.catch(err => dispatch(deleteListFail(id, err))); |
||||
}; |
||||
|
||||
export const deleteListRequest = id => ({ |
||||
type: LIST_DELETE_REQUEST, |
||||
id, |
||||
}); |
||||
|
||||
export const deleteListSuccess = id => ({ |
||||
type: LIST_DELETE_SUCCESS, |
||||
id, |
||||
}); |
||||
|
||||
export const deleteListFail = (id, error) => ({ |
||||
type: LIST_DELETE_FAIL, |
||||
id, |
||||
error, |
||||
}); |
||||
|
||||
export const fetchListAccounts = listId => (dispatch, getState) => { |
||||
dispatch(fetchListAccountsRequest(listId)); |
||||
|
||||
api(getState).get(`/api/v1/lists/${listId}/accounts`, { params: { limit: 0 } }) |
||||
.then(({ data }) => dispatch(fetchListAccountsSuccess(listId, data))) |
||||
.catch(err => dispatch(fetchListAccountsFail(listId, err))); |
||||
}; |
||||
|
||||
export const fetchListAccountsRequest = id => ({ |
||||
type: LIST_ACCOUNTS_FETCH_REQUEST, |
||||
id, |
||||
}); |
||||
|
||||
export const fetchListAccountsSuccess = (id, accounts, next) => ({ |
||||
type: LIST_ACCOUNTS_FETCH_SUCCESS, |
||||
id, |
||||
accounts, |
||||
next, |
||||
}); |
||||
|
||||
export const fetchListAccountsFail = (id, error) => ({ |
||||
type: LIST_ACCOUNTS_FETCH_FAIL, |
||||
id, |
||||
error, |
||||
}); |
||||
|
||||
export const fetchListSuggestions = q => (dispatch, getState) => { |
||||
const params = { |
||||
q, |
||||
resolve: false, |
||||
limit: 4, |
||||
following: true, |
||||
}; |
||||
|
||||
api(getState).get('/api/v1/accounts/search', { params }) |
||||
.then(({ data }) => dispatch(fetchListSuggestionsReady(q, data))); |
||||
}; |
||||
|
||||
export const fetchListSuggestionsReady = (query, accounts) => ({ |
||||
type: LIST_EDITOR_SUGGESTIONS_READY, |
||||
query, |
||||
accounts, |
||||
}); |
||||
|
||||
export const clearListSuggestions = () => ({ |
||||
type: LIST_EDITOR_SUGGESTIONS_CLEAR, |
||||
}); |
||||
|
||||
export const changeListSuggestions = value => ({ |
||||
type: LIST_EDITOR_SUGGESTIONS_CHANGE, |
||||
value, |
||||
}); |
||||
|
||||
export const addToListEditor = accountId => (dispatch, getState) => { |
||||
dispatch(addToList(getState().getIn(['listEditor', 'listId']), accountId)); |
||||
}; |
||||
|
||||
export const addToList = (listId, accountId) => (dispatch, getState) => { |
||||
dispatch(addToListRequest(listId, accountId)); |
||||
|
||||
api(getState).post(`/api/v1/lists/${listId}/accounts`, { account_ids: [accountId] }) |
||||
.then(() => dispatch(addToListSuccess(listId, accountId))) |
||||
.catch(err => dispatch(addToListFail(listId, accountId, err))); |
||||
}; |
||||
|
||||
export const addToListRequest = (listId, accountId) => ({ |
||||
type: LIST_EDITOR_ADD_REQUEST, |
||||
listId, |
||||
accountId, |
||||
}); |
||||
|
||||
export const addToListSuccess = (listId, accountId) => ({ |
||||
type: LIST_EDITOR_ADD_SUCCESS, |
||||
listId, |
||||
accountId, |
||||
}); |
||||
|
||||
export const addToListFail = (listId, accountId, error) => ({ |
||||
type: LIST_EDITOR_ADD_FAIL, |
||||
listId, |
||||
accountId, |
||||
error, |
||||
}); |
||||
|
||||
export const removeFromListEditor = accountId => (dispatch, getState) => { |
||||
dispatch(removeFromList(getState().getIn(['listEditor', 'listId']), accountId)); |
||||
}; |
||||
|
||||
export const removeFromList = (listId, accountId) => (dispatch, getState) => { |
||||
dispatch(removeFromListRequest(listId, accountId)); |
||||
|
||||
api(getState).delete(`/api/v1/lists/${listId}/accounts`, { params: { account_ids: [accountId] } }) |
||||
.then(() => dispatch(removeFromListSuccess(listId, accountId))) |
||||
.catch(err => dispatch(removeFromListFail(listId, accountId, err))); |
||||
}; |
||||
|
||||
export const removeFromListRequest = (listId, accountId) => ({ |
||||
type: LIST_EDITOR_REMOVE_REQUEST, |
||||
listId, |
||||
accountId, |
||||
}); |
||||
|
||||
export const removeFromListSuccess = (listId, accountId) => ({ |
||||
type: LIST_EDITOR_REMOVE_SUCCESS, |
||||
listId, |
||||
accountId, |
||||
}); |
||||
|
||||
export const removeFromListFail = (listId, accountId, error) => ({ |
||||
type: LIST_EDITOR_REMOVE_FAIL, |
||||
listId, |
||||
accountId, |
||||
error, |
||||
}); |
@ -0,0 +1,77 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { connect } from 'react-redux'; |
||||
import { makeGetAccount } from 'flavours/glitch/selectors'; |
||||
import ImmutablePureComponent from 'react-immutable-pure-component'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import Avatar from 'flavours/glitch/components/avatar'; |
||||
import DisplayName from 'flavours/glitch/components/display_name'; |
||||
import IconButton from 'flavours/glitch/components/icon_button'; |
||||
import { defineMessages, injectIntl } from 'react-intl'; |
||||
import { removeFromListEditor, addToListEditor } from 'flavours/glitch/actions/lists'; |
||||
|
||||
const messages = defineMessages({ |
||||
remove: { id: 'lists.account.remove', defaultMessage: 'Remove from list' }, |
||||
add: { id: 'lists.account.add', defaultMessage: 'Add to list' }, |
||||
}); |
||||
|
||||
const makeMapStateToProps = () => { |
||||
const getAccount = makeGetAccount(); |
||||
|
||||
const mapStateToProps = (state, { accountId, added }) => ({ |
||||
account: getAccount(state, accountId), |
||||
added: typeof added === 'undefined' ? state.getIn(['listEditor', 'accounts', 'items']).includes(accountId) : added, |
||||
}); |
||||
|
||||
return mapStateToProps; |
||||
}; |
||||
|
||||
const mapDispatchToProps = (dispatch, { accountId }) => ({ |
||||
onRemove: () => dispatch(removeFromListEditor(accountId)), |
||||
onAdd: () => dispatch(addToListEditor(accountId)), |
||||
}); |
||||
|
||||
@connect(makeMapStateToProps, mapDispatchToProps) |
||||
@injectIntl |
||||
export default class Account extends ImmutablePureComponent { |
||||
|
||||
static propTypes = { |
||||
account: ImmutablePropTypes.map.isRequired, |
||||
intl: PropTypes.object.isRequired, |
||||
onRemove: PropTypes.func.isRequired, |
||||
onAdd: PropTypes.func.isRequired, |
||||
added: PropTypes.bool, |
||||
}; |
||||
|
||||
static defaultProps = { |
||||
added: false, |
||||
}; |
||||
|
||||
render () { |
||||
const { account, intl, onRemove, onAdd, added } = this.props; |
||||
|
||||
let button; |
||||
|
||||
if (added) { |
||||
button = <IconButton icon='times' title={intl.formatMessage(messages.remove)} onClick={onRemove} />; |
||||
} else { |
||||
button = <IconButton icon='plus' title={intl.formatMessage(messages.add)} onClick={onAdd} />; |
||||
} |
||||
|
||||
return ( |
||||
<div className='account'> |
||||
<div className='account__wrapper'> |
||||
<div className='account__display-name'> |
||||
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div> |
||||
<DisplayName account={account} /> |
||||
</div> |
||||
|
||||
<div className='account__relationship'> |
||||
{button} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import { connect } from 'react-redux'; |
||||
import { defineMessages, injectIntl } from 'react-intl'; |
||||
import { fetchListSuggestions, clearListSuggestions, changeListSuggestions } from '../../../actions/lists'; |
||||
import classNames from 'classnames'; |
||||
|
||||
const messages = defineMessages({ |
||||
search: { id: 'lists.search', defaultMessage: 'Search among people you follow' }, |
||||
}); |
||||
|
||||
const mapStateToProps = state => ({ |
||||
value: state.getIn(['listEditor', 'suggestions', 'value']), |
||||
}); |
||||
|
||||
const mapDispatchToProps = dispatch => ({ |
||||
onSubmit: value => dispatch(fetchListSuggestions(value)), |
||||
onClear: () => dispatch(clearListSuggestions()), |
||||
onChange: value => dispatch(changeListSuggestions(value)), |
||||
}); |
||||
|
||||
@connect(mapStateToProps, mapDispatchToProps) |
||||
@injectIntl |
||||
export default class Search extends React.PureComponent { |
||||
|
||||
static propTypes = { |
||||
intl: PropTypes.object.isRequired, |
||||
value: PropTypes.string.isRequired, |
||||
onChange: PropTypes.func.isRequired, |
||||
onSubmit: PropTypes.func.isRequired, |
||||
onClear: PropTypes.func.isRequired, |
||||
}; |
||||
|
||||
handleChange = e => { |
||||
this.props.onChange(e.target.value); |
||||
} |
||||
|
||||
handleKeyUp = e => { |
||||
if (e.keyCode === 13) { |
||||
this.props.onSubmit(this.props.value); |
||||
} |
||||
} |
||||
|
||||
handleClear = () => { |
||||
this.props.onClear(); |
||||
} |
||||
|
||||
render () { |
||||
const { value, intl } = this.props; |
||||
const hasValue = value.length > 0; |
||||
|
||||
return ( |
||||
<div className='list-editor__search search'> |
||||
<label> |
||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.search)}</span> |
||||
|
||||
<input |
||||
className='search__input' |
||||
type='text' |
||||
value={value} |
||||
onChange={this.handleChange} |
||||
onKeyUp={this.handleKeyUp} |
||||
placeholder={intl.formatMessage(messages.search)} |
||||
/> |
||||
</label> |
||||
|
||||
<div role='button' tabIndex='0' className='search__icon' onClick={this.handleClear}> |
||||
<i className={classNames('fa fa-search', { active: !hasValue })} /> |
||||
<i aria-label={intl.formatMessage(messages.search)} className={classNames('fa fa-times-circle', { active: hasValue })} /> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,80 @@ |
||||
import React from 'react'; |
||||
import PropTypes from 'prop-types'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import { connect } from 'react-redux'; |
||||
import ImmutablePureComponent from 'react-immutable-pure-component'; |
||||
import { injectIntl } from 'react-intl'; |
||||
import { setupListEditor, clearListSuggestions, resetListEditor } from 'flavours/glitch/actions/lists'; |
||||
import Account from './components/account'; |
||||
import Search from './components/search'; |
||||
import Motion from 'flavours/glitch/util/optional_motion'; |
||||
import spring from 'react-motion/lib/spring'; |
||||
|
||||
const mapStateToProps = state => ({ |
||||
title: state.getIn(['listEditor', 'title']), |
||||
accountIds: state.getIn(['listEditor', 'accounts', 'items']), |
||||
searchAccountIds: state.getIn(['listEditor', 'suggestions', 'items']), |
||||
}); |
||||
|
||||
const mapDispatchToProps = dispatch => ({ |
||||
onInitialize: listId => dispatch(setupListEditor(listId)), |
||||
onClear: () => dispatch(clearListSuggestions()), |
||||
onReset: () => dispatch(resetListEditor()), |
||||
}); |
||||
|
||||
@connect(mapStateToProps, mapDispatchToProps) |
||||
@injectIntl |
||||
export default class ListEditor extends ImmutablePureComponent { |
||||
|
||||
static propTypes = { |
||||
listId: PropTypes.string.isRequired, |
||||
onClose: PropTypes.func.isRequired, |
||||
intl: PropTypes.object.isRequired, |
||||
onInitialize: PropTypes.func.isRequired, |
||||
onClear: PropTypes.func.isRequired, |
||||
onReset: PropTypes.func.isRequired, |
||||
title: PropTypes.string.isRequired, |
||||
accountIds: ImmutablePropTypes.list.isRequired, |
||||
searchAccountIds: ImmutablePropTypes.list.isRequired, |
||||
}; |
||||
|
||||
componentDidMount () { |
||||
const { onInitialize, listId } = this.props; |
||||
onInitialize(listId); |
||||
} |
||||
|
||||
componentWillUnmount () { |
||||
const { onReset } = this.props; |
||||
onReset(); |
||||
} |
||||
|
||||
render () { |
||||
const { title, accountIds, searchAccountIds, onClear } = this.props; |
||||
const showSearch = searchAccountIds.size > 0; |
||||
|
||||
return ( |
||||
<div className='modal-root__modal list-editor'> |
||||
<h4>{title}</h4> |
||||
|
||||
<Search /> |
||||
|
||||
<div className='drawer__pager'> |
||||
<div className='drawer__inner list-editor__accounts'> |
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)} |
||||
</div> |
||||
|
||||
{showSearch && <div role='button' tabIndex='-1' className='drawer__backdrop' onClick={onClear} />} |
||||
|
||||
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}> |
||||
{({ x }) => |
||||
<div className='drawer__inner backdrop' style={{ transform: x === 0 ? null : `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}> |
||||
{searchAccountIds.map(accountId => <Account key={accountId} accountId={accountId} />)} |
||||
</div> |
||||
} |
||||
</Motion> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,170 @@ |
||||
import React from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import PropTypes from 'prop-types'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container'; |
||||
import Column from 'flavours/glitch/components/column'; |
||||
import ColumnHeader from 'flavours/glitch/components/column_header'; |
||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns'; |
||||
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; |
||||
import { connectListStream } from 'flavours/glitch/actions/streaming'; |
||||
import { refreshListTimeline, expandListTimeline } from 'flavours/glitch/actions/timelines'; |
||||
import { fetchList, deleteList } from 'flavours/glitch/actions/lists'; |
||||
import { openModal } from 'flavours/glitch/actions/modal'; |
||||
import MissingIndicator from 'flavours/glitch/components/missing_indicator'; |
||||
import LoadingIndicator from 'flavours/glitch/components/loading_indicator'; |
||||
|
||||
const messages = defineMessages({ |
||||
deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, |
||||
deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, |
||||
}); |
||||
|
||||
const mapStateToProps = (state, props) => ({ |
||||
list: state.getIn(['lists', props.params.id]), |
||||
hasUnread: state.getIn(['timelines', `list:${props.params.id}`, 'unread']) > 0, |
||||
}); |
||||
|
||||
@connect(mapStateToProps) |
||||
@injectIntl |
||||
export default class ListTimeline extends React.PureComponent { |
||||
|
||||
static contextTypes = { |
||||
router: PropTypes.object, |
||||
}; |
||||
|
||||
static propTypes = { |
||||
params: PropTypes.object.isRequired, |
||||
dispatch: PropTypes.func.isRequired, |
||||
columnId: PropTypes.string, |
||||
hasUnread: PropTypes.bool, |
||||
multiColumn: PropTypes.bool, |
||||
list: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]), |
||||
intl: PropTypes.object.isRequired, |
||||
}; |
||||
|
||||
handlePin = () => { |
||||
const { columnId, dispatch } = this.props; |
||||
|
||||
if (columnId) { |
||||
dispatch(removeColumn(columnId)); |
||||
} else { |
||||
dispatch(addColumn('LIST', { id: this.props.params.id })); |
||||
this.context.router.history.push('/'); |
||||
} |
||||
} |
||||
|
||||
handleMove = (dir) => { |
||||
const { columnId, dispatch } = this.props; |
||||
dispatch(moveColumn(columnId, dir)); |
||||
} |
||||
|
||||
handleHeaderClick = () => { |
||||
this.column.scrollTop(); |
||||
} |
||||
|
||||
componentDidMount () { |
||||
const { dispatch } = this.props; |
||||
const { id } = this.props.params; |
||||
|
||||
dispatch(fetchList(id)); |
||||
dispatch(refreshListTimeline(id)); |
||||
|
||||
this.disconnect = dispatch(connectListStream(id)); |
||||
} |
||||
|
||||
componentWillUnmount () { |
||||
if (this.disconnect) { |
||||
this.disconnect(); |
||||
this.disconnect = null; |
||||
} |
||||
} |
||||
|
||||
setRef = c => { |
||||
this.column = c; |
||||
} |
||||
|
||||
handleLoadMore = () => { |
||||
const { id } = this.props.params; |
||||
this.props.dispatch(expandListTimeline(id)); |
||||
} |
||||
|
||||
handleEditClick = () => { |
||||
this.props.dispatch(openModal('LIST_EDITOR', { listId: this.props.params.id })); |
||||
} |
||||
|
||||
handleDeleteClick = () => { |
||||
const { dispatch, columnId, intl } = this.props; |
||||
const { id } = this.props.params; |
||||
|
||||
dispatch(openModal('CONFIRM', { |
||||
message: intl.formatMessage(messages.deleteMessage), |
||||
confirm: intl.formatMessage(messages.deleteConfirm), |
||||
onConfirm: () => { |
||||
dispatch(deleteList(id)); |
||||
|
||||
if (!!columnId) { |
||||
dispatch(removeColumn(columnId)); |
||||
} else { |
||||
this.context.router.history.push('/lists'); |
||||
} |
||||
}, |
||||
})); |
||||
} |
||||
|
||||
render () { |
||||
const { hasUnread, columnId, multiColumn, list } = this.props; |
||||
const { id } = this.props.params; |
||||
const pinned = !!columnId; |
||||
const title = list ? list.get('title') : id; |
||||
|
||||
if (typeof list === 'undefined') { |
||||
return ( |
||||
<Column> |
||||
<LoadingIndicator /> |
||||
</Column> |
||||
); |
||||
} else if (list === false) { |
||||
return ( |
||||
<Column> |
||||
<MissingIndicator /> |
||||
</Column> |
||||
); |
||||
} |
||||
|
||||
return ( |
||||
<Column ref={this.setRef}> |
||||
<ColumnHeader |
||||
icon='bars' |
||||
active={hasUnread} |
||||
title={title} |
||||
onPin={this.handlePin} |
||||
onMove={this.handleMove} |
||||
onClick={this.handleHeaderClick} |
||||
pinned={pinned} |
||||
multiColumn={multiColumn} |
||||
> |
||||
<div className='column-header__links'> |
||||
<button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleEditClick}> |
||||
<i className='fa fa-pencil' /> <FormattedMessage id='lists.edit' defaultMessage='Edit list' /> |
||||
</button> |
||||
|
||||
<button className='text-btn column-header__setting-btn' tabIndex='0' onClick={this.handleDeleteClick}> |
||||
<i className='fa fa-trash' /> <FormattedMessage id='lists.delete' defaultMessage='Delete list' /> |
||||
</button> |
||||
</div> |
||||
|
||||
<hr /> |
||||
</ColumnHeader> |
||||
|
||||
<StatusListContainer |
||||
trackScroll={!pinned} |
||||
scrollKey={`list_timeline-${columnId}`} |
||||
timelineId={`list:${id}`} |
||||
loadMore={this.handleLoadMore} |
||||
emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet.' />} |
||||
/> |
||||
</Column> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,78 @@ |
||||
import React from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import PropTypes from 'prop-types'; |
||||
import { changeListEditorTitle, submitListEditor } from 'flavours/glitch/actions/lists'; |
||||
import IconButton from 'flavours/glitch/components/icon_button'; |
||||
import { defineMessages, injectIntl } from 'react-intl'; |
||||
|
||||
const messages = defineMessages({ |
||||
label: { id: 'lists.new.title_placeholder', defaultMessage: 'New list title' }, |
||||
title: { id: 'lists.new.create', defaultMessage: 'Add list' }, |
||||
}); |
||||
|
||||
const mapStateToProps = state => ({ |
||||
value: state.getIn(['listEditor', 'title']), |
||||
disabled: state.getIn(['listEditor', 'isSubmitting']), |
||||
}); |
||||
|
||||
const mapDispatchToProps = dispatch => ({ |
||||
onChange: value => dispatch(changeListEditorTitle(value)), |
||||
onSubmit: () => dispatch(submitListEditor(true)), |
||||
}); |
||||
|
||||
@connect(mapStateToProps, mapDispatchToProps) |
||||
@injectIntl |
||||
export default class NewListForm extends React.PureComponent { |
||||
|
||||
static propTypes = { |
||||
value: PropTypes.string.isRequired, |
||||
disabled: PropTypes.bool, |
||||
intl: PropTypes.object.isRequired, |
||||
onChange: PropTypes.func.isRequired, |
||||
onSubmit: PropTypes.func.isRequired, |
||||
}; |
||||
|
||||
handleChange = e => { |
||||
this.props.onChange(e.target.value); |
||||
} |
||||
|
||||
handleSubmit = e => { |
||||
e.preventDefault(); |
||||
this.props.onSubmit(); |
||||
} |
||||
|
||||
handleClick = () => { |
||||
this.props.onSubmit(); |
||||
} |
||||
|
||||
render () { |
||||
const { value, disabled, intl } = this.props; |
||||
|
||||
const label = intl.formatMessage(messages.label); |
||||
const title = intl.formatMessage(messages.title); |
||||
|
||||
return ( |
||||
<form className='column-inline-form' onSubmit={this.handleSubmit}> |
||||
<label> |
||||
<span style={{ display: 'none' }}>{label}</span> |
||||
|
||||
<input |
||||
className='setting-text' |
||||
value={value} |
||||
disabled={disabled} |
||||
onChange={this.handleChange} |
||||
placeholder={label} |
||||
/> |
||||
</label> |
||||
|
||||
<IconButton |
||||
disabled={disabled} |
||||
icon='plus' |
||||
title={title} |
||||
onClick={this.handleClick} |
||||
/> |
||||
</form> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,76 @@ |
||||
import React from 'react'; |
||||
import { connect } from 'react-redux'; |
||||
import PropTypes from 'prop-types'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import LoadingIndicator from 'flavours/glitch/components/loading_indicator'; |
||||
import Column from 'flavours/glitch/features/ui/components/column'; |
||||
import ColumnBackButtonSlim from 'flavours/glitch/components/column_back_button_slim'; |
||||
import { fetchLists } from 'flavours/glitch/actions/lists'; |
||||
import { defineMessages, injectIntl } from 'react-intl'; |
||||
import ImmutablePureComponent from 'react-immutable-pure-component'; |
||||
import ColumnLink from 'flavours/glitch/features/ui/components/column_link'; |
||||
import ColumnSubheading from 'flavours/glitch/features/ui/components/column_subheading'; |
||||
import NewListForm from './components/new_list_form'; |
||||
import { createSelector } from 'reselect'; |
||||
|
||||
const messages = defineMessages({ |
||||
heading: { id: 'column.lists', defaultMessage: 'Lists' }, |
||||
subheading: { id: 'lists.subheading', defaultMessage: 'Your lists' }, |
||||
}); |
||||
|
||||
const getOrderedLists = createSelector([state => state.get('lists')], lists => { |
||||
if (!lists) { |
||||
return lists; |
||||
} |
||||
|
||||
return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title'))); |
||||
}); |
||||
|
||||
const mapStateToProps = state => ({ |
||||
lists: getOrderedLists(state), |
||||
}); |
||||
|
||||
@connect(mapStateToProps) |
||||
@injectIntl |
||||
export default class Lists extends ImmutablePureComponent { |
||||
|
||||
static propTypes = { |
||||
params: PropTypes.object.isRequired, |
||||
dispatch: PropTypes.func.isRequired, |
||||
lists: ImmutablePropTypes.list, |
||||
intl: PropTypes.object.isRequired, |
||||
}; |
||||
|
||||
componentWillMount () { |
||||
this.props.dispatch(fetchLists()); |
||||
} |
||||
|
||||
render () { |
||||
const { intl, lists } = this.props; |
||||
|
||||
if (!lists) { |
||||
return ( |
||||
<Column> |
||||
<LoadingIndicator /> |
||||
</Column> |
||||
); |
||||
} |
||||
|
||||
return ( |
||||
<Column icon='bars' heading={intl.formatMessage(messages.heading)}> |
||||
<ColumnBackButtonSlim /> |
||||
|
||||
<NewListForm /> |
||||
|
||||
<div className='scrollable'> |
||||
<ColumnSubheading text={intl.formatMessage(messages.subheading)} /> |
||||
|
||||
{lists.map(list => |
||||
<ColumnLink key={list.get('id')} to={`/timelines/list/${list.get('id')}`} icon='bars' text={list.get('title')} /> |
||||
)} |
||||
</div> |
||||
</Column> |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/ar.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/bg.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/ca.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/de.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,52 @@ |
||||
import inherited from 'mastodon/locales/en.json'; |
||||
|
||||
const messages = { |
||||
'getting_started.open_source_notice': 'Glitchsoc is free open source software forked from {Mastodon}. You can contribute or report issues on GitHub at {github}.', |
||||
'layout.auto': 'Auto', |
||||
'layout.current_is': 'Your current layout is:', |
||||
'layout.desktop': 'Desktop', |
||||
'layout.mobile': 'Mobile', |
||||
'navigation_bar.app_settings': 'App settings', |
||||
'getting_started.onboarding': 'Show me around', |
||||
'onboarding.page_one.federation': '{domain} is an \'instance\' of Mastodon. Mastodon is a network of independent servers joining up to make one larger social network. We call these servers instances.', |
||||
'onboarding.page_one.welcome': 'Welcome to {domain}!', |
||||
'onboarding.page_six.github': '{domain} runs on Glitchsoc. Glitchsoc is a friendly {fork} of {Mastodon}, and is compatible with any Mastodon instance or app. Glitchsoc is entirely free and open-source. You can report bugs, request features, or contribute to the code on {github}.', |
||||
'settings.auto_collapse': 'Automatic collapsing', |
||||
'settings.auto_collapse_all': 'Everything', |
||||
'settings.auto_collapse_lengthy': 'Lengthy toots', |
||||
'settings.auto_collapse_media': 'Toots with media', |
||||
'settings.auto_collapse_notifications': 'Notifications', |
||||
'settings.auto_collapse_reblogs': 'Boosts', |
||||
'settings.auto_collapse_replies': 'Replies', |
||||
'settings.close': 'Close', |
||||
'settings.collapsed_statuses': 'Collapsed toots', |
||||
'settings.enable_collapsed': 'Enable collapsed toots', |
||||
'settings.general': 'General', |
||||
'settings.image_backgrounds': 'Image backgrounds', |
||||
'settings.image_backgrounds_media': 'Preview collapsed toot media', |
||||
'settings.image_backgrounds_users': 'Give collapsed toots an image background', |
||||
'settings.media': 'Media', |
||||
'settings.media_letterbox': 'Letterbox media', |
||||
'settings.media_fullwidth': 'Full-width media previews', |
||||
'settings.preferences': 'User preferences', |
||||
'settings.wide_view': 'Wide view (Desktop mode only)', |
||||
'settings.navbar_under': 'Navbar at the bottom (Mobile only)', |
||||
'status.collapse': 'Collapse', |
||||
'status.uncollapse': 'Uncollapse', |
||||
|
||||
"favourite_modal.combo": "You can press {combo} to skip this next time", |
||||
|
||||
'home.column_settings.show_direct': 'Show DMs', |
||||
|
||||
'notification.markForDeletion': 'Mark for deletion', |
||||
'notifications.clear': 'Clear all my notifications', |
||||
'notifications.marked_clear_confirmation': 'Are you sure you want to permanently clear all selected notifications?', |
||||
'notifications.marked_clear': 'Clear selected notifications', |
||||
|
||||
'notification_purge.btn_all': 'Select\nall', |
||||
'notification_purge.btn_none': 'Select\nnone', |
||||
'notification_purge.btn_invert': 'Invert\nselection', |
||||
'notification_purge.btn_apply': 'Clear\nselected', |
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/eo.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/es.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/fa.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/fi.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/fr.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/he.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/hr.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/hu.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/id.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/io.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/it.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,48 @@ |
||||
import inherited from 'mastodon/locales/ja.json'; |
||||
|
||||
const messages = { |
||||
'getting_started.open_source_notice': 'Glitchsocは{Mastodon}によるフリーなオープンソースソフトウェアです。誰でもGitHub({github})から開発に參加したり、問題を報告したりできます。', |
||||
'layout.auto': '自動', |
||||
'layout.current_is': 'あなたの現在のレイアウト:', |
||||
'layout.desktop': 'デスクトップ', |
||||
'layout.mobile': 'モバイル', |
||||
'navigation_bar.app_settings': 'アプリ設定', |
||||
'getting_started.onboarding': '解説', |
||||
'onboarding.page_one.federation': '{domain}はMastodonのインスタンスです。Mastodonとは、独立したサーバが連携して作るソーシャルネットワークです。これらのサーバーをインスタンスと呼びます。', |
||||
'onboarding.page_one.welcome': '{domain}へようこそ!', |
||||
'onboarding.page_six.github': '{domain}はGlitchsocを使用しています。Glitchsocは{Mastodon}のフレンドリーな{fork}で、どんなMastodonアプリやインスタンスとも互換性があります。Glitchsocは完全に無料で、オープンソースです。{github}でバグ報告や機能要望あるいは貢獻をすることが可能です。', |
||||
'settings.auto_collapse': '自動折りたたみ', |
||||
'settings.auto_collapse_all': 'すべて', |
||||
'settings.auto_collapse_lengthy': '長いトゥート', |
||||
'settings.auto_collapse_media': 'メディア付きトゥート', |
||||
'settings.auto_collapse_notifications': '通知', |
||||
'settings.auto_collapse_reblogs': 'ブースト', |
||||
'settings.auto_collapse_replies': '返信', |
||||
'settings.close': '閉じる', |
||||
'settings.collapsed_statuses': 'トゥート', |
||||
'settings.enable_collapsed': 'トゥート折りたたみを有効にする', |
||||
'settings.general': '一般', |
||||
'settings.image_backgrounds': '画像背景', |
||||
'settings.image_backgrounds_media': '折りたまれたメディア付きテゥートをプレビュー', |
||||
'settings.image_backgrounds_users': '折りたまれたトゥートの背景を変更する', |
||||
'settings.media': 'メディア', |
||||
'settings.media_letterbox': 'メディアをレターボックス式で表示', |
||||
'settings.media_fullwidth': '全幅メディアプリビュー', |
||||
'settings.preferences': 'ユーザー設定', |
||||
'settings.wide_view': 'ワイドビュー(デスクトップレイアウトのみ)', |
||||
'settings.navbar_under': 'ナビを画面下部に移動させる(モバイルレイアウトのみ)', |
||||
'status.collapse': '折りたたむ', |
||||
'status.uncollapse': '折りたたみを解除', |
||||
|
||||
'notification.markForDeletion': '選択', |
||||
'notifications.clear': '通知を全てクリアする', |
||||
'notifications.marked_clear_confirmation': '削除した全ての通知を完全に削除してもよろしいですか?', |
||||
'notifications.marked_clear': '選択した通知を削除する', |
||||
|
||||
'notification_purge.btn_all': 'すべて\n選択', |
||||
'notification_purge.btn_none': '選択\n解除', |
||||
'notification_purge.btn_invert': '選択を\n反転', |
||||
'notification_purge.btn_apply': '選択したものを\n削除', |
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/ko.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/nl.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/no.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/oc.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,48 @@ |
||||
import inherited from 'mastodon/locales/pl.json'; |
||||
|
||||
const messages = { |
||||
'getting_started.open_source_notice': 'Glitchsoc jest wolnym i otwartoźródłowym forkiem oprogramowania {Mastodon}. Możesz współtworzyć projekt lub zgłaszać błędy na GitHubie pod adresem {github}.', |
||||
'layout.auto': 'Automatyczny', |
||||
'layout.current_is': 'Twój obecny układ to:', |
||||
'layout.desktop': 'Desktopowy', |
||||
'layout.mobile': 'Mobilny', |
||||
'navigation_bar.app_settings': 'Ustawienia aplikacji', |
||||
'getting_started.onboarding': 'Rozejrzyj się', |
||||
'onboarding.page_one.federation': '{domain} jest \'instancją\' Mastodona. Mastodon to sieć działających niezależnie serwerów tworzących jedną sieć społecznościową. Te serwery nazywane są instancjami.', |
||||
'onboarding.page_one.welcome': 'Witamy na {domain}!', |
||||
'onboarding.page_six.github': '{domain} jest oparty na Glitchsoc. Glitchsoc jest {forkiem} {Mastodon}a kompatybilnym z każdym klientem i aplikacją Mastodona. Glitchsoc jest całkowicie wolnym i otwartoźródłowym oprogramowaniem. Możesz zgłaszać błędy i sugestie funkcji oraz współtworzyć projekt na {github}.', |
||||
'settings.auto_collapse': 'Automatyczne zwijanie', |
||||
'settings.auto_collapse_all': 'Wszystko', |
||||
'settings.auto_collapse_lengthy': 'Długie wpisy', |
||||
'settings.auto_collapse_media': 'Wpisy z zawartością multimedialną', |
||||
'settings.auto_collapse_notifications': 'Powiadomienia', |
||||
'settings.auto_collapse_reblogs': 'Podbicia', |
||||
'settings.auto_collapse_replies': 'Odpowiedzi', |
||||
'settings.close': 'Zamknij', |
||||
'settings.collapsed_statuses': 'Zwijanie wpisów', |
||||
'settings.enable_collapsed': 'Włącz zwijanie wpisów', |
||||
'settings.general': 'Ogólne', |
||||
'settings.image_backgrounds': 'Obrazy w tle', |
||||
'settings.image_backgrounds_media': 'Wyświetlaj zawartość multimedialną zwiniętych wpisów', |
||||
'settings.image_backgrounds_users': 'Nadaj tło zwiniętym wpisom', |
||||
'settings.media': 'Zawartość multimedialna', |
||||
'settings.media_letterbox': 'Letterbox media', |
||||
'settings.media_fullwidth': 'Podgląd zawartości multimedialnej o pełnej szerokości', |
||||
'settings.preferences': 'Preferencje użyytkownika', |
||||
'settings.wide_view': 'Szeroki widok (tylko w trybie desktopowym)', |
||||
'settings.navbar_under': 'Pasek nawigacji na dole (tylko w trybie mobilnym)', |
||||
'status.collapse': 'Zwiń', |
||||
'status.uncollapse': 'Rozwiń', |
||||
|
||||
'notification.markForDeletion': 'Oznacz do usunięcia', |
||||
'notifications.clear': 'Wyczyść wszystkie powiadomienia', |
||||
'notifications.marked_clear_confirmation': 'Czy na pewno chcesz bezpowrtonie usunąć wszystkie powiadomienia?', |
||||
'notifications.marked_clear': 'Usuń zaznaczone powiadomienia', |
||||
|
||||
'notification_purge.btn_all': 'Zaznacz\nwszystkie', |
||||
'notification_purge.btn_none': 'Odznacz\nwszystkie', |
||||
'notification_purge.btn_invert': 'Odwróć\nzaznaczenie', |
||||
'notification_purge.btn_apply': 'Usuń\nzaznaczone', |
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/pt-BR.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/pt.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/ru.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/sv.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/th.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/tr.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/uk.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/zh-CN.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/zh-HK.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,7 @@ |
||||
import inherited from 'mastodon/locales/zh-TW.json'; |
||||
|
||||
const messages = { |
||||
// No translations available.
|
||||
}; |
||||
|
||||
export default Object.assign({}, inherited, messages); |
@ -0,0 +1,6 @@ |
||||
en: |
||||
flavours: |
||||
glitch: Glitch Edition |
||||
skins: |
||||
glitch: |
||||
default: Default |
@ -0,0 +1,89 @@ |
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; |
||||
import { |
||||
LIST_CREATE_REQUEST, |
||||
LIST_CREATE_FAIL, |
||||
LIST_CREATE_SUCCESS, |
||||
LIST_UPDATE_REQUEST, |
||||
LIST_UPDATE_FAIL, |
||||
LIST_UPDATE_SUCCESS, |
||||
LIST_EDITOR_RESET, |
||||
LIST_EDITOR_SETUP, |
||||
LIST_EDITOR_TITLE_CHANGE, |
||||
LIST_ACCOUNTS_FETCH_REQUEST, |
||||
LIST_ACCOUNTS_FETCH_SUCCESS, |
||||
LIST_ACCOUNTS_FETCH_FAIL, |
||||
LIST_EDITOR_SUGGESTIONS_READY, |
||||
LIST_EDITOR_SUGGESTIONS_CLEAR, |
||||
LIST_EDITOR_SUGGESTIONS_CHANGE, |
||||
LIST_EDITOR_ADD_SUCCESS, |
||||
LIST_EDITOR_REMOVE_SUCCESS, |
||||
} from '../actions/lists'; |
||||
|
||||
const initialState = ImmutableMap({ |
||||
listId: null, |
||||
isSubmitting: false, |
||||
title: '', |
||||
|
||||
accounts: ImmutableMap({ |
||||
items: ImmutableList(), |
||||
loaded: false, |
||||
isLoading: false, |
||||
}), |
||||
|
||||
suggestions: ImmutableMap({ |
||||
value: '', |
||||
items: ImmutableList(), |
||||
}), |
||||
}); |
||||
|
||||
export default function listEditorReducer(state = initialState, action) { |
||||
switch(action.type) { |
||||
case LIST_EDITOR_RESET: |
||||
return initialState; |
||||
case LIST_EDITOR_SETUP: |
||||
return state.withMutations(map => { |
||||
map.set('listId', action.list.get('id')); |
||||
map.set('title', action.list.get('title')); |
||||
map.set('isSubmitting', false); |
||||
}); |
||||
case LIST_EDITOR_TITLE_CHANGE: |
||||
return state.set('title', action.value); |
||||
case LIST_CREATE_REQUEST: |
||||
case LIST_UPDATE_REQUEST: |
||||
return state.set('isSubmitting', true); |
||||
case LIST_CREATE_FAIL: |
||||
case LIST_UPDATE_FAIL: |
||||
return state.set('isSubmitting', false); |
||||
case LIST_CREATE_SUCCESS: |
||||
case LIST_UPDATE_SUCCESS: |
||||
return state.withMutations(map => { |
||||
map.set('isSubmitting', false); |
||||
map.set('listId', action.list.id); |
||||
}); |
||||
case LIST_ACCOUNTS_FETCH_REQUEST: |
||||
return state.setIn(['accounts', 'isLoading'], true); |
||||
case LIST_ACCOUNTS_FETCH_FAIL: |
||||
return state.setIn(['accounts', 'isLoading'], false); |
||||
case LIST_ACCOUNTS_FETCH_SUCCESS: |
||||
return state.update('accounts', accounts => accounts.withMutations(map => { |
||||
map.set('isLoading', false); |
||||
map.set('loaded', true); |
||||
map.set('items', ImmutableList(action.accounts.map(item => item.id))); |
||||
})); |
||||
case LIST_EDITOR_SUGGESTIONS_CHANGE: |
||||
return state.setIn(['suggestions', 'value'], action.value); |
||||
case LIST_EDITOR_SUGGESTIONS_READY: |
||||
return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id))); |
||||
case LIST_EDITOR_SUGGESTIONS_CLEAR: |
||||
return state.update('suggestions', suggestions => suggestions.withMutations(map => { |
||||
map.set('items', ImmutableList()); |
||||
map.set('value', ''); |
||||
})); |
||||
case LIST_EDITOR_ADD_SUCCESS: |
||||
return state.updateIn(['accounts', 'items'], list => list.unshift(action.accountId)); |
||||
case LIST_EDITOR_REMOVE_SUCCESS: |
||||
return state.updateIn(['accounts', 'items'], list => list.filterNot(item => item === action.accountId)); |
||||
default: |
||||
return state; |
||||
} |
||||
}; |
@ -0,0 +1,37 @@ |
||||
import { |
||||
LIST_FETCH_SUCCESS, |
||||
LIST_FETCH_FAIL, |
||||
LISTS_FETCH_SUCCESS, |
||||
LIST_CREATE_SUCCESS, |
||||
LIST_UPDATE_SUCCESS, |
||||
LIST_DELETE_SUCCESS, |
||||
} from '../actions/lists'; |
||||
import { Map as ImmutableMap, fromJS } from 'immutable'; |
||||
|
||||
const initialState = ImmutableMap(); |
||||
|
||||
const normalizeList = (state, list) => state.set(list.id, fromJS(list)); |
||||
|
||||
const normalizeLists = (state, lists) => { |
||||
lists.forEach(list => { |
||||
state = normalizeList(state, list); |
||||
}); |
||||
|
||||
return state; |
||||
}; |
||||
|
||||
export default function lists(state = initialState, action) { |
||||
switch(action.type) { |
||||
case LIST_FETCH_SUCCESS: |
||||
case LIST_CREATE_SUCCESS: |
||||
case LIST_UPDATE_SUCCESS: |
||||
return normalizeList(state, action.list); |
||||
case LISTS_FETCH_SUCCESS: |
||||
return normalizeLists(state, action.lists); |
||||
case LIST_DELETE_SUCCESS: |
||||
case LIST_FETCH_FAIL: |
||||
return state.set(action.id, false); |
||||
default: |
||||
return state; |
||||
} |
||||
}; |
@ -0,0 +1,6 @@ |
||||
en: |
||||
flavours: |
||||
vanilla: Vanilla Mastodon |
||||
skins: |
||||
vanilla: |
||||
default: Default |
@ -1,48 +0,0 @@ |
||||
{ |
||||
"getting_started.open_source_notice": "Glitchsoc is free open source software forked from {Mastodon}. You can contribute or report issues on GitHub at {github}.", |
||||
"layout.auto": "Auto", |
||||
"layout.current_is": "Your current layout is:", |
||||
"layout.desktop": "Desktop", |
||||
"layout.mobile": "Mobile", |
||||
"navigation_bar.app_settings": "App settings", |
||||
"getting_started.onboarding": "Show me around", |
||||
"onboarding.page_one.federation": "{domain} is an 'instance' of Mastodon. Mastodon is a network of independent servers joining up to make one larger social network. We call these servers instances.", |
||||
"onboarding.page_one.welcome": "Welcome to {domain}!", |
||||
"onboarding.page_six.github": "{domain} runs on Glitchsoc. Glitchsoc is a friendly {fork} of {Mastodon}, and is compatible with any Mastodon instance or app. Glitchsoc is entirely free and open-source. You can report bugs, request features, or contribute to the code on {github}.", |
||||
"settings.auto_collapse": "Automatic collapsing", |
||||
"settings.auto_collapse_all": "Everything", |
||||
"settings.auto_collapse_lengthy": "Lengthy toots", |
||||
"settings.auto_collapse_media": "Toots with media", |
||||
"settings.auto_collapse_notifications": "Notifications", |
||||
"settings.auto_collapse_reblogs": "Boosts", |
||||
"settings.auto_collapse_replies": "Replies", |
||||
"settings.close": "Close", |
||||
"settings.collapsed_statuses": "Collapsed toots", |
||||
"settings.enable_collapsed": "Enable collapsed toots", |
||||
"settings.general": "General", |
||||
"settings.image_backgrounds": "Image backgrounds", |
||||
"settings.image_backgrounds_media": "Preview collapsed toot media", |
||||
"settings.image_backgrounds_users": "Give collapsed toots an image background", |
||||
"settings.media": "Media", |
||||
"settings.media_letterbox": "Letterbox media", |
||||
"settings.media_fullwidth": "Full-width media previews", |
||||
"settings.preferences": "User preferences", |
||||
"settings.wide_view": "Wide view (Desktop mode only)", |
||||
"settings.navbar_under": "Navbar at the bottom (Mobile only)", |
||||
"status.collapse": "Collapse", |
||||
"status.uncollapse": "Uncollapse", |
||||
|
||||
"favourite_modal.combo": "You can press {combo} to skip this next time", |
||||
|
||||
"home.column_settings.show_direct": "Show DMs", |
||||
|
||||
"notification.markForDeletion": "Mark for deletion", |
||||
"notifications.clear": "Clear all my notifications", |
||||
"notifications.marked_clear_confirmation": "Are you sure you want to permanently clear all selected notifications?", |
||||
"notifications.marked_clear": "Clear selected notifications", |
||||
|
||||
"notification_purge.btn_all": "Select\nall", |
||||
"notification_purge.btn_none": "Select\nnone", |
||||
"notification_purge.btn_invert": "Invert\nselection", |
||||
"notification_purge.btn_apply": "Clear\nselected" |
||||
} |
@ -1,44 +0,0 @@ |
||||
{ |
||||
"getting_started.open_source_notice": "Glitchsoc jest wolnym i otwartoźródłowym forkiem oprogramowania {Mastodon}. Możesz współtworzyć projekt lub zgłaszać błędy na GitHubie pod adresem {github}.", |
||||
"layout.auto": "Automatyczny", |
||||
"layout.current_is": "Twój obecny układ to:", |
||||
"layout.desktop": "Desktopowy", |
||||
"layout.mobile": "Mobilny", |
||||
"navigation_bar.app_settings": "Ustawienia aplikacji", |
||||
"getting_started.onboarding": "Rozejrzyj się", |
||||
"onboarding.page_one.federation": "{domain} jest 'instancją' Mastodona. Mastodon to sieć działających niezależnie serwerów tworzących jedną sieć społecznościową. Te serwery nazywane są instancjami.", |
||||
"onboarding.page_one.welcome": "Witamy na {domain}!", |
||||
"onboarding.page_six.github": "{domain} jest oparty na Glitchsoc. Glitchsoc jest {forkiem} {Mastodon}a kompatybilnym z każdym klientem i aplikacją Mastodona. Glitchsoc jest całkowicie wolnym i otwartoźródłowym oprogramowaniem. Możesz zgłaszać błędy i sugestie funkcji oraz współtworzyć projekt na {github}.", |
||||
"settings.auto_collapse": "Automatyczne zwijanie", |
||||
"settings.auto_collapse_all": "Wszystko", |
||||
"settings.auto_collapse_lengthy": "Długie wpisy", |
||||
"settings.auto_collapse_media": "Wpisy z zawartością multimedialną", |
||||
"settings.auto_collapse_notifications": "Powiadomienia", |
||||
"settings.auto_collapse_reblogs": "Podbicia", |
||||
"settings.auto_collapse_replies": "Odpowiedzi", |
||||
"settings.close": "Zamknij", |
||||
"settings.collapsed_statuses": "Zwijanie wpisów", |
||||
"settings.enable_collapsed": "Włącz zwijanie wpisów", |
||||
"settings.general": "Ogólne", |
||||
"settings.image_backgrounds": "Obrazy w tle", |
||||
"settings.image_backgrounds_media": "Wyświetlaj zawartość multimedialną zwiniętych wpisów", |
||||
"settings.image_backgrounds_users": "Nadaj tło zwiniętym wpisom", |
||||
"settings.media": "Zawartość multimedialna", |
||||
"settings.media_letterbox": "Letterbox media", |
||||
"settings.media_fullwidth": "Podgląd zawartości multimedialnej o pełnej szerokości", |
||||
"settings.preferences": "Preferencje użyytkownika", |
||||
"settings.wide_view": "Szeroki widok (tylko w trybie desktopowym)", |
||||
"settings.navbar_under": "Pasek nawigacji na dole (tylko w trybie mobilnym)", |
||||
"status.collapse": "Zwiń", |
||||
"status.uncollapse": "Rozwiń", |
||||
|
||||
"notification.markForDeletion": "Oznacz do usunięcia", |
||||
"notifications.clear": "Wyczyść wszystkie powiadomienia", |
||||
"notifications.marked_clear_confirmation": "Czy na pewno chcesz bezpowrtonie usunąć wszystkie powiadomienia?", |
||||
"notifications.marked_clear": "Usuń zaznaczone powiadomienia", |
||||
|
||||
"notification_purge.btn_all": "Zaznacz\nwszystkie", |
||||
"notification_purge.btn_none": "Odznacz\nwszystkie", |
||||
"notification_purge.btn_invert": "Odwróć\nzaznaczenie", |
||||
"notification_purge.btn_apply": "Usuń\nzaznaczone" |
||||
} |
@ -0,0 +1,4 @@ |
||||
en: |
||||
skins: |
||||
vanilla: |
||||
win95: Masto95 |
@ -0,0 +1,6 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names.{rb,yml}').to_s] |
||||
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names', '*.{rb,yml}').to_s] |
||||
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names.{rb,yml}').to_s] |
||||
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names', '*.{rb,yml}').to_s] |
@ -1,70 +1,66 @@ |
||||
// A message from upstream:
|
||||
// ========================
|
||||
// To avoid adding a lot of boilerplate, locale packs are
|
||||
// automatically generated here. These are written into the tmp/
|
||||
// directory and then used to generate locale_en.js, locale_fr.js, etc.
|
||||
|
||||
const fs = require('fs'); |
||||
const path = require('path'); |
||||
// Glitch note:
|
||||
// ============
|
||||
// This code has been entirely rewritten to support glitch flavours.
|
||||
// However, the underlying process is exactly the same.
|
||||
|
||||
const { existsSync, readdirSync, writeFileSync } = require('fs'); |
||||
const { join, resolve } = require('path'); |
||||
const rimraf = require('rimraf'); |
||||
const mkdirp = require('mkdirp'); |
||||
const { flavours } = require('./configuration.js'); |
||||
|
||||
const localesJsonPath = path.join(__dirname, '../../app/javascript/mastodon/locales'); |
||||
const locales = fs.readdirSync(localesJsonPath).filter(filename => { |
||||
return /\.json$/.test(filename) && |
||||
!/defaultMessages/.test(filename) && |
||||
!/whitelist/.test(filename); |
||||
}).map(filename => filename.replace(/\.json$/, '')); |
||||
|
||||
const outPath = path.join(__dirname, '../../tmp/packs'); |
||||
|
||||
rimraf.sync(outPath); |
||||
mkdirp.sync(outPath); |
||||
|
||||
const outPaths = []; |
||||
|
||||
locales.forEach(locale => { |
||||
const localePath = path.join(outPath, `locale_${locale}.js`); |
||||
const baseLocale = locale.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
|
||||
const localeDataPath = [ |
||||
// first try react-intl
|
||||
`../../node_modules/react-intl/locale-data/${baseLocale}.js`, |
||||
// then check locales/locale-data
|
||||
`../../app/javascript/mastodon/locales/locale-data/${baseLocale}.js`, |
||||
// fall back to English (this is what react-intl does anyway)
|
||||
'../../node_modules/react-intl/locale-data/en.js', |
||||
].filter(filename => fs.existsSync(path.join(outPath, filename))) |
||||
.map(filename => filename.replace(/..\/..\/node_modules\//, ''))[0]; |
||||
|
||||
let glitchInject = ` |
||||
const mergedMessages = messages; |
||||
`;
|
||||
|
||||
const glitchPath = `../../app/javascript/glitch/locales/${locale}.json`; |
||||
if (fs.existsSync(path.join(outPath, glitchPath))) { |
||||
glitchInject = ` |
||||
import glitchMessages from ${JSON.stringify(glitchPath)}; |
||||
|
||||
let mergedMessages = messages; |
||||
Object.keys(glitchMessages).forEach(function (key) { |
||||
mergedMessages[key] = glitchMessages[key]; |
||||
}); |
||||
|
||||
`;
|
||||
module.exports = Object.keys(flavours).reduce(function (map, entry) { |
||||
const flavour = flavours[entry]; |
||||
if (!flavour.locales) { |
||||
return map; |
||||
} |
||||
const locales = readdirSync(flavour.locales).filter( |
||||
filename => /\.js(?:on)?$/.test(filename) && !/defaultMessages|whitelist|index/.test(filename) |
||||
); |
||||
const outPath = resolve('tmp', 'locales', entry); |
||||
|
||||
rimraf.sync(outPath); |
||||
mkdirp.sync(outPath); |
||||
|
||||
const localeContent = `//
|
||||
// locale_${locale}.js
|
||||
locales.forEach(function (locale) { |
||||
const localeName = locale.replace(/\.js(?:on)?$/, ''); |
||||
const localePath = join(outPath, `${localeName}.js`); |
||||
const baseLocale = localeName.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
|
||||
const localeDataPath = [ |
||||
// first try react-intl
|
||||
`node_modules/react-intl/locale-data/${baseLocale}.js`, |
||||
// then check locales/locale-data
|
||||
`app/javascript/locales/locale-data/${baseLocale}.js`, |
||||
// fall back to English (this is what react-intl does anyway)
|
||||
'node_modules/react-intl/locale-data/en.js', |
||||
].filter( |
||||
filename => existsSync(filename) |
||||
).map( |
||||
filename => filename.replace(/(?:node_modules|app\/javascript)\//, '') |
||||
)[0]; |
||||
const localeContent = `//
|
||||
// locales/${entry}/${localeName}.js
|
||||
// automatically generated by generateLocalePacks.js
|
||||
//
|
||||
import messages from '../../app/javascript/mastodon/locales/${locale}.json'; |
||||
import localeData from ${JSON.stringify(localeDataPath)}; |
||||
import { setLocale } from 'locales'; |
||||
${glitchInject} |
||||
setLocale({messages: mergedMessages, localeData: localeData}); |
||||
`;
|
||||
fs.writeFileSync(localePath, localeContent, 'utf8'); |
||||
outPaths.push(localePath); |
||||
}); |
||||
|
||||
module.exports = outPaths; |
||||
import messages from '../../../${flavour.locales}/${locale.replace(/\.js$/, '')}'; |
||||
import localeData from '${localeDataPath}'; |
||||
import { setLocale } from 'locales'; |
||||
|
||||
setLocale({ |
||||
localeData, |
||||
messages, |
||||
}); |
||||
`;
|
||||
writeFileSync(localePath, localeContent, 'utf8'); |
||||
map[`locales/${entry}/${localeName}`] = localePath; |
||||
}); |
||||
|
||||
return map; |
||||
}, {}); |
||||
|
Loading…
Reference in new issue