FIX: Rename deprecated icons, allow custom icons in badges

- adds a migration renaming FA4 icon names in badges
- allows all icons to be used in badges (previously was limited to icons prefixed with fa-)
- renames remaining FA 4.7 icons equivalents
This commit is contained in:
Penar Musaraj 2019-07-16 11:13:44 -04:00 committed by GitHub
parent ed5b31f427
commit a571efba35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 33 additions and 22 deletions

View File

@ -5,7 +5,7 @@ import { bufferedRender } from "discourse-common/lib/buffered-render";
export default Ember.Component.extend( export default Ember.Component.extend(
bufferedRender({ bufferedRender({
classes: ["text-muted", "text-danger", "text-successful", "text-muted"], classes: ["text-muted", "text-danger", "text-successful", "text-muted"],
icons: ["circle-o", "times-circle", "circle", "circle"], icons: ["far-circle", "times-circle", "circle", "circle"],
@computed("deliveryStatuses", "model.last_delivery_status") @computed("deliveryStatuses", "model.last_delivery_status")
status(deliveryStatuses, lastDeliveryStatus) { status(deliveryStatuses, lastDeliveryStatus) {

View File

@ -6,7 +6,7 @@
<button {{action "save"}} disabled={{model.disableSave}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button> <button {{action "save"}} disabled={{model.disableSave}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button>
{{/unless}} {{/unless}}
<button {{action "copy" model}} class='btn btn-default'>{{d-icon "copy"}} {{i18n 'admin.customize.copy'}}</button> <button {{action "copy" model}} class='btn btn-default'>{{d-icon "copy"}} {{i18n 'admin.customize.copy'}}</button>
<button {{action "copyToClipboard" model}} class='btn btn-default'>{{d-icon "clipboard"}} {{i18n 'admin.customize.copy_to_clipboard'}}</button> <button {{action "copyToClipboard" model}} class='btn btn-default'>{{d-icon "far-clipboard"}} {{i18n 'admin.customize.copy_to_clipboard'}}</button>
{{#if model.theme_id}} {{#if model.theme_id}}
{{i18n "admin.customize.theme_owner"}} {{i18n "admin.customize.theme_owner"}}
{{#link-to "adminCustomizeThemes.show" model.theme_id}}{{model.theme_name}}{{/link-to}} {{#link-to "adminCustomizeThemes.show" model.theme_id}}{{model.theme_name}}{{/link-to}}

View File

@ -25,7 +25,7 @@
<td class='description'>{{webHook.description}}</td> <td class='description'>{{webHook.description}}</td>
<td class='controls'> <td class='controls'>
{{#link-to 'adminWebHooks.show' webHook tagName='button' classNames='btn btn-default no-text'}}{{d-icon 'far-edit'}}{{/link-to}} {{#link-to 'adminWebHooks.show' webHook tagName='button' classNames='btn btn-default no-text'}}{{d-icon 'far-edit'}}{{/link-to}}
{{d-button class="destroy btn-danger" action=(action "destroy") actionParam=webHook icon="remove"}} {{d-button class="destroy btn-danger" action=(action "destroy") actionParam=webHook icon="times"}}
</td> </td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -6,7 +6,7 @@ export default htmlHelper(function({ icon, image }) {
return `<img src='${image}'>`; return `<img src='${image}'>`;
} }
if (Ember.isEmpty(icon) || icon.indexOf("fa-") < 0) { if (Ember.isEmpty(icon)) {
return ""; return "";
} }

View File

@ -69,11 +69,11 @@ export const SAVE_LABELS = {
export const SAVE_ICONS = { export const SAVE_ICONS = {
[EDIT]: "pencil-alt", [EDIT]: "pencil-alt",
[EDIT_SHARED_DRAFT]: "clipboard", [EDIT_SHARED_DRAFT]: "far-clipboard",
[REPLY]: "reply", [REPLY]: "reply",
[CREATE_TOPIC]: "plus", [CREATE_TOPIC]: "plus",
[PRIVATE_MESSAGE]: "envelope", [PRIVATE_MESSAGE]: "envelope",
[CREATE_SHARED_DRAFT]: "clipboard" [CREATE_SHARED_DRAFT]: "far-clipboard"
}; };
const Composer = RestModel.extend({ const Composer = RestModel.extend({

View File

@ -58,7 +58,7 @@
args=(hash model=model)}} args=(hash model=model)}}
<section class='about stats'> <section class='about stats'>
<h3>{{d-icon "bar-chart"}} {{i18n 'about.stats'}}</h3> <h3>{{d-icon "far-chart-bar"}} {{i18n 'about.stats'}}</h3>
<table class='table'> <table class='table'>
<tr> <tr>

View File

@ -17,7 +17,7 @@
action=(action "publish") action=(action "publish")
label="shared_drafts.publish" label="shared_drafts.publish"
class="btn-primary publish-shared-draft" class="btn-primary publish-shared-draft"
icon="clipboard"}} icon="far-clipboard"}}
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}

View File

@ -107,14 +107,14 @@ export function buildManageButtons(attrs, currentUser, siteSettings) {
contents.push({ contents.push({
action: "toggleWiki", action: "toggleWiki",
label: "post.controls.unwiki", label: "post.controls.unwiki",
icon: "pencil-square-o", icon: "far-edit",
className: "btn-default wiki wikied" className: "btn-default wiki wikied"
}); });
} else { } else {
contents.push({ contents.push({
action: "toggleWiki", action: "toggleWiki",
label: "post.controls.wiki", label: "post.controls.wiki",
icon: "pencil-square-o", icon: "far-edit",
className: "btn-default wiki" className: "btn-default wiki"
}); });
} }

View File

@ -40,7 +40,7 @@ export default createWidget("post-edits-indicator", {
let title; let title;
if (attrs.wiki) { if (attrs.wiki) {
icon = "pencil-square-o"; icon = "far-edit";
className = `${className || ""} wiki`.trim(); className = `${className || ""} wiki`.trim();
if (attrs.version > 1) { if (attrs.version > 1) {

View File

@ -178,7 +178,7 @@ registerButton("wiki-edit", attrs => {
action: "editPost", action: "editPost",
className: "edit create", className: "edit create",
title: "post.controls.edit", title: "post.controls.edit",
icon: "pencil-square-o", icon: "far-edit",
alwaysShowYours: true alwaysShowYours: true
}; };
if (!attrs.mobileView) { if (!attrs.mobileView) {

View File

@ -67,7 +67,7 @@ export default DropdownSelectBoxComponent.extend({
content.title = I18n.t("composer.composer_actions.edit"); content.title = I18n.t("composer.composer_actions.edit");
break; break;
case CREATE_SHARED_DRAFT: case CREATE_SHARED_DRAFT:
content.icon = "clipboard"; content.icon = "far-clipboard";
content.title = I18n.t("composer.composer_actions.draft"); content.title = I18n.t("composer.composer_actions.draft");
break; break;
} }
@ -167,7 +167,7 @@ export default DropdownSelectBoxComponent.extend({
items.push({ items.push({
name: I18n.t("composer.composer_actions.shared_draft.label"), name: I18n.t("composer.composer_actions.shared_draft.label"),
description: I18n.t("composer.composer_actions.shared_draft.desc"), description: I18n.t("composer.composer_actions.shared_draft.desc"),
icon: "clipboard", icon: "far-clipboard",
id: "shared_draft" id: "shared_draft"
}); });
} }

View File

@ -4240,7 +4240,7 @@ en:
enabled: Enable badge enabled: Enable badge
icon: Icon icon: Icon
image: Image image: Image
icon_help: "Use a Font Awesome class" 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)"
query: Badge Query (SQL) query: Badge Query (SQL)
target_posts: Query targets posts target_posts: Query targets posts

View File

@ -270,7 +270,7 @@ end
Badge.seed do |b| Badge.seed do |b|
b.id = Badge::Anniversary b.id = Badge::Anniversary
b.name = "Anniversary" b.name = "Anniversary"
b.default_icon = "fa-clock-o" b.default_icon = "far-clock"
b.badge_type_id = BadgeType::Silver b.badge_type_id = BadgeType::Silver
b.default_badge_grouping_id = BadgeGrouping::Community b.default_badge_grouping_id = BadgeGrouping::Community
b.query = nil b.query = nil
@ -427,7 +427,7 @@ end
Badge.seed do |b| Badge.seed do |b|
b.id = id b.id = id
b.name = name b.name = name
b.default_icon = "fa-eye" b.default_icon = "far-eye"
b.badge_type_id = level b.badge_type_id = level
b.query = BadgeQueries.consecutive_visits(days) b.query = BadgeQueries.consecutive_visits(days)
b.default_badge_grouping_id = BadgeGrouping::Community b.default_badge_grouping_id = BadgeGrouping::Community

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class RenameDeprecatedBadgeIcons < ActiveRecord::Migration[5.2]
def up
execute "UPDATE badges SET icon = 'far-clock' WHERE icon = 'fa-clock-o'"
execute "UPDATE badges SET icon = 'far-eye' WHERE icon = 'fa-eye'"
end
def down
end
end

View File

@ -246,7 +246,7 @@ export default {
browser: "Google Chrome", browser: "Google Chrome",
device: "Linux Computer", device: "Linux Computer",
os: "Linux", os: "Linux",
icon: "linux", icon: "fab-linux",
created_at: "2018-09-08T21:22:56.225Z", created_at: "2018-09-08T21:22:56.225Z",
seen_at: "2018-09-08T21:22:56.512Z", seen_at: "2018-09-08T21:22:56.512Z",
is_active: false is_active: false
@ -258,7 +258,7 @@ export default {
browser: "Google Chrome", browser: "Google Chrome",
device: "Linux Computer", device: "Linux Computer",
os: "Linux", os: "Linux",
icon: "linux", icon: "fab-linux",
created_at: "2018-09-08T21:33:41.616Z", created_at: "2018-09-08T21:33:41.616Z",
seen_at: "2018-09-08T21:33:42.209Z", seen_at: "2018-09-08T21:33:42.209Z",
is_active: true is_active: true
@ -270,7 +270,7 @@ export default {
browser: "Internet Explorer", browser: "Internet Explorer",
device: "Windows Computer", device: "Windows Computer",
os: "Windows", os: "Windows",
icon: "windows", icon: "fab-windows",
created_at: "2018-09-07T21:44:41.616Z", created_at: "2018-09-07T21:44:41.616Z",
seen_at: "2018-09-08T21:44:42.209Z", seen_at: "2018-09-08T21:44:42.209Z",
is_active: false is_active: false

View File

@ -21,7 +21,7 @@ widgetTest("extendability", {
beforeEach(store) { beforeEach(store) {
TopicStatusIcons.addObject([ TopicStatusIcons.addObject([
"has_accepted_answer", "has_accepted_answer",
"check-square-o", "far-check-square",
"solved" "solved"
]); ]);
this.set("args", { this.set("args", {
@ -32,6 +32,6 @@ widgetTest("extendability", {
}); });
}, },
test(assert) { test(assert) {
assert.ok(find(".topic-status .d-icon-check-square-o").length); assert.ok(find(".topic-status .d-icon-far-check-square").length);
} }
}); });