حسنًا، لقد قمت للتو ببعض تصحيح الأخطاء المحلية، وأؤكد أن هذا قابل للتكرار بنسبة 100٪ في تثبيتات discourse الافتراضية.
دعني ألخص هنا:
هناك إعدادان عندما يتعلق الأمر بغير المصنف:
allow_uncategorized_topics افتراضي إيقاف
suppress_uncategorized_badge افتراضي تشغيل
عندما يتم تعطيل allow_uncategorized_topics (الإعداد الافتراضي) فإننا نسرب وجوده في أماكن معينة.
إذا حاولت التحايل عن طريق تمكين غير المصنف حتى تتمكن من حذفه، فستواجه:
في Discourse، هذه الفئة غريبة جدًا من حيث:
- يجب أن تكون موجودة
- لا يمكن حذفها
- نقوم بحقنها في الكثير من المنطق في أماكن كثيرة:
يمكننا إصلاح التسرب عن طريق إضافة المزيد والمزيد من الشروط، ربما وصلنا إلى 10 الآن على كل من العميل والخادم.
أو يمكننا إصلاح هذا في الجوهر، فقط السماح للمسؤولين بـ حذف الفئة، ثم تختفي ولن نحتاج أبدًا إلى التحقق منها على أي حال.
توصيتي هنا هي:
- حذف كلا الإعدادين وحذف الإعداد المخفي
uncategorized_category_id - وجود مفهوم للفئة الافتراضية (وهو ما لدينا بالفعل) - لدينا بالفعل
default_composer_category uncategorizedإذن لم تعد مفهومًا خاصًا، أشياء أقل للتعامل معها.- وجود مكون سمة لمن يريدون “فئة بدون شارة”
يمكن إصلاح خطأ البحث الحالي بشيء مثل:
diff --git a/app/assets/javascripts/select-kit/addon/components/search-advanced-category-chooser.js b/app/assets/javascripts/select-kit/addon/components/search-advanced-category-chooser.js
index a678919d16..83a9ed27db 100644
--- a/app/assets/javascripts/select-kit/addon/components/search-advanced-category-chooser.js
+++ b/app/assets/javascripts/select-kit/addon/components/search-advanced-category-chooser.js
@@ -1,4 +1,5 @@
import { classNames } from "@ember-decorators/component";
+import { setting } from "discourse/lib/computed";
import CategoryChooserComponent from "select-kit/components/category-chooser";
import {
pluginApiIdentifiers,
@@ -7,11 +8,13 @@ import {
@classNames("search-advanced-category-chooser")
@selectKitOptions({
- allowUncategorized: true,
+ allowUncategorized: "allowUncategorized",
clearable: true,
none: "category.all",
displayCategoryDescription: false,
permissionType: null,
})
@pluginApiIdentifiers("search-advanced-category-chooser")
-export default class SearchAdvancedCategoryChooser extends CategoryChooserComponent {}
+export default class SearchAdvancedCategoryChooser extends CategoryChooserComponent {
+ @setting("allow_uncategorized_topics") allowUncategorized;
+}
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import SearchAdvancedCategoryChooser from "select-kit/components/search-advanced-category-chooser";
module(
"Integration | Component | select-kit/search-advanced-category-chooser",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.set("subject", selectKit());
});
test("respects allow_uncategorized_topics setting when false", async function (assert) {
this.siteSettings.allow_uncategorized_topics = false;
await render(
"<template><SearchAdvancedCategoryChooser /></template>"
);
await this.subject.expand();
// Uncategorized category (ID 17 in test data) should not be present when setting is false
assert.false(
this.subject.rowByValue(17).exists(),
"uncategorized category is not available when allow_uncategorized_topics is false"
);
});
test("shows uncategorized category when allow_uncategorized_topics is true", async function (assert) {
this.siteSettings.allow_uncategorized_topics = true;
await render(
"<template><SearchAdvancedCategoryChooser /></template>"
);
await this.subject.expand();
// Uncategorized category (ID 17 in test data) should be present when setting is true
assert.true(
this.subject.rowByValue(17).exists(),
"uncategorized category is available when allow_uncategorized_topics is true"
);
});
test("has correct default options", async function (assert) {
await render(
"<template><SearchAdvancedCategoryChooser /></template>"
);
assert.strictEqual(
this.subject.header().label(),
"All categories",
"has correct default none label"
);
});
}
);
لكن هذا مجرد خطأ البحث المتقدم، نحن نلعب لعبة “ضرب الخلد”…

