Skip to content

Commit

Permalink
Merge pull request mastodon#1311 from ThibG/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes
  • Loading branch information
ClearlyClaire committed Apr 4, 2020
2 parents 5c53170 + ec6464f commit 6e42626
Show file tree
Hide file tree
Showing 21 changed files with 248 additions and 442 deletions.
12 changes: 8 additions & 4 deletions .circleci/config.yml
Expand Up @@ -139,9 +139,10 @@ jobs:
docker:
- image: circleci/ruby:2.7-buster-node
environment: *ruby_environment
- image: circleci/postgres:10.6-alpine
- image: circleci/postgres:12.2
environment:
POSTGRES_USER: root
POSTGRES_HOST_AUTH_METHOD: trust
- image: circleci/redis:5-alpine
steps:
- *attach_workspace
Expand All @@ -158,9 +159,10 @@ jobs:
docker:
- image: circleci/ruby:2.7-buster-node
environment: *ruby_environment
- image: circleci/postgres:10.6-alpine
- image: circleci/postgres:12.2
environment:
POSTGRES_USER: root
POSTGRES_HOST_AUTH_METHOD: trust
- image: circleci/redis:5-alpine
<<: *test_steps

Expand All @@ -169,9 +171,10 @@ jobs:
docker:
- image: circleci/ruby:2.6-buster-node
environment: *ruby_environment
- image: circleci/postgres:10.6-alpine
- image: circleci/postgres:12.2
environment:
POSTGRES_USER: root
POSTGRES_HOST_AUTH_METHOD: trust
- image: circleci/redis:5-alpine
<<: *test_steps

Expand All @@ -180,9 +183,10 @@ jobs:
docker:
- image: circleci/ruby:2.5-buster-node
environment: *ruby_environment
- image: circleci/postgres:10.6-alpine
- image: circleci/postgres:12.2
environment:
POSTGRES_USER: root
POSTGRES_HOST_AUTH_METHOD: trust
- image: circleci/redis:5-alpine
<<: *test_steps

Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Expand Up @@ -91,7 +91,7 @@ VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "ubuntu/xenial64"
config.vm.box = "ubuntu/bionic64"

config.vm.provider :virtualbox do |vb|
vb.name = "mastodon"
Expand Down
14 changes: 12 additions & 2 deletions app/controllers/admin/action_logs_controller.rb
Expand Up @@ -2,8 +2,18 @@

module Admin
class ActionLogsController < BaseController
def index
@action_logs = Admin::ActionLog.page(params[:page])
before_action :set_action_logs

def index; end

private

def set_action_logs
@action_logs = Admin::ActionLogFilter.new(filter_params).results.page(params[:page])
end

def filter_params
params.slice(:page, *Admin::ActionLogFilter::KEYS).permit(:page, *Admin::ActionLogFilter::KEYS)
end
end
end
75 changes: 2 additions & 73 deletions app/helpers/admin/action_logs_helper.rb
Expand Up @@ -9,79 +9,8 @@ def log_target(log)
end
end

def relevant_log_changes(log)
if log.target_type == 'CustomEmoji' && [:enable, :disable, :destroy].include?(log.action)
log.recorded_changes.slice('domain')
elsif log.target_type == 'CustomEmoji' && log.action == :update
log.recorded_changes.slice('domain', 'visible_in_picker')
elsif log.target_type == 'User' && [:promote, :demote].include?(log.action)
log.recorded_changes.slice('moderator', 'admin')
elsif log.target_type == 'User' && [:change_email].include?(log.action)
log.recorded_changes.slice('email', 'unconfirmed_email')
elsif log.target_type == 'DomainBlock'
log.recorded_changes.slice('severity', 'reject_media')
elsif log.target_type == 'Status' && log.action == :update
log.recorded_changes.slice('sensitive')
elsif log.target_type == 'Announcement' && log.action == :update
log.recorded_changes.slice('text', 'starts_at', 'ends_at', 'all_day')
end
end

