From c6ff387ce9d7660c804e9ba55096167dc427a751 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 1 Sep 2017 12:14:16 -0400 Subject: [PATCH] Use more semantic names for various tracking icons This way they can be replaced by plugins without conflicting with other icons. For example `circle` is used in some places that doesn't represent `tracking`. --- .../discourse-common/lib/icon-library.js.es6 | 12 ++++++++++++ .../discourse/controllers/topic-bulk-actions.js.es6 | 2 +- .../discourse/lib/notification-levels.js.es6 | 10 +++++----- .../discourse/templates/preferences/categories.hbs | 8 ++++---- .../templates/preferences/notifications.hbs | 2 +- .../discourse/templates/preferences/tags.hbs | 8 ++++---- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 b/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 index f1c3c09ffd5..03c2240d5cb 100644 --- a/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 +++ b/app/assets/javascripts/discourse-common/lib/icon-library.js.es6 @@ -1,6 +1,14 @@ import { h } from 'virtual-dom'; let _renderers = []; +const REPLACEMENTS = { + 'd-tracking': 'circle', + 'd-muted': 'times-circle', + 'd-regular': 'circle-o', + 'd-watching': 'exclamation-circle', + 'd-watching-first': 'dot-circle-o' +}; + export function renderIcon(renderType, id, params) { for (let i=0; i<_renderers.length; i++) { let renderer = _renderers[i]; @@ -44,6 +52,8 @@ registerIconRenderer({ name: 'font-awesome', string(id, params) { + id = REPLACEMENTS[id] || id; + let tagName = params.tagName || 'i'; let html = `<${tagName} class='${faClasses(id, params)}'`; if (params.title) { html += ` title='${I18n.t(params.title)}'`; } @@ -56,6 +66,8 @@ registerIconRenderer({ }, node(id, params) { + id = REPLACEMENTS[id] || id; + let tagName = params.tagName || 'i'; const properties = { diff --git a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 index ef7d23eba78..4b2a19d457e 100644 --- a/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic-bulk-actions.js.es6 @@ -25,7 +25,7 @@ function addBulkButton(action, key, opts) { addBulkButton('showChangeCategory', 'change_category', {icon: 'pencil'}); addBulkButton('closeTopics', 'close_topics', {icon: 'lock'}); addBulkButton('archiveTopics', 'archive_topics', {icon: 'folder'}); -addBulkButton('showNotificationLevel', 'notification_level', {icon: 'circle-o'}); +addBulkButton('showNotificationLevel', 'notification_level', {icon: 'd-regular'}); addBulkButton('resetRead', 'reset_read', {icon: 'backward'}); addBulkButton('unlistTopics', 'unlist_topics', { icon: 'eye-slash', diff --git a/app/assets/javascripts/discourse/lib/notification-levels.js.es6 b/app/assets/javascripts/discourse/lib/notification-levels.js.es6 index 6d744790e26..adeae1bcaa1 100644 --- a/app/assets/javascripts/discourse/lib/notification-levels.js.es6 +++ b/app/assets/javascripts/discourse/lib/notification-levels.js.es6 @@ -9,15 +9,15 @@ export const NotificationLevels = { WATCHING_FIRST_POST, WATCHING, TRACKING, REG export function buttonDetails(level) { switch(level) { case WATCHING_FIRST_POST: - return { id: WATCHING_FIRST_POST, key: 'watching_first_post', icon: 'dot-circle-o' }; + return { id: WATCHING_FIRST_POST, key: 'watching_first_post', icon: 'd-watching-first' }; case WATCHING: - return { id: WATCHING, key: 'watching', icon: 'exclamation-circle' }; + return { id: WATCHING, key: 'watching', icon: 'd-watching' }; case TRACKING: - return { id: TRACKING, key: 'tracking', icon: 'circle' }; + return { id: TRACKING, key: 'tracking', icon: 'd-tracking' }; case MUTED: - return { id: MUTED, key: 'muted', icon: 'times-circle' }; + return { id: MUTED, key: 'muted', icon: 'd-muted' }; default: - return { id: REGULAR, key: 'regular', icon: 'circle-o' }; + return { id: REGULAR, key: 'regular', icon: 'd-regular' }; } } diff --git a/app/assets/javascripts/discourse/templates/preferences/categories.hbs b/app/assets/javascripts/discourse/templates/preferences/categories.hbs index 856feedcf7d..27a07fef118 100644 --- a/app/assets/javascripts/discourse/templates/preferences/categories.hbs +++ b/app/assets/javascripts/discourse/templates/preferences/categories.hbs @@ -3,7 +3,7 @@
- + {{category-selector categories=model.watchedCategories blacklist=selectedCategories}}
{{i18n 'user.watched_categories_instructions'}}
@@ -12,7 +12,7 @@
- + {{category-selector categories=model.trackedCategories blacklist=selectedCategories}}
{{i18n 'user.tracked_categories_instructions'}}
@@ -21,13 +21,13 @@
- + {{category-selector categories=model.watchedFirstPostCategories}}
{{i18n 'user.watched_first_post_categories_instructions'}}
- + {{category-selector categories=model.mutedCategories blacklist=selectedCategories}}
{{i18n 'user.muted_categories_instructions'}}
diff --git a/app/assets/javascripts/discourse/templates/preferences/notifications.hbs b/app/assets/javascripts/discourse/templates/preferences/notifications.hbs index c9cf37ac4d1..0ddeefe9986 100644 --- a/app/assets/javascripts/discourse/templates/preferences/notifications.hbs +++ b/app/assets/javascripts/discourse/templates/preferences/notifications.hbs @@ -29,7 +29,7 @@
- + {{user-selector excludeCurrentUser=true usernames=model.muted_usernames class="user-selector"}}
{{i18n 'user.muted_users_instructions'}}
diff --git a/app/assets/javascripts/discourse/templates/preferences/tags.hbs b/app/assets/javascripts/discourse/templates/preferences/tags.hbs index 390429833ff..1c24147a2f6 100644 --- a/app/assets/javascripts/discourse/templates/preferences/tags.hbs +++ b/app/assets/javascripts/discourse/templates/preferences/tags.hbs @@ -4,25 +4,25 @@
- + {{tag-chooser tags=model.watched_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
{{i18n 'user.watched_tags_instructions'}}
- + {{tag-chooser tags=model.tracked_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
{{i18n 'user.tracked_tags_instructions'}}
- + {{tag-chooser tags=model.watching_first_post_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
{{i18n 'user.watched_first_post_tags_instructions'}}
- + {{tag-chooser tags=model.muted_tags blacklist=selectedTags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true"}}
{{i18n 'user.muted_tags_instructions'}}