From dd0b4e26a71d50d9b0c5d4be3d3d277949be5594 Mon Sep 17 00:00:00 2001 From: Kelv Date: Thu, 5 Dec 2024 10:00:41 +0800 Subject: [PATCH 01/45] DEV: update fa6 icons to drop fa prefix (#30100) * remove fa- part of prefix from font awesome icon names --- ...41127072350_remap_fa5_icon_names_to_fa6.rb | 768 +---------------- .../20241204085540_remap_to_fa6_icon_names.rb | 794 ++++++++++++++++++ ...pec.rb => remap_to_fa6_icon_names_spec.rb} | 30 +- 3 files changed, 806 insertions(+), 786 deletions(-) create mode 100644 db/migrate/20241204085540_remap_to_fa6_icon_names.rb rename spec/migrations/{remap_fa5_icon_names_to_fa6_spec.rb => remap_to_fa6_icon_names_spec.rb} (86%) diff --git a/db/migrate/20241127072350_remap_fa5_icon_names_to_fa6.rb b/db/migrate/20241127072350_remap_fa5_icon_names_to_fa6.rb index c2d72f1813d..cf408ed3feb 100644 --- a/db/migrate/20241127072350_remap_fa5_icon_names_to_fa6.rb +++ b/db/migrate/20241127072350_remap_fa5_icon_names_to_fa6.rb @@ -1,776 +1,10 @@ # frozen_string_literal: true class RemapFa5IconNamesToFa6 < ActiveRecord::Migration[7.1] - FA5_REMAPS = { - "adjust" => "circle-half-stroke", - "air-freshener" => "spray-can-sparkles", - "alien-monster" => "alien-8bit", - "allergies" => "hand-dots", - "ambulance" => "truck-medical", - "american-sign-language-interpreting" => "hands-asl-interpreting", - "analytics" => "chart-mixed", - "angle-double-down" => "angles-down", - "angle-double-left" => "angles-left", - "angle-double-right" => "angles-right", - "angle-double-up" => "angles-up", - "angry" => "face-angry", - "apple-alt" => "apple-whole", - "apple-crate" => "crate-apple", - "archive" => "box-archive", - "arrow-alt-circle-down" => "circle-down", - "arrow-alt-circle-left" => "circle-left", - "arrow-alt-circle-right" => "circle-right", - "arrow-alt-circle-up" => "circle-up", - "arrow-alt-down" => "down", - "arrow-alt-from-bottom" => "up-from-line", - "arrow-alt-from-left" => "right-from-line", - "arrow-alt-from-right" => "left-from-line", - "arrow-alt-from-top" => "down-from-line", - "arrow-alt-left" => "left", - "arrow-alt-right" => "right", - "arrow-alt-square-down" => "square-down", - "arrow-alt-square-left" => "square-left", - "arrow-alt-square-right" => "square-right", - "arrow-alt-square-up" => "square-up", - "arrow-alt-to-bottom" => "down-to-line", - "arrow-alt-to-left" => "left-to-line", - "arrow-alt-to-right" => "right-to-line", - "arrow-alt-to-top" => "up-to-line", - "arrow-alt-up" => "up", - "arrow-circle-down" => "circle-arrow-down", - "arrow-circle-left" => "circle-arrow-left", - "arrow-circle-right" => "circle-arrow-right", - "arrow-circle-up" => "circle-arrow-up", - "arrow-from-bottom" => "arrow-up-from-line", - "arrow-from-left" => "arrow-right-from-line", - "arrow-from-right" => "arrow-left-from-line", - "arrow-from-top" => "arrow-down-from-line", - "arrow-square-down" => "square-arrow-down", - "arrow-square-left" => "square-arrow-left", - "arrow-square-right" => "square-arrow-right", - "arrow-square-up" => "square-arrow-up", - "arrow-to-bottom" => "arrow-down-to-line", - "arrow-to-left" => "arrow-left-to-line", - "arrow-to-right" => "arrow-right-to-line", - "arrow-to-top" => "arrow-up-to-line", - "arrows" => "arrows-up-down-left-right", - "arrows-alt" => "up-down-left-right", - "arrows-alt-h" => "left-right", - "arrows-alt-v" => "up-down", - "arrows-h" => "arrows-left-right", - "arrows-v" => "arrows-up-down", - "assistive-listening-systems" => "ear-listen", - "atlas" => "book-atlas", - "atom-alt" => "atom-simple", - "backspace" => "delete-left", - "balance-scale" => "scale-balanced", - "balance-scale-left" => "scale-unbalanced", - "balance-scale-right" => "scale-unbalanced-flip", - "band-aid" => "bandage", - "barcode-alt" => "rectangle-barcode", - "baseball-ball" => "baseball", - "basketball-ball" => "basketball", - "bed-alt" => "bed-front", - "beer" => "beer-mug-empty", - "betamax" => "cassette-betamax", - "bible" => "book-bible", - "biking" => "person-biking", - "biking-mountain" => "person-biking-mountain", - "birthday-cake" => "cake-candles", - "blind" => "person-walking-with-cane", - "book-alt" => "book-blank", - "book-dead" => "book-skull", - "book-reader" => "book-open-reader", - "book-spells" => "book-sparkles", - "border-style" => "border-top-left", - "border-style-alt" => "border-bottom-right", - "box-alt" => "box-taped", - "box-fragile" => "square-fragile", - "box-full" => "box-open-full", - "box-up" => "square-this-way-up", - "box-usd" => "box-dollar", - "boxes" => "boxes-stacked", - "boxes-alt" => "boxes-stacked", - "brackets" => "brackets-square", - "broadcast-tower" => "tower-broadcast", - "burn" => "fire-flame-simple", - "bus-alt" => "bus-simple", - "calculator-alt" => "calculator-simple", - "calendar-alt" => "calendar-days", - "calendar-edit" => "calendar-pen", - "calendar-times" => "calendar-xmark", - "camera-alt" => "camera", - "camera-home" => "camera-security", - "car-alt" => "car-rear", - "car-crash" => "car-burst", - "car-mechanic" => "car-wrench", - "caravan-alt" => "caravan-simple", - "caret-circle-down" => "circle-caret-down", - "caret-circle-left" => "circle-caret-left", - "caret-circle-right" => "circle-caret-right", - "caret-circle-up" => "circle-caret-up", - "caret-square-down" => "square-caret-down", - "caret-square-left" => "square-caret-left", - "caret-square-right" => "square-caret-right", - "caret-square-up" => "square-caret-up", - "cctv" => "camera-cctv", - "chalkboard-teacher" => "chalkboard-user", - "chart-pie-alt" => "chart-pie-simple", - "check-circle" => "circle-check", - "check-square" => "square-check", - "cheeseburger" => "burger-cheese", - "chess-bishop-alt" => "chess-bishop-piece", - "chess-clock-alt" => "chess-clock-flip", - "chess-king-alt" => "chess-king-piece", - "chess-knight-alt" => "chess-knight-piece", - "chess-pawn-alt" => "chess-pawn-piece", - "chess-queen-alt" => "chess-queen-piece", - "chess-rook-alt" => "chess-rook-piece", - "chevron-circle-down" => "circle-chevron-down", - "chevron-circle-left" => "circle-chevron-left", - "chevron-circle-right" => "circle-chevron-right", - "chevron-circle-up" => "circle-chevron-up", - "chevron-double-down" => "chevrons-down", - "chevron-double-left" => "chevrons-left", - "chevron-double-right" => "chevrons-right", - "chevron-double-up" => "chevrons-up", - "chevron-square-down" => "square-chevron-down", - "chevron-square-left" => "square-chevron-left", - "chevron-square-right" => "square-chevron-right", - "chevron-square-up" => "square-chevron-up", - "clinic-medical" => "house-chimney-medical", - "cloud-download" => "cloud-arrow-down", - "cloud-download-alt" => "cloud-arrow-down", - "cloud-upload" => "cloud-arrow-up", - "cloud-upload-alt" => "cloud-arrow-up", - "cocktail" => "martini-glass-citrus", - "coffee" => "mug-saucer", - "coffee-togo" => "cup-togo", - "cog" => "gear", - "cogs" => "gears", - "columns" => "table-columns", - "comment-alt" => "message", - "comment-alt-check" => "message-check", - "comment-alt-dollar" => "message-dollar", - "comment-alt-dots" => "message-dots", - "comment-alt-edit" => "message-pen", - "comment-alt-exclamation" => "message-exclamation", - "comment-alt-lines" => "message-lines", - "comment-alt-medical" => "message-medical", - "comment-alt-minus" => "message-minus", - "comment-alt-music" => "message-music", - "comment-alt-plus" => "message-plus", - "comment-alt-slash" => "message-slash", - "comment-alt-smile" => "message-smile", - "comment-alt-times" => "message-xmark", - "comment-edit" => "comment-pen", - "comment-times" => "comment-xmark", - "comments-alt" => "messages", - "comments-alt-dollar" => "messages-dollar", - "compress-alt" => "down-left-and-up-right-to-center", - "compress-arrows-alt" => "minimize", - "concierge-bell" => "bell-concierge", - "construction" => "triangle-person-digging", - "conveyor-belt-alt" => "conveyor-belt-boxes", - "cowbell-more" => "cowbell-circle-plus", - "cricket" => "cricket-bat-ball", - "crop-alt" => "crop-simple", - "curling" => "curling-stone", - "cut" => "scissors", - "deaf" => "ear-deaf", - "debug" => "ban-bug", - "desktop-alt" => "desktop", - "dewpoint" => "droplet-degree", - "diagnoses" => "person-dots-from-line", - "digging" => "person-digging", - "digital-tachograph" => "tachograph-digital", - "directions" => "diamond-turn-right", - "dizzy" => "face-dizzy", - "dolly-flatbed" => "cart-flatbed", - "dolly-flatbed-alt" => "cart-flatbed-boxes", - "dolly-flatbed-empty" => "cart-flatbed-empty", - "donate" => "circle-dollar-to-slot", - "dot-circle" => "circle-dot", - "drafting-compass" => "compass-drafting", - "drone-alt" => "drone-front", - "dryer-alt" => "dryer-heat", - "eclipse-alt" => "moon-over-sun", - "edit" => "pen-to-square", - "ellipsis-h" => "ellipsis", - "ellipsis-h-alt" => "ellipsis-stroke", - "ellipsis-v" => "ellipsis-vertical", - "ellipsis-v-alt" => "ellipsis-stroke-vertical", - "envelope-square" => "square-envelope", - "exchange" => "arrow-right-arrow-left", - "exchange-alt" => "right-left", - "exclamation-circle" => "circle-exclamation", - "exclamation-square" => "square-exclamation", - "exclamation-triangle" => "triangle-exclamation", - "expand-alt" => "up-right-and-down-left-from-center", - "expand-arrows" => "arrows-maximize", - "expand-arrows-alt" => "maximize", - "external-link" => "arrow-up-right-from-square", - "external-link-alt" => "up-right-from-square", - "external-link-square" => "square-arrow-up-right", - "external-link-square-alt" => "square-up-right", - "eyedropper" => "eye-dropper", - "fast-backward" => "backward-fast", - "fast-forward" => "forward-fast", - "feather-alt" => "feather-pointed", - "female" => "person-dress", - "field-hockey" => "field-hockey-stick-ball", - "fighter-jet" => "jet-fighter", - "file-alt" => "file-lines", - "file-archive" => "file-zipper", - "file-chart-line" => "file-chart-column", - "file-download" => "file-arrow-down", - "file-edit" => "file-pen", - "file-medical-alt" => "file-waveform", - "file-search" => "file-magnifying-glass", - "file-times" => "file-xmark", - "file-upload" => "file-arrow-up", - "film-alt" => "film-simple", - "fire-alt" => "fire-flame-curved", - "first-aid" => "kit-medical", - "fist-raised" => "hand-fist", - "flag-alt" => "flag-swallowtail", - "flame" => "fire-flame", - "flask-poison" => "flask-round-poison", - "flask-potion" => "flask-round-potion", - "flushed" => "face-flushed", - "fog" => "cloud-fog", - "folder-download" => "folder-arrow-down", - "folder-times" => "folder-xmark", - "folder-upload" => "folder-arrow-up", - "font-awesome-alt" => "square-font-awesome-stroke", - "font-awesome-flag" => "font-awesome", - "font-awesome-logo-full" => "font-awesome", - "football-ball" => "football", - "fragile" => "wine-glass-crack", - "frosty-head" => "snowman-head", - "frown" => "face-frown", - "frown-open" => "face-frown-open", - "funnel-dollar" => "filter-circle-dollar", - "game-board-alt" => "game-board-simple", - "gamepad-alt" => "gamepad-modern", - "glass-champagne" => "champagne-glass", - "glass-cheers" => "champagne-glasses", - "glass-martini" => "martini-glass-empty", - "glass-martini-alt" => "martini-glass", - "glass-whiskey" => "whiskey-glass", - "glass-whiskey-rocks" => "whiskey-glass-ice", - "glasses-alt" => "glasses-round", - "globe-africa" => "earth-africa", - "globe-americas" => "earth-americas", - "globe-asia" => "earth-asia", - "globe-europe" => "earth-europe", - "golf-ball" => "golf-ball-tee", - "grimace" => "face-grimace", - "grin" => "face-grin", - "grin-alt" => "face-grin-wide", - "grin-beam" => "face-grin-beam", - "grin-beam-sweat" => "face-grin-beam-sweat", - "grin-hearts" => "face-grin-hearts", - "grin-squint" => "face-grin-squint", - "grin-squint-tears" => "face-grin-squint-tears", - "grin-stars" => "face-grin-stars", - "grin-tears" => "face-grin-tears", - "grin-tongue" => "face-grin-tongue", - "grin-tongue-squint" => "face-grin-tongue-squint", - "grin-tongue-wink" => "face-grin-tongue-wink", - "grin-wink" => "face-grin-wink", - "grip-horizontal" => "grip", - "h-square" => "square-h", - "hamburger" => "burger", - "hand-holding-usd" => "hand-holding-dollar", - "hand-holding-water" => "hand-holding-droplet", - "hand-paper" => "hand", - "hand-receiving" => "hands-holding-diamond", - "hand-rock" => "hand-back-fist", - "hands-heart" => "hands-holding-heart", - "hands-helping" => "handshake-angle", - "hands-usd" => "hands-holding-dollar", - "hands-wash" => "hands-bubbles", - "handshake-alt" => "handshake-simple", - "handshake-alt-slash" => "handshake-simple-slash", - "hard-hat" => "helmet-safety", - "hdd" => "hard-drive", - "head-vr" => "head-side-goggles", - "headphones-alt" => "headphones-simple", - "heart-broken" => "heart-crack", - "heart-circle" => "circle-heart", - "heart-rate" => "wave-pulse", - "heart-square" => "square-heart", - "heartbeat" => "heart-pulse", - "hiking" => "person-hiking", - "history" => "clock-rotate-left", - "home" => "house", - "home-alt" => "house", - "home-heart" => "house-heart", - "home-lg" => "house-chimney", - "home-lg-alt" => "house", - "hospital-alt" => "hospital", - "hospital-symbol" => "circle-h", - "hot-tub" => "hot-tub-person", - "hourglass-half" => "hourglass", - "house-damage" => "house-chimney-crack", - "house-leave" => "house-person-leave", - "house-return" => "house-person-return", - "hryvnia" => "hryvnia-sign", - "humidity" => "droplet-percent", - "icons-alt" => "symbols", - "id-card-alt" => "id-card-clip", - "industry-alt" => "industry-windows", - "info-circle" => "circle-info", - "info-square" => "square-info", - "innosoft" => "42-group", - "inventory" => "shelves", - "journal-whills" => "book-journal-whills", - "kiss" => "face-kiss", - "kiss-beam" => "face-kiss-beam", - "kiss-wink-heart" => "face-kiss-wink-heart", - "landmark-alt" => "landmark-dome", - "laptop-house" => "house-laptop", - "laugh" => "face-laugh", - "laugh-beam" => "face-laugh-beam", - "laugh-squint" => "face-laugh-squint", - "laugh-wink" => "face-laugh-wink", - "level-down" => "arrow-turn-down", - "level-down-alt" => "turn-down", - "level-up" => "arrow-turn-up", - "level-up-alt" => "turn-up", - "list-alt" => "rectangle-list", - "location" => "location-crosshairs", - "location-circle" => "circle-location-arrow", - "location-slash" => "location-crosshairs-slash", - "lock-alt" => "lock-keyhole", - "lock-open-alt" => "lock-keyhole-open", - "long-arrow-alt-down" => "down-long", - "long-arrow-alt-left" => "left-long", - "long-arrow-alt-right" => "right-long", - "long-arrow-alt-up" => "up-long", - "long-arrow-down" => "arrow-down-long", - "long-arrow-left" => "arrow-left-long", - "long-arrow-right" => "arrow-right-long", - "long-arrow-up" => "arrow-up-long", - "low-vision" => "eye-low-vision", - "luchador" => "luchador-mask", - "luggage-cart" => "cart-flatbed-suitcase", - "magic" => "wand-magic", - "mail-bulk" => "envelopes-bulk", - "male" => "person", - "map-marked" => "map-location", - "map-marked-alt" => "map-location-dot", - "map-marker" => "location-pin", - "map-marker-alt" => "location-dot", - "map-marker-alt-slash" => "location-dot-slash", - "map-marker-check" => "location-check", - "map-marker-edit" => "location-pen", - "map-marker-exclamation" => "location-exclamation", - "map-marker-minus" => "location-minus", - "map-marker-plus" => "location-plus", - "map-marker-question" => "location-question", - "map-marker-slash" => "location-pin-slash", - "map-marker-smile" => "location-smile", - "map-marker-times" => "location-xmark", - "map-signs" => "signs-post", - "mars-stroke-h" => "mars-stroke-right", - "mars-stroke-v" => "mars-stroke-up", - "medium-m" => "medium", - "medkit" => "suitcase-medical", - "meh" => "face-meh", - "meh-blank" => "face-meh-blank", - "meh-rolling-eyes" => "face-rolling-eyes", - "microphone-alt" => "microphone-lines", - "microphone-alt-slash" => "microphone-lines-slash", - "mind-share" => "brain-arrow-curved-right", - "minus-circle" => "circle-minus", - "minus-hexagon" => "hexagon-minus", - "minus-octagon" => "octagon-minus", - "minus-square" => "square-minus", - "mobile-alt" => "mobile-screen-button", - "mobile-android" => "mobile", - "mobile-android-alt" => "mobile-screen", - "money-bill-alt" => "money-bill-1", - "money-bill-wave-alt" => "money-bill-1-wave", - "money-check-alt" => "money-check-dollar", - "money-check-edit" => "money-check-pen", - "money-check-edit-alt" => "money-check-dollar-pen", - "monitor-heart-rate" => "monitor-waveform", - "mouse" => "computer-mouse", - "mouse-alt" => "computer-mouse-scrollwheel", - "mouse-pointer" => "arrow-pointer", - "music-alt" => "music-note", - "music-alt-slash" => "music-note-slash", - "oil-temp" => "oil-temperature", - "page-break" => "file-dashed-line", - "paint-brush" => "paintbrush", - "paint-brush-alt" => "paintbrush-fine", - "paint-brush-fine" => "paintbrush-fine", - "pallet-alt" => "pallet-boxes", - "paragraph-rtl" => "paragraph-left", - "parking" => "square-parking", - "parking-circle" => "circle-parking", - "parking-circle-slash" => "ban-parking", - "parking-slash" => "square-parking-slash", - "pastafarianism" => "spaghetti-monster-flying", - "pause-circle" => "circle-pause", - "paw-alt" => "paw-simple", - "pen-alt" => "pen-clip", - "pen-square" => "square-pen", - "pencil-alt" => "pencil", - "pencil-paintbrush" => "pen-paintbrush", - "pencil-ruler" => "pen-ruler", - "pennant" => "flag-pennant", - "people-arrows" => "people-arrows-left-right", - "people-carry" => "people-carry-box", - "percentage" => "percent", - "person-carry" => "person-carry-box", - "phone-alt" => "phone-flip", - "phone-laptop" => "laptop-mobile", - "phone-square" => "square-phone", - "phone-square-alt" => "square-phone-flip", - "photo-video" => "photo-film", - "plane-alt" => "plane-engines", - "play-circle" => "circle-play", - "plus-circle" => "circle-plus", - "plus-hexagon" => "hexagon-plus", - "plus-octagon" => "octagon-plus", - "plus-square" => "square-plus", - "poll" => "square-poll-vertical", - "poll-h" => "square-poll-horizontal", - "portal-enter" => "person-to-portal", - "portal-exit" => "person-from-portal", - "portrait" => "image-portrait", - "pound-sign" => "sterling-sign", - "pray" => "person-praying", - "praying-hands" => "hands-praying", - "prescription-bottle-alt" => "prescription-bottle-medical", - "presentation" => "presentation-screen", - "print-search" => "print-magnifying-glass", - "procedures" => "bed-pulse", - "project-diagram" => "diagram-project", - "question-circle" => "circle-question", - "question-square" => "square-question", - "quran" => "book-quran", - "rabbit-fast" => "rabbit-running", - "radiation-alt" => "circle-radiation", - "radio-alt" => "radio-tuner", - "random" => "shuffle", - "rectangle-landscape" => "rectangle", - "rectangle-portrait" => "rectangle-vertical", - "redo" => "arrow-rotate-right", - "redo-alt" => "rotate-right", - "remove-format" => "text-slash", - "repeat-1-alt" => "arrows-repeat-1", - "repeat-alt" => "arrows-repeat", - "retweet-alt" => "arrows-retweet", - "rss-square" => "square-rss", - "running" => "person-running", - "sad-cry" => "face-sad-cry", - "sad-tear" => "face-sad-tear", - "save" => "floppy-disk", - "sax-hot" => "saxophone-fire", - "scalpel-path" => "scalpel-line-dashed", - "scanner-image" => "scanner", - "search" => "magnifying-glass", - "search-dollar" => "magnifying-glass-dollar", - "search-location" => "magnifying-glass-location", - "search-minus" => "magnifying-glass-minus", - "search-plus" => "magnifying-glass-plus", - "sensor-alert" => "sensor-triangle-exclamation", - "sensor-smoke" => "sensor-cloud", - "share-alt" => "share-nodes", - "share-alt-square" => "square-share-nodes", - "share-square" => "share-from-square", - "shield-alt" => "shield-halved", - "shipping-fast" => "truck-fast", - "shipping-timed" => "truck-clock", - "shopping-bag" => "bag-shopping", - "shopping-basket" => "basket-shopping", - "shopping-cart" => "cart-shopping", - "shuttle-van" => "van-shuttle", - "sign" => "sign-hanging", - "sign-in" => "arrow-right-to-bracket", - "sign-in-alt" => "right-to-bracket", - "sign-language" => "hands", - "sign-out" => "arrow-right-from-bracket", - "sign-out-alt" => "right-from-bracket", - "signal-1" => "signal-weak", - "signal-2" => "signal-fair", - "signal-3" => "signal-good", - "signal-4" => "signal-strong", - "signal-alt" => "signal-bars", - "signal-alt-1" => "signal-bars-weak", - "signal-alt-2" => "signal-bars-fair", - "signal-alt-3" => "signal-bars-good", - "signal-alt-slash" => "signal-bars-slash", - "skating" => "person-skating", - "ski-jump" => "person-ski-jumping", - "ski-lift" => "person-ski-lift", - "skiing" => "person-skiing", - "skiing-nordic" => "person-skiing-nordic", - "slack-hash" => "slack", - "sledding" => "person-sledding", - "sliders-h" => "sliders", - "sliders-h-square" => "square-sliders", - "sliders-v" => "sliders-up", - "sliders-v-square" => "square-sliders-vertical", - "smile" => "face-smile", - "smile-beam" => "face-smile-beam", - "smile-plus" => "face-smile-plus", - "smile-wink" => "face-smile-wink", - "smoking-ban" => "ban-smoking", - "sms" => "comment-sms", - "snapchat-ghost" => "snapchat", - "snowboarding" => "person-snowboarding", - "snowmobile" => "person-snowmobiling", - "sort-alpha-down" => "arrow-down-a-z", - "sort-alpha-down-alt" => "arrow-down-z-a", - "sort-alpha-up" => "arrow-up-a-z", - "sort-alpha-up-alt" => "arrow-up-z-a", - "sort-alt" => "arrow-down-arrow-up", - "sort-amount-down" => "arrow-down-wide-short", - "sort-amount-down-alt" => "arrow-down-short-wide", - "sort-amount-up" => "arrow-up-wide-short", - "sort-amount-up-alt" => "arrow-up-short-wide", - "sort-circle" => "circle-sort", - "sort-circle-down" => "circle-sort-down", - "sort-circle-up" => "circle-sort-up", - "sort-numeric-down" => "arrow-down-1-9", - "sort-numeric-down-alt" => "arrow-down-9-1", - "sort-numeric-up" => "arrow-up-1-9", - "sort-numeric-up-alt" => "arrow-up-9-1", - "sort-shapes-down" => "arrow-down-triangle-square", - "sort-shapes-down-alt" => "arrow-down-square-triangle", - "sort-shapes-up" => "arrow-up-triangle-square", - "sort-shapes-up-alt" => "arrow-up-square-triangle", - "sort-size-down" => "arrow-down-big-small", - "sort-size-down-alt" => "arrow-down-small-big", - "sort-size-up" => "arrow-up-big-small", - "sort-size-up-alt" => "arrow-up-small-big", - "soup" => "bowl-hot", - "space-shuttle" => "shuttle-space", - "space-station-moon-alt" => "space-station-moon-construction", - "square-root-alt" => "square-root-variable", - "star-half-alt" => "star-half-stroke", - "starfighter-alt" => "starfighter-twin-ion-engine", - "step-backward" => "backward-step", - "step-forward" => "forward-step", - "sticky-note" => "note-sticky", - "stop-circle" => "circle-stop", - "store-alt" => "shop", - "store-alt-slash" => "shop-slash", - "stream" => "bars-staggered", - "subway" => "train-subway", - "surprise" => "face-surprise", - "swimmer" => "person-swimming", - "swimming-pool" => "water-ladder", - "sync" => "arrows-rotate", - "sync-alt" => "rotate", - "table-tennis" => "table-tennis-paddle-ball", - "tablet-alt" => "tablet-screen-button", - "tablet-android" => "tablet", - "tablet-android-alt" => "tablet-screen", - "tachometer" => "gauge-simple", - "tachometer-alt" => "gauge", - "tachometer-alt-average" => "gauge-med", - "tachometer-alt-fast" => "gauge", - "tachometer-alt-fastest" => "gauge-max", - "tachometer-alt-slow" => "gauge-low", - "tachometer-alt-slowest" => "gauge-min", - "tachometer-average" => "gauge-simple-med", - "tachometer-fast" => "gauge-simple", - "tachometer-fastest" => "gauge-simple-max", - "tachometer-slow" => "gauge-simple-low", - "tachometer-slowest" => "gauge-simple-min", - "tanakh" => "book-tanakh", - "tasks" => "list-check", - "tasks-alt" => "bars-progress", - "telegram-plane" => "telegram", - "temperature-down" => "temperature-arrow-down", - "temperature-frigid" => "temperature-snow", - "temperature-hot" => "temperature-sun", - "temperature-up" => "temperature-arrow-up", - "tenge" => "tenge-sign", - "th" => "table-cells", - "th-large" => "table-cells-large", - "th-list" => "table-list", - "theater-masks" => "masks-theater", - "thermometer-empty" => "temperature-empty", - "thermometer-full" => "temperature-full", - "thermometer-half" => "temperature-half", - "thermometer-quarter" => "temperature-quarter", - "thermometer-three-quarters" => "temperature-three-quarters", - "thumb-tack" => "thumbtack", - "thunderstorm" => "cloud-bolt", - "thunderstorm-moon" => "cloud-bolt-moon", - "thunderstorm-sun" => "cloud-bolt-sun", - "ticket-alt" => "ticket-simple", - "times" => "xmark", - "times-circle" => "circle-xmark", - "times-hexagon" => "hexagon-xmark", - "times-octagon" => "octagon-xmark", - "times-square" => "square-xmark", - "tint" => "droplet", - "tint-slash" => "droplet-slash", - "tired" => "face-tired", - "toilet-paper-alt" => "toilet-paper-blank", - "tombstone-alt" => "tombstone-blank", - "tools" => "screwdriver-wrench", - "torah" => "scroll-torah", - "tram" => "train-tram", - "transgender-alt" => "transgender", - "trash-alt" => "trash-can", - "trash-restore" => "trash-arrow-up", - "trash-restore-alt" => "trash-can-arrow-up", - "trash-undo-alt" => "trash-can-undo", - "tree-alt" => "tree-deciduous", - "triangle-music" => "triangle-instrument", - "trophy-alt" => "trophy-star", - "truck-couch" => "truck-ramp-couch", - "truck-loading" => "truck-ramp-box", - "tshirt" => "shirt", - "tv-alt" => "tv", - "undo" => "arrow-rotate-left", - "undo-alt" => "rotate-left", - "university" => "building-columns", - "unlink" => "link-slash", - "unlock-alt" => "unlock-keyhole", - "usd-circle" => "circle-dollar", - "usd-square" => "square-dollar", - "user-alt" => "user-large", - "user-alt-slash" => "user-large-slash", - "user-chart" => "chart-user", - "user-circle" => "circle-user", - "user-cog" => "user-gear", - "user-edit" => "user-pen", - "user-friends" => "user-group", - "user-hard-hat" => "user-helmet-safety", - "user-md" => "user-doctor", - "user-md-chat" => "user-doctor-message", - "user-times" => "user-xmark", - "users-class" => "screen-users", - "users-cog" => "users-gear", - "users-crown" => "user-group-crown", - "utensil-fork" => "fork", - "utensil-knife" => "knife", - "utensil-spoon" => "spoon", - "utensils-alt" => "fork-knife", - "vhs" => "cassette-vhs", - "volleyball-ball" => "volleyball", - "volume-down" => "volume-low", - "volume-mute" => "volume-xmark", - "volume-up" => "volume-high", - "vote-nay" => "xmark-to-slot", - "vote-yea" => "check-to-slot", - "walking" => "person-walking", - "warehouse-alt" => "warehouse-full", - "washer" => "washing-machine", - "water-lower" => "water-arrow-down", - "water-rise" => "water-arrow-up", - "waveform-path" => "waveform-lines", - "webcam" => "camera-web", - "webcam-slash" => "camera-web-slash", - "weight" => "weight-scale", - "wifi-1" => "wifi-weak", - "wifi-2" => "wifi-fair", - "window-alt" => "window-flip", - "window-close" => "rectangle-xmark", - "wine-glass-alt" => "wine-glass-empty", - } - SVG_ICON_SUBSET_SETTING_NAME = "svg_icon_subset" - def up - migrate_svg_icon_subset_site_setting - migrate_icon_names + # no-op - reimplemented in 20241204085540_remap_to_fa6_icon_names.rb end def down raise ActiveRecord::IrreversibleMigration end - - def migrate_svg_icon_subset_site_setting - # name is unique across site settings - setting = - execute( - "SELECT value FROM site_settings WHERE name = '#{SVG_ICON_SUBSET_SETTING_NAME}'", - ).first - return if !setting - - original_setting_value = setting["value"] - - new_setting_value = - original_setting_value - .split("|") - .map do |icon_name| - prefix = nil - - case icon_name - when /^fab-/ - prefix = "fab" - lookup_name = icon_name.sub(/^fab-/, "") - when /^far-/ - prefix = "far" - lookup_name = icon_name.sub(/^far-/, "") - when /^fab fa-/ - prefix = "fab" - lookup_name = icon_name.sub(/^fab fa-/, "") - when /^far fa-/ - prefix = "far" - lookup_name = icon_name.sub(/^far fa-/, "") - when /^fas fa-/ - lookup_name = icon_name.sub(/^fas fa-/, "") - when /^fa-/ - lookup_name = icon_name.sub(/^fa-/, "") - else - lookup_name = icon_name - end - - new_icon_name = FA5_REMAPS[lookup_name] || lookup_name - new_icon_name = "#{prefix}-#{new_icon_name}" if prefix - new_icon_name - end - .join("|") - - return if new_setting_value == original_setting_value - - execute( - "UPDATE site_settings SET value = '#{new_setting_value}' WHERE name = '#{SVG_ICON_SUBSET_SETTING_NAME}'", - ) - end - - def migrate_icon_names - mappings = FA5_REMAPS.map { |from, to| "('#{from}', '#{to}')" }.join(", ") - - tables_to_update = { - groups: "flair_icon", - post_action_types: "icon", - badges: "icon", - sidebar_urls: "icon", - directory_columns: "icon", - } - - tables_to_update.each { |table_name, column_name| execute <<~SQL } - WITH remaps AS ( - SELECT from_icon, to_icon FROM (VALUES #{mappings}) AS mapping(from_icon, to_icon) - ) - UPDATE #{table_name} - SET #{column_name} = - CASE - WHEN #{column_name} LIKE 'fab-%' THEN CONCAT('fab-', remaps.to_icon) - WHEN #{column_name} LIKE 'far-%' THEN CONCAT('far-', remaps.to_icon) - WHEN #{column_name} LIKE 'fab fa-%' THEN CONCAT('fab-', remaps.to_icon) - WHEN #{column_name} LIKE 'far fa-%' THEN CONCAT('far-', remaps.to_icon) - ELSE remaps.to_icon - END - FROM remaps - WHERE #{column_name} = remaps.from_icon - OR #{column_name} = CONCAT('fa-', remaps.from_icon) - OR #{column_name} = CONCAT('far-', remaps.from_icon) - OR #{column_name} = CONCAT('fab-', remaps.from_icon) - OR #{column_name} = CONCAT('far fa-', remaps.from_icon) - OR #{column_name} = CONCAT('fab fa-', remaps.from_icon) - OR #{column_name} = CONCAT('fas fa-', remaps.from_icon); - SQL - end end diff --git a/db/migrate/20241204085540_remap_to_fa6_icon_names.rb b/db/migrate/20241204085540_remap_to_fa6_icon_names.rb new file mode 100644 index 00000000000..ca50024797a --- /dev/null +++ b/db/migrate/20241204085540_remap_to_fa6_icon_names.rb @@ -0,0 +1,794 @@ +# frozen_string_literal: true +class RemapToFa6IconNames < ActiveRecord::Migration[7.2] + FA5_REMAPS = { + "adjust" => "circle-half-stroke", + "air-freshener" => "spray-can-sparkles", + "alien-monster" => "alien-8bit", + "allergies" => "hand-dots", + "ambulance" => "truck-medical", + "american-sign-language-interpreting" => "hands-asl-interpreting", + "analytics" => "chart-mixed", + "angle-double-down" => "angles-down", + "angle-double-left" => "angles-left", + "angle-double-right" => "angles-right", + "angle-double-up" => "angles-up", + "angry" => "face-angry", + "apple-alt" => "apple-whole", + "apple-crate" => "crate-apple", + "archive" => "box-archive", + "arrow-alt-circle-down" => "circle-down", + "arrow-alt-circle-left" => "circle-left", + "arrow-alt-circle-right" => "circle-right", + "arrow-alt-circle-up" => "circle-up", + "arrow-alt-down" => "down", + "arrow-alt-from-bottom" => "up-from-line", + "arrow-alt-from-left" => "right-from-line", + "arrow-alt-from-right" => "left-from-line", + "arrow-alt-from-top" => "down-from-line", + "arrow-alt-left" => "left", + "arrow-alt-right" => "right", + "arrow-alt-square-down" => "square-down", + "arrow-alt-square-left" => "square-left", + "arrow-alt-square-right" => "square-right", + "arrow-alt-square-up" => "square-up", + "arrow-alt-to-bottom" => "down-to-line", + "arrow-alt-to-left" => "left-to-line", + "arrow-alt-to-right" => "right-to-line", + "arrow-alt-to-top" => "up-to-line", + "arrow-alt-up" => "up", + "arrow-circle-down" => "circle-arrow-down", + "arrow-circle-left" => "circle-arrow-left", + "arrow-circle-right" => "circle-arrow-right", + "arrow-circle-up" => "circle-arrow-up", + "arrow-from-bottom" => "arrow-up-from-line", + "arrow-from-left" => "arrow-right-from-line", + "arrow-from-right" => "arrow-left-from-line", + "arrow-from-top" => "arrow-down-from-line", + "arrow-square-down" => "square-arrow-down", + "arrow-square-left" => "square-arrow-left", + "arrow-square-right" => "square-arrow-right", + "arrow-square-up" => "square-arrow-up", + "arrow-to-bottom" => "arrow-down-to-line", + "arrow-to-left" => "arrow-left-to-line", + "arrow-to-right" => "arrow-right-to-line", + "arrow-to-top" => "arrow-up-to-line", + "arrows" => "arrows-up-down-left-right", + "arrows-alt" => "up-down-left-right", + "arrows-alt-h" => "left-right", + "arrows-alt-v" => "up-down", + "arrows-h" => "arrows-left-right", + "arrows-v" => "arrows-up-down", + "assistive-listening-systems" => "ear-listen", + "atlas" => "book-atlas", + "atom-alt" => "atom-simple", + "backspace" => "delete-left", + "balance-scale" => "scale-balanced", + "balance-scale-left" => "scale-unbalanced", + "balance-scale-right" => "scale-unbalanced-flip", + "band-aid" => "bandage", + "barcode-alt" => "rectangle-barcode", + "baseball-ball" => "baseball", + "basketball-ball" => "basketball", + "bed-alt" => "bed-front", + "beer" => "beer-mug-empty", + "betamax" => "cassette-betamax", + "bible" => "book-bible", + "biking" => "person-biking", + "biking-mountain" => "person-biking-mountain", + "birthday-cake" => "cake-candles", + "blind" => "person-walking-with-cane", + "book-alt" => "book-blank", + "book-dead" => "book-skull", + "book-reader" => "book-open-reader", + "book-spells" => "book-sparkles", + "border-style" => "border-top-left", + "border-style-alt" => "border-bottom-right", + "box-alt" => "box-taped", + "box-fragile" => "square-fragile", + "box-full" => "box-open-full", + "box-up" => "square-this-way-up", + "box-usd" => "box-dollar", + "boxes" => "boxes-stacked", + "boxes-alt" => "boxes-stacked", + "brackets" => "brackets-square", + "broadcast-tower" => "tower-broadcast", + "burn" => "fire-flame-simple", + "bus-alt" => "bus-simple", + "calculator-alt" => "calculator-simple", + "calendar-alt" => "calendar-days", + "calendar-edit" => "calendar-pen", + "calendar-times" => "calendar-xmark", + "camera-alt" => "camera", + "camera-home" => "camera-security", + "car-alt" => "car-rear", + "car-crash" => "car-burst", + "car-mechanic" => "car-wrench", + "caravan-alt" => "caravan-simple", + "caret-circle-down" => "circle-caret-down", + "caret-circle-left" => "circle-caret-left", + "caret-circle-right" => "circle-caret-right", + "caret-circle-up" => "circle-caret-up", + "caret-square-down" => "square-caret-down", + "caret-square-left" => "square-caret-left", + "caret-square-right" => "square-caret-right", + "caret-square-up" => "square-caret-up", + "cctv" => "camera-cctv", + "chalkboard-teacher" => "chalkboard-user", + "chart-pie-alt" => "chart-pie-simple", + "check-circle" => "circle-check", + "check-square" => "square-check", + "cheeseburger" => "burger-cheese", + "chess-bishop-alt" => "chess-bishop-piece", + "chess-clock-alt" => "chess-clock-flip", + "chess-king-alt" => "chess-king-piece", + "chess-knight-alt" => "chess-knight-piece", + "chess-pawn-alt" => "chess-pawn-piece", + "chess-queen-alt" => "chess-queen-piece", + "chess-rook-alt" => "chess-rook-piece", + "chevron-circle-down" => "circle-chevron-down", + "chevron-circle-left" => "circle-chevron-left", + "chevron-circle-right" => "circle-chevron-right", + "chevron-circle-up" => "circle-chevron-up", + "chevron-double-down" => "chevrons-down", + "chevron-double-left" => "chevrons-left", + "chevron-double-right" => "chevrons-right", + "chevron-double-up" => "chevrons-up", + "chevron-square-down" => "square-chevron-down", + "chevron-square-left" => "square-chevron-left", + "chevron-square-right" => "square-chevron-right", + "chevron-square-up" => "square-chevron-up", + "clinic-medical" => "house-chimney-medical", + "cloud-download" => "cloud-arrow-down", + "cloud-download-alt" => "cloud-arrow-down", + "cloud-upload" => "cloud-arrow-up", + "cloud-upload-alt" => "cloud-arrow-up", + "cocktail" => "martini-glass-citrus", + "coffee" => "mug-saucer", + "coffee-togo" => "cup-togo", + "cog" => "gear", + "cogs" => "gears", + "columns" => "table-columns", + "comment-alt" => "message", + "comment-alt-check" => "message-check", + "comment-alt-dollar" => "message-dollar", + "comment-alt-dots" => "message-dots", + "comment-alt-edit" => "message-pen", + "comment-alt-exclamation" => "message-exclamation", + "comment-alt-lines" => "message-lines", + "comment-alt-medical" => "message-medical", + "comment-alt-minus" => "message-minus", + "comment-alt-music" => "message-music", + "comment-alt-plus" => "message-plus", + "comment-alt-slash" => "message-slash", + "comment-alt-smile" => "message-smile", + "comment-alt-times" => "message-xmark", + "comment-edit" => "comment-pen", + "comment-times" => "comment-xmark", + "comments-alt" => "messages", + "comments-alt-dollar" => "messages-dollar", + "compress-alt" => "down-left-and-up-right-to-center", + "compress-arrows-alt" => "minimize", + "concierge-bell" => "bell-concierge", + "construction" => "triangle-person-digging", + "conveyor-belt-alt" => "conveyor-belt-boxes", + "cowbell-more" => "cowbell-circle-plus", + "cricket" => "cricket-bat-ball", + "crop-alt" => "crop-simple", + "curling" => "curling-stone", + "cut" => "scissors", + "deaf" => "ear-deaf", + "debug" => "ban-bug", + "desktop-alt" => "desktop", + "dewpoint" => "droplet-degree", + "diagnoses" => "person-dots-from-line", + "digging" => "person-digging", + "digital-tachograph" => "tachograph-digital", + "directions" => "diamond-turn-right", + "dizzy" => "face-dizzy", + "dolly-flatbed" => "cart-flatbed", + "dolly-flatbed-alt" => "cart-flatbed-boxes", + "dolly-flatbed-empty" => "cart-flatbed-empty", + "donate" => "circle-dollar-to-slot", + "dot-circle" => "circle-dot", + "drafting-compass" => "compass-drafting", + "drone-alt" => "drone-front", + "dryer-alt" => "dryer-heat", + "eclipse-alt" => "moon-over-sun", + "edit" => "pen-to-square", + "ellipsis-h" => "ellipsis", + "ellipsis-h-alt" => "ellipsis-stroke", + "ellipsis-v" => "ellipsis-vertical", + "ellipsis-v-alt" => "ellipsis-stroke-vertical", + "envelope-square" => "square-envelope", + "exchange" => "arrow-right-arrow-left", + "exchange-alt" => "right-left", + "exclamation-circle" => "circle-exclamation", + "exclamation-square" => "square-exclamation", + "exclamation-triangle" => "triangle-exclamation", + "expand-alt" => "up-right-and-down-left-from-center", + "expand-arrows" => "arrows-maximize", + "expand-arrows-alt" => "maximize", + "external-link" => "arrow-up-right-from-square", + "external-link-alt" => "up-right-from-square", + "external-link-square" => "square-arrow-up-right", + "external-link-square-alt" => "square-up-right", + "eyedropper" => "eye-dropper", + "fast-backward" => "backward-fast", + "fast-forward" => "forward-fast", + "feather-alt" => "feather-pointed", + "female" => "person-dress", + "field-hockey" => "field-hockey-stick-ball", + "fighter-jet" => "jet-fighter", + "file-alt" => "file-lines", + "file-archive" => "file-zipper", + "file-chart-line" => "file-chart-column", + "file-download" => "file-arrow-down", + "file-edit" => "file-pen", + "file-medical-alt" => "file-waveform", + "file-search" => "file-magnifying-glass", + "file-times" => "file-xmark", + "file-upload" => "file-arrow-up", + "film-alt" => "film-simple", + "fire-alt" => "fire-flame-curved", + "first-aid" => "kit-medical", + "fist-raised" => "hand-fist", + "flag-alt" => "flag-swallowtail", + "flame" => "fire-flame", + "flask-poison" => "flask-round-poison", + "flask-potion" => "flask-round-potion", + "flushed" => "face-flushed", + "fog" => "cloud-fog", + "folder-download" => "folder-arrow-down", + "folder-times" => "folder-xmark", + "folder-upload" => "folder-arrow-up", + "font-awesome-alt" => "square-font-awesome-stroke", + "font-awesome-flag" => "font-awesome", + "font-awesome-logo-full" => "font-awesome", + "football-ball" => "football", + "fragile" => "wine-glass-crack", + "frosty-head" => "snowman-head", + "frown" => "face-frown", + "frown-open" => "face-frown-open", + "funnel-dollar" => "filter-circle-dollar", + "game-board-alt" => "game-board-simple", + "gamepad-alt" => "gamepad-modern", + "glass-champagne" => "champagne-glass", + "glass-cheers" => "champagne-glasses", + "glass-martini" => "martini-glass-empty", + "glass-martini-alt" => "martini-glass", + "glass-whiskey" => "whiskey-glass", + "glass-whiskey-rocks" => "whiskey-glass-ice", + "glasses-alt" => "glasses-round", + "globe-africa" => "earth-africa", + "globe-americas" => "earth-americas", + "globe-asia" => "earth-asia", + "globe-europe" => "earth-europe", + "golf-ball" => "golf-ball-tee", + "grimace" => "face-grimace", + "grin" => "face-grin", + "grin-alt" => "face-grin-wide", + "grin-beam" => "face-grin-beam", + "grin-beam-sweat" => "face-grin-beam-sweat", + "grin-hearts" => "face-grin-hearts", + "grin-squint" => "face-grin-squint", + "grin-squint-tears" => "face-grin-squint-tears", + "grin-stars" => "face-grin-stars", + "grin-tears" => "face-grin-tears", + "grin-tongue" => "face-grin-tongue", + "grin-tongue-squint" => "face-grin-tongue-squint", + "grin-tongue-wink" => "face-grin-tongue-wink", + "grin-wink" => "face-grin-wink", + "grip-horizontal" => "grip", + "h-square" => "square-h", + "hamburger" => "burger", + "hand-holding-usd" => "hand-holding-dollar", + "hand-holding-water" => "hand-holding-droplet", + "hand-paper" => "hand", + "hand-receiving" => "hands-holding-diamond", + "hand-rock" => "hand-back-fist", + "hands-heart" => "hands-holding-heart", + "hands-helping" => "handshake-angle", + "hands-usd" => "hands-holding-dollar", + "hands-wash" => "hands-bubbles", + "handshake-alt" => "handshake-simple", + "handshake-alt-slash" => "handshake-simple-slash", + "hard-hat" => "helmet-safety", + "hdd" => "hard-drive", + "head-vr" => "head-side-goggles", + "headphones-alt" => "headphones-simple", + "heart-broken" => "heart-crack", + "heart-circle" => "circle-heart", + "heart-rate" => "wave-pulse", + "heart-square" => "square-heart", + "heartbeat" => "heart-pulse", + "hiking" => "person-hiking", + "history" => "clock-rotate-left", + "home" => "house", + "home-alt" => "house", + "home-heart" => "house-heart", + "home-lg" => "house-chimney", + "home-lg-alt" => "house", + "hospital-alt" => "hospital", + "hospital-symbol" => "circle-h", + "hot-tub" => "hot-tub-person", + "hourglass-half" => "hourglass", + "house-damage" => "house-chimney-crack", + "house-leave" => "house-person-leave", + "house-return" => "house-person-return", + "hryvnia" => "hryvnia-sign", + "humidity" => "droplet-percent", + "icons-alt" => "symbols", + "id-card-alt" => "id-card-clip", + "industry-alt" => "industry-windows", + "info-circle" => "circle-info", + "info-square" => "square-info", + "innosoft" => "42-group", + "inventory" => "shelves", + "journal-whills" => "book-journal-whills", + "kiss" => "face-kiss", + "kiss-beam" => "face-kiss-beam", + "kiss-wink-heart" => "face-kiss-wink-heart", + "landmark-alt" => "landmark-dome", + "laptop-house" => "house-laptop", + "laugh" => "face-laugh", + "laugh-beam" => "face-laugh-beam", + "laugh-squint" => "face-laugh-squint", + "laugh-wink" => "face-laugh-wink", + "level-down" => "arrow-turn-down", + "level-down-alt" => "turn-down", + "level-up" => "arrow-turn-up", + "level-up-alt" => "turn-up", + "list-alt" => "rectangle-list", + "location" => "location-crosshairs", + "location-circle" => "circle-location-arrow", + "location-slash" => "location-crosshairs-slash", + "lock-alt" => "lock-keyhole", + "lock-open-alt" => "lock-keyhole-open", + "long-arrow-alt-down" => "down-long", + "long-arrow-alt-left" => "left-long", + "long-arrow-alt-right" => "right-long", + "long-arrow-alt-up" => "up-long", + "long-arrow-down" => "arrow-down-long", + "long-arrow-left" => "arrow-left-long", + "long-arrow-right" => "arrow-right-long", + "long-arrow-up" => "arrow-up-long", + "low-vision" => "eye-low-vision", + "luchador" => "luchador-mask", + "luggage-cart" => "cart-flatbed-suitcase", + "magic" => "wand-magic", + "mail-bulk" => "envelopes-bulk", + "male" => "person", + "map-marked" => "map-location", + "map-marked-alt" => "map-location-dot", + "map-marker" => "location-pin", + "map-marker-alt" => "location-dot", + "map-marker-alt-slash" => "location-dot-slash", + "map-marker-check" => "location-check", + "map-marker-edit" => "location-pen", + "map-marker-exclamation" => "location-exclamation", + "map-marker-minus" => "location-minus", + "map-marker-plus" => "location-plus", + "map-marker-question" => "location-question", + "map-marker-slash" => "location-pin-slash", + "map-marker-smile" => "location-smile", + "map-marker-times" => "location-xmark", + "map-signs" => "signs-post", + "mars-stroke-h" => "mars-stroke-right", + "mars-stroke-v" => "mars-stroke-up", + "medium-m" => "medium", + "medkit" => "suitcase-medical", + "meh" => "face-meh", + "meh-blank" => "face-meh-blank", + "meh-rolling-eyes" => "face-rolling-eyes", + "microphone-alt" => "microphone-lines", + "microphone-alt-slash" => "microphone-lines-slash", + "mind-share" => "brain-arrow-curved-right", + "minus-circle" => "circle-minus", + "minus-hexagon" => "hexagon-minus", + "minus-octagon" => "octagon-minus", + "minus-square" => "square-minus", + "mobile-alt" => "mobile-screen-button", + "mobile-android" => "mobile", + "mobile-android-alt" => "mobile-screen", + "money-bill-alt" => "money-bill-1", + "money-bill-wave-alt" => "money-bill-1-wave", + "money-check-alt" => "money-check-dollar", + "money-check-edit" => "money-check-pen", + "money-check-edit-alt" => "money-check-dollar-pen", + "monitor-heart-rate" => "monitor-waveform", + "mouse" => "computer-mouse", + "mouse-alt" => "computer-mouse-scrollwheel", + "mouse-pointer" => "arrow-pointer", + "music-alt" => "music-note", + "music-alt-slash" => "music-note-slash", + "oil-temp" => "oil-temperature", + "page-break" => "file-dashed-line", + "paint-brush" => "paintbrush", + "paint-brush-alt" => "paintbrush-fine", + "paint-brush-fine" => "paintbrush-fine", + "pallet-alt" => "pallet-boxes", + "paragraph-rtl" => "paragraph-left", + "parking" => "square-parking", + "parking-circle" => "circle-parking", + "parking-circle-slash" => "ban-parking", + "parking-slash" => "square-parking-slash", + "pastafarianism" => "spaghetti-monster-flying", + "pause-circle" => "circle-pause", + "paw-alt" => "paw-simple", + "pen-alt" => "pen-clip", + "pen-square" => "square-pen", + "pencil-alt" => "pencil", + "pencil-paintbrush" => "pen-paintbrush", + "pencil-ruler" => "pen-ruler", + "pennant" => "flag-pennant", + "people-arrows" => "people-arrows-left-right", + "people-carry" => "people-carry-box", + "percentage" => "percent", + "person-carry" => "person-carry-box", + "phone-alt" => "phone-flip", + "phone-laptop" => "laptop-mobile", + "phone-square" => "square-phone", + "phone-square-alt" => "square-phone-flip", + "photo-video" => "photo-film", + "plane-alt" => "plane-engines", + "play-circle" => "circle-play", + "plus-circle" => "circle-plus", + "plus-hexagon" => "hexagon-plus", + "plus-octagon" => "octagon-plus", + "plus-square" => "square-plus", + "poll" => "square-poll-vertical", + "poll-h" => "square-poll-horizontal", + "portal-enter" => "person-to-portal", + "portal-exit" => "person-from-portal", + "portrait" => "image-portrait", + "pound-sign" => "sterling-sign", + "pray" => "person-praying", + "praying-hands" => "hands-praying", + "prescription-bottle-alt" => "prescription-bottle-medical", + "presentation" => "presentation-screen", + "print-search" => "print-magnifying-glass", + "procedures" => "bed-pulse", + "project-diagram" => "diagram-project", + "question-circle" => "circle-question", + "question-square" => "square-question", + "quran" => "book-quran", + "rabbit-fast" => "rabbit-running", + "radiation-alt" => "circle-radiation", + "radio-alt" => "radio-tuner", + "random" => "shuffle", + "rectangle-landscape" => "rectangle", + "rectangle-portrait" => "rectangle-vertical", + "redo" => "arrow-rotate-right", + "redo-alt" => "rotate-right", + "remove-format" => "text-slash", + "repeat-1-alt" => "arrows-repeat-1", + "repeat-alt" => "arrows-repeat", + "retweet-alt" => "arrows-retweet", + "rss-square" => "square-rss", + "running" => "person-running", + "sad-cry" => "face-sad-cry", + "sad-tear" => "face-sad-tear", + "save" => "floppy-disk", + "sax-hot" => "saxophone-fire", + "scalpel-path" => "scalpel-line-dashed", + "scanner-image" => "scanner", + "search" => "magnifying-glass", + "search-dollar" => "magnifying-glass-dollar", + "search-location" => "magnifying-glass-location", + "search-minus" => "magnifying-glass-minus", + "search-plus" => "magnifying-glass-plus", + "sensor-alert" => "sensor-triangle-exclamation", + "sensor-smoke" => "sensor-cloud", + "share-alt" => "share-nodes", + "share-alt-square" => "square-share-nodes", + "share-square" => "share-from-square", + "shield-alt" => "shield-halved", + "shipping-fast" => "truck-fast", + "shipping-timed" => "truck-clock", + "shopping-bag" => "bag-shopping", + "shopping-basket" => "basket-shopping", + "shopping-cart" => "cart-shopping", + "shuttle-van" => "van-shuttle", + "sign" => "sign-hanging", + "sign-in" => "arrow-right-to-bracket", + "sign-in-alt" => "right-to-bracket", + "sign-language" => "hands", + "sign-out" => "arrow-right-from-bracket", + "sign-out-alt" => "right-from-bracket", + "signal-1" => "signal-weak", + "signal-2" => "signal-fair", + "signal-3" => "signal-good", + "signal-4" => "signal-strong", + "signal-alt" => "signal-bars", + "signal-alt-1" => "signal-bars-weak", + "signal-alt-2" => "signal-bars-fair", + "signal-alt-3" => "signal-bars-good", + "signal-alt-slash" => "signal-bars-slash", + "skating" => "person-skating", + "ski-jump" => "person-ski-jumping", + "ski-lift" => "person-ski-lift", + "skiing" => "person-skiing", + "skiing-nordic" => "person-skiing-nordic", + "slack-hash" => "slack", + "sledding" => "person-sledding", + "sliders-h" => "sliders", + "sliders-h-square" => "square-sliders", + "sliders-v" => "sliders-up", + "sliders-v-square" => "square-sliders-vertical", + "smile" => "face-smile", + "smile-beam" => "face-smile-beam", + "smile-plus" => "face-smile-plus", + "smile-wink" => "face-smile-wink", + "smoking-ban" => "ban-smoking", + "sms" => "comment-sms", + "snapchat-ghost" => "snapchat", + "snowboarding" => "person-snowboarding", + "snowmobile" => "person-snowmobiling", + "sort-alpha-down" => "arrow-down-a-z", + "sort-alpha-down-alt" => "arrow-down-z-a", + "sort-alpha-up" => "arrow-up-a-z", + "sort-alpha-up-alt" => "arrow-up-z-a", + "sort-alt" => "arrow-down-arrow-up", + "sort-amount-down" => "arrow-down-wide-short", + "sort-amount-down-alt" => "arrow-down-short-wide", + "sort-amount-up" => "arrow-up-wide-short", + "sort-amount-up-alt" => "arrow-up-short-wide", + "sort-circle" => "circle-sort", + "sort-circle-down" => "circle-sort-down", + "sort-circle-up" => "circle-sort-up", + "sort-numeric-down" => "arrow-down-1-9", + "sort-numeric-down-alt" => "arrow-down-9-1", + "sort-numeric-up" => "arrow-up-1-9", + "sort-numeric-up-alt" => "arrow-up-9-1", + "sort-shapes-down" => "arrow-down-triangle-square", + "sort-shapes-down-alt" => "arrow-down-square-triangle", + "sort-shapes-up" => "arrow-up-triangle-square", + "sort-shapes-up-alt" => "arrow-up-square-triangle", + "sort-size-down" => "arrow-down-big-small", + "sort-size-down-alt" => "arrow-down-small-big", + "sort-size-up" => "arrow-up-big-small", + "sort-size-up-alt" => "arrow-up-small-big", + "soup" => "bowl-hot", + "space-shuttle" => "shuttle-space", + "space-station-moon-alt" => "space-station-moon-construction", + "square-root-alt" => "square-root-variable", + "star-half-alt" => "star-half-stroke", + "starfighter-alt" => "starfighter-twin-ion-engine", + "step-backward" => "backward-step", + "step-forward" => "forward-step", + "sticky-note" => "note-sticky", + "stop-circle" => "circle-stop", + "store-alt" => "shop", + "store-alt-slash" => "shop-slash", + "stream" => "bars-staggered", + "subway" => "train-subway", + "surprise" => "face-surprise", + "swimmer" => "person-swimming", + "swimming-pool" => "water-ladder", + "sync" => "arrows-rotate", + "sync-alt" => "rotate", + "table-tennis" => "table-tennis-paddle-ball", + "tablet-alt" => "tablet-screen-button", + "tablet-android" => "tablet", + "tablet-android-alt" => "tablet-screen", + "tachometer" => "gauge-simple", + "tachometer-alt" => "gauge", + "tachometer-alt-average" => "gauge-med", + "tachometer-alt-fast" => "gauge", + "tachometer-alt-fastest" => "gauge-max", + "tachometer-alt-slow" => "gauge-low", + "tachometer-alt-slowest" => "gauge-min", + "tachometer-average" => "gauge-simple-med", + "tachometer-fast" => "gauge-simple", + "tachometer-fastest" => "gauge-simple-max", + "tachometer-slow" => "gauge-simple-low", + "tachometer-slowest" => "gauge-simple-min", + "tanakh" => "book-tanakh", + "tasks" => "list-check", + "tasks-alt" => "bars-progress", + "telegram-plane" => "telegram", + "temperature-down" => "temperature-arrow-down", + "temperature-frigid" => "temperature-snow", + "temperature-hot" => "temperature-sun", + "temperature-up" => "temperature-arrow-up", + "tenge" => "tenge-sign", + "th" => "table-cells", + "th-large" => "table-cells-large", + "th-list" => "table-list", + "theater-masks" => "masks-theater", + "thermometer-empty" => "temperature-empty", + "thermometer-full" => "temperature-full", + "thermometer-half" => "temperature-half", + "thermometer-quarter" => "temperature-quarter", + "thermometer-three-quarters" => "temperature-three-quarters", + "thumb-tack" => "thumbtack", + "thunderstorm" => "cloud-bolt", + "thunderstorm-moon" => "cloud-bolt-moon", + "thunderstorm-sun" => "cloud-bolt-sun", + "ticket-alt" => "ticket-simple", + "times" => "xmark", + "times-circle" => "circle-xmark", + "times-hexagon" => "hexagon-xmark", + "times-octagon" => "octagon-xmark", + "times-square" => "square-xmark", + "tint" => "droplet", + "tint-slash" => "droplet-slash", + "tired" => "face-tired", + "toilet-paper-alt" => "toilet-paper-blank", + "tombstone-alt" => "tombstone-blank", + "tools" => "screwdriver-wrench", + "torah" => "scroll-torah", + "tram" => "train-tram", + "transgender-alt" => "transgender", + "trash-alt" => "trash-can", + "trash-restore" => "trash-arrow-up", + "trash-restore-alt" => "trash-can-arrow-up", + "trash-undo-alt" => "trash-can-undo", + "tree-alt" => "tree-deciduous", + "triangle-music" => "triangle-instrument", + "trophy-alt" => "trophy-star", + "truck-couch" => "truck-ramp-couch", + "truck-loading" => "truck-ramp-box", + "tshirt" => "shirt", + "tv-alt" => "tv", + "undo" => "arrow-rotate-left", + "undo-alt" => "rotate-left", + "university" => "building-columns", + "unlink" => "link-slash", + "unlock-alt" => "unlock-keyhole", + "usd-circle" => "circle-dollar", + "usd-square" => "square-dollar", + "user-alt" => "user-large", + "user-alt-slash" => "user-large-slash", + "user-chart" => "chart-user", + "user-circle" => "circle-user", + "user-cog" => "user-gear", + "user-edit" => "user-pen", + "user-friends" => "user-group", + "user-hard-hat" => "user-helmet-safety", + "user-md" => "user-doctor", + "user-md-chat" => "user-doctor-message", + "user-times" => "user-xmark", + "users-class" => "screen-users", + "users-cog" => "users-gear", + "users-crown" => "user-group-crown", + "utensil-fork" => "fork", + "utensil-knife" => "knife", + "utensil-spoon" => "spoon", + "utensils-alt" => "fork-knife", + "vhs" => "cassette-vhs", + "volleyball-ball" => "volleyball", + "volume-down" => "volume-low", + "volume-mute" => "volume-xmark", + "volume-up" => "volume-high", + "vote-nay" => "xmark-to-slot", + "vote-yea" => "check-to-slot", + "walking" => "person-walking", + "warehouse-alt" => "warehouse-full", + "washer" => "washing-machine", + "water-lower" => "water-arrow-down", + "water-rise" => "water-arrow-up", + "waveform-path" => "waveform-lines", + "webcam" => "camera-web", + "webcam-slash" => "camera-web-slash", + "weight" => "weight-scale", + "wifi-1" => "wifi-weak", + "wifi-2" => "wifi-fair", + "window-alt" => "window-flip", + "window-close" => "rectangle-xmark", + "wine-glass-alt" => "wine-glass-empty", + } + SVG_ICON_SUBSET_SETTING_NAME = "svg_icon_subset" + + def up + migrate_svg_icon_subset_site_setting + migrate_icon_names + end + + def down + raise ActiveRecord::IrreversibleMigration + end + + def migrate_svg_icon_subset_site_setting + # name is unique across site settings + setting = + execute( + "SELECT value FROM site_settings WHERE name = '#{SVG_ICON_SUBSET_SETTING_NAME}'", + ).first + return if !setting + + original_setting_value = setting["value"] + + new_setting_value = + original_setting_value + .split("|") + .map do |icon_name| + prefix = nil + + case icon_name + when /^fab-/ + prefix = "fab" + lookup_name = icon_name.sub(/^fab-/, "") + when /^far-/ + prefix = "far" + lookup_name = icon_name.sub(/^far-/, "") + when /^fab fa-/ + prefix = "fab" + lookup_name = icon_name.sub(/^fab fa-/, "") + when /^far fa-/ + prefix = "far" + lookup_name = icon_name.sub(/^far fa-/, "") + when /^fas fa-/ + lookup_name = icon_name.sub(/^fas fa-/, "") + when /^fa-/ + lookup_name = icon_name.sub(/^fa-/, "") + else + lookup_name = icon_name + end + + new_icon_name = FA5_REMAPS[lookup_name] || lookup_name + new_icon_name = "#{prefix}-#{new_icon_name}" if prefix + new_icon_name + end + .join("|") + + return if new_setting_value == original_setting_value + + execute( + "UPDATE site_settings SET value = '#{new_setting_value}' WHERE name = '#{SVG_ICON_SUBSET_SETTING_NAME}'", + ) + end + + def migrate_icon_names + mappings = FA5_REMAPS.map { |from, to| "('#{from}', '#{to}')" }.join(", ") + + tables_to_update = { + groups: "flair_icon", + post_action_types: "icon", + badges: "icon", + sidebar_urls: "icon", + directory_columns: "icon", + } + + tables_to_update.each do |table_name, column_name| + execute <<~SQL + WITH remaps AS ( + SELECT from_icon, to_icon FROM (VALUES #{mappings}) AS mapping(from_icon, to_icon) + ) + UPDATE #{table_name} + SET #{column_name} = + CASE + WHEN #{column_name} LIKE 'fab-%' THEN CONCAT('fab-', remaps.to_icon) + WHEN #{column_name} LIKE 'far-%' THEN CONCAT('far-', remaps.to_icon) + WHEN #{column_name} LIKE 'fab fa-%' THEN CONCAT('fab-', remaps.to_icon) + WHEN #{column_name} LIKE 'far fa-%' THEN CONCAT('far-', remaps.to_icon) + ELSE remaps.to_icon + END + FROM remaps + WHERE #{column_name} = remaps.from_icon + OR #{column_name} = CONCAT('fa-', remaps.from_icon) + OR #{column_name} = CONCAT('far-', remaps.from_icon) + OR #{column_name} = CONCAT('fab-', remaps.from_icon) + OR #{column_name} = CONCAT('far fa-', remaps.from_icon) + OR #{column_name} = CONCAT('fab fa-', remaps.from_icon) + OR #{column_name} = CONCAT('fas fa-', remaps.from_icon); + SQL + + execute <<~SQL + UPDATE #{table_name} + SET #{column_name} = + CASE + WHEN #{column_name} LIKE 'fas fa-%' THEN SUBSTRING(#{column_name} FROM 8) + WHEN #{column_name} LIKE 'far fa-%' THEN CONCAT('far-', SUBSTRING(#{column_name} FROM 8)) + WHEN #{column_name} LIKE 'fab fa-%' THEN CONCAT('fab-', SUBSTRING(#{column_name} FROM 8)) + WHEN #{column_name} LIKE 'fa-%' THEN SUBSTRING(#{column_name} FROM 4) + ELSE #{column_name} + END + WHERE #{column_name} LIKE 'fa-%' + OR #{column_name} LIKE 'far fa-%' + OR #{column_name} LIKE 'fab fa-%' + OR #{column_name} LIKE 'fas fa-%'; + SQL + end + end +end diff --git a/spec/migrations/remap_fa5_icon_names_to_fa6_spec.rb b/spec/migrations/remap_to_fa6_icon_names_spec.rb similarity index 86% rename from spec/migrations/remap_fa5_icon_names_to_fa6_spec.rb rename to spec/migrations/remap_to_fa6_icon_names_spec.rb index c48d805af25..d11b98a43df 100644 --- a/spec/migrations/remap_fa5_icon_names_to_fa6_spec.rb +++ b/spec/migrations/remap_to_fa6_icon_names_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require Rails.root.join("db/migrate/20241127072350_remap_fa5_icon_names_to_fa6.rb") +require Rails.root.join("db/migrate/20241204085540_remap_to_fa6_icon_names.rb") -RSpec.describe RemapFa5IconNamesToFa6 do +RSpec.describe RemapToFa6IconNames do let(:migrate) { described_class.new.up } let(:icon_mapping) do { @@ -12,36 +12,28 @@ RSpec.describe RemapFa5IconNamesToFa6 do "far fa-ambulance" => "far-truck-medical", "fab fa-ambulance" => "fab-truck-medical", "fas fa-ambulance" => "truck-medical", + "fa-gear" => "gear", + "far-gear" => "far-gear", + "fab-gear" => "fab-gear", + "far fa-gear" => "far-gear", + "fab fa-gear" => "fab-gear", + "fas fa-gear" => "gear", + "gear" => "gear", } end context "when svg_icon_subset site setting has values to be remapped" do - let(:svg_icon_subset_icon_mapping) do - { - "fa-ambulance" => "truck-medical", - "far-ambulance" => "far-truck-medical", - "fab-ambulance" => "fab-truck-medical", - "far fa-ambulance" => "far-truck-medical", - "far fa-gear" => "far-gear", - "gear" => "gear", - "fab fa-ambulance" => "fab-truck-medical", - "fas fa-ambulance" => "truck-medical", - } - end - let!(:site_setting) do SiteSetting.create!( name: "svg_icon_subset", - value: svg_icon_subset_icon_mapping.keys.join("|"), + value: icon_mapping.keys.join("|"), data_type: SiteSettings::TypeSupervisor.types[:list], ) end it "remaps the values correctly" do silence_stdout { migrate } - expect(site_setting.reload.value.split("|")).to match_array( - svg_icon_subset_icon_mapping.values, - ) + expect(site_setting.reload.value.split("|")).to match_array(icon_mapping.values) end end From 8a89a772487654a20121425e0e9b727f9aea7fe3 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 5 Dec 2024 15:41:13 +1000 Subject: [PATCH 02/45] FIX: Discard empty bundles for reviewables (#30121) Followup c7e471d35a0d394899eda5af26de64511e199cc6 It is currently possible to add a bundle (which is a collection of actions used for a dropdown on the client) for a reviewable via actions.add_bundle and then never add any actions to it. This causes the client to explode, as seen in the referenced commit, because of the way our store expects to resolve objects referenced by ID that are passed down by the serializer, which then causes Ember to have an unrecoverable render error. Fixing this on the serializer level is not really possible because of all the ActiveModel::Serializer magic that serializes objects by ID reference when doing things like has_many. `Reviewable#actions_for` is a better place to do this anyway, because this is the main location where the bundles and actions are built for every action via the serializer. --- app/models/reviewable.rb | 9 +++++++- lib/reviewable/actions.rb | 4 ++++ spec/models/reviewable_spec.rb | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb index 5535ca375f3..a9e957b7f34 100644 --- a/app/models/reviewable.rb +++ b/app/models/reviewable.rb @@ -270,8 +270,15 @@ class Reviewable < ActiveRecord::Base def actions_for(guardian, args = nil) args ||= {} + built_actions = + Actions.new(self, guardian).tap { |actions| build_actions(actions, guardian, args) } - Actions.new(self, guardian).tap { |actions| build_actions(actions, guardian, args) } + # Empty bundles can cause big issues on the client side, so we remove them + # here. It's not valid anyway to have a bundle with no actions, but you can + # add a bundle via actions.add_bundle and then not add any actions to it. + built_actions.bundles.reject!(&:empty?) + + built_actions end def editable_for(guardian, args = nil) diff --git a/lib/reviewable/actions.rb b/lib/reviewable/actions.rb index 4df0eaee70f..5714035eeea 100644 --- a/lib/reviewable/actions.rb +++ b/lib/reviewable/actions.rb @@ -30,6 +30,10 @@ class Reviewable < ActiveRecord::Base @label = label @actions = [] end + + def empty? + @actions.empty? + end end class Action < Item diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb index de197304323..387e4f65115 100644 --- a/spec/models/reviewable_spec.rb +++ b/spec/models/reviewable_spec.rb @@ -621,6 +621,45 @@ RSpec.describe Reviewable, type: :model do end end + describe "#actions_for" do + fab!(:reviewable) { Fabricate(:reviewable_queued_post) } + fab!(:user) + + it "gets the bundles and actions for a reviewable" do + actions = reviewable.actions_for(user.guardian) + expect(actions.bundles.map(&:id)).to eq(%w[approve_post reject_post revise_and_reject_post]) + expect(actions.bundles.find { |b| b.id == "approve_post" }.actions.map(&:id)).to eq( + ["approve_post"], + ) + expect(actions.bundles.find { |b| b.id == "reject_post" }.actions.map(&:id)).to eq( + ["reject_post"], + ) + expect(actions.bundles.find { |b| b.id == "revise_and_reject_post" }.actions.map(&:id)).to eq( + ["revise_and_reject_post"], + ) + end + + describe "handling empty bundles" do + class ReviewableTestRecord < Reviewable + def build_actions(actions, guardian, args) + actions.add(:approve_post) do |action| + action.icon = "check" + action.label = "reviewables.actions.approve_post.title" + end + actions.add_bundle("empty_bundle", icon: "xmark", label: "Empty Bundle") + end + end + + it "does not return empty bundles with no actions" do + actions = ReviewableTestRecord.new.actions_for(user.guardian) + expect(actions.bundles.map(&:id)).to eq(%w[approve_post]) + expect(actions.bundles.find { |b| b.id == "approve_post" }.actions.map(&:id)).to eq( + ["approve_post"], + ) + end + end + end + describe "default actions" do let(:reviewable) { Reviewable.new } let(:actions) { Reviewable::Actions.new(reviewable, Guardian.new) } From 1ca90c3070d7548162718d90883285fbed2a390f Mon Sep 17 00:00:00 2001 From: Kelv Date: Thu, 5 Dec 2024 15:20:02 +0800 Subject: [PATCH 03/45] DEV: update more deprecated font awesome icon names (#30123) * update more deprecated font awesome icon names * add migration to remove deprecated default for badges.icon --- .../app/components/group-card-contents.js | 2 +- .../group-manage-email-settings-test.js | 2 +- .../tests/acceptance/search-full-test.js | 2 +- .../tests/fixtures/badges-fixture.js | 56 +++++++++---------- .../tests/fixtures/group-fixtures.js | 12 ++-- .../discourse/tests/fixtures/user-fixtures.js | 6 +- .../components/user-avatar-flair-test.js | 10 ++-- .../components/widgets/avatar-flair-test.js | 2 +- app/models/badge.rb | 6 +- .../confirm_request.html.erb | 2 +- db/fixtures/006_badges.rb | 8 +-- ...05035402_change_default_for_badges_icon.rb | 12 ++++ .../discourse/components/chat-message.gjs | 2 +- plugins/chat/plugin.rb | 2 +- spec/lib/svg_sprite/svg_sprite_spec.rb | 3 +- 15 files changed, 69 insertions(+), 58 deletions(-) create mode 100644 db/migrate/20241205035402_change_default_for_badges_icon.rb diff --git a/app/assets/javascripts/discourse/app/components/group-card-contents.js b/app/assets/javascripts/discourse/app/components/group-card-contents.js index 82ef2b5e201..c3cb1ba0637 100644 --- a/app/assets/javascripts/discourse/app/components/group-card-contents.js +++ b/app/assets/javascripts/discourse/app/components/group-card-contents.js @@ -62,7 +62,7 @@ export default class GroupCardContents extends CardContentsBase.extend( this.setProperties({ group }); if (!group.flair_url && !group.flair_bg_color) { - group.set("flair_url", "fa-users"); + group.set("flair_url", "users"); } if (group.can_see_members && group.members.length < maxMembersToDisplay) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js index 079ea9d9898..bcd21cf70bc 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js @@ -215,7 +215,7 @@ acceptance( visible: true, public_admission: true, public_exit: false, - flair_url: "fa-circle-half-stroke", + flair_url: "circle-half-stroke", is_group_owner: true, mentionable: true, messageable: true, diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js index dc0f7f71ffd..ca8c4919a75 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js @@ -70,7 +70,7 @@ acceptance("Search - Full Page", function (needs) { grant_count: 0, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", image: null, listable: true, enabled: true, diff --git a/app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js b/app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js index bcced94920a..664b3474de6 100644 --- a/app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js +++ b/app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js @@ -60,7 +60,7 @@ export default { grant_count: 11, allow_title: true, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 8, @@ -75,7 +75,7 @@ export default { grant_count: 10, allow_title: true, multiple_grant: false, - icon: "fa-gear", + icon: "gear", listable: true, enabled: true, badge_grouping_id: 8, @@ -89,7 +89,7 @@ export default { grant_count: 29, allow_title: true, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 4, @@ -103,7 +103,7 @@ export default { grant_count: 200, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 8, @@ -118,7 +118,7 @@ export default { grant_count: 9, allow_title: true, multiple_grant: false, - icon: "fa-bug", + icon: "bug", listable: true, enabled: true, badge_grouping_id: 7, @@ -132,7 +132,7 @@ export default { grant_count: 0, allow_title: true, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 8, @@ -146,7 +146,7 @@ export default { grant_count: 467, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 4, @@ -161,7 +161,7 @@ export default { grant_count: 183, allow_title: false, multiple_grant: false, - icon: "fa-bug", + icon: "bug", listable: true, enabled: true, badge_grouping_id: 7, @@ -175,7 +175,7 @@ export default { grant_count: 4, allow_title: true, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 4, @@ -189,7 +189,7 @@ export default { grant_count: 278, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -203,7 +203,7 @@ export default { grant_count: 5834, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 4, @@ -217,7 +217,7 @@ export default { grant_count: 60, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -231,7 +231,7 @@ export default { grant_count: 22, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 3, @@ -245,7 +245,7 @@ export default { grant_count: 2, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 3, @@ -259,7 +259,7 @@ export default { grant_count: 2387, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -273,7 +273,7 @@ export default { grant_count: 285, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -287,7 +287,7 @@ export default { grant_count: 42, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 2, @@ -301,7 +301,7 @@ export default { grant_count: 1718, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 2, @@ -315,7 +315,7 @@ export default { grant_count: 270, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -330,7 +330,7 @@ export default { grant_count: 545, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -344,7 +344,7 @@ export default { grant_count: 397, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -358,7 +358,7 @@ export default { grant_count: 259, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 3, @@ -372,7 +372,7 @@ export default { grant_count: 933, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 2, @@ -396,7 +396,7 @@ export default { grant_count: 545, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -419,7 +419,7 @@ export default { grant_count: 10, allow_title: true, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -437,7 +437,7 @@ export default { grant_count: 545, allow_title: false, multiple_grant: false, - icon: "fa-certificate", + icon: "certificate", listable: true, enabled: true, badge_grouping_id: 1, @@ -1714,7 +1714,7 @@ export default { { id: 1, name: "Only icon", - icon: "fa-rocket", + icon: "rocket", }, { id: 2, @@ -1724,7 +1724,7 @@ export default { { id: 3, name: "Both image and icon", - icon: "fa-rocket", + icon: "rocket", image_url: "/images/avatar.png?3", multiple_grant: true, query: "SELECT 1", diff --git a/app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js index ec2d46c6351..00c732d3e7d 100644 --- a/app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js +++ b/app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js @@ -42,7 +42,7 @@ export default { visible: true, public_admission: true, public_exit: false, - flair_url: "fa-circle-half-stroke", + flair_url: "circle-half-stroke", is_group_owner: true, mentionable: true, messageable: true, @@ -66,7 +66,7 @@ export default { visible: true, public_admission: true, public_exit: false, - flair_url: "fa-circle-half-stroke", + flair_url: "circle-half-stroke", is_group_owner: true, mentionable: true, messageable: true, @@ -260,7 +260,7 @@ export default { }, }, "/groups/discourse/posts.json": { - "posts": [ + posts: [ { id: 94607, cooked: @@ -1319,8 +1319,8 @@ export default { avatar_template: "/user_avatar/meta.discourse.org/codinghorror/{size}/5297.png", }, - } - ] + }, + ], }, "/groups/alternative-group.json": { group: { @@ -1334,7 +1334,7 @@ export default { has_messages: true, public_admission: true, public_exit: false, - flair_url: "fa-circle-half-stroke", + flair_url: "circle-half-stroke", is_group_owner: true, mentionable: true, messageable: true, diff --git a/app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js index b180a2b9fe9..68f718e3a1b 100644 --- a/app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js +++ b/app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js @@ -49,7 +49,7 @@ export default { grant_count: 14, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", image: null, listable: true, enabled: true, @@ -349,7 +349,7 @@ export default { grant_count: 14, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", image: null, listable: true, enabled: true, @@ -3210,7 +3210,7 @@ export default { grant_count: 14, allow_title: false, multiple_grant: true, - icon: "fa-certificate", + icon: "certificate", image: null, listable: true, enabled: true, diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js index 332aacda2bb..da9a112c809 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-avatar-flair-test.js @@ -9,28 +9,28 @@ function setupSiteGroups(that) { { id: 1, name: "admins", - flair_url: "fa-bars", + flair_url: "bars", flair_bg_color: "CC000A", flair_color: "FFFFFA", }, { id: 2, name: "staff", - flair_url: "fa-bars", + flair_url: "bars", flair_bg_color: "CC0005", flair_color: "FFFFF5", }, { id: 3, name: "trust_level_1", - flair_url: "fa-dice-one", + flair_url: "dice-one", flair_bg_color: "CC0001", flair_color: "FFFFF1", }, { id: 4, name: "trust_level_2", - flair_url: "fa-dice-two", + flair_url: "dice-two", flair_bg_color: "CC0002", flair_color: "FFFFF2", }, @@ -159,7 +159,7 @@ module("Integration | Component | user-avatar-flair", function (hooks) { moderator: false, trust_level: 3, flair_name: "Band Geeks", - flair_url: "fa-xmark", + flair_url: "xmark", flair_bg_color: "123456", flair_color: "B0B0B0", flair_group_id: 41, diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js index f60951ff57c..022e6ebc125 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/avatar-flair-test.js @@ -8,7 +8,7 @@ module("Integration | Component | Widget | avatar-flair", function (hooks) { test("avatar flair with an icon", async function (assert) { this.set("args", { - flair_url: "fa-bars", + flair_url: "bars", flair_bg_color: "CC0000", flair_color: "FFFFFF", }); diff --git a/app/models/badge.rb b/app/models/badge.rb index 2a58c1242d3..3ee34bd60df 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -252,7 +252,7 @@ class Badge < ActiveRecord::Base def default_icon=(val) if self.image_upload_id.blank? self.icon ||= val - self.icon = val if self.icon == "fa-certificate" + self.icon = val if self.icon == "certificate" end end @@ -353,7 +353,7 @@ end # updated_at :datetime not null # allow_title :boolean default(FALSE), not null # multiple_grant :boolean default(FALSE), not null -# icon :string default("fa-certificate") +# icon :string default("certificate") # listable :boolean default(TRUE) # target_posts :boolean default(FALSE) # query :text @@ -363,9 +363,9 @@ end # trigger :integer # show_posts :boolean default(FALSE), not null # system :boolean default(FALSE), not null -# show_in_post_header :boolean default(FALSE), not null # long_description :text # image_upload_id :integer +# show_in_post_header :boolean default(FALSE), not null # # Indexes # diff --git a/app/views/users/omniauth_callbacks/confirm_request.html.erb b/app/views/users/omniauth_callbacks/confirm_request.html.erb index 8074820193c..e8e5a85def6 100644 --- a/app/views/users/omniauth_callbacks/confirm_request.html.erb +++ b/app/views/users/omniauth_callbacks/confirm_request.html.erb @@ -5,7 +5,7 @@
<%= hidden_field_tag :authenticity_token, form_authenticity_token %> <%= button_tag(type: "submit", class: "btn btn-primary") do %> - <%= SvgSprite.raw_svg('fa-plug') %><%= t 'login.omniauth_confirm_button' %> + <%= SvgSprite.raw_svg('plug') %><%= t 'login.omniauth_confirm_button' %> <% end %>
diff --git a/db/fixtures/006_badges.rb b/db/fixtures/006_badges.rb index 12bf022cbf7..735e86268bb 100644 --- a/db/fixtures/006_badges.rb +++ b/db/fixtures/006_badges.rb @@ -156,7 +156,7 @@ end Badge.seed do |b| b.id = id b.name = name - b.default_icon = "fa-user-plus" + b.default_icon = "user-plus" b.badge_type_id = type b.multiple_grant = false b.target_posts = false @@ -339,7 +339,7 @@ end Badge.seed do |b| b.id = id b.name = name - b.default_icon = "fa-heart" + b.default_icon = "heart" b.badge_type_id = level b.query = BadgeQueries.liked_posts(post_count, like_count) b.default_badge_grouping_id = BadgeGrouping::Community @@ -357,7 +357,7 @@ end Badge.seed do |b| b.id = id b.name = name - b.default_icon = "fa-heart" + b.default_icon = "heart" b.badge_type_id = level b.query = BadgeQueries.liked_back(count, ratio) b.default_badge_grouping_id = BadgeGrouping::Community @@ -375,7 +375,7 @@ end Badge.seed do |b| b.id = id b.name = name - b.default_icon = "fa-heart" + b.default_icon = "heart" b.badge_type_id = level b.query = BadgeQueries.like_rate_limit(count) b.default_badge_grouping_id = BadgeGrouping::Community diff --git a/db/migrate/20241205035402_change_default_for_badges_icon.rb b/db/migrate/20241205035402_change_default_for_badges_icon.rb new file mode 100644 index 00000000000..22f637f1e6f --- /dev/null +++ b/db/migrate/20241205035402_change_default_for_badges_icon.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +class ChangeDefaultForBadgesIcon < ActiveRecord::Migration[7.2] + def change + change_column_default :badges, :icon, from: "fa-certificate", to: "certificate" + + up_only { execute <<~SQL } + UPDATE badges + SET icon = 'certificate' + WHERE icon = 'fa-certificate'; + SQL + end +end diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs index a739f1c54e7..9f7ece30f10 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.gjs @@ -667,7 +667,7 @@ export default class ChatMessage extends Component {
diff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rb index 9deed76a1c6..76f4562f39a 100644 --- a/plugins/chat/plugin.rb +++ b/plugins/chat/plugin.rb @@ -24,7 +24,7 @@ register_svg_icon "clipboard" register_svg_icon "file-audio" register_svg_icon "file-video" register_svg_icon "file-image" -register_svg_icon "stop-circle" +register_svg_icon "circle-stop" # route: /admin/plugins/chat add_admin_route "chat.admin.title", "chat", use_new_show_route: true diff --git a/spec/lib/svg_sprite/svg_sprite_spec.rb b/spec/lib/svg_sprite/svg_sprite_spec.rb index a2711a0dc61..82829c4362c 100644 --- a/spec/lib/svg_sprite/svg_sprite_spec.rb +++ b/spec/lib/svg_sprite/svg_sprite_spec.rb @@ -26,13 +26,12 @@ RSpec.describe SvgSprite do end it "can search for a specific FA icon" do - expect(SvgSprite.search("fa-heart")).to match(/heart/) expect(SvgSprite.search("poo-storm")).to match(/poo-storm/) expect(SvgSprite.search("this-is-not-an-icon")).to eq(false) end it "can get a raw SVG for an icon" do - expect(SvgSprite.raw_svg("fa-heart")).to match(/svg.*svg/) # SVG inside SVG + expect(SvgSprite.raw_svg("heart")).to match(/svg.*svg/) # SVG inside SVG expect(SvgSprite.raw_svg("this-is-not-an-icon")).to eq("") end From b3c94839edbc675dd5d72b7476783d5a0c47ee5f Mon Sep 17 00:00:00 2001 From: David Battersby Date: Thu, 5 Dec 2024 13:33:55 +0400 Subject: [PATCH 04/45] FIX: improve chat channel sorting for DMs (#30124) This change sorts unread channels in descending order based on last message date, so channels with the latest activity will always appear at the top. It also adds some improvements for sorting channels with unread threads, now when multiple channels have unread threads, they will be sorted by last thread reply date to ensure more active channels rise to the top. For DM channels, the order is now: - Urgent (green badge) - unread messages, mentions and unread watched threads (most recent activity at top) - Unread (blue badge) - unread tracked threads (most recent thread reply at top) - Everything else (most recent message at top) --- .../components/chat-channel-metadata.gjs | 13 ++- .../discourse/models/chat-channel.js | 10 ++ .../services/chat-channels-manager.js | 31 ++++-- .../spec/system/list_channels/drawer_spec.rb | 96 ++++++++++++------- 4 files changed, 106 insertions(+), 44 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs index e628c932e87..681c472b8c0 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel-metadata.gjs @@ -3,7 +3,11 @@ import { i18n } from "discourse-i18n"; export default class ChatChannelMetadata extends Component { get lastMessageFormattedDate() { - return moment(this.args.channel.lastMessage.createdAt).calendar(null, { + const lastMessageDate = this.showThreadUnreadDate + ? this.args.channel.lastUnreadThreadDate + : this.args.channel.lastMessage.createdAt; + + return moment(lastMessageDate).calendar(null, { sameDay: "LT", lastDay: `[${i18n("chat.dates.yesterday")}]`, lastWeek: "dddd", @@ -11,6 +15,13 @@ export default class ChatChannelMetadata extends Component { }); } + get showThreadUnreadDate() { + return ( + this.args.channel.lastUnreadThreadDate > + this.args.channel.lastMessage.createdAt + ); + } +