Feature: Unlisted custom emojis (#5485)
This commit is contained in:
@ -22,6 +22,14 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @custom_emoji.update(resource_params)
|
||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.updated_msg')
|
||||
else
|
||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.update_failed_msg')
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@custom_emoji.destroy
|
||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.destroyed_msg')
|
||||
@ -56,7 +64,7 @@ module Admin
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:custom_emoji).permit(:shortcode, :image)
|
||||
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
|
||||
end
|
||||
|
||||
def filtered_custom_emojis
|
||||
|
@ -46,7 +46,7 @@ const getFrequentlyUsedEmojis = createSelector([
|
||||
|
||||
const getCustomEmojis = createSelector([
|
||||
state => state.get('custom_emojis'),
|
||||
], emojis => emojis.sort((a, b) => {
|
||||
], emojis => emojis.filter(e => e.get('visible_in_picker')).sort((a, b) => {
|
||||
const aShort = a.get('shortcode').toLowerCase();
|
||||
const bShort = b.get('shortcode').toLowerCase();
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
# disabled :boolean default(FALSE), not null
|
||||
# uri :string
|
||||
# image_remote_url :string
|
||||
# visible_in_picker :boolean default(TRUE), not null
|
||||
#
|
||||
|
||||
class CustomEmoji < ApplicationRecord
|
||||
|
@ -3,7 +3,7 @@
|
||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :shortcode, :url, :static_url
|
||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||
|
||||
def url
|
||||
full_asset_url(object.image.url)
|
||||
|
@ -9,7 +9,12 @@
|
||||
- else
|
||||
= custom_emoji.domain
|
||||
%td
|
||||
- unless custom_emoji.local?
|
||||
- if custom_emoji.local?
|
||||
- if custom_emoji.visible_in_picker
|
||||
= table_link_to 'eye', t('admin.custom_emojis.listed'), admin_custom_emoji_path(custom_emoji, custom_emoji: { visible_in_picker: false }), method: :patch
|
||||
- else
|
||||
= table_link_to 'eye-slash', t('admin.custom_emojis.unlisted'), admin_custom_emoji_path(custom_emoji, custom_emoji: { visible_in_picker: true }), method: :patch
|
||||
- else
|
||||
= table_link_to 'copy', t('admin.custom_emojis.copy'), copy_admin_custom_emoji_path(custom_emoji, page: params[:page]), method: :post
|
||||
%td
|
||||
- if custom_emoji.disabled?
|
||||
|
Reference in New Issue
Block a user