Commit e7227128 authored by Jason Salyers's avatar Jason Salyers
Browse files

Merge branch 'jsalyers-blacklist-updates' into 'develop'

[JES] Updates to blacklisting. Fixes some small bugs and re-arranges the page a bit

See merge request !165
parents b0d3bce1 7344146c
...@@ -34,6 +34,7 @@ class ListManagement extends React.Component { ...@@ -34,6 +34,7 @@ class ListManagement extends React.Component {
updates_are_pending: false, updates_are_pending: false,
first_time_user: false, first_time_user: false,
expand_welcome_panel: false, expand_welcome_panel: false,
warning_message: '',
}; };
this.handle_filter_change = this.handle_filter_change.bind(this); this.handle_filter_change = this.handle_filter_change.bind(this);
this.validate_accounts_to_add = this.validate_accounts_to_add.bind( this.validate_accounts_to_add = this.validate_accounts_to_add.bind(
...@@ -144,7 +145,11 @@ class ListManagement extends React.Component { ...@@ -144,7 +145,11 @@ class ListManagement extends React.Component {
result.length != this.state.all_listed_accounts.length result.length != this.state.all_listed_accounts.length
) { ) {
//updates came through, so set pending to false //updates came through, so set pending to false
this.setState({ updates_are_pending: false }); this.setState({
updates_are_pending: false,
warning_message: '',
});
this.multiadd = '';
} }
this.setState({ all_listed_accounts: result }); this.setState({ all_listed_accounts: result });
}, },
...@@ -239,6 +244,19 @@ class ListManagement extends React.Component { ...@@ -239,6 +244,19 @@ class ListManagement extends React.Component {
let accounts = []; let accounts = [];
let validated_accounts = []; let validated_accounts = [];
let all_users = text.split(','); let all_users = text.split(',');
if (this.state.error_message !== '')
this.setState({ error_message: '' });
if (all_users.length > 100)
this.setState({
warning_message:
'You are adding a large number of accounts. Numerous brodcast operations will be required.',
});
else this.setState({ warning_message: '' });
let names_only = this.state.all_listed_accounts.map(item => {
return item.name;
});
for (var user of all_users) { for (var user of all_users) {
if (user !== '') accounts.push(user); if (user !== '') accounts.push(user);
} }
...@@ -248,6 +266,10 @@ class ListManagement extends React.Component { ...@@ -248,6 +266,10 @@ class ListManagement extends React.Component {
let result_string = JSON.stringify(result); let result_string = JSON.stringify(result);
for (var check_user of all_users) { for (var check_user of all_users) {
if (check_user === '') continue; if (check_user === '') continue;
if (names_only.includes(check_user)) {
bad_accounts.push(check_user);
continue;
}
if (!result_string.includes(check_user)) if (!result_string.includes(check_user))
bad_accounts.push(check_user); bad_accounts.push(check_user);
else validated_accounts.push(check_user); else validated_accounts.push(check_user);
...@@ -305,16 +327,29 @@ class ListManagement extends React.Component { ...@@ -305,16 +327,29 @@ class ListManagement extends React.Component {
let follower = this.props.username; let follower = this.props.username;
let following = this.state.validated_accounts; let following = this.state.validated_accounts;
let followings = [];
if (following.length > 100) {
let i = 0;
while (following.length > 0) {
let new_following = following.splice(0, 100);
followings.push(new_following);
}
} else {
followings.push(following);
}
this.setState({ is_busy: true }); this.setState({ is_busy: true });
this.props.updateList(follower, following, what, () => { for (var following_list of followings) {
this.multiadd.value = ''; this.props.updateList(follower, following_list, what, () => {});
}
this.setState({ this.setState({
is_busy: false, is_busy: false,
validated_accounts: [], validate_accounts: [],
unmatched_accounts: [], unmatched_accounts: [],
updates_are_pending: true, updates_are_pending: true,
}); });
}); this.multiadd.value = '';
} }
generate_table_rows() { generate_table_rows() {
...@@ -602,7 +637,7 @@ class ListManagement extends React.Component { ...@@ -602,7 +637,7 @@ class ListManagement extends React.Component {
this.state.expand_welcome_panel) && ( this.state.expand_welcome_panel) && (
<div> <div>
<center> <center>
<table style={{ width: '35%', border: '2' }}> <table style={{ width: '35%', border: 2 }}>
<thead /> <thead />
<tbody> <tbody>
...@@ -676,9 +711,12 @@ class ListManagement extends React.Component { ...@@ -676,9 +711,12 @@ class ListManagement extends React.Component {
</div> </div>
)} )}
<p /> <p />
<div> <div>
<center> <center>
<h4>{header_text}</h4> <h5>
<b>{header_text}</b>
</h5>
{(this.props.list_type === 'blacklisted' || {(this.props.list_type === 'blacklisted' ||
this.props.list_type === 'muted') && ( this.props.list_type === 'muted') && (
<h6> <h6>
...@@ -690,29 +728,7 @@ class ListManagement extends React.Component { ...@@ -690,29 +728,7 @@ class ListManagement extends React.Component {
: mute_list_description} : mute_list_description}
</h6> </h6>
)} )}
<p />
<table style={{ width: '35%' }}>
<thead />
<tbody>
<tr>
<td style={{ textAlign: 'right' }}>
<right>
{tt(
'list_management_jsx.search_for_user'
)}
</right>
</td>
<td>
<input
type="text"
ref={el => (this.searchbox = el)}
style={{ width: '350px' }}
onChange={this.handle_filter_change}
/>
</td>
</tr>
</tbody>
</table>
<p /> <p />
<table style={{ width: '35%' }}> <table style={{ width: '35%' }}>
...@@ -765,6 +781,13 @@ class ListManagement extends React.Component { ...@@ -765,6 +781,13 @@ class ListManagement extends React.Component {
{tt('list_management_jsx.last')} {tt('list_management_jsx.last')}
</span> </span>
)} )}
{list_length > 0 && (
<div>
{tt('list_management_jsx.users_on_list', {
user_count: list_length,
})}
</div>
)}
{list_length > this.state.entries_per_page && ( {list_length > this.state.entries_per_page && (
<div> <div>
{tt('list_management_jsx.page_count', { {tt('list_management_jsx.page_count', {
...@@ -778,11 +801,13 @@ class ListManagement extends React.Component { ...@@ -778,11 +801,13 @@ class ListManagement extends React.Component {
<div> <div>
<p /> <p />
<p /> <p />
<h4> <h5>
<b>
{tt( {tt(
'list_management_jsx.add_users_to_list' 'list_management_jsx.add_users_to_list'
)} )}
</h4> </b>
</h5>
<table style={{ width: '35%' }}> <table style={{ width: '35%' }}>
<thead /> <thead />
<tbody> <tbody>
...@@ -815,10 +840,7 @@ class ListManagement extends React.Component { ...@@ -815,10 +840,7 @@ class ListManagement extends React.Component {
<td style={{ width: '25%' }}> <td style={{ width: '25%' }}>
{this.state.validated_accounts {this.state.validated_accounts
.length > 0 && .length > 0 && (
this.state
.unmatched_accounts
.length == 0 && (
<span <span
className="button slim hollow secondary" className="button slim hollow secondary"
onClick={ onClick={
...@@ -833,16 +855,42 @@ class ListManagement extends React.Component { ...@@ -833,16 +855,42 @@ class ListManagement extends React.Component {
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
)}
<h5>
<b>Search This List</b>
</h5>
<table style={{ width: '35%' }}>
<thead />
<tbody>
<tr>
<td
colSpan="2"
style={{ textAlign: 'right' }}
>
<center>
<input
type="text"
ref={el =>
(this.searchbox = el)
}
style={{ width: '350px' }}
onChange={
this.handle_filter_change
}
/>
</center>
</td>
</tr>
</tbody>
</table>
<p /> <p />
<h4> <h4>{tt('list_management_jsx.reset_header')}</h4>
{tt('list_management_jsx.reset_header')}
</h4>
<span <span
className="button slim hollow secondary" className="button slim hollow secondary"
onClick={this.handle_reset_list.bind( onClick={this.handle_reset_list.bind(this, false)}
this,
false
)}
> >
{this.state.is_busy {this.state.is_busy
? tt('list_management_jsx.button_busy') ? tt('list_management_jsx.button_busy')
...@@ -850,17 +898,12 @@ class ListManagement extends React.Component { ...@@ -850,17 +898,12 @@ class ListManagement extends React.Component {
</span> </span>
<span <span
className="button slim hollow secondary" className="button slim hollow secondary"
onClick={this.handle_reset_list.bind( onClick={this.handle_reset_list.bind(this, true)}
this,
true
)}
> >
{this.state.is_busy {this.state.is_busy
? tt('list_management_jsx.button_busy') ? tt('list_management_jsx.button_busy')
: reset_all_button_text} : reset_all_button_text}
</span> </span>
</div>
)}
{this.state.unmatched_accounts.length > 0 && ( {this.state.unmatched_accounts.length > 0 && (
<div style={{ color: 'red' }}> <div style={{ color: 'red' }}>
...@@ -879,6 +922,16 @@ class ListManagement extends React.Component { ...@@ -879,6 +922,16 @@ class ListManagement extends React.Component {
</b> </b>
</div> </div>
)} )}
{this.state.error_message !== '' && (
<div style={{ color: 'red' }}>
<b>{this.state.error_message}</b>
</div>
)}
{this.state.warning_message !== '' && (
<div style={{ color: 'orange' }}>
<b>{this.state.warning_message}</b>
</div>
)}
</center> </center>
</div> </div>
</div> </div>
......
...@@ -893,7 +893,8 @@ ...@@ -893,7 +893,8 @@
"button_mute": "Mute Users", "button_mute": "Mute Users",
"button_follow_blacklists": "Follow Blacklists", "button_follow_blacklists": "Follow Blacklists",
"button_follow_muted_lists": "Follow Muted Lists", "button_follow_muted_lists": "Follow Muted Lists",
"unknown_accounts": "Unable to find account(s): ", "unknown_accounts":
"These accounts cannot be added because they can't be validated or are already on the list: ",
"page_count": "Viewing Page %(current)s of %(total)s", "page_count": "Viewing Page %(current)s of %(total)s",
"search_for_user": "Search List For Account:", "search_for_user": "Search List For Account:",
"add_users_to_list": "Add Account(s) To List", "add_users_to_list": "Add Account(s) To List",
...@@ -932,6 +933,7 @@ ...@@ -932,6 +933,7 @@
"first": "First", "first": "First",
"previous": "Previous", "previous": "Previous",
"next": "Next", "next": "Next",
"last": "Last" "last": "Last",
"users_on_list": "Users On List: %(user_count)s"
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment