FIX: Rename deprecated icons, allow custom icons in badges

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
diff --git a/app/assets/javascripts/admin/components/admin-web-hook-status.js.es6 b/app/assets/javascripts/admin/components/admin-web-hook-status.js.es6
index 1dc7a27..6e325b2 100644
--- a/app/assets/javascripts/admin/components/admin-web-hook-status.js.es6
+++ b/app/assets/javascripts/admin/components/admin-web-hook-status.js.es6
@@ -5,7 +5,7 @@ import { bufferedRender } from "discourse-common/lib/buffered-render";
 export default Ember.Component.extend(
   bufferedRender({
     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")
     status(deliveryStatuses, lastDeliveryStatus) {
diff --git a/app/assets/javascripts/admin/templates/customize-colors-show.hbs b/app/assets/javascripts/admin/templates/customize-colors-show.hbs
index fd44f99..521cd86 100644
--- a/app/assets/javascripts/admin/templates/customize-colors-show.hbs
+++ b/app/assets/javascripts/admin/templates/customize-colors-show.hbs
@@ -6,7 +6,7 @@
       <button {{action "save"}} disabled={{model.disableSave}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button>
       {{/unless}}
       <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}}
       {{i18n "admin.customize.theme_owner"}}
       {{#link-to "adminCustomizeThemes.show" model.theme_id}}{{model.theme_name}}{{/link-to}}
diff --git a/app/assets/javascripts/admin/templates/web-hooks.hbs b/app/assets/javascripts/admin/templates/web-hooks.hbs
index b48c0e3..389f7d4 100644
--- a/app/assets/javascripts/admin/templates/web-hooks.hbs
+++ b/app/assets/javascripts/admin/templates/web-hooks.hbs
@@ -25,7 +25,7 @@
             <td class='description'>{{webHook.description}}</td>
             <td class='controls'>
               {{#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>
           </tr>
         {{/each}}
diff --git a/app/assets/javascripts/discourse/helpers/icon-or-image.js.es6 b/app/assets/javascripts/discourse/helpers/icon-or-image.js.es6
index 8e48171..0751b6f 100644
--- a/app/assets/javascripts/discourse/helpers/icon-or-image.js.es6
+++ b/app/assets/javascripts/discourse/helpers/icon-or-image.js.es6
@@ -6,7 +6,7 @@ export default htmlHelper(function({ icon, image }) {
     return `<img src='${image}'>`;
   }
 
-  if (Ember.isEmpty(icon) || icon.indexOf("fa-") < 0) {
+  if (Ember.isEmpty(icon)) {
     return "";
   }
 
diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6
index 7e4f38a..cdce634 100644
--- a/app/assets/javascripts/discourse/models/composer.js.es6
+++ b/app/assets/javascripts/discourse/models/composer.js.es6
@@ -69,11 +69,11 @@ export const SAVE_LABELS = {
 
 export const SAVE_ICONS = {
   [EDIT]: "pencil-alt",
-  [EDIT_SHARED_DRAFT]: "clipboard",
+  [EDIT_SHARED_DRAFT]: "far-clipboard",
   [REPLY]: "reply",
   [CREATE_TOPIC]: "plus",
   [PRIVATE_MESSAGE]: "envelope",
-  [CREATE_SHARED_DRAFT]: "clipboard"
+  [CREATE_SHARED_DRAFT]: "far-clipboard"
 };
 
 const Composer = RestModel.extend({
diff --git a/app/assets/javascripts/discourse/templates/about.hbs b/app/assets/javascripts/discourse/templates/about.hbs
index e0b3ca0..495a7a3 100644
--- a/app/assets/javascripts/discourse/templates/about.hbs
+++ b/app/assets/javascripts/discourse/templates/about.hbs
@@ -58,7 +58,7 @@
                     args=(hash model=model)}}
 
       <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'>
           <tr>
diff --git a/app/assets/javascripts/discourse/templates/components/shared-draft-controls.hbs b/app/assets/javascripts/discourse/templates/components/shared-draft-controls.hbs
index feeed4b..0f45814 100644
--- a/app/assets/javascripts/discourse/templates/components/shared-draft-controls.hbs
+++ b/app/assets/javascripts/discourse/templates/components/shared-draft-controls.hbs
@@ -17,7 +17,7 @@
           action=(action "publish")
           label="shared_drafts.publish"
           class="btn-primary publish-shared-draft"
-          icon="clipboard"}}
+          icon="far-clipboard"}}
       {{/if}}
     </div>
   {{/if}}
diff --git a/app/assets/javascripts/discourse/widgets/post-admin-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-admin-menu.js.es6
index 2ae0a48..83e7734 100644
--- a/app/assets/javascripts/discourse/widgets/post-admin-menu.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-admin-menu.js.es6
@@ -107,14 +107,14 @@ export function buildManageButtons(attrs, currentUser, siteSettings) {
       contents.push({
         action: "toggleWiki",
         label: "post.controls.unwiki",
-        icon: "pencil-square-o",
+        icon: "far-edit",
         className: "btn-default wiki wikied"
       });
     } else {
       contents.push({
         action: "toggleWiki",
         label: "post.controls.wiki",
-        icon: "pencil-square-o",
+        icon: "far-edit",
         className: "btn-default wiki"
       });
     }
diff --git a/app/assets/javascripts/discourse/widgets/post-edits-indicator.js.es6 b/app/assets/javascripts/discourse/widgets/post-edits-indicator.js.es6
index 81f339d..46f7ed3 100644
--- a/app/assets/javascripts/discourse/widgets/post-edits-indicator.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-edits-indicator.js.es6
@@ -40,7 +40,7 @@ export default createWidget("post-edits-indicator", {
     let title;
 
     if (attrs.wiki) {
-      icon = "pencil-square-o";
+      icon = "far-edit";
       className = `${className || ""} wiki`.trim();
 
       if (attrs.version > 1) {
diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6
index e3d8c6b..4eadb59 100644
--- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6
@@ -178,7 +178,7 @@ registerButton("wiki-edit", attrs => {
       action: "editPost",
       className: "edit create",
       title: "post.controls.edit",
-      icon: "pencil-square-o",
+      icon: "far-edit",
       alwaysShowYours: true
     };
     if (!attrs.mobileView) {
diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js.es6 b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
index 2f95497..80f7f4c 100644
--- a/app/assets/javascripts/select-kit/components/composer-actions.js.es6
+++ b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
@@ -67,7 +67,7 @@ export default DropdownSelectBoxComponent.extend({
         content.title = I18n.t("composer.composer_actions.edit");
         break;
       case CREATE_SHARED_DRAFT:
-        content.icon = "clipboard";
+        content.icon = "far-clipboard";
         content.title = I18n.t("composer.composer_actions.draft");
         break;
     }
@@ -167,7 +167,7 @@ export default DropdownSelectBoxComponent.extend({
         items.push({
           name: I18n.t("composer.composer_actions.shared_draft.label"),
           description: I18n.t("composer.composer_actions.shared_draft.desc"),
-          icon: "clipboard",

[... diff too long, it was truncated ...]

GitHub sha: a571efba

1 Like

Any reasons why you didn’t specify the down queries?

def down
  execute "UPDATE badges SET icon = 'fa-clock' WHERE icon = 'far-clock-o'"
  execute "UPDATE badges SET icon = 'fa-eye' WHERE icon = 'far-eye'"
end

Yes, because the new name format has been supported in core since November 2018. Do you think it should still be included?

Honestly, I’m not sure we ever needed to migrate down a database. But I guess there’s no harm done in providing the down queries when they’re easy to do.

1 Like

Adds down SQL statements to badge icons migration

The main time I migrate down is during development and building a feature. But you could make a good argument that there’s not much point carrying them forever, espsecially since we have some Irreversible ones.

2 Likes