From 34e5f807ec738279be513aab7c68980966bf7d87 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 8 May 2020 15:50:55 -0400 Subject: [PATCH] DEV: User UPPER_CASE for constants --- .../discourse/app/components/edit-category-settings.js | 4 ++-- app/assets/javascripts/discourse/app/lib/constants.js | 4 ++-- app/assets/javascripts/discourse/app/lib/highlight-search.js | 4 ++-- .../javascripts/discourse/app/routes/discovery-categories.js | 4 ++-- lib/tasks/javascript.rake | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/edit-category-settings.js b/app/assets/javascripts/discourse/app/components/edit-category-settings.js index f0ab1cea121..d3b647984e9 100644 --- a/app/assets/javascripts/discourse/app/components/edit-category-settings.js +++ b/app/assets/javascripts/discourse/app/components/edit-category-settings.js @@ -2,7 +2,7 @@ import discourseComputed from "discourse-common/utils/decorators"; import { empty, and } from "@ember/object/computed"; import { setting } from "discourse/lib/computed"; import { buildCategoryPanel } from "discourse/components/edit-category-panel"; -import { SearchPriorities } from "discourse/lib/constants"; +import { SEARCH_PRIORITIES } from "discourse/lib/constants"; import Group from "discourse/models/group"; const categorySortCriteria = []; @@ -71,7 +71,7 @@ export default buildCategoryPanel("settings", { searchPrioritiesOptions() { const options = []; - Object.entries(SearchPriorities).forEach(entry => { + Object.entries(SEARCH_PRIORITIES).forEach(entry => { const [name, value] = entry; options.push({ diff --git a/app/assets/javascripts/discourse/app/lib/constants.js b/app/assets/javascripts/discourse/app/lib/constants.js index 8b752571d55..32114cdfe80 100644 --- a/app/assets/javascripts/discourse/app/lib/constants.js +++ b/app/assets/javascripts/discourse/app/lib/constants.js @@ -1,7 +1,7 @@ // DO NOT EDIT THIS FILE!!! // Update it by running `rake javascript:update_constants` -export const SearchPriorities = { +export const SEARCH_PRIORITIES = { ignore: 1, very_low: 2, low: 3, @@ -10,4 +10,4 @@ export const SearchPriorities = { very_high: 5 }; -export const SearchPhraseRegexp = '"([^"]+)"'; +export const SEARCH_PHRASE_REGEXP = '"([^"]+)"'; diff --git a/app/assets/javascripts/discourse/app/lib/highlight-search.js b/app/assets/javascripts/discourse/app/lib/highlight-search.js index e7dfc465ec7..6f233426565 100644 --- a/app/assets/javascripts/discourse/app/lib/highlight-search.js +++ b/app/assets/javascripts/discourse/app/lib/highlight-search.js @@ -1,4 +1,4 @@ -import { SearchPhraseRegexp } from "discourse/lib/constants"; +import { SEARCH_PHRASE_REGEXP } from "discourse/lib/constants"; import highlightHTML from "discourse/lib/highlight-html"; export const CLASS_NAME = "search-highlight"; @@ -7,7 +7,7 @@ export default function(elem, term, opts = {}) { if (!_.isEmpty(term)) { // special case ignore "l" which is used for magic sorting let words = _.reject( - term.match(new RegExp(`${SearchPhraseRegexp}|[^\\s]+`, "g")), + term.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g")), t => t === "l" ); diff --git a/app/assets/javascripts/discourse/app/routes/discovery-categories.js b/app/assets/javascripts/discourse/app/routes/discovery-categories.js index c1f440d453a..600c0ccdc84 100644 --- a/app/assets/javascripts/discourse/app/routes/discovery-categories.js +++ b/app/assets/javascripts/discourse/app/routes/discovery-categories.js @@ -8,7 +8,7 @@ import { defaultHomepage } from "discourse/lib/utilities"; import TopicList from "discourse/models/topic-list"; import { ajax } from "discourse/lib/ajax"; import PreloadStore from "discourse/lib/preload-store"; -import { SearchPriorities } from "discourse/lib/constants"; +import { SEARCH_PRIORITIES } from "discourse/lib/constants"; import { hash } from "rsvp"; import Site from "discourse/models/site"; @@ -145,7 +145,7 @@ export function openNewCategoryModal(context) { allow_badges: true, topic_featured_link_allowed: true, custom_fields: {}, - search_priority: SearchPriorities.normal + search_priority: SEARCH_PRIORITIES.normal }); showModal("edit-category", { model }).set("selectedTab", "general"); diff --git a/lib/tasks/javascript.rake b/lib/tasks/javascript.rake index 835c83cfca2..79cd860689c 100644 --- a/lib/tasks/javascript.rake +++ b/lib/tasks/javascript.rake @@ -17,9 +17,9 @@ task 'javascript:update_constants' => :environment do // DO NOT EDIT THIS FILE!!! // Update it by running `rake javascript:update_constants` - export const SearchPriorities = #{Searchable::PRIORITIES.to_json}; + export const SEARCH_PRIORITIES = #{Searchable::PRIORITIES.to_json}; - export const SearchPhraseRegexp = '#{Search::PHRASE_MATCH_REGEXP_PATTERN}'; + export const SEARCH_PHRASE_REGEXP = '#{Search::PHRASE_MATCH_REGEXP_PATTERN}'; JS output_path = "#{Rails.root}/app/assets/javascripts/discourse/app/lib/constants.js"