mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
FEATURE: Link to text customization when editing system badges (#11345)
Being that system badges ship with every instance of Discourse, we've opted to define the name, description, and long description in our locales files to promote translation into other languages. When an admin visited the overview page of a system badge in their admin panel, they were met with disabled inputs for these text properties. The problem is that we failed to educate the admin that the text needs to be managed via the site text customization settings. This change adds a small "Customize Text" link under theses inputs that takes the admin to the specific site text customization where they can make desired changes.
This commit is contained in:
parent
3e1b84963d
commit
a446e0fde1
|
@ -56,6 +56,11 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||
return modelQuery && modelQuery.trim().length > 0;
|
||||
},
|
||||
|
||||
@discourseComputed("model.i18n_name")
|
||||
textCustomizationPrefix(i18n_name) {
|
||||
return `badges.${i18n_name}.`;
|
||||
},
|
||||
|
||||
@observes("model.id")
|
||||
_resetSaving: function () {
|
||||
this.set("saving", false);
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
<label for="name">{{i18n "admin.badges.name"}}</label>
|
||||
{{#if readOnly}}
|
||||
{{input type="text" name="name" value=buffered.name disabled=true}}
|
||||
<p class="help">
|
||||
{{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "name")}}
|
||||
{{i18n "admin.badges.read_only_setting_help"}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{else}}
|
||||
{{input type="text" name="name" value=buffered.name}}
|
||||
{{/if}}
|
||||
|
@ -64,6 +69,11 @@
|
|||
<label for="description">{{i18n "admin.badges.description"}}</label>
|
||||
{{#if buffered.system}}
|
||||
{{textarea name="description" value=buffered.description disabled=true}}
|
||||
<p class="help">
|
||||
{{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "description")}}
|
||||
{{i18n "admin.badges.read_only_setting_help"}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{else}}
|
||||
{{textarea name="description" value=buffered.description}}
|
||||
{{/if}}
|
||||
|
@ -73,6 +83,11 @@
|
|||
<label for="long_description">{{i18n "admin.badges.long_description"}}</label>
|
||||
{{#if buffered.system}}
|
||||
{{textarea name="long_description" value=buffered.long_description disabled=true}}
|
||||
<p class="help">
|
||||
{{#link-to "adminSiteText.edit" (concat textCustomizationPrefix "long_description")}}
|
||||
{{i18n "admin.badges.read_only_setting_help"}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{else}}
|
||||
{{textarea name="long_description" value=buffered.long_description}}
|
||||
{{/if}}
|
||||
|
|
|
@ -289,15 +289,15 @@ class Badge < ActiveRecord::Base
|
|||
query.blank? && !system?
|
||||
end
|
||||
|
||||
def i18n_name
|
||||
@i18n_name ||= self.class.i18n_name(name)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def ensure_not_system
|
||||
self.id = [Badge.maximum(:id) + 1, 100].max unless id
|
||||
end
|
||||
|
||||
def i18n_name
|
||||
@i18n_name ||= self.class.i18n_name(name)
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AdminBadgeSerializer < BadgeSerializer
|
||||
attributes :query, :trigger, :target_posts, :auto_revoke, :show_posts
|
||||
attributes :query, :trigger, :target_posts, :auto_revoke, :show_posts, :i18n_name
|
||||
|
||||
def include_long_description?
|
||||
true
|
||||
end
|
||||
|
||||
def include_i18n_name?
|
||||
object.system?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4889,6 +4889,7 @@ en:
|
|||
image: Image
|
||||
icon_help: "Enter a Font Awesome icon name (use prefix 'far-' for regular icons and 'fab-' for brand icons)"
|
||||
image_help: "Enter the URL of the image (overrides icon field if both are set)"
|
||||
read_only_setting_help: "Customize text"
|
||||
query: Badge Query (SQL)
|
||||
target_posts: Query targets posts
|
||||
auto_revoke: Run revocation query daily
|
||||
|
|
Loading…
Reference in New Issue
Block a user