From bb5558de627ca9bc26949570025f6193cd7cbd98 Mon Sep 17 00:00:00 2001
From: namelessGonbai <43787036+namelessGonbai@users.noreply.github.com>
Date: Tue, 6 Nov 2018 02:52:38 +0900
Subject: [PATCH] Implement adding a user to a list from their profile (#9062)
* Add add user to list from thier profile
* Fix listAdderCss
---
app/javascript/mastodon/actions/lists.js | 54 ++++++++++++++
.../features/account/components/action_bar.js | 3 +
.../account_timeline/components/header.js | 6 ++
.../containers/header_container.js | 6 ++
.../features/list_adder/components/account.js | 43 +++++++++++
.../features/list_adder/components/list.js | 68 +++++++++++++++++
.../mastodon/features/list_adder/index.js | 73 +++++++++++++++++++
.../features/ui/components/modal_root.js | 2 +
.../features/ui/util/async-components.js | 4 +
app/javascript/mastodon/locales/ar.json | 1 +
app/javascript/mastodon/locales/ast.json | 1 +
app/javascript/mastodon/locales/bg.json | 1 +
app/javascript/mastodon/locales/ca.json | 1 +
app/javascript/mastodon/locales/co.json | 1 +
app/javascript/mastodon/locales/cs.json | 1 +
app/javascript/mastodon/locales/cy.json | 1 +
app/javascript/mastodon/locales/da.json | 1 +
app/javascript/mastodon/locales/de.json | 1 +
.../mastodon/locales/defaultMessages.json | 16 ++++
app/javascript/mastodon/locales/el.json | 1 +
app/javascript/mastodon/locales/en.json | 1 +
app/javascript/mastodon/locales/eo.json | 1 +
app/javascript/mastodon/locales/es.json | 1 +
app/javascript/mastodon/locales/eu.json | 1 +
app/javascript/mastodon/locales/fa.json | 1 +
app/javascript/mastodon/locales/fi.json | 1 +
app/javascript/mastodon/locales/fr.json | 1 +
app/javascript/mastodon/locales/gl.json | 1 +
app/javascript/mastodon/locales/he.json | 1 +
app/javascript/mastodon/locales/hr.json | 1 +
app/javascript/mastodon/locales/hu.json | 1 +
app/javascript/mastodon/locales/hy.json | 1 +
app/javascript/mastodon/locales/id.json | 1 +
app/javascript/mastodon/locales/io.json | 1 +
app/javascript/mastodon/locales/it.json | 1 +
app/javascript/mastodon/locales/ja.json | 1 +
app/javascript/mastodon/locales/ka.json | 1 +
app/javascript/mastodon/locales/ko.json | 1 +
app/javascript/mastodon/locales/nl.json | 1 +
app/javascript/mastodon/locales/no.json | 1 +
app/javascript/mastodon/locales/oc.json | 1 +
app/javascript/mastodon/locales/pl.json | 1 +
app/javascript/mastodon/locales/pt-BR.json | 1 +
app/javascript/mastodon/locales/pt.json | 1 +
app/javascript/mastodon/locales/ro.json | 1 +
app/javascript/mastodon/locales/ru.json | 1 +
app/javascript/mastodon/locales/sk.json | 1 +
app/javascript/mastodon/locales/sl.json | 1 +
app/javascript/mastodon/locales/sr-Latn.json | 1 +
app/javascript/mastodon/locales/sr.json | 1 +
app/javascript/mastodon/locales/sv.json | 1 +
app/javascript/mastodon/locales/ta.json | 1 +
app/javascript/mastodon/locales/te.json | 1 +
app/javascript/mastodon/locales/th.json | 1 +
app/javascript/mastodon/locales/tr.json | 1 +
app/javascript/mastodon/locales/uk.json | 1 +
app/javascript/mastodon/locales/zh-CN.json | 1 +
app/javascript/mastodon/locales/zh-HK.json | 1 +
app/javascript/mastodon/locales/zh-TW.json | 1 +
app/javascript/mastodon/reducers/index.js | 2 +
.../mastodon/reducers/list_adder.js | 47 ++++++++++++
.../styles/mastodon/components.scss | 41 +++++++++++
62 files changed, 414 insertions(+)
create mode 100644 app/javascript/mastodon/features/list_adder/components/account.js
create mode 100644 app/javascript/mastodon/features/list_adder/components/list.js
create mode 100644 app/javascript/mastodon/features/list_adder/index.js
create mode 100644 app/javascript/mastodon/reducers/list_adder.js
diff --git a/app/javascript/mastodon/actions/lists.js b/app/javascript/mastodon/actions/lists.js
index 12cb171599..d736bacef4 100644
--- a/app/javascript/mastodon/actions/lists.js
+++ b/app/javascript/mastodon/actions/lists.js
@@ -42,6 +42,13 @@ 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 LIST_ADDER_RESET = 'LIST_ADDER_RESET';
+export const LIST_ADDER_SETUP = 'LIST_ADDER_SETUP';
+
+export const LIST_ADDER_LISTS_FETCH_REQUEST = 'LIST_ADDER_LISTS_FETCH_REQUEST';
+export const LIST_ADDER_LISTS_FETCH_SUCCESS = 'LIST_ADDER_LISTS_FETCH_SUCCESS';
+export const LIST_ADDER_LISTS_FETCH_FAIL = 'LIST_ADDER_LISTS_FETCH_FAIL';
+
export const fetchList = id => (dispatch, getState) => {
if (getState().getIn(['lists', id])) {
return;
@@ -316,3 +323,50 @@ export const removeFromListFail = (listId, accountId, error) => ({
accountId,
error,
});
+
+export const resetListAdder = () => ({
+ type: LIST_ADDER_RESET,
+});
+
+export const setupListAdder = accountId => (dispatch, getState) => {
+ dispatch({
+ type: LIST_ADDER_SETUP,
+ account: getState().getIn(['accounts', accountId]),
+ });
+ dispatch(fetchLists());
+ dispatch(fetchAccountLists(accountId));
+};
+
+export const fetchAccountLists = accountId => (dispatch, getState) => {
+ dispatch(fetchAccountListsRequest(accountId));
+
+ api(getState).get(`/api/v1/accounts/${accountId}/lists`)
+ .then(({ data }) => dispatch(fetchAccountListsSuccess(accountId, data)))
+ .catch(err => dispatch(fetchAccountListsFail(accountId, err)));
+};
+
+export const fetchAccountListsRequest = id => ({
+ type:LIST_ADDER_LISTS_FETCH_REQUEST,
+ id,
+});
+
+export const fetchAccountListsSuccess = (id, lists) => ({
+ type: LIST_ADDER_LISTS_FETCH_SUCCESS,
+ id,
+ lists,
+});
+
+export const fetchAccountListsFail = (id, err) => ({
+ type: LIST_ADDER_LISTS_FETCH_FAIL,
+ id,
+ err,
+});
+
+export const addToListAdder = listId => (dispatch, getState) => {
+ dispatch(addToList(listId, getState().getIn(['listAdder', 'accountId'])));
+};
+
+export const removeFromListAdder = listId => (dispatch, getState) => {
+ dispatch(removeFromList(listId, getState().getIn(['listAdder', 'accountId'])));
+};
+
diff --git a/app/javascript/mastodon/features/account/components/action_bar.js b/app/javascript/mastodon/features/account/components/action_bar.js
index c9ae2df98b..e6ae1a2fd7 100644
--- a/app/javascript/mastodon/features/account/components/action_bar.js
+++ b/app/javascript/mastodon/features/account/components/action_bar.js
@@ -34,6 +34,7 @@ const messages = defineMessages({
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
endorse: { id: 'account.endorse', defaultMessage: 'Feature on profile' },
unendorse: { id: 'account.unendorse', defaultMessage: 'Don\'t feature on profile' },
+ add_or_remove_from_list: { id: 'account.add_or_remove_from_list', defaultMessage: 'Add or Remove from lists' },
});
export default @injectIntl
@@ -51,6 +52,7 @@ class ActionBar extends React.PureComponent {
onBlockDomain: PropTypes.func.isRequired,
onUnblockDomain: PropTypes.func.isRequired,
onEndorseToggle: PropTypes.func.isRequired,
+ onAddToList: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
@@ -105,6 +107,7 @@ class ActionBar extends React.PureComponent {
}
menu.push({ text: intl.formatMessage(account.getIn(['relationship', 'endorsed']) ? messages.unendorse : messages.endorse), action: this.props.onEndorseToggle });
+ menu.push({ text: intl.formatMessage(messages.add_or_remove_from_list), action: this.props.onAddToList });
menu.push(null);
}
diff --git a/app/javascript/mastodon/features/account_timeline/components/header.js b/app/javascript/mastodon/features/account_timeline/components/header.js
index ab29e4bdf7..779e116e04 100644
--- a/app/javascript/mastodon/features/account_timeline/components/header.js
+++ b/app/javascript/mastodon/features/account_timeline/components/header.js
@@ -23,6 +23,7 @@ export default class Header extends ImmutablePureComponent {
onBlockDomain: PropTypes.func.isRequired,
onUnblockDomain: PropTypes.func.isRequired,
onEndorseToggle: PropTypes.func.isRequired,
+ onAddToList: PropTypes.func.isRequired,
hideTabs: PropTypes.bool,
};
@@ -78,6 +79,10 @@ export default class Header extends ImmutablePureComponent {
this.props.onEndorseToggle(this.props.account);
}
+ handleAddToList = () => {
+ this.props.onAddToList(this.props.account);
+ }
+
render () {
const { account, hideTabs } = this.props;
@@ -106,6 +111,7 @@ export default class Header extends ImmutablePureComponent {
onBlockDomain={this.handleBlockDomain}
onUnblockDomain={this.handleUnblockDomain}
onEndorseToggle={this.handleEndorseToggle}
+ onAddToList={this.handleAddToList}
/>
{!hideTabs && (
diff --git a/app/javascript/mastodon/features/account_timeline/containers/header_container.js b/app/javascript/mastodon/features/account_timeline/containers/header_container.js
index 02803893d8..0fd79d0368 100644
--- a/app/javascript/mastodon/features/account_timeline/containers/header_container.js
+++ b/app/javascript/mastodon/features/account_timeline/containers/header_container.js
@@ -116,6 +116,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(unblockDomain(domain));
},
+ onAddToList(account){
+ dispatch(openModal('LIST_ADDER', {
+ accountId: account.get('id'),
+ }));
+ },
+
});
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));
diff --git a/app/javascript/mastodon/features/list_adder/components/account.js b/app/javascript/mastodon/features/list_adder/components/account.js
new file mode 100644
index 0000000000..1369aac074
--- /dev/null
+++ b/app/javascript/mastodon/features/list_adder/components/account.js
@@ -0,0 +1,43 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { makeGetAccount } from '../../../selectors';
+import ImmutablePureComponent from 'react-immutable-pure-component';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import Avatar from '../../../components/avatar';
+import DisplayName from '../../../components/display_name';
+import { injectIntl } from 'react-intl';
+
+const makeMapStateToProps = () => {
+ const getAccount = makeGetAccount();
+
+ const mapStateToProps = (state, { accountId }) => ({
+ account: getAccount(state, accountId),
+ });
+
+ return mapStateToProps;
+};
+
+
+export default @connect(makeMapStateToProps)
+@injectIntl
+class Account extends ImmutablePureComponent {
+
+ static propTypes = {
+ account: ImmutablePropTypes.map.isRequired,
+ };
+
+ render () {
+ const { account } = this.props;
+ return (
+
+ );
+ }
+
+}
diff --git a/app/javascript/mastodon/features/list_adder/components/list.js b/app/javascript/mastodon/features/list_adder/components/list.js
new file mode 100644
index 0000000000..cb8eb7d7a9
--- /dev/null
+++ b/app/javascript/mastodon/features/list_adder/components/list.js
@@ -0,0 +1,68 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
+import ImmutablePureComponent from 'react-immutable-pure-component';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import IconButton from '../../../components/icon_button';
+import { defineMessages, injectIntl } from 'react-intl';
+import { removeFromListAdder, addToListAdder } from '../../../actions/lists';
+
+const messages = defineMessages({
+ remove: { id: 'lists.account.remove', defaultMessage: 'Remove from list' },
+ add: { id: 'lists.account.add', defaultMessage: 'Add to list' },
+});
+
+const MapStateToProps = (state, { listId, added }) => ({
+ list: state.get('lists').get(listId),
+ added: typeof added === 'undefined' ? state.getIn(['listAdder', 'lists', 'items']).includes(listId) : added,
+});
+
+const mapDispatchToProps = (dispatch, { listId }) => ({
+ onRemove: () => dispatch(removeFromListAdder(listId)),
+ onAdd: () => dispatch(addToListAdder(listId)),
+});
+
+export default @connect(MapStateToProps, mapDispatchToProps)
+@injectIntl
+class List extends ImmutablePureComponent {
+
+ static propTypes = {
+ list: ImmutablePropTypes.map.isRequired,
+ intl: PropTypes.object.isRequired,
+ onRemove: PropTypes.func.isRequired,
+ onAdd: PropTypes.func.isRequired,
+ added: PropTypes.bool,
+ };
+
+ static defaultProps = {
+ added: false,
+ };
+
+ render () {
+ const { list, intl, onRemove, onAdd, added } = this.props;
+
+ let button;
+
+ if (added) {
+ button = ;
+ } else {
+ button = ;
+ }
+
+ return (
+
+
+
+
+ {list.get('title')}
+
+
+
+ {button}
+
+
+
+ );
+ }
+
+}
diff --git a/app/javascript/mastodon/features/list_adder/index.js b/app/javascript/mastodon/features/list_adder/index.js
new file mode 100644
index 0000000000..cb8a15e8c7
--- /dev/null
+++ b/app/javascript/mastodon/features/list_adder/index.js
@@ -0,0 +1,73 @@
+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 { setupListAdder, resetListAdder } from '../../actions/lists';
+import { createSelector } from 'reselect';
+import List from './components/list';
+import Account from './components/account';
+import NewListForm from '../lists/components/new_list_form';
+// hack
+
+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 => ({
+ listIds: getOrderedLists(state).map(list=>list.get('id')),
+});
+
+const mapDispatchToProps = dispatch => ({
+ onInitialize: accountId => dispatch(setupListAdder(accountId)),
+ onReset: () => dispatch(resetListAdder()),
+});
+
+export default @connect(mapStateToProps, mapDispatchToProps)
+@injectIntl
+class ListAdder extends ImmutablePureComponent {
+
+ static propTypes = {
+ accountId: PropTypes.string.isRequired,
+ onClose: PropTypes.func.isRequired,
+ intl: PropTypes.object.isRequired,
+ onInitialize: PropTypes.func.isRequired,
+ onReset: PropTypes.func.isRequired,
+ listIds: ImmutablePropTypes.list.isRequired,
+ };
+
+ componentDidMount () {
+ const { onInitialize, accountId } = this.props;
+ onInitialize(accountId);
+ }
+
+ componentWillUnmount () {
+ const { onReset } = this.props;
+ onReset();
+ }
+
+ render () {
+ const { accountId, listIds } = this.props;
+
+ return (
+
+
+
+
+
+
+
+ {listIds.map(ListId =>
)}
+
+
+ );
+ }
+
+}
diff --git a/app/javascript/mastodon/features/ui/components/modal_root.js b/app/javascript/mastodon/features/ui/components/modal_root.js
index d8e0345547..b3b1ea8623 100644
--- a/app/javascript/mastodon/features/ui/components/modal_root.js
+++ b/app/javascript/mastodon/features/ui/components/modal_root.js
@@ -16,6 +16,7 @@ import {
ReportModal,
EmbedModal,
ListEditor,
+ ListAdder,
} from '../../../features/ui/util/async-components';
const MODAL_COMPONENTS = {
@@ -30,6 +31,7 @@ const MODAL_COMPONENTS = {
'EMBED': EmbedModal,
'LIST_EDITOR': ListEditor,
'FOCAL_POINT': () => Promise.resolve({ default: FocalPointModal }),
+ 'LIST_ADDER':ListAdder,
};
export default class ModalRoot extends React.PureComponent {
diff --git a/app/javascript/mastodon/features/ui/util/async-components.js b/app/javascript/mastodon/features/ui/util/async-components.js
index 8cf2a6e7d7..2a15c052f1 100644
--- a/app/javascript/mastodon/features/ui/util/async-components.js
+++ b/app/javascript/mastodon/features/ui/util/async-components.js
@@ -129,3 +129,7 @@ export function EmbedModal () {
export function ListEditor () {
return import(/* webpackChunkName: "features/list_editor" */'../../list_editor');
}
+
+export function ListAdder () {
+ return import(/*webpackChunkName: "features/list_adder" */'../../list_adder');
+}
diff --git a/app/javascript/mastodon/locales/ar.json b/app/javascript/mastodon/locales/ar.json
index db2593afc4..8cd9ba773a 100644
--- a/app/javascript/mastodon/locales/ar.json
+++ b/app/javascript/mastodon/locales/ar.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "روبوت",
"account.block": "حظر @{name}",
"account.block_domain": "إخفاء كل شيئ قادم من إسم النطاق {domain}",
diff --git a/app/javascript/mastodon/locales/ast.json b/app/javascript/mastodon/locales/ast.json
index d84774f349..ab0f5b8926 100644
--- a/app/javascript/mastodon/locales/ast.json
+++ b/app/javascript/mastodon/locales/ast.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robó",
"account.block": "Bloquiar a @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/bg.json b/app/javascript/mastodon/locales/bg.json
index a4366126f8..853361b804 100644
--- a/app/javascript/mastodon/locales/bg.json
+++ b/app/javascript/mastodon/locales/bg.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Блокирай",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/ca.json b/app/javascript/mastodon/locales/ca.json
index 2e766da6af..f4c5f97bef 100644
--- a/app/javascript/mastodon/locales/ca.json
+++ b/app/javascript/mastodon/locales/ca.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bloca @{name}",
"account.block_domain": "Amaga-ho tot de {domain}",
diff --git a/app/javascript/mastodon/locales/co.json b/app/javascript/mastodon/locales/co.json
index 357ff0ac8d..f322ce53d8 100644
--- a/app/javascript/mastodon/locales/co.json
+++ b/app/javascript/mastodon/locales/co.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bluccà @{name}",
"account.block_domain": "Piattà tuttu da {domain}",
diff --git a/app/javascript/mastodon/locales/cs.json b/app/javascript/mastodon/locales/cs.json
index 5f82dd8e00..e809eb1366 100644
--- a/app/javascript/mastodon/locales/cs.json
+++ b/app/javascript/mastodon/locales/cs.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robot",
"account.block": "Zablokovat uživatele @{name}",
"account.block_domain": "Skrýt vše z {domain}",
diff --git a/app/javascript/mastodon/locales/cy.json b/app/javascript/mastodon/locales/cy.json
index 78c8d02f00..71a34272e6 100644
--- a/app/javascript/mastodon/locales/cy.json
+++ b/app/javascript/mastodon/locales/cy.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blocio @{name}",
"account.block_domain": "Cuddio popeth rhag {domain}",
diff --git a/app/javascript/mastodon/locales/da.json b/app/javascript/mastodon/locales/da.json
index d76f4ac1f8..54cae027f3 100644
--- a/app/javascript/mastodon/locales/da.json
+++ b/app/javascript/mastodon/locales/da.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robot",
"account.block": "Bloker @{name}",
"account.block_domain": "Skjul alt fra {domain}",
diff --git a/app/javascript/mastodon/locales/de.json b/app/javascript/mastodon/locales/de.json
index 81b8ceeddc..a81a52d516 100644
--- a/app/javascript/mastodon/locales/de.json
+++ b/app/javascript/mastodon/locales/de.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "@{name} blockieren",
"account.block_domain": "Alles von {domain} verstecken",
diff --git a/app/javascript/mastodon/locales/defaultMessages.json b/app/javascript/mastodon/locales/defaultMessages.json
index 0bbe2c3075..64735c0abd 100644
--- a/app/javascript/mastodon/locales/defaultMessages.json
+++ b/app/javascript/mastodon/locales/defaultMessages.json
@@ -577,6 +577,9 @@
"defaultMessage": "Don't feature on profile",
"id": "account.unendorse"
},
+ {
+ "id": "account.add_or_remove_from_list"
+ },
{
"defaultMessage": "Information below may reflect the user's profile incompletely.",
"id": "account.disclaimer_full"
@@ -1444,6 +1447,19 @@
],
"path": "app/javascript/mastodon/features/keyboard_shortcuts/index.json"
},
+ {
+ "descriptors": [
+ {
+ "defaultMessage": "Remove from list",
+ "id": "lists.account.remove"
+ },
+ {
+ "defaultMessage": "Add to list",
+ "id": "lists.account.add"
+ }
+ ],
+ "path": "app/javascript/mastodon/features/list_adder/components/list.json"
+ },
{
"descriptors": [
{
diff --git a/app/javascript/mastodon/locales/el.json b/app/javascript/mastodon/locales/el.json
index 8e67e7f908..06356f8e6a 100644
--- a/app/javascript/mastodon/locales/el.json
+++ b/app/javascript/mastodon/locales/el.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Μποτ",
"account.block": "Απόκλεισε τον/την @{name}",
"account.block_domain": "Απόκρυψε τα πάντα από το {domain}",
diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json
index 42be2db763..bf593f21b3 100644
--- a/app/javascript/mastodon/locales/en.json
+++ b/app/javascript/mastodon/locales/en.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Block @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/eo.json b/app/javascript/mastodon/locales/eo.json
index 0522ce95b2..ef9f99abb2 100644
--- a/app/javascript/mastodon/locales/eo.json
+++ b/app/javascript/mastodon/locales/eo.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Roboto",
"account.block": "Bloki @{name}",
"account.block_domain": "Kaŝi ĉion de {domain}",
diff --git a/app/javascript/mastodon/locales/es.json b/app/javascript/mastodon/locales/es.json
index f06ac11a4a..5112098095 100644
--- a/app/javascript/mastodon/locales/es.json
+++ b/app/javascript/mastodon/locales/es.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bloquear",
"account.block_domain": "Ocultar todo de {domain}",
diff --git a/app/javascript/mastodon/locales/eu.json b/app/javascript/mastodon/locales/eu.json
index 300e7eae4f..fb129967e3 100644
--- a/app/javascript/mastodon/locales/eu.json
+++ b/app/javascript/mastodon/locales/eu.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokeatu @{name}",
"account.block_domain": "Ezkutatu {domain} domeinuko guztia",
diff --git a/app/javascript/mastodon/locales/fa.json b/app/javascript/mastodon/locales/fa.json
index 7198931c48..e1d7d9628e 100644
--- a/app/javascript/mastodon/locales/fa.json
+++ b/app/javascript/mastodon/locales/fa.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "ربات",
"account.block": "مسدودسازی @{name}",
"account.block_domain": "پنهانسازی همه چیز از سرور {domain}",
diff --git a/app/javascript/mastodon/locales/fi.json b/app/javascript/mastodon/locales/fi.json
index fc623dab86..abbcded90a 100644
--- a/app/javascript/mastodon/locales/fi.json
+++ b/app/javascript/mastodon/locales/fi.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Botti",
"account.block": "Estä @{name}",
"account.block_domain": "Piilota kaikki sisältö verkkotunnuksesta {domain}",
diff --git a/app/javascript/mastodon/locales/fr.json b/app/javascript/mastodon/locales/fr.json
index d8b16672be..c6cb3cba8c 100644
--- a/app/javascript/mastodon/locales/fr.json
+++ b/app/javascript/mastodon/locales/fr.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bloquer @{name}",
"account.block_domain": "Tout masquer venant de {domain}",
diff --git a/app/javascript/mastodon/locales/gl.json b/app/javascript/mastodon/locales/gl.json
index 2f8b76d3ae..98011dac7a 100644
--- a/app/javascript/mastodon/locales/gl.json
+++ b/app/javascript/mastodon/locales/gl.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bloquear @{name}",
"account.block_domain": "Ocultar calquer contido de {domain}",
diff --git a/app/javascript/mastodon/locales/he.json b/app/javascript/mastodon/locales/he.json
index 1ef20f2310..d0c96917e3 100644
--- a/app/javascript/mastodon/locales/he.json
+++ b/app/javascript/mastodon/locales/he.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "חסימת @{name}",
"account.block_domain": "להסתיר הכל מהקהילה {domain}",
diff --git a/app/javascript/mastodon/locales/hr.json b/app/javascript/mastodon/locales/hr.json
index c9b8e7f759..c50138e23f 100644
--- a/app/javascript/mastodon/locales/hr.json
+++ b/app/javascript/mastodon/locales/hr.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokiraj @{name}",
"account.block_domain": "Sakrij sve sa {domain}",
diff --git a/app/javascript/mastodon/locales/hu.json b/app/javascript/mastodon/locales/hu.json
index 66a1d4c09c..90d186d577 100644
--- a/app/javascript/mastodon/locales/hu.json
+++ b/app/javascript/mastodon/locales/hu.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "@{name} letiltása",
"account.block_domain": "Minden elrejtése innen: {domain}",
diff --git a/app/javascript/mastodon/locales/hy.json b/app/javascript/mastodon/locales/hy.json
index e7d251a352..388cc43811 100644
--- a/app/javascript/mastodon/locales/hy.json
+++ b/app/javascript/mastodon/locales/hy.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Արգելափակել @{name}֊ին",
"account.block_domain": "Թաքցնել ամենը հետեւյալ տիրույթից՝ {domain}",
diff --git a/app/javascript/mastodon/locales/id.json b/app/javascript/mastodon/locales/id.json
index 1c84ed0615..4f3b654abc 100644
--- a/app/javascript/mastodon/locales/id.json
+++ b/app/javascript/mastodon/locales/id.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokir @{name}",
"account.block_domain": "Sembunyikan segalanya dari {domain}",
diff --git a/app/javascript/mastodon/locales/io.json b/app/javascript/mastodon/locales/io.json
index 9963a52a5e..55a5ba748b 100644
--- a/app/javascript/mastodon/locales/io.json
+++ b/app/javascript/mastodon/locales/io.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokusar @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/it.json b/app/javascript/mastodon/locales/it.json
index 711a360a99..d6f6ff3e23 100644
--- a/app/javascript/mastodon/locales/it.json
+++ b/app/javascript/mastodon/locales/it.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blocca @{name}",
"account.block_domain": "Nascondi tutto da {domain}",
diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json
index f607240251..8f3f5c23cd 100644
--- a/app/javascript/mastodon/locales/ja.json
+++ b/app/javascript/mastodon/locales/ja.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "@{name}さんをブロック",
"account.block_domain": "{domain}全体を非表示",
diff --git a/app/javascript/mastodon/locales/ka.json b/app/javascript/mastodon/locales/ka.json
index 9d6d0d66d7..5d6537b906 100644
--- a/app/javascript/mastodon/locales/ka.json
+++ b/app/javascript/mastodon/locales/ka.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "ბოტი",
"account.block": "დაბლოკე @{name}",
"account.block_domain": "დაიმალოს ყველაფერი დომენიდან {domain}",
diff --git a/app/javascript/mastodon/locales/ko.json b/app/javascript/mastodon/locales/ko.json
index c779017f3a..a7228d4d55 100644
--- a/app/javascript/mastodon/locales/ko.json
+++ b/app/javascript/mastodon/locales/ko.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "봇",
"account.block": "@{name}을 차단",
"account.block_domain": "{domain} 전체를 숨김",
diff --git a/app/javascript/mastodon/locales/nl.json b/app/javascript/mastodon/locales/nl.json
index 7a8ff6868c..ec53a66b4c 100644
--- a/app/javascript/mastodon/locales/nl.json
+++ b/app/javascript/mastodon/locales/nl.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokkeer @{name}",
"account.block_domain": "Verberg alles van {domain}",
diff --git a/app/javascript/mastodon/locales/no.json b/app/javascript/mastodon/locales/no.json
index 7c7e7600e4..d827a9816d 100644
--- a/app/javascript/mastodon/locales/no.json
+++ b/app/javascript/mastodon/locales/no.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokkér @{name}",
"account.block_domain": "Skjul alt fra {domain}",
diff --git a/app/javascript/mastodon/locales/oc.json b/app/javascript/mastodon/locales/oc.json
index 5df64e192d..49da27568f 100644
--- a/app/javascript/mastodon/locales/oc.json
+++ b/app/javascript/mastodon/locales/oc.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robòt",
"account.block": "Blocar @{name}",
"account.block_domain": "Tot amagar del domeni {domain}",
diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json
index b6410bbdfd..c020dda0e5 100644
--- a/app/javascript/mastodon/locales/pl.json
+++ b/app/javascript/mastodon/locales/pl.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokuj @{name}",
"account.block_domain": "Blokuj wszystko z {domain}",
diff --git a/app/javascript/mastodon/locales/pt-BR.json b/app/javascript/mastodon/locales/pt-BR.json
index 061d10f4dd..440a39c00c 100644
--- a/app/javascript/mastodon/locales/pt-BR.json
+++ b/app/javascript/mastodon/locales/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robô",
"account.block": "Bloquear @{name}",
"account.block_domain": "Esconder tudo de {domain}",
diff --git a/app/javascript/mastodon/locales/pt.json b/app/javascript/mastodon/locales/pt.json
index adb10dd075..94d01f2a46 100644
--- a/app/javascript/mastodon/locales/pt.json
+++ b/app/javascript/mastodon/locales/pt.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Bloquear @{name}",
"account.block_domain": "Esconder tudo do domínio {domain}",
diff --git a/app/javascript/mastodon/locales/ro.json b/app/javascript/mastodon/locales/ro.json
index 2a6479b91d..ed6f2c7b1a 100644
--- a/app/javascript/mastodon/locales/ro.json
+++ b/app/javascript/mastodon/locales/ro.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blochează @{name}",
"account.block_domain": "Ascunde tot de la {domain}",
diff --git a/app/javascript/mastodon/locales/ru.json b/app/javascript/mastodon/locales/ru.json
index cd65adcb53..d41cbd09d6 100644
--- a/app/javascript/mastodon/locales/ru.json
+++ b/app/javascript/mastodon/locales/ru.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Бот",
"account.block": "Блокировать",
"account.block_domain": "Блокировать все с {domain}",
diff --git a/app/javascript/mastodon/locales/sk.json b/app/javascript/mastodon/locales/sk.json
index cca2e3c629..8d1547d664 100644
--- a/app/javascript/mastodon/locales/sk.json
+++ b/app/javascript/mastodon/locales/sk.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokuj @{name}",
"account.block_domain": "Ukry všetko z {domain}",
diff --git a/app/javascript/mastodon/locales/sl.json b/app/javascript/mastodon/locales/sl.json
index 175a34efde..01f2ccbf98 100644
--- a/app/javascript/mastodon/locales/sl.json
+++ b/app/javascript/mastodon/locales/sl.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robot",
"account.block": "Blokiraj @{name}",
"account.block_domain": "Skrij vse iz {domain}",
diff --git a/app/javascript/mastodon/locales/sr-Latn.json b/app/javascript/mastodon/locales/sr-Latn.json
index 6020512c4a..b3075d2f1c 100644
--- a/app/javascript/mastodon/locales/sr-Latn.json
+++ b/app/javascript/mastodon/locales/sr-Latn.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Blokiraj korisnika @{name}",
"account.block_domain": "Sakrij sve sa domena {domain}",
diff --git a/app/javascript/mastodon/locales/sr.json b/app/javascript/mastodon/locales/sr.json
index 41d9e12b08..4ed720c9f2 100644
--- a/app/javascript/mastodon/locales/sr.json
+++ b/app/javascript/mastodon/locales/sr.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Бот",
"account.block": "Блокирај @{name}",
"account.block_domain": "Сакриј све са домена {domain}",
diff --git a/app/javascript/mastodon/locales/sv.json b/app/javascript/mastodon/locales/sv.json
index dbe9f709ac..7beee3cdc7 100644
--- a/app/javascript/mastodon/locales/sv.json
+++ b/app/javascript/mastodon/locales/sv.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Robot",
"account.block": "Blockera @{name}",
"account.block_domain": "Dölj allt från {domain}",
diff --git a/app/javascript/mastodon/locales/ta.json b/app/javascript/mastodon/locales/ta.json
index 803e004ccd..0c712e84c0 100644
--- a/app/javascript/mastodon/locales/ta.json
+++ b/app/javascript/mastodon/locales/ta.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Block @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/te.json b/app/javascript/mastodon/locales/te.json
index af036e300f..c602362bf7 100644
--- a/app/javascript/mastodon/locales/te.json
+++ b/app/javascript/mastodon/locales/te.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "బాట్",
"account.block": "@{name} ను బ్లాక్ చేయి",
"account.block_domain": "{domain} నుంచి అన్నీ దాచిపెట్టు",
diff --git a/app/javascript/mastodon/locales/th.json b/app/javascript/mastodon/locales/th.json
index fe36a966ce..86d8c9b2b5 100644
--- a/app/javascript/mastodon/locales/th.json
+++ b/app/javascript/mastodon/locales/th.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Block @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/tr.json b/app/javascript/mastodon/locales/tr.json
index 323617f1d4..98ae1185d4 100644
--- a/app/javascript/mastodon/locales/tr.json
+++ b/app/javascript/mastodon/locales/tr.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Bot",
"account.block": "Engelle @{name}",
"account.block_domain": "Hide everything from {domain}",
diff --git a/app/javascript/mastodon/locales/uk.json b/app/javascript/mastodon/locales/uk.json
index cdc13c5746..95a947f78b 100644
--- a/app/javascript/mastodon/locales/uk.json
+++ b/app/javascript/mastodon/locales/uk.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "Бот",
"account.block": "Заблокувати @{name}",
"account.block_domain": "Заглушити {domain}",
diff --git a/app/javascript/mastodon/locales/zh-CN.json b/app/javascript/mastodon/locales/zh-CN.json
index 9fee25e15f..3d837001ae 100644
--- a/app/javascript/mastodon/locales/zh-CN.json
+++ b/app/javascript/mastodon/locales/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "机器人",
"account.block": "屏蔽 @{name}",
"account.block_domain": "隐藏来自 {domain} 的内容",
diff --git a/app/javascript/mastodon/locales/zh-HK.json b/app/javascript/mastodon/locales/zh-HK.json
index 26eba48f82..035a645b84 100644
--- a/app/javascript/mastodon/locales/zh-HK.json
+++ b/app/javascript/mastodon/locales/zh-HK.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "機械人",
"account.block": "封鎖 @{name}",
"account.block_domain": "隱藏來自 {domain} 的一切文章",
diff --git a/app/javascript/mastodon/locales/zh-TW.json b/app/javascript/mastodon/locales/zh-TW.json
index 6d4a9a0bb2..acacc571d1 100644
--- a/app/javascript/mastodon/locales/zh-TW.json
+++ b/app/javascript/mastodon/locales/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "account.add_or_remove_from_list": "Add or Remove from lists",
"account.badges.bot": "機器人",
"account.block": "封鎖 @{name}",
"account.block_domain": "隱藏來自 {domain} 的一切嘟文",
diff --git a/app/javascript/mastodon/reducers/index.js b/app/javascript/mastodon/reducers/index.js
index 2c98af1db3..0f0de849f7 100644
--- a/app/javascript/mastodon/reducers/index.js
+++ b/app/javascript/mastodon/reducers/index.js
@@ -25,6 +25,7 @@ import height_cache from './height_cache';
import custom_emojis from './custom_emojis';
import lists from './lists';
import listEditor from './list_editor';
+import listAdder from './list_adder';
import filters from './filters';
import conversations from './conversations';
import suggestions from './suggestions';
@@ -56,6 +57,7 @@ const reducers = {
custom_emojis,
lists,
listEditor,
+ listAdder,
filters,
conversations,
suggestions,
diff --git a/app/javascript/mastodon/reducers/list_adder.js b/app/javascript/mastodon/reducers/list_adder.js
new file mode 100644
index 0000000000..b8c1b0e269
--- /dev/null
+++ b/app/javascript/mastodon/reducers/list_adder.js
@@ -0,0 +1,47 @@
+import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
+import {
+ LIST_ADDER_RESET,
+ LIST_ADDER_SETUP,
+ LIST_ADDER_LISTS_FETCH_REQUEST,
+ LIST_ADDER_LISTS_FETCH_SUCCESS,
+ LIST_ADDER_LISTS_FETCH_FAIL,
+ LIST_EDITOR_ADD_SUCCESS,
+ LIST_EDITOR_REMOVE_SUCCESS,
+} from '../actions/lists';
+
+const initialState = ImmutableMap({
+ accountId: null,
+
+ lists: ImmutableMap({
+ items: ImmutableList(),
+ loaded: false,
+ isLoading: false,
+ }),
+});
+
+export default function listAdderReducer(state = initialState, action) {
+ switch(action.type) {
+ case LIST_ADDER_RESET:
+ return initialState;
+ case LIST_ADDER_SETUP:
+ return state.withMutations(map => {
+ map.set('accountId', action.account.get('id'));
+ });
+ case LIST_ADDER_LISTS_FETCH_REQUEST:
+ return state.setIn(['lists', 'isLoading'], true);
+ case LIST_ADDER_LISTS_FETCH_FAIL:
+ return state.setIn(['lists', 'isLoading'], false);
+ case LIST_ADDER_LISTS_FETCH_SUCCESS:
+ return state.update('lists', lists => lists.withMutations(map => {
+ map.set('isLoading', false);
+ map.set('loaded', true);
+ map.set('items', ImmutableList(action.lists.map(item => item.id)));
+ }));
+ case LIST_EDITOR_ADD_SUCCESS:
+ return state.updateIn(['lists', 'items'], list => list.unshift(action.listId));
+ case LIST_EDITOR_REMOVE_SUCCESS:
+ return state.updateIn(['lists', 'items'], list => list.filterNot(item => item === action.listId));
+ default:
+ return state;
+ }
+};
diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss
index e5d9f7b9f1..481648054d 100644
--- a/app/javascript/styles/mastodon/components.scss
+++ b/app/javascript/styles/mastodon/components.scss
@@ -5344,6 +5344,47 @@ noscript {
}
}
+.list-adder {
+ background: $ui-base-color;
+ flex-direction: column;
+ border-radius: 8px;
+ box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
+ width: 380px;
+ overflow: hidden;
+
+ @media screen and (max-width: 420px) {
+ width: 90%;
+ }
+
+ &__account {
+ background: lighten($ui-base-color, 13%);
+ }
+
+ &__lists {
+ background: lighten($ui-base-color, 13%);
+ height: 50vh;
+ border-radius: 0 0 8px 8px;
+ overflow-y: auto;
+ }
+
+ .list {
+ padding: 10px;
+ border-bottom: 1px solid lighten($ui-base-color, 8%);
+ }
+
+ .list__wrapper {
+ display: flex;
+ }
+
+ .list__display-name {
+ flex: 1 1 auto;
+ overflow: hidden;
+ text-decoration: none;
+ font-size: 16px;
+ padding: 10px;
+ }
+}
+
.focal-point-modal {
max-width: 80vw;
max-height: 80vh;