mirror of
https://github.com/discourse/discourse.git
synced 2025-06-09 01:56:46 +08:00
FIX: Show max tag error and prevent search (#26233)
Show the tag limit and prevent searches when max is 0
This commit is contained in:
@ -67,6 +67,29 @@ module(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("disables search and shows limit when max_tags_per_topic is zero", async function (assert) {
|
||||||
|
this.set("value", ["cat", "kit"]);
|
||||||
|
this.siteSettings.max_tags_per_topic = 0;
|
||||||
|
|
||||||
|
await render(hbs`<MiniTagChooser @value={{this.value}} />`);
|
||||||
|
|
||||||
|
assert.strictEqual(this.subject.header().value(), "cat,kit");
|
||||||
|
await this.subject.expand();
|
||||||
|
|
||||||
|
const error = query(".select-kit-error").innerText;
|
||||||
|
assert.strictEqual(
|
||||||
|
error,
|
||||||
|
I18n.t("select_kit.max_content_reached", {
|
||||||
|
count: 0,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await this.subject.fillInFilter("dawg");
|
||||||
|
assert.notOk(
|
||||||
|
exists(".select-kit-collection .select-kit-row"),
|
||||||
|
"it doesn’t show any options"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("required_tag_group", async function (assert) {
|
test("required_tag_group", async function (assert) {
|
||||||
this.set("value", ["foo", "bar"]);
|
this.set("value", ["foo", "bar"]);
|
||||||
|
|
||||||
|
@ -70,6 +70,13 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
search(filter) {
|
search(filter) {
|
||||||
|
const maximum = this.selectKit.options.maximum;
|
||||||
|
if (maximum === 0) {
|
||||||
|
const key = "select_kit.max_content_reached";
|
||||||
|
this.addError(I18n.t(key, { count: maximum }));
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
q: filter || "",
|
q: filter || "",
|
||||||
limit: this.maxTagSearchResults,
|
limit: this.maxTagSearchResults,
|
||||||
|
@ -371,7 +371,9 @@ export default Component.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
addError(error) {
|
addError(error) {
|
||||||
|
if (!this.errorsCollection.includes(error)) {
|
||||||
this.errorsCollection.pushObject(error);
|
this.errorsCollection.pushObject(error);
|
||||||
|
}
|
||||||
|
|
||||||
this._safeAfterRender(() => this.popper && this.popper.update());
|
this._safeAfterRender(() => this.popper && this.popper.update());
|
||||||
},
|
},
|
||||||
@ -649,6 +651,12 @@ export default Component.extend(
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.selectKit.options.maximum === 0) {
|
||||||
|
this.set("selectKit.isLoading", false);
|
||||||
|
this.set("selectKit.hasNoContent", false);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
content = content.concat(makeArray(result));
|
content = content.concat(makeArray(result));
|
||||||
content = this.selectKit.modifyContent(content).filter(Boolean);
|
content = this.selectKit.modifyContent(content).filter(Boolean);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user