def log_extra_attributes(hash)
safe_join(hash.to_a.map { |key, value| safe_join([content_tag(:span, key, class: 'diff-key'), '=', log_change(value)]) }, ' ')
end

def log_change(val)
return content_tag(:span, val, class: 'diff-neutral') unless val.is_a?(Array)
safe_join([content_tag(:span, val.first, class: 'diff-old'), content_tag(:span, val.last, class: 'diff-new')], '→')
end

def icon_for_log(log)
case log.target_type
when 'Account', 'User'
'user'
when 'CustomEmoji'
'file'
when 'Report'
'flag'
when 'DomainBlock'
'lock'
when 'DomainAllow'
'plus-circle'
when 'EmailDomainBlock'
'envelope'
when 'Status'
'pencil'
when 'AccountWarning'
'warning'
when 'Announcement'
'bullhorn'
end
end

def class_for_log_icon(log)
case log.action
when :enable, :unsuspend, :unsilence, :confirm, :promote, :resolve
'positive'
when :create
opposite_verbs?(log) ? 'negative' : 'positive'
when :update, :reset_password, :disable_2fa, :memorialize, :change_email
'neutral'
when :demote, :silence, :disable, :suspend, :remove_avatar, :remove_header, :reopen
'negative'
when :destroy
opposite_verbs?(log) ? 'positive' : 'negative'
else
''
end
end

private

def opposite_verbs?(log)
%w(DomainBlock EmailDomainBlock AccountWarning).include?(log.target_type)
end

def linkable_log_target(record)
case record.class.name
when 'Account'
Expand All @@ -99,7 +28,7 @@ def linkable_log_target(record)
when 'AccountWarning'
link_to record.target_account.acct, admin_account_path(record.target_account_id)
when 'Announcement'
link_to "##{record.id}", edit_admin_announcement_path(record.id)
link_to truncate(record.text), edit_admin_announcement_path(record.id)
end
end

Expand All @@ -118,7 +47,7 @@ def log_target_from_history(type, attributes)
I18n.t('admin.action_logs.deleted_status')
end
when 'Announcement'
"##{attributes['id']}"
truncate(attributes['text'])
end
end
end
1 change: 1 addition & 0 deletions app/helpers/admin/filter_helper.rb
Expand Up @@ -10,6 +10,7 @@ module Admin::FilterHelper
InviteFilter::KEYS,
RelationshipFilter::KEYS,
AnnouncementFilter::KEYS,
Admin::ActionLogFilter::KEYS,
].flatten.freeze

def filter_link_to(text, link_to_params, link_class_params = link_to_params)
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/core/admin.js
Expand Up @@ -32,6 +32,10 @@ delegate(document, '.media-spoiler-hide-button', 'click', () => {
});
});

delegate(document, '.filter-subset--with-select select', 'change', ({ target }) => {
target.form.submit();
});

