Add page for authorizing/rejecting follow requests

This commit is contained in:
Eugen Rochko
2016-12-23 00:04:52 +01:00
parent 3c841c7306
commit b302b9202b
14 changed files with 99 additions and 10 deletions

View File

@ -27,6 +27,7 @@ const Header = React.createClass({
let displayName = account.get('display_name');
let info = '';
let actionBtn = '';
let lockedIcon = '';
if (displayName.length === 0) {
displayName = account.get('username');
@ -52,6 +53,10 @@ const Header = React.createClass({
}
}
if (account.get('locked')) {
lockedIcon = <i className='fa fa-lock' />;
}
const content = { __html: emojify(account.get('note')) };
const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
@ -66,7 +71,7 @@ const Header = React.createClass({
<span style={{ display: 'inline-block', color: '#fff', fontSize: '20px', lineHeight: '27px', fontWeight: '500' }} className='account__header__display-name' dangerouslySetInnerHTML={displayNameHTML} />
</a>
<span style={{ fontSize: '14px', fontWeight: '400', display: 'block', color: '#2b90d9', marginBottom: '10px' }}>@{account.get('acct')}</span>
<span style={{ fontSize: '14px', fontWeight: '400', display: 'block', color: '#2b90d9', marginBottom: '10px' }}>@{account.get('acct')} {lockedIcon}</span>
<div style={{ color: '#616b86', fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
{info}

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
class FollowRequestsController < ApplicationController
layout 'auth'
before_action :authenticate_user!
before_action :set_follow_request, except: :index
def index
@follow_requests = FollowRequest.where(target_account: current_account)
end
def authorize
@follow_request.authorize!
redirect_to follow_requests_path
end
def reject
@follow_request.reject!
redirect_to follow_requests_path
end
private
def set_follow_request
@follow_request = FollowRequest.find(params[:id])
end
end

View File

@ -9,7 +9,7 @@ module Admin::AccountsHelper
link_to text, filter_params(more_params), class: params.merge(more_params).compact == params.compact ? 'selected' : ''
end
def table_link_to(icon, text, path)
link_to safe_join([fa_icon(icon), text]), path, class: 'table-action-link'
def table_link_to(icon, text, path, options = {})
link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
end
end

View File

@ -0,0 +1,2 @@
module FollowRequestsHelper
end

View File

@ -2,7 +2,6 @@
= Rails.configuration.x.local_domain
- content_for :header_tags do
= javascript_include_tag 'application_public'
%meta{ property: 'og:site_name', content: 'Mastodon' }/
%meta{ property: 'og:type', content: 'website' }/
%meta{ property: 'og:title', content: Rails.configuration.x.local_domain }/

View File

@ -9,7 +9,9 @@
.avatar= image_tag @account.avatar.url( :original)
%h1.name
= display_name(@account)
%small= "@#{@account.username}"
%small
= "@#{@account.username}"
= fa_icon('lock') if @account.locked?
.details
.bio
.account__header__content= Formatter.instance.simplified_format(@account)

View File

@ -0,0 +1,16 @@
- content_for :page_title do
= t('follow_requests.title')
- if @follow_requests.empty?
%p.nothing-here= t('accounts.nothing_here')
- else
%table.table
%tbody
- @follow_requests.each do |follow_request|
%tr
%td= link_to follow_request.account.acct, web_path("accounts/#{follow_request.account.id}")
%td
= table_link_to 'check-circle', t('follow_requests.authorize'), authorize_follow_request_path(follow_request), method: :post
= table_link_to 'times-circle', t('follow_requests.reject'), reject_follow_request_path(follow_request), method: :post
.form-footer= render "settings/shared/links"

View File

@ -1,3 +1,6 @@
- content_for :header_tags do
= javascript_include_tag 'application_public'
- content_for :content do
.container
.logo-container

View File

@ -1,6 +1,8 @@
%ul.no-list
- if controller_name != 'profiles'
%li= link_to t('settings.edit_profile'), settings_profile_path
- if controller_name != 'follow_requests'
%li= link_to t('follow_requests.title'), follow_requests_path
- if controller_name != 'preferences'
%li= link_to t('settings.preferences'), settings_preferences_path
- if controller_name != 'registrations'