mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:55:54 +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;
|
return modelQuery && modelQuery.trim().length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@discourseComputed("model.i18n_name")
|
||||||
|
textCustomizationPrefix(i18n_name) {
|
||||||
|
return `badges.${i18n_name}.`;
|
||||||
|
},
|
||||||
|
|
||||||
@observes("model.id")
|
@observes("model.id")
|
||||||
_resetSaving: function () {
|
_resetSaving: function () {
|
||||||
this.set("saving", false);
|
this.set("saving", false);
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
<label for="name">{{i18n "admin.badges.name"}}</label>
|
<label for="name">{{i18n "admin.badges.name"}}</label>
|
||||||
{{#if readOnly}}
|
{{#if readOnly}}
|
||||||
{{input type="text" name="name" value=buffered.name disabled=true}}
|
{{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}}
|
{{else}}
|
||||||
{{input type="text" name="name" value=buffered.name}}
|
{{input type="text" name="name" value=buffered.name}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -64,6 +69,11 @@
|
||||||
<label for="description">{{i18n "admin.badges.description"}}</label>
|
<label for="description">{{i18n "admin.badges.description"}}</label>
|
||||||
{{#if buffered.system}}
|
{{#if buffered.system}}
|
||||||
{{textarea name="description" value=buffered.description disabled=true}}
|
{{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}}
|
{{else}}
|
||||||
{{textarea name="description" value=buffered.description}}
|
{{textarea name="description" value=buffered.description}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -73,6 +83,11 @@
|
||||||
<label for="long_description">{{i18n "admin.badges.long_description"}}</label>
|
<label for="long_description">{{i18n "admin.badges.long_description"}}</label>
|
||||||
{{#if buffered.system}}
|
{{#if buffered.system}}
|
||||||
{{textarea name="long_description" value=buffered.long_description disabled=true}}
|
{{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}}
|
{{else}}
|
||||||
{{textarea name="long_description" value=buffered.long_description}}
|
{{textarea name="long_description" value=buffered.long_description}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -289,15 +289,15 @@ class Badge < ActiveRecord::Base
|
||||||
query.blank? && !system?
|
query.blank? && !system?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def i18n_name
|
||||||
|
@i18n_name ||= self.class.i18n_name(name)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def ensure_not_system
|
def ensure_not_system
|
||||||
self.id = [Badge.maximum(:id) + 1, 100].max unless id
|
self.id = [Badge.maximum(:id) + 1, 100].max unless id
|
||||||
end
|
end
|
||||||
|
|
||||||
def i18n_name
|
|
||||||
@i18n_name ||= self.class.i18n_name(name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AdminBadgeSerializer < BadgeSerializer
|
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?
|
def include_long_description?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_i18n_name?
|
||||||
|
object.system?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4889,6 +4889,7 @@ en:
|
||||||
image: Image
|
image: Image
|
||||||
icon_help: "Enter a Font Awesome icon name (use prefix 'far-' for regular icons and 'fab-' for brand icons)"
|
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)"
|
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)
|
query: Badge Query (SQL)
|
||||||
target_posts: Query targets posts
|
target_posts: Query targets posts
|
||||||
auto_revoke: Run revocation query daily
|
auto_revoke: Run revocation query daily
|
||||||
|
|
Loading…
Reference in New Issue
Block a user