const onDomainBlockSeverityChange = (target) => {
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
Expand Down
17 changes: 16 additions & 1 deletion app/javascript/flavours/glitch/features/follow_requests/index.js
Expand Up @@ -11,6 +11,7 @@ import { fetchFollowRequests, expandFollowRequests } from 'flavours/glitch/actio
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ScrollableList from 'flavours/glitch/components/scrollable_list';
import { me } from 'flavours/glitch/util/initial_state';

const messages = defineMessages({
heading: { id: 'column.follow_requests', defaultMessage: 'Follow requests' },
Expand All @@ -19,6 +20,8 @@ const messages = defineMessages({
const mapStateToProps = state => ({
accountIds: state.getIn(['user_lists', 'follow_requests', 'items']),
hasMore: !!state.getIn(['user_lists', 'follow_requests', 'next']),
locked: !!state.getIn(['accounts', me, 'locked']),
domain: state.getIn(['meta', 'domain']),
});

export default @connect(mapStateToProps)
Expand All @@ -30,6 +33,8 @@ class FollowRequests extends ImmutablePureComponent {
dispatch: PropTypes.func.isRequired,
hasMore: PropTypes.bool,
accountIds: ImmutablePropTypes.list,
locked: PropTypes.bool,
domain: PropTypes.string,
intl: PropTypes.object.isRequired,
multiColumn: PropTypes.bool,
};
Expand All @@ -43,7 +48,7 @@ class FollowRequests extends ImmutablePureComponent {
}, 300, { leading: true });

render () {
const { intl, accountIds, hasMore, multiColumn } = this.props;
const { intl, accountIds, hasMore, multiColumn, locked, domain } = this.props;

if (!accountIds) {
return (
Expand All @@ -54,6 +59,15 @@ class FollowRequests extends ImmutablePureComponent {
}

const emptyMessage = <FormattedMessage id='empty_column.follow_requests' defaultMessage="You don't have any follow requests yet. When you receive one, it will show up here." />;
const unlockedPrependMessage = locked ? null : (
<div className='follow_requests-unlocked_explanation'>
<FormattedMessage
id='follow_requests.unlocked_explanation'
defaultMessage='Even though your account is not locked, the {domain} staff thought you might want to review follow requests from these accounts manually.'
values={{ domain: domain }}
/>
</div>
);

return (
<Column bindToDocument={!multiColumn} name='follow-requests' icon='user-plus' heading={intl.formatMessage(messages.heading)}>
Expand All @@ -65,6 +79,7 @@ class FollowRequests extends ImmutablePureComponent {
hasMore={hasMore}
emptyMessage={emptyMessage}
bindToDocument={!multiColumn}
prepend={unlockedPrependMessage}
>
{accountIds.map(id =>
<AccountAuthorizeContainer key={id} id={id} />,
Expand Down
68 changes: 13 additions & 55 deletions app/javascript/flavours/glitch/styles/admin.scss
Expand Up @@ -418,6 +418,11 @@ body,
}
}

&--with-select strong {
display: block;
margin-bottom: 10px;
}

a {
display: inline-block;
color: $darker-text-color;
Expand Down Expand Up @@ -567,19 +572,22 @@ body,
}

.log-entry {
margin-bottom: 20px;
line-height: 20px;
padding: 15px 0;
background: $ui-base-color;
border-bottom: 1px solid lighten($ui-base-color, 4%);

&:last-child {
border-bottom: 0;
}

&__header {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 10px;
background: $ui-base-color;
color: $darker-text-color;
border-radius: 4px 4px 0 0;
font-size: 14px;
position: relative;
padding: 0 10px;
}

&__avatar {
Expand All @@ -606,63 +614,13 @@ body,
color: $dark-text-color;
}

&__extras {
background: lighten($ui-base-color, 6%);
border-radius: 0 0 4px 4px;
padding: 10px;
color: $darker-text-color;
font-family: $font-monospace, monospace;
font-size: 12px;
word-wrap: break-word;
min-height: 20px;
}

&__icon {
font-size: 28px;
margin-right: 10px;
color: $dark-text-color;
}

&__icon__overlay {
position: absolute;
top: 10px;
right: 10px;
width: 10px;
height: 10px;
border-radius: 50%;

&.positive {
background: $success-green;
}

&.negative {
background: lighten($error-red, 12%);
}

&.neutral {
background: $ui-highlight-color;
}
}

a,
.username,
.target {
color: $secondary-text-color;
text-decoration: none;
font-weight: 500;
}

.diff-old {
color: lighten($error-red, 12%);
}

.diff-neutral {
color: $secondary-text-color;
}

.diff-new {
color: $success-green;
}
}

a.name-tag,
Expand Down
Expand Up @@ -452,7 +452,8 @@
}

.empty-column-indicator,
.error-column {
.error-column,
.follow_requests-unlocked_explanation {
color: $dark-text-color;
background: $ui-base-color;
text-align: center;
Expand Down Expand Up @@ -482,6 +483,11 @@
}
}

.follow_requests-unlocked_explanation {
background: darken($ui-base-color, 4%);
contain: initial;
}

.error-column {
flex-direction: column;
}
Expand Down

0 comments on commit 6e42626

Please sign in to comment.