-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# frozen_string_literal: true | ||
|
||
class Settings::RequestCustomEmojisController < Settings::BaseController | ||
include Authorization | ||
|
||
def index | ||
@is_admin = authorize? | ||
@custom_emojis = RequestCustomEmoji.order(:state, :shortcode).page(params[:page]) | ||
@form = Form::RequestCustomEmojiBatch.new | ||
end | ||
|
||
def new | ||
@custom_emoji = RequestCustomEmoji.new | ||
end | ||
|
||
def create | ||
@custom_emoji = RequestCustomEmoji.new(resource_params) | ||
@custom_emoji.account_id = current_account.id | ||
if CustomEmoji.find_by(shortcode: @custom_emoji.shortcode, domain: nil) | ||
@custom_emoji.errors.add(:shortcode, I18n.t('settings.request_custom_emoji.errors.already_exists')) | ||
render :new | ||
return | ||
end | ||
|
||
if @custom_emoji.save | ||
redirect_to settings_request_custom_emojis_path, notice: I18n.t('settings.request_custom_emoji.created_msg') | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def batch | ||
@form = Form::RequestCustomEmojiBatch.new(form_custom_emoji_batch_params.merge(current_account: current_account, action: action_from_button)) | ||
@form.save | ||
rescue ActionController::ParameterMissing | ||
flash[:alert] = I18n.t('admin.accounts.no_account_selected') | ||
rescue Mastodon::NotPermittedError | ||
flash[:alert] = I18n.t('admin.custom_emojis.not_permitted') | ||
ensure | ||
redirect_to settings_request_custom_emojis_path | ||
end | ||
|
||
private | ||
|
||
def resource_params | ||
params.require(:request_custom_emoji).permit(:shortcode, :image) | ||
end | ||
|
||
def form_custom_emoji_batch_params | ||
params.require(:form_request_custom_emoji_batch).permit(:action, request_custom_emoji_ids: []) | ||
Check failure on line 50 in app/controllers/settings/request_custom_emojis_controller.rb GitHub Actions / lint
|
||
end | ||
|
||
def action_from_button | ||
if params[:approve] | ||
'approve' | ||
elsif params[:reject] | ||
'reject' | ||
elsif params[:delete] | ||
'delete' | ||
end | ||
end | ||
|
||
def authorize? | ||
begin | ||
authorize(:custom_emoji, :index?) | ||
rescue Mastodon::NotPermittedError | ||
return false | ||
end | ||
return true | ||
Check failure on line 69 in app/controllers/settings/request_custom_emojis_controller.rb GitHub Actions / lint
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
Check failure on line 2 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
Check failure on line 2 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
Check failure on line 2 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
|
||
import ImmutablePureComponent from 'react-immutable-pure-component'; | ||
Check failure on line 3 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
|
||
import { defineMessages, injectIntl } from 'react-intl'; | ||
Check failure on line 4 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
|
||
|
||
const messages = defineMessages({ | ||
cautionMessage: { id: 'custom.caution_message', defaultMessage: 'CAUTION' }, | ||
}); | ||
|
||
class LiteracyCaution extends ImmutablePureComponent { | ||
static propTypes = { | ||
intl: PropTypes.object.isRequired, | ||
} | ||
|
||
render() { | ||
const { intl } = this.props; | ||
return ( | ||
<div className="literacy-caution"> | ||
Check failure on line 18 in app/javascript/mastodon/features/compose/components/literacy_caution.jsx GitHub Actions / lint
|
||
<a href="https://onlineguide.isc.kyutech.ac.jp/guide2020/index.php/home/2020-02-04-02-50-29/2020-03-03-01-40-44"> | ||
<p> | ||
{ intl.formatMessage(messages.cautionMessage) } | ||
</p> | ||
</a> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default injectIntl(LiteracyCaution); |