mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
UX: Update badge icons (#20462)
This commit is contained in:
parent
42b451ef8a
commit
4855a2879c
|
@ -66,6 +66,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::Reader
|
||||
b.name = "Reader"
|
||||
b.default_icon = "book-reader"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = false
|
||||
|
@ -79,6 +80,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::ReadGuidelines
|
||||
b.name = "Read Guidelines"
|
||||
b.default_icon = "file-alt"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = false
|
||||
|
@ -92,6 +94,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstLink
|
||||
b.name = "First Link"
|
||||
b.default_icon = "link"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -105,6 +108,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstQuote
|
||||
b.name = "First Quote"
|
||||
b.default_icon = "quote-right"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -118,6 +122,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstLike
|
||||
b.name = "First Like"
|
||||
b.default_icon = "heart"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -131,6 +136,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstFlag
|
||||
b.name = "First Flag"
|
||||
b.default_icon = "flag"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -167,6 +173,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstShare
|
||||
b.name = "First Share"
|
||||
b.default_icon = "share-alt"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -186,6 +193,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_icon = "share-alt"
|
||||
b.badge_type_id = level
|
||||
b.multiple_grant = true
|
||||
b.target_posts = true
|
||||
|
@ -201,6 +209,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::Welcome
|
||||
b.name = "Welcome"
|
||||
b.default_icon = "heart"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -214,6 +223,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::Autobiographer
|
||||
b.name = "Autobiographer"
|
||||
b.default_icon = "user-edit"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.query = BadgeQueries::Autobiographer
|
||||
|
@ -225,6 +235,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::Editor
|
||||
b.name = "Editor"
|
||||
b.default_icon = "pen"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.query = BadgeQueries::Editor
|
||||
|
@ -236,6 +247,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::WikiEditor
|
||||
b.name = "Wiki Editor"
|
||||
b.default_icon = "far-edit"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -249,6 +261,23 @@ end
|
|||
[Badge::NicePost, "Nice Post", BadgeType::Bronze, false],
|
||||
[Badge::GoodPost, "Good Post", BadgeType::Silver, false],
|
||||
[Badge::GreatPost, "Great Post", BadgeType::Gold, false],
|
||||
].each do |id, name, type, topic|
|
||||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_icon = "reply"
|
||||
b.badge_type_id = type
|
||||
b.multiple_grant = true
|
||||
b.target_posts = true
|
||||
b.show_posts = true
|
||||
b.query = BadgeQueries.like_badge(Badge.like_badge_counts[id], topic)
|
||||
b.default_badge_grouping_id = BadgeGrouping::Posting
|
||||
b.trigger = Badge::Trigger::PostAction
|
||||
b.system = true
|
||||
end
|
||||
end
|
||||
|
||||
[
|
||||
[Badge::NiceTopic, "Nice Topic", BadgeType::Bronze, true],
|
||||
[Badge::GoodTopic, "Good Topic", BadgeType::Silver, true],
|
||||
[Badge::GreatTopic, "Great Topic", BadgeType::Gold, true],
|
||||
|
@ -256,6 +285,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_icon = "file-signature"
|
||||
b.badge_type_id = type
|
||||
b.multiple_grant = true
|
||||
b.target_posts = true
|
||||
|
@ -270,7 +300,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::Anniversary
|
||||
b.name = "Anniversary"
|
||||
b.default_icon = "far-clock"
|
||||
b.default_icon = "birthday-cake"
|
||||
b.badge_type_id = BadgeType::Silver
|
||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||
b.query = nil
|
||||
|
@ -288,6 +318,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_icon = "link"
|
||||
b.badge_type_id = level
|
||||
b.multiple_grant = true
|
||||
b.target_posts = true
|
||||
|
@ -357,6 +388,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstMention
|
||||
b.name = "First Mention"
|
||||
b.default_icon = "at"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -370,6 +402,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstEmoji
|
||||
b.name = "First Emoji"
|
||||
b.default_icon = "smile"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -383,6 +416,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstOnebox
|
||||
b.name = "First Onebox"
|
||||
b.default_icon = "cube"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -396,6 +430,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstReplyByEmail
|
||||
b.name = "First Reply By Email"
|
||||
b.default_icon = "envelope"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -409,6 +444,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::NewUserOfTheMonth
|
||||
b.name = "New User of the Month"
|
||||
b.default_icon = "medal"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = false
|
||||
|
|
38
db/migrate/20230227050147_update_badge_icons.rb
Normal file
38
db/migrate/20230227050147_update_badge_icons.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateBadgeIcons < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
icon_id_replacement = [
|
||||
["book-reader", [Badge::Reader], "fa-certificate"],
|
||||
["file-alt", [Badge::ReadGuidelines], "fa-certificate"],
|
||||
[
|
||||
"link",
|
||||
[Badge::FirstLink, Badge::PopularLink, Badge::HotLink, Badge::FamousLink],
|
||||
"fa-certificate",
|
||||
],
|
||||
["quote-right", [Badge::FirstQuote], "fa-certificate"],
|
||||
["heart", [Badge::FirstLike, Badge::Welcome], "fa-certificate"],
|
||||
["flag", [Badge::FirstFlag], "fa-certificate"],
|
||||
[
|
||||
"share-alt",
|
||||
[Badge::FirstShare, Badge::NiceShare, Badge::GoodShare, Badge::GreatShare],
|
||||
"fa-certificate",
|
||||
],
|
||||
["user-edit", [Badge::Autobiographer], "fa-certificate"],
|
||||
["pen", [Badge::Editor], "fa-certificate"],
|
||||
["far-edit", [Badge::WikiEditor], "fa-certificate"],
|
||||
["reply", [Badge::NicePost, Badge::GoodPost, Badge::GreatPost], "fa-certificate"],
|
||||
["file-signature", [Badge::NiceTopic, Badge::GoodTopic, Badge::GreatTopic], "fa-certificate"],
|
||||
["at", [Badge::FirstMention], "fa-certificate"],
|
||||
["smile", [Badge::FirstEmoji], "fa-certificate"],
|
||||
["cube", [Badge::FirstOnebox], "fa-certificate"],
|
||||
["envelope", [Badge::FirstReplyByEmail], "fa-certificate"],
|
||||
["medal", [Badge::NewUserOfTheMonth], "fa-certificate"],
|
||||
["birthday-cake", [Badge::Anniversary], "far-clock"],
|
||||
]
|
||||
|
||||
icon_id_replacement.each do |new_icon, badge_ids, old_icon|
|
||||
execute "UPDATE badges SET icon = '#{new_icon}' WHERE id IN (#{badge_ids.join(",")}) AND icon = '#{old_icon}'"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,7 +12,11 @@ new_user_narrative_badge = Badge.find_by(name: DiscourseNarrativeBot::NewUserNar
|
|||
|
||||
unless new_user_narrative_badge
|
||||
new_user_narrative_badge =
|
||||
Badge.create!(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME, badge_type_id: 3)
|
||||
Badge.create!(
|
||||
name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME,
|
||||
badge_type_id: 3,
|
||||
icon: "stamp",
|
||||
)
|
||||
end
|
||||
|
||||
advanced_user_narrative_badge =
|
||||
|
@ -20,7 +24,11 @@ advanced_user_narrative_badge =
|
|||
|
||||
unless advanced_user_narrative_badge
|
||||
advanced_user_narrative_badge =
|
||||
Badge.create!(name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME, badge_type_id: 2)
|
||||
Badge.create!(
|
||||
name: DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME,
|
||||
badge_type_id: 2,
|
||||
icon: "stamp",
|
||||
)
|
||||
end
|
||||
|
||||
badge_grouping = BadgeGrouping.find(1)
|
||||
|
@ -29,5 +37,10 @@ badge_grouping = BadgeGrouping.find(1)
|
|||
[new_user_narrative_badge, I18n.t("badges.certified.description")],
|
||||
[advanced_user_narrative_badge, I18n.t("badges.licensed.description")],
|
||||
].each do |badge, description|
|
||||
badge.update!(badge_grouping: badge_grouping, description: description, system: true)
|
||||
badge.update!(
|
||||
badge_grouping: badge_grouping,
|
||||
description: description,
|
||||
system: true,
|
||||
icon: "stamp",
|
||||
)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateNarrativeBadgeIcons < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
execute <<~SQL
|
||||
UPDATE badges
|
||||
SET icon = 'stamp'
|
||||
WHERE
|
||||
name IN ('#{DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME}', '#{DiscourseNarrativeBot::AdvancedUserNarrative::BADGE_NAME}')
|
||||
AND icon = 'fa-certificate'
|
||||
SQL
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user