diff --git a/javascripts/discourse/components/modal/ucd-warning.hbs b/javascripts/discourse/components/modal/ucd-warning.hbs index edf81a3..812672d 100644 --- a/javascripts/discourse/components/modal/ucd-warning.hbs +++ b/javascripts/discourse/components/modal/ucd-warning.hbs @@ -1,7 +1,7 @@ diff --git a/javascripts/discourse/components/modal/ucd-warning.js b/javascripts/discourse/components/modal/ucd-warning.js index cb562d9..9157883 100644 --- a/javascripts/discourse/components/modal/ucd-warning.js +++ b/javascripts/discourse/components/modal/ucd-warning.js @@ -1,10 +1,24 @@ -import { action } from "@ember/object"; -import { inject as service } from "@ember/service"; import Component from "@glimmer/component"; +import { inject as service } from "@ember/service"; +import { action } from "@ember/object"; +import { htmlSafe } from "@ember/template"; +import I18n from "I18n"; +import { emojiUnescape } from "discourse/lib/text"; +import { escape } from "pretty-text/sanitizer"; +import { randomizeEmojiDiversity } from "../../lib/emoji-diversity"; export default class ModalUcdWarning extends Component { @service ucdState; + get title() { + return htmlSafe( + [ + emojiUnescape(escape(randomizeEmojiDiversity(settings.emoji_icon))), + escape(I18n.t(themePrefix("warning_modal.title"))), + ].join(" ") + ); + } + @action closeModal() { if (this.args.model.ucd_shouldPermanentlyDismiss) { diff --git a/javascripts/unformatted-code-detector/core/code-energy.js b/javascripts/discourse/core/code-energy.js similarity index 100% rename from javascripts/unformatted-code-detector/core/code-energy.js rename to javascripts/discourse/core/code-energy.js diff --git a/javascripts/unformatted-code-detector/core/detect-code.js b/javascripts/discourse/core/detect-code.js similarity index 100% rename from javascripts/unformatted-code-detector/core/detect-code.js rename to javascripts/discourse/core/detect-code.js diff --git a/javascripts/unformatted-code-detector/core/sensitivity.js b/javascripts/discourse/core/sensitivity.js similarity index 100% rename from javascripts/unformatted-code-detector/core/sensitivity.js rename to javascripts/discourse/core/sensitivity.js diff --git a/javascripts/unformatted-code-detector/core/strip-ignored-content.js b/javascripts/discourse/core/strip-ignored-content.js similarity index 100% rename from javascripts/unformatted-code-detector/core/strip-ignored-content.js rename to javascripts/discourse/core/strip-ignored-content.js diff --git a/javascripts/unformatted-code-detector/initializers/init.js b/javascripts/discourse/initializers/init.js similarity index 73% rename from javascripts/unformatted-code-detector/initializers/init.js rename to javascripts/discourse/initializers/init.js index 778cdb8..8733bbf 100644 --- a/javascripts/unformatted-code-detector/initializers/init.js +++ b/javascripts/discourse/initializers/init.js @@ -1,12 +1,6 @@ import { withPluginApi } from "discourse/lib/plugin-api"; import { detectUnformattedCode, printDebugInfo } from "../core/detect-code"; -import { randomizeEmojiDiversity } from "../lib/emoji-diversity"; -import { emojiUnescape } from "discourse/lib/text"; -import { htmlSafe } from "@ember/template"; -import { registerUnbound } from "discourse-common/lib/helpers"; -import I18n from "I18n"; -import { escape } from "pretty-text/sanitizer"; -import ModalUcdWarning from "../../discourse/components/modal/ucd-warning"; +import ModalUcdWarning from "../components/modal/ucd-warning"; import { inject as service } from "@ember/service"; const getDisableAtTrustLevel = () => @@ -30,15 +24,6 @@ export default { } }; - registerUnbound("modal-ucd-title", () => { - return htmlSafe( - [ - emojiUnescape(escape(randomizeEmojiDiversity(settings.emoji_icon))), - escape(I18n.t(themePrefix("warning_modal.title"))), - ].join(" ") - ); - }); - api.modifyClass("model:composer", { ucdState: service("ucd-state"), pluginId: "unformatted-code-detector", diff --git a/javascripts/unformatted-code-detector/lib/boundaries.js b/javascripts/discourse/lib/boundaries.js similarity index 100% rename from javascripts/unformatted-code-detector/lib/boundaries.js rename to javascripts/discourse/lib/boundaries.js diff --git a/javascripts/unformatted-code-detector/lib/emoji-diversity.js b/javascripts/discourse/lib/emoji-diversity.js similarity index 100% rename from javascripts/unformatted-code-detector/lib/emoji-diversity.js rename to javascripts/discourse/lib/emoji-diversity.js diff --git a/test/unit/detect-code/with-html-test.js b/test/unit/detect-code/with-html-test.js index 0f6ef6b..7ce6211 100644 --- a/test/unit/detect-code/with-html-test.js +++ b/test/unit/detect-code/with-html-test.js @@ -7,7 +7,7 @@ import { withFormattedHTML, withUnformattedCode, } from "../../fixtures/basic"; -import { detectUnformattedCode } from "../../../unformatted-code-detector/core/detect-code"; +import { detectUnformattedCode } from "../../../discourse/core/detect-code"; module("With HTML", function (hooks) { hooks.beforeEach(function () { diff --git a/test/unit/detect-code/without-html-test.js b/test/unit/detect-code/without-html-test.js index 7491587..1eadaca 100644 --- a/test/unit/detect-code/without-html-test.js +++ b/test/unit/detect-code/without-html-test.js @@ -1,7 +1,7 @@ import { module } from "qunit"; import { expectAll } from "../../helpers/utils"; import { withBareHTML } from "../../fixtures/basic"; -import { detectUnformattedCode } from "../../../unformatted-code-detector/core/detect-code"; +import { detectUnformattedCode } from "../../../discourse/core/detect-code"; module("Without HTML", function (hooks) { hooks.beforeEach(function () { diff --git a/test/unit/emoji-diversity-test.js b/test/unit/emoji-diversity-test.js index e813467..2852a3b 100644 --- a/test/unit/emoji-diversity-test.js +++ b/test/unit/emoji-diversity-test.js @@ -1,5 +1,5 @@ import { module, test } from "qunit"; -import { randomizeEmojiGender } from "../../unformatted-code-detector/lib/emoji-diversity"; +import { randomizeEmojiGender } from "../../discourse/lib/emoji-diversity"; const originalMathRandom = Math.random; diff --git a/test/unit/from-bug-reports-test.js b/test/unit/from-bug-reports-test.js index 5540af9..085db8a 100644 --- a/test/unit/from-bug-reports-test.js +++ b/test/unit/from-bug-reports-test.js @@ -1,7 +1,7 @@ import { module } from "qunit"; import { expectAll } from "../helpers/utils"; import { falseNegatives, falsePositives } from "../fixtures/bug-reports"; -import { detectUnformattedCode } from "../../unformatted-code-detector/core/detect-code"; +import { detectUnformattedCode } from "../../discourse/core/detect-code"; module("bug reports", function () { expectAll(detectUnformattedCode, falseNegatives, true); diff --git a/test/unit/post-length-test.js b/test/unit/post-length-test.js index 9aee430..703a66a 100644 --- a/test/unit/post-length-test.js +++ b/test/unit/post-length-test.js @@ -1,8 +1,7 @@ +import { module } from "qunit"; import { expectAll } from "../helpers/utils"; - import { withUnformattedCode } from "../fixtures/basic"; -import { detectUnformattedCode } from "../../unformatted-code-detector/core/detect-code"; -import { module } from "qunit"; +import { detectUnformattedCode } from "../../discourse/core/detect-code"; module("ignore if too short", function (hooks) { hooks.beforeEach(function () { diff --git a/test/unit/sensitivity-test.js b/test/unit/sensitivity-test.js index efea2a4..0b5bb2b 100644 --- a/test/unit/sensitivity-test.js +++ b/test/unit/sensitivity-test.js @@ -1,5 +1,5 @@ import { module, test } from "qunit"; -import { applySensitivity } from "../../unformatted-code-detector/core/sensitivity"; +import { applySensitivity } from "../../discourse/core/sensitivity"; module("apply sensitivity", function () { test("lowest sensitivity", function (assert) { diff --git a/test/unit/sequential-lines-test.js b/test/unit/sequential-lines-test.js index ae13a6d..6416b31 100644 --- a/test/unit/sequential-lines-test.js +++ b/test/unit/sequential-lines-test.js @@ -2,11 +2,11 @@ import { module, test } from "qunit"; import { getCodeEnergy, numSequentialLinesWithThresholdCodeEnergy, -} from "../../unformatted-code-detector/core/detect-code"; +} from "../../discourse/core/detect-code"; import { CodeEnergyLevels, codeEnergyValues, -} from "../../unformatted-code-detector/core/code-energy"; +} from "../../discourse/core/code-energy"; module("sequential lines", function (hooks) { hooks.beforeEach(function